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: <ZqePwtX4b18wiubO@casper.infradead.org>
Date: Mon, 29 Jul 2024 13:49:06 +0100
From: Matthew Wilcox <willy@...radead.org>
To: Barry Song <21cnbao@...il.com>
Cc: akpm@...ux-foundation.org, linux-mm@...ck.org, ying.huang@...el.com,
	baolin.wang@...ux.alibaba.com, chrisl@...nel.org, david@...hat.com,
	hannes@...xchg.org, hughd@...gle.com, kaleshsingh@...gle.com,
	kasong@...cent.com, linux-kernel@...r.kernel.org, mhocko@...e.com,
	minchan@...nel.org, nphamcs@...il.com, ryan.roberts@....com,
	senozhatsky@...omium.org, shakeel.butt@...ux.dev,
	shy828301@...il.com, surenb@...gle.com, v-songbaohua@...o.com,
	xiang@...nel.org, yosryahmed@...gle.com,
	Chuanhua Han <hanchuanhua@...o.com>
Subject: Re: [PATCH v5 3/4] mm: support large folios swapin as a whole for
 zRAM-like swapfile

On Mon, Jul 29, 2024 at 04:46:42PM +1200, Barry Song wrote:
> On Mon, Jul 29, 2024 at 4:41 PM Barry Song <21cnbao@...il.com> wrote:
> >
> > On Mon, Jul 29, 2024 at 3:51 PM Matthew Wilcox <willy@...radead.org> wrote:
> > >
> > > On Fri, Jul 26, 2024 at 09:46:17PM +1200, Barry Song wrote:
> > > > -                     folio = vma_alloc_folio(GFP_HIGHUSER_MOVABLE, 0,
> > > > -                                             vma, vmf->address, false);
> > > > +                     folio = alloc_swap_folio(vmf);
> > > >                       page = &folio->page;
> > >
> > > This is no longer correct.  You need to set 'page' to the precise page
> > > that is being faulted rather than the first page of the folio.  It was
> > > fine before because it always allocated a single-page folio, but now it
> > > must use folio_page() or folio_file_page() (whichever has the correct
> > > semantics for you).
> > >
> > > Also you need to fix your test suite to notice this bug.  I suggest
> > > doing that first so that you know whether you've got the calculation
> > > correct.
> >
> > I don't understand why the code is designed in the way the page
> > is the first page of this folio. Otherwise, we need lots of changes
> > later while mapping the folio in ptes and rmap.

What?

        folio = swap_cache_get_folio(entry, vma, vmf->address);
        if (folio)
                page = folio_file_page(folio, swp_offset(entry));

page is the precise page, not the first page of the folio.

> For both accessing large folios in the swapcache and allocating
> new large folios, the page points to the first page of the folio. we
> are mapping the whole folio not the specific page.

But what address are we mapping the whole folio at?

> for swapcache cases, you can find the same thing here,
> 
>         if (folio_test_large(folio) && folio_test_swapcache(folio)) {
>                 ...
>                 entry = folio->swap;
>                 page = &folio->page;
>         }

Yes, but you missed some important lines from your quote:

                page_idx = idx;
                address = folio_start;
                ptep = folio_ptep;
                nr_pages = nr;

We deliberate adjust the address so that, yes, we're mapping the entire
folio, but we're mapping it at an address that means that the page we
actually faulted on ends up at the address that we faulted on.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ