[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAMgjq7Axhj-OGe6p1_KHAcR=j92=3MjMMz1YafsPxHWqsmemiA@mail.gmail.com>
Date: Wed, 10 Sep 2025 20:56:20 +0800
From: Kairui Song <ryncsn@...il.com>
To: David Hildenbrand <david@...hat.com>
Cc: linux-mm@...ck.org, Andrew Morton <akpm@...ux-foundation.org>,
Matthew Wilcox <willy@...radead.org>, Hugh Dickins <hughd@...gle.com>, Chris Li <chrisl@...nel.org>,
Barry Song <baohua@...nel.org>, Baoquan He <bhe@...hat.com>, Nhat Pham <nphamcs@...il.com>,
Kemeng Shi <shikemeng@...weicloud.com>, Baolin Wang <baolin.wang@...ux.alibaba.com>,
Ying Huang <ying.huang@...ux.alibaba.com>, Johannes Weiner <hannes@...xchg.org>,
Yosry Ahmed <yosryahmed@...gle.com>, Lorenzo Stoakes <lorenzo.stoakes@...cle.com>,
Zi Yan <ziy@...dia.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 05/15] mm, swap: always lock and check the swap cache
folio before use
On Tue, Sep 9, 2025 at 11:19 PM David Hildenbrand <david@...hat.com> wrote:
>
> On 09.09.25 16:58, Kairui Song wrote:
> > On Mon, Sep 8, 2025 at 10:08 PM David Hildenbrand <david@...hat.com> wrote:
> >>
> >>
> >>>
> >>> folio_lock(folio);
> >>> + if (!folio_matches_swap_entry(folio, entry)) {
> >>> + folio_unlock(folio);
> >>> + folio_put(folio);
> >>> + continue;
> >>> + }
> >>> +
> >>
> >> I wonder if we should put that into unuse_pte() instead. It checks for
> >> other types of races (like the page table entry getting modified) already.
> >
> > Doing this earlier here might help to avoid the folio_wait_writeback
> > below?
>
> Why would we care about optimizing that out in that corner case?
>
> And checking the folio right after locking seems to follow the
> > convention more strictly.
>
> I'd just slap it into unuse_pte() where you can return immediately and
> we don't need another duplicated
>
> folio_unlock(folio);
> folio_put(folio);
> continue;
Yeah, removing the duplication is a very good point.
>
> --
> Cheers
>
> David / dhildenb
>
Powered by blists - more mailing lists