Re: [PATCH] mm: reuse the unshared swapcache page in do_wp_page

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




> On Jan 20, 2022, at 10:00 AM, David Hildenbrand <david@xxxxxxxxxx> wrote:
> 
> On 20.01.22 18:48, Nadav Amit wrote:
>> 
>>> On Jan 20, 2022, at 6:15 AM, David Hildenbrand <david@xxxxxxxxxx> wrote:
>>> 
>>> On 17.01.22 14:31, zhangliang (AG) wrote:
>>>> Sure, I will do that :)
>>> 
>>> I'm polishing up / testing the patches and might send something out for discussion shortly.
>>> Just a note that on my branch was a version with a wrong condition that should have been fixed now.
>>> 
>> 
>> Sorry for being late for the discussion.
>> 
>> David, does any of it regards the lru_cache_add() reference issue that I
>> mentioned? [1]
> 
> No, unfortunately not in that part of my work. *Maybe* we could also try
> to handle that reference similarly to the swapcache, but the question is
> if we can't wait for PageAnonExclusive.
> 
> Right now I have the following in mind to get most parts working as
> exptected:
> 
> 1. Optimize reuse logic for the swapcache as it seems to be easy
> 2. Streamline COW logic and remove reuse_swap_page() -- fix the CVE for
>   THP.
> 3. Introduce PageAnonExclusive and allow FOLL_PIN only on
>   PageAnonExclusive pages.
> 4. Convert O_DIRECT to FOLL_PIN
> 
> We will never ever have to copy a page PageAnonExclusive page in the COW
> handler and can immediately reuse it without even locking the page. The
> existing reuse logic is essentially then used to reset PageAnonExclusive
> on a page (thus it makes sense to work on it) where the flag is not set
> anymore -- or on a fresh page if we have to copy.
> 
> That implies that all these additional references won't care if your app
> doesn't fork() or KSM isn't active. Consequently, anything that
> read-protects anonymous pages will work as expected and should be as
> fast as it gets.
> 
> Sounds good? At least to me. If only swap/migration entries wouldn't be
> harder to handle than I'd wish, that's why it's taking a little and will
> take a little longer.

Thanks for the quick response. I would have to see the logic to set/clear
PageAnonExclusive to fully understand how things are handled.

BTW, I just saw this patch form PeterZ [1] that seems to be related, as
it deals with changing protection on pinned pages.


[1] https://lore.kernel.org/linux-mm/20220120160822.666778608@xxxxxxxxxxxxx/




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux