From: Lance Yang <ioworker0@gmail.com>
To: David Hildenbrand <david@redhat.com>
Cc: Matthew Wilcox <willy@infradead.org>,
akpm@linux-foundation.org, ryan.roberts@arm.com,
21cnbao@gmail.com, baolin.wang@linux.alibaba.com,
ziy@nvidia.com, fengwei.yin@intel.com, ying.huang@intel.com,
libang.li@antgroup.com, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/1] mm/mlock: implement folio_mlock_step() using folio_pte_batch()
Date: Mon, 3 Jun 2024 23:08:42 +0800 [thread overview]
Message-ID: <CAK1f24n9UB=Xqj23vLG7fYKUfvZgLqFVF-tsyc_nDrwAKC98CQ@mail.gmail.com> (raw)
In-Reply-To: <c0309ab6-8bae-42b7-8d27-1df895689fb8@redhat.com>
On Mon, Jun 3, 2024 at 10:56 PM David Hildenbrand <david@redhat.com> wrote:
>
> On 03.06.24 16:43, Matthew Wilcox wrote:
> > On Mon, Jun 03, 2024 at 10:07:45PM +0800, Lance Yang wrote:
> >> +++ b/mm/mlock.c
> >> @@ -307,26 +307,15 @@ void munlock_folio(struct folio *folio)
> >> static inline unsigned int folio_mlock_step(struct folio *folio,
> >> pte_t *pte, unsigned long addr, unsigned long end)
> >> {
> >> - unsigned int count, i, nr = folio_nr_pages(folio);
> >> - unsigned long pfn = folio_pfn(folio);
> >> + const fpb_t fpb_flags = FPB_IGNORE_DIRTY | FPB_IGNORE_SOFT_DIRTY;
> >> + unsigned int count = (end - addr) >> PAGE_SHIFT;
> >
> > This is a pre-existing bug, but ... what happens if you're on a 64-bit
> > system and you mlock() a range that is exactly 2^44 bytes? Seems to me
> > that count becomes 0. Why not use an unsigned long here and avoid the
> > problem entirely?
> >
> > folio_pte_batch() also needs to take an unsigned long max_nr in that
> > case, because you aren't restricting it to folio_nr_pages().
>
> Yeah, likely we should also take a look at other folio_pte_batch() users
> like copy_present_ptes() that pass the count as an int. Nothing should
> really be broken, but we might not batch as much as we could, which is
> unfortunate.
Could I change folio_pte_batch() to take an unsigned long max_nr?
Thanks,
Lance
>
> --
> Cheers,
>
> David / dhildenb
>
next prev parent reply other threads:[~2024-06-03 15:08 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-03 14:07 Lance Yang
2024-06-03 14:43 ` Matthew Wilcox
2024-06-03 14:55 ` Lance Yang
2024-06-03 14:56 ` David Hildenbrand
2024-06-03 15:01 ` Matthew Wilcox
2024-06-03 15:26 ` David Hildenbrand
2024-06-03 15:46 ` Lance Yang
2024-06-03 21:00 ` Barry Song
2024-06-03 15:08 ` Lance Yang [this message]
2024-06-03 15:27 ` David Hildenbrand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAK1f24n9UB=Xqj23vLG7fYKUfvZgLqFVF-tsyc_nDrwAKC98CQ@mail.gmail.com' \
--to=ioworker0@gmail.com \
--cc=21cnbao@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=david@redhat.com \
--cc=fengwei.yin@intel.com \
--cc=libang.li@antgroup.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ryan.roberts@arm.com \
--cc=willy@infradead.org \
--cc=ying.huang@intel.com \
--cc=ziy@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox