Re: [PATCH 08/11] mm: convert vma_interval_tree to half closed intervals

From: Matthew Wilcox
Date: Thu Oct 03 2019 - 16:41:12 EST


On Thu, Oct 03, 2019 at 01:18:55PM -0700, Davidlohr Bueso wrote:
> +++ b/mm/nommu.c
> @@ -1793,7 +1793,7 @@ int nommu_shrink_inode_mappings(struct inode *inode, size_t size,
> size_t r_size, r_top;
>
> low = newsize >> PAGE_SHIFT;
> - high = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
> + high = (size + PAGE_SIZE) >> PAGE_SHIFT;

Uhh ... are you sure about this? size is in bytes here, and we're rounding
up to the next page size. So if size is [1-4096], then we add on 4095 and get
the answer 1. With your patch, if size is [0-4095], we get the answer 1.
I think you meant:

high = ((size + PAGE_SIZE - 1) >> PAGE_SHIFT) + 1;