[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZIOHL1dtyoaR1S/w@casper.infradead.org>
Date: Fri, 9 Jun 2023 21:10:23 +0100
From: Matthew Wilcox <willy@...radead.org>
To: Sidhartha Kumar <sidhartha.kumar@...cle.com>
Cc: linux-kernel@...r.kernel.org, linux-mm@...ck.org,
akpm@...ux-foundation.org, songmuchun@...edance.com,
mike.kravetz@...cle.com, david@...hat.com, nphamcs@...il.com,
jthoughton@...gle.com
Subject: Re: [PATCH 2/2] mm/hugetlb: add wrapper functions for interactions
with page cache
On Fri, Jun 09, 2023 at 12:49:47PM -0700, Sidhartha Kumar wrote:
> +++ b/fs/hugetlbfs/inode.c
> @@ -617,20 +617,19 @@ static void remove_inode_hugepages(struct inode *inode, loff_t lstart,
> struct hstate *h = hstate_inode(inode);
> struct address_space *mapping = &inode->i_data;
> const pgoff_t start = lstart >> huge_page_shift(h);
> - const pgoff_t end = lend >> huge_page_shift(h);
> struct folio_batch fbatch;
> pgoff_t next, index;
> int i, freed = 0;
> bool truncate_op = (lend == LLONG_MAX);
>
> folio_batch_init(&fbatch);
> - next = start;
> - while (filemap_get_folios(mapping, &next, end - 1, &fbatch)) {
> + next = lstart;
That's suspicious. Surely it should be
next = lstart / PAGE_SIZE;
> + while (filemap_get_folios(mapping, &next, lend - 1, &fbatch)) {
and 'end' is supposed to be a pgoff_t, so lend - 1 is also suspicious.
> - index = folio->index;
> + index = (folio->index) >> huge_page_shift(h);
You don't need to use brackets here. While C's operator precedence is
legendarily confusing, the arrow operator binds far tighter than the
shift operator.
Powered by blists - more mailing lists