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]
Date:   Mon, 2 Aug 2021 12:20:17 +0000
From:   Tiberiu Georgescu <tiberiu.georgescu@...anix.com>
To:     "Eric W. Biederman" <ebiederm@...ssion.com>
CC:     Andrew Morton <akpm@...ux-foundation.org>,
        "viro@...iv.linux.org.uk" <viro@...iv.linux.org.uk>,
        Peter Xu <peterx@...hat.com>,
        David Hildenbrand <david@...hat.com>,
        "christian.brauner@...ntu.com" <christian.brauner@...ntu.com>,
        "adobriyan@...il.com" <adobriyan@...il.com>,
        "songmuchun@...edance.com" <songmuchun@...edance.com>,
        "axboe@...nel.dk" <axboe@...nel.dk>,
        "vincenzo.frascino@....com" <vincenzo.frascino@....com>,
        "catalin.marinas@....com" <catalin.marinas@....com>,
        "peterz@...radead.org" <peterz@...radead.org>,
        "chinwen.chang@...iatek.com" <chinwen.chang@...iatek.com>,
        Miaohe Lin <linmiaohe@...wei.com>,
        "jannh@...gle.com" <jannh@...gle.com>,
        Alistair Popple <apopple@...dia.com>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "linux-fsdevel@...r.kernel.org" <linux-fsdevel@...r.kernel.org>,
        "linux-mm@...ck.org" <linux-mm@...ck.org>,
        Ivan Teterevkov <ivan.teterevkov@...anix.com>,
        Florian Schmidt <flosch@...anix.com>,
        "Carl Waldspurger [C]" <carl.waldspurger@...anix.com>,
        Jonathan Davies <jond@...anix.com>
Subject: Re: [PATCH 0/1] pagemap: swap location for shared pages


> On 30 Jul 2021, at 18:28, Eric W. Biederman <ebiederm@...ssion.com> wrote:
> 
> Tiberiu A Georgescu <tiberiu.georgescu@...anix.com> writes:
> 
>> This patch follows up on a previous RFC:
>> 20210714152426.216217-1-tiberiu.georgescu@...anix.com
>> 
>> When a page allocated using the MAP_SHARED flag is swapped out, its pagemap
>> entry is cleared. In many cases, there is no difference between swapped-out
>> shared pages and newly allocated, non-dirty pages in the pagemap
>> interface.
> 
> What is the point?

The reason why this patch is important has been discussed in my RFC
patch and on this thread:
https://lore.kernel.org/lkml/20210715201651.212134-1-peterx@redhat.com/.
The most relevant reply should be Ivan's:
https://lore.kernel.org/lkml/CY4PR0201MB3460E372956C0E1B8D33F904E9E39@CY4PR0201MB3460.namprd02.prod.outlook.com/

In short, this swap information helps us enhance live migration in some cases.
> 
> You say a shared swapped out page is the same as a clean shared page
> and you are exactly correct.  What is the point in knowing a shared
> page was swapped out?  What does is the gain?
> 
What I meant was that shared swapped out pages and clean shared pages
have their ptes identical pre-patch. I understand they are somewhat similar
concepts when it comes to file shared pages, where swapping is done
directly on the disk.

Our case focuses on anonymous pages and shared pages with identical 
underlying behaviour (like pages allocated using memfd). These pages get 
cleared once the runtime is over, and the difference between allocated,
but uninitialised pages, and dirty pages that have been swapped out is 
significant, as the former could still contain usable data.

The post-patch pagemap entry now contains the swap type and offset for
swapped out pages, regardless of whether the page is private or shared.
This, by definition of the pagemap, should be the correct behaviour.

> I tried to understand the point by looking at your numbers below
> and everything I could see looked worse post patch.

Indeed, the numbers are mostly bigger post-patch. It is a tradeoff between
correctness and performance. However, the tradeoff is not inconvenient on sparse 
single accesses, and it can be made significantly faster by leveraging batching.
In future work, the performance can be improved by leveraging a mechanism 
proposed by Peter Xu: Special PTEs:
https://lore.kernel.org/lkml/20210715201422.211004-1-peterx@redhat.com/

The main concern of the RFC was that the xarray check would slow down
checking empty pages significantly. Thankfully, we can only see a small 
overhead when no allocated shared page is dirtied.

> 
> Eric
> 
Hope I was able to clarifiy a few things. Now, having laid out the context,
please have another look at my proposed patch.

Thank you,
Tibi

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ