From: "Yin, Fengwei" <fengwei.yin@intel.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: <linux-mm@kvack.org>, <linux-perf-users@vger.kernel.org>,
<peterz@infradead.org>, <mingo@redhat.com>, <acme@kernel.org>,
<urezki@gmail.com>, <hch@infradead.org>, <lstoakes@gmail.com>
Subject: Re: [RFC PATCH 4/4] perf: Use folios for the aux ringbuffer & pagefault path
Date: Wed, 23 Aug 2023 20:45:27 +0800 [thread overview]
Message-ID: <8de1d4b0-69b1-43f1-8d63-d3c0079e4cf6@intel.com> (raw)
In-Reply-To: <ZOX6WXatEmIWXx7O@casper.infradead.org>
On 8/23/2023 8:23 PM, Matthew Wilcox wrote:
> On Wed, Aug 23, 2023 at 03:38:13PM +0800, Yin Fengwei wrote:
>> On 8/22/23 04:20, Matthew Wilcox (Oracle) wrote:
>>> - get_page(vmf->page);
>>> - vmf->page->mapping = vmf->vma->vm_file->f_mapping;
>>> - vmf->page->index = vmf->pgoff;
>>> + folio_get(folio);
>>> + rcu_read_unlock();
>>> + folio_lock(folio);
>>> + if (!folio->mapping)
>>> + folio->mapping = vmf->vma->vm_file->f_mapping;
>>>
>>> - ret = 0;
>>> + return VM_FAULT_LOCKED;
>> In __do_fault():
>>
>> if (unlikely(!(ret & VM_FAULT_LOCKED)))
>> lock_page(vmf->page);
>> else
>> VM_BUG_ON_PAGE(!PageLocked(vmf->page), vmf->page);
>>
>> As we lock folio, not sure whether !PageLocked(vmf->page) can be true
>> here. My understanding is yes if vmf->pgoff belongs to tail pages. Did
>> I can miss something here?
>
> There's only one lock bit per folio; there's no lock bit for individual
> pages. When we check PageLocked() on a tail page, it redirects to the
> head page.
>
> __PAGEFLAG(Locked, locked, PF_NO_TAIL)
>
> #define PF_NO_TAIL(page, enforce) ({ \
> VM_BUG_ON_PGFLAGS(enforce && PageTail(page), page); \
> PF_POISONED_CHECK(compound_head(page)); })
>
> #define TESTPAGEFLAG(uname, lname, policy) \
> static __always_inline int Page##uname(struct page *page) \
> { return test_bit(PG_##lname, &policy(page, 0)->flags); }
>
> and that expands out to:
>
> static __always_inline int PageLocked(struct page *page)
> { return test_bit(PG_##locked, &compound_head(page)->flags); }
>
Ah. Here is the trick. Thanks a lot for detail explanation.
Regards
Yin, Fengwei
next prev parent reply other threads:[~2023-08-23 12:45 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-21 20:20 [RFC PATCH 0/4] Convert perf ringbuffer to folios Matthew Wilcox (Oracle)
2023-08-21 20:20 ` [RFC PATCH 1/4] perf: Convert perf_mmap_(alloc,free)_page " Matthew Wilcox (Oracle)
2023-08-23 7:28 ` Yin Fengwei
2023-08-27 7:33 ` Lorenzo Stoakes
2023-09-13 13:31 ` Peter Zijlstra
2023-09-22 20:19 ` Lorenzo Stoakes
2023-08-21 20:20 ` [RFC PATCH 2/4] mm: Add vmalloc_user_node() Matthew Wilcox (Oracle)
2023-09-13 13:32 ` Peter Zijlstra
2023-08-21 20:20 ` [RFC PATCH 3/4] perf: Use vmalloc_to_folio() Matthew Wilcox (Oracle)
2023-08-22 7:54 ` Zhu Yanjun
2023-08-23 7:30 ` Yin Fengwei
2023-08-23 12:16 ` Matthew Wilcox
2023-08-27 7:22 ` Lorenzo Stoakes
2023-08-21 20:20 ` [RFC PATCH 4/4] perf: Use folios for the aux ringbuffer & pagefault path Matthew Wilcox (Oracle)
2023-08-23 7:38 ` Yin Fengwei
2023-08-23 12:23 ` Matthew Wilcox
2023-08-23 12:45 ` Yin, Fengwei [this message]
2023-08-27 8:01 ` Lorenzo Stoakes
2023-08-27 11:50 ` Matthew Wilcox
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=8de1d4b0-69b1-43f1-8d63-d3c0079e4cf6@intel.com \
--to=fengwei.yin@intel.com \
--cc=acme@kernel.org \
--cc=hch@infradead.org \
--cc=linux-mm@kvack.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=lstoakes@gmail.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=urezki@gmail.com \
--cc=willy@infradead.org \
/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