lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d1c01214-4548-414d-be84-21c38cfe3ede@vivo.com>
Date:   Wed, 25 Oct 2023 09:17:43 +0800
From:   zhiguojiang <justinjiang@...o.com>
To:     David Hildenbrand <david@...hat.com>,
        Andrew Morton <akpm@...ux-foundation.org>, linux-mm@...ck.org,
        linux-kernel@...r.kernel.org
Cc:     opensource.kernel@...o.com
Subject: Re: [PATCH] mm/rmap: vm_flags including VM_EXEC can exit timely



在 2023/10/24 23:51, David Hildenbrand 写道:
> On 24.10.23 16:49, Zhiguo Jiang wrote:
>> When pra->vm_flags include VM_EXEC flag and folio is file detected in
>> folio_referenced_one(), the folio referenced traversal process can be
>> exited timely to reduce the detecting folio referenced time.
>>
>
> Can you further elaborate what the logic behind that is?
>
> Why can we stop here if we're dealing with a pagecache folio in an 
> executable VMA?
>
Functions call flow:folio_referenced() --> rmap_walk() --> 
rmap_walk_ksm()/rmap_walk_anon()/rmap_walk_file() --> rwc->rmap_one() 
--> folio_referenced_one(). And folio_referenced() is called by two 
interfaces: folio_check_references() and shrink_active_list().

1. folio_check_references():
When (referenced_ptes > 0 && (vm_flags & VM_EXEC) && 
folio_is_file_lru(folio)) is detected in folio_check_references(), 
FOLIOREF_ACTIVATE will be returned and the folio will be added to the 
active file lru. So when VM_EXEC is detected in folio_referenced_one(), 
we can stop continuing to detect the reference relationship between this 
folio and other vmas, and exit directly to avoid unnecessary traversal.

2. shrink_active_list():
The shrink_active_list() is the same as the folio_check_references().

>> Signed-off-by: Zhiguo Jiang <justinjiang@...o.com>
>> ---
>>   mm/rmap.c | 2 ++
>>   1 file changed, 2 insertions(+)
>>   mode change 100644 => 100755 mm/rmap.c
>>
>> diff --git a/mm/rmap.c b/mm/rmap.c
>> index 7a27a2b41802..932f3b7e8521
>> --- a/mm/rmap.c
>> +++ b/mm/rmap.c
>> @@ -884,6 +884,8 @@ static bool folio_referenced_one(struct folio 
>> *folio,
>>       if (referenced) {
>>           pra->referenced++;
>>           pra->vm_flags |= vma->vm_flags & ~VM_LOCKED;
>> +        if ((pra->vm_flags | VM_EXEC) && folio_is_file_lru(folio))
>> +            return false;
>>       }
>>         if (!pra->mapcount)
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ