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] [day] [month] [year] [list]
Message-ID: <51d0b44e-c1d1-a8e0-50cb-df9386a0f039@oracle.com>
Date:   Fri, 22 Oct 2021 23:11:42 -0700
From:   Anthony Yznaga <anthony.yznaga@...cle.com>
To:     Matthew Wilcox <willy@...radead.org>
Cc:     Andrew Morton <akpm@...ux-foundation.org>,
        Mel Gorman <mgorman@...hsingularity.net>, linux-mm@...ck.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] mm: Optimise put_pages_list()


On 10/22/21 6:13 PM, Matthew Wilcox wrote:
> On Fri, Oct 22, 2021 at 04:26:59PM -0700, Anthony Yznaga wrote:
>> On 10/7/21 12:21 PM, Matthew Wilcox (Oracle) wrote:
>>> Instead of calling put_page() one page at a time, pop pages off
>>> the list if their refcount was too high and pass the remainder to
>>> put_unref_page_list().  This should be a speed improvement, but I have
>>> no measurements to support that.  Current callers do not care about
>>> performance, but I hope to add some which do.
>>>
>>> Signed-off-by: Matthew Wilcox (Oracle) <willy@...radead.org>
>>> ---
>>> v2:
>>>    - Handle compound pages (Mel)
>>>    - Comment why we don't need to handle PageLRU
>>>    - Added call to __ClearPageWaiters(), matching that in release_pages()
>>>
>>>    mm/swap.c | 23 ++++++++++++++++-------
>>>    1 file changed, 16 insertions(+), 7 deletions(-)
>>>
>>> diff --git a/mm/swap.c b/mm/swap.c
>>> index af3cad4e5378..9f334d503fd2 100644
>>> --- a/mm/swap.c
>>> +++ b/mm/swap.c
>>> @@ -134,18 +134,27 @@ EXPORT_SYMBOL(__put_page);
>>>     * put_pages_list() - release a list of pages
>>>     * @pages: list of pages threaded on page->lru
>>>     *
>>> - * Release a list of pages which are strung together on page.lru.  Currently
>>> - * used by read_cache_pages() and related error recovery code.
>>> + * Release a list of pages which are strung together on page.lru.
>>>     */
>>>    void put_pages_list(struct list_head *pages)
>>>    {
>>> -	while (!list_empty(pages)) {
>>> -		struct page *victim;
>>> +	struct page *page, *next;
>>> -		victim = lru_to_page(pages);
>>> -		list_del(&victim->lru);
>>> -		put_page(victim);
>>> +	list_for_each_entry_safe(page, next, pages, lru) {
>>> +		if (!put_page_testzero(page)) {
>>> +			list_del(&page->lru);
>>> +			continue;
>>> +		}
>>
>> I know that compound pages are not currently passed to put_pages_list(),
>> but I assume the put_page_testzero() should only be done on the head
>> page similar to release_pages()?
> Fun fact about pages: You can't put a tail page on an LRU list.  Why?
>
> struct page {
> ...
>          union {
>                  struct {        /* Page cache and anonymous pages */
>                          struct list_head lru;
> ...
>                  struct {        /* Tail pages of compound page */
>                          unsigned long compound_head;    /* Bit zero is set */
>
> so if you try to put a tail page on the LRU list, it becomes no longer
> a tail page.

Ah, makes sense.  Thanks!

In that case here's my r-b:

Reviewed-by: Anthony Yznaga <anthony.yznaga@...cle.com>

Anthony


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ