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: <e724c44b-4135-3302-16fa-1df624fa81fa@linux.alibaba.com>
Date:   Fri, 17 Jul 2020 13:09:43 +0800
From:   Alex Shi <alex.shi@...ux.alibaba.com>
To:     Alexander Duyck <alexander.duyck@...il.com>
Cc:     Andrew Morton <akpm@...ux-foundation.org>,
        Mel Gorman <mgorman@...hsingularity.net>,
        Tejun Heo <tj@...nel.org>, Hugh Dickins <hughd@...gle.com>,
        Konstantin Khlebnikov <khlebnikov@...dex-team.ru>,
        Daniel Jordan <daniel.m.jordan@...cle.com>,
        Yang Shi <yang.shi@...ux.alibaba.com>,
        Matthew Wilcox <willy@...radead.org>,
        Johannes Weiner <hannes@...xchg.org>,
        kbuild test robot <lkp@...el.com>,
        linux-mm <linux-mm@...ck.org>,
        LKML <linux-kernel@...r.kernel.org>, cgroups@...r.kernel.org,
        Shakeel Butt <shakeelb@...gle.com>,
        Joonsoo Kim <iamjoonsoo.kim@....com>,
        Wei Yang <richard.weiyang@...il.com>,
        "Kirill A. Shutemov" <kirill@...temov.name>
Subject: Re: [PATCH v16 15/22] mm/compaction: do page isolation first in
 compaction


>> @@ -950,6 +951,21 @@ static bool too_many_isolated(pg_data_t *pgdat)
>>                 if (!(cc->gfp_mask & __GFP_FS) && page_mapping(page))
>>                         goto isolate_fail;
>>
>> +               /*
>> +                * Be careful not to clear PageLRU until after we're
>> +                * sure the page is not being freed elsewhere -- the
>> +                * page release code relies on it.
>> +                */
>> +               if (unlikely(!get_page_unless_zero(page)))
>> +                       goto isolate_fail;
>> +
>> +               if (__isolate_lru_page_prepare(page, isolate_mode) != 0)
>> +                       goto isolate_fail_put;
>> +
>> +               /* Try isolate the page */
>> +               if (!TestClearPageLRU(page))
>> +                       goto isolate_fail_put;
>> +
>>                 /* If we already hold the lock, we can skip some rechecking */
>>                 if (!locked) {
>>                         locked = compact_lock_irqsave(&pgdat->lru_lock,
> 
> Why not do the __isolate_lru_page_prepare before getting the page?
> That way you can avoid performing an extra atomic operation on non-LRU
> pages.
>

This change come from Hugh Dickins as mentioned from commit log:
>> trylock_page() is not safe to use at this time: its setting PG_locked
>> can race with the page being freed or allocated ("Bad page"), and can
>> also erase flags being set by one of those "sole owners" of a freshly
>> allocated page who use non-atomic __SetPageFlag().

Hi Hugh,

would you like to show more details of the bug?

...

>> +                        * sure the page is not being freed elsewhere -- the
>> +                        * page release code relies on it.
>> +                        */
>> +                       if (unlikely(!get_page_unless_zero(page)))
>> +                               goto busy;
>> +
>> +                       if (!TestClearPageLRU(page)) {
>> +                               /*
>> +                                * This page may in other isolation path,
>> +                                * but we still hold lru_lock.
>> +                                */
>> +                               put_page(page);
>> +                               goto busy;
>> +                       }
>> +
> 
> I wonder if it wouldn't make sense to combine these two atomic ops
> with tests and the put_page into a single inline function? Then it
> could be possible to just do one check and if succeeds you do the
> block of code below, otherwise you just fall-through into the -EBUSY
> case.
> 

Uh, since get_page changes page->_refcount, TestClearPageLRU changes page->flags,
So I don't know how to combine them, could you make it more clear with code?

Thanks
Alex

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ