Re: [RFC PATCH 4/4] perf: Use folios for the aux ringbuffer & pagefault path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux