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: <683d7a13-70a5-6ba9-e290-9ac4db309535@redhat.com>
Date:   Wed, 26 Jan 2022 15:36:42 +0100
From:   David Hildenbrand <david@...hat.com>
To:     Matthew Wilcox <willy@...radead.org>
Cc:     linux-kernel@...r.kernel.org,
        Andrew Morton <akpm@...ux-foundation.org>,
        Hugh Dickins <hughd@...gle.com>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        David Rientjes <rientjes@...gle.com>,
        Shakeel Butt <shakeelb@...gle.com>,
        John Hubbard <jhubbard@...dia.com>,
        Jason Gunthorpe <jgg@...dia.com>,
        Mike Kravetz <mike.kravetz@...cle.com>,
        Mike Rapoport <rppt@...ux.ibm.com>,
        Yang Shi <shy828301@...il.com>,
        "Kirill A . Shutemov" <kirill.shutemov@...ux.intel.com>,
        Vlastimil Babka <vbabka@...e.cz>, Jann Horn <jannh@...gle.com>,
        Michal Hocko <mhocko@...nel.org>,
        Nadav Amit <namit@...are.com>, Rik van Riel <riel@...riel.com>,
        Roman Gushchin <guro@...com>,
        Andrea Arcangeli <aarcange@...hat.com>,
        Peter Xu <peterx@...hat.com>,
        Donald Dutile <ddutile@...hat.com>,
        Christoph Hellwig <hch@....de>,
        Oleg Nesterov <oleg@...hat.com>, Jan Kara <jack@...e.cz>,
        Liang Zhang <zhangliang5@...wei.com>, linux-mm@...ck.org
Subject: Re: [PATCH RFC v2 2/9] mm: optimize do_wp_page() for fresh pages in
 local LRU pagevecs

On 26.01.22 15:31, Matthew Wilcox wrote:
> On Wed, Jan 26, 2022 at 10:55:50AM +0100, David Hildenbrand wrote:
>> diff --git a/mm/memory.c b/mm/memory.c
>> index bcd3b7c50891..61d67ceef734 100644
>> --- a/mm/memory.c
>> +++ b/mm/memory.c
>> @@ -3298,7 +3298,17 @@ static vm_fault_t do_wp_page(struct vm_fault *vmf)
>>  		 *
>>  		 * PageKsm() doesn't necessarily raise the page refcount.
>>  		 */
>> -		if (PageKsm(page) || page_count(page) > 1 + PageSwapCache(page))
>> +		if (PageKsm(page))
>> +			goto copy;
>> +		if (page_count(page) > 1 + PageSwapCache(page) + !PageLRU(page))
>> +			goto copy;
>> +		if (!PageLRU(page))
>> +			/*
>> +			 * Note: We cannot easily detect+handle references from
>> +			 * remote LRU pagevecs or references to PageLRU() pages.
>> +			 */
>> +			lru_add_drain();
>> +		if (page_count(page) > 1 + PageSwapCache(page))
>>  			goto copy;
> 
> I worry we're starting to get too accurate here.  How about:
> 

In that simplified case we'll essentially trylock_page() and for most
pages that are ordinarily shared by e.g., 2 processes.

> 		if (PageKsm(page) || page_count(page) > 3)
> 			goto copy;
> 		if (!PageLRU(page))
> 			lru_add_drain();
> 		if (!trylock_page(page))
> 			goto copy;
> ...
> 

I think we might at least want the

if (page_count(page) > 1 + PageSwapCache(page))
	goto copy;

check here.

>>  		if (!trylock_page(page))
>>  			goto copy;
>> -- 
>> 2.34.1
>>
> 


-- 
Thanks,

David / dhildenb

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ