Re: [PATCH v10 22/33] mm/filemap: Add __folio_lock_or_retry

From: Vlastimil Babka
Date: Tue May 18 2021 - 06:45:49 EST


On 5/18/21 12:38 PM, Vlastimil Babka wrote:
>> --- a/mm/filemap.c
>> +++ b/mm/filemap.c
>> @@ -1623,20 +1623,18 @@ static int __folio_lock_async(struct folio *folio, struct wait_page_queue *wait)
>>
>> /*
>> * Return values:
>> - * 1 - page is locked; mmap_lock is still held.
>> - * 0 - page is not locked.
>> + * 1 - folio is locked; mmap_lock is still held.
>> + * 0 - folio is not locked.
>> * mmap_lock has been released (mmap_read_unlock(), unless flags had both
>> * FAULT_FLAG_ALLOW_RETRY and FAULT_FLAG_RETRY_NOWAIT set, in
>> * which case mmap_lock is still held.
>> *
>> * If neither ALLOW_RETRY nor KILLABLE are set, will always return 1
>> - * with the page locked and the mmap_lock unperturbed.
>> + * with the folio locked and the mmap_lock unperturbed.
>> */
>> -int __lock_page_or_retry(struct page *page, struct mm_struct *mm,
>> +int __folio_lock_or_retry(struct folio *folio, struct mm_struct *mm,
>> unsigned int flags)
>> {
>> - struct folio *folio = page_folio(page);
>> -
>> if (fault_flag_allow_retry_first(flags)) {
>> /*
>> * CAUTION! In this case, mmap_lock is not released
>
> A bit later in this branch, 'page' is accessed, but it no longer exists. And
> thus as expected, it doesn't compile. Assuming it's fixed later, but
> bisectability etc...

Also, the switch from 'page' to &folio->page in there should probably have been
done already in "[PATCH v10 20/33] mm/filemap: Add folio_lock_killable", not in
this patch?