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: <6466a351-4c3a-4a02-b76f-8785daf36c0b@meta.com>
Date: Mon, 15 Sep 2025 12:54:36 -0400
From: Chris Mason <clm@...a.com>
To: Kairui Song <ryncsn@...il.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>,
        David Hildenbrand <david@...hat.com>,
        Yosry Ahmed <yosryahmed@...gle.com>,
        Lorenzo Stoakes <lorenzo.stoakes@...cle.com>, Zi Yan <ziy@...dia.com>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 14/15] mm, swap: implement dynamic allocation of swap
 table



On 9/15/25 12:24 PM, Kairui Song wrote:
> On Mon, Sep 15, 2025 at 11:55 PM Chris Mason <clm@...a.com> wrote:
>>
>> On Thu, 11 Sep 2025 00:08:32 +0800 Kairui Song <ryncsn@...il.com> wrote:

[ ... ]
             spin_lock(&si->global_cluster_lock);
>>> +     /*
>>> +      * Back to atomic context. First, check if we migrated to a new
>>> +      * CPU with a usable percpu cluster. If so, try using that instead.
>>> +      * No need to check it for the spinning device, as swap is
>>> +      * serialized by the global lock on them.
>>> +      *
>>> +      * The is_usable check is a bit rough, but ensures order 0 success.
>>> +      */
>>> +     offset = this_cpu_read(percpu_swap_cluster.offset[order]);
>>> +     if ((si->flags & SWP_SOLIDSTATE) && offset) {
>>> +             pcp_ci = swap_cluster_lock(si, offset);
>>> +             if (cluster_is_usable(pcp_ci, order) &&
>>> +                 pcp_ci->count < SWAPFILE_CLUSTER) {
>>> +                     ci = pcp_ci;
>>                        ^^^^^^^^^^^^^
>> ci came from the caller, and in the case of isolate_lock_cluster() they
>> had just removed it from a list.  We overwrite ci and return something
>> different.
> 
> Yes, that's expected. See the comment above. We have just dropped
> local lock so it's possible that we migrated to another CPU which has
> its own percpu cache ci (percpu_swap_cluster.offset).
> 
> To avoid fragmentation, drop the isolated ci and use the percpu ci
> instead. But you are right that I need to add the ci back to the list,
> or it will be leaked. Thanks!

Yeah, the comment helped a lot (thank you).  It was just the leak I was
worried about ;)

-chris


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ