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:   Wed, 23 Mar 2022 09:06:03 +0800
From:   Muchun Song <songmuchun@...edance.com>
To:     Waiman Long <longman@...hat.com>
Cc:     Andrew Morton <akpm@...ux-foundation.org>,
        Linux Memory Management List <linux-mm@...ck.org>,
        LKML <linux-kernel@...r.kernel.org>,
        Roman Gushchin <roman.gushchin@...ux.dev>
Subject: Re: [PATCH-mm v3] mm/list_lru: Optimize memcg_reparent_list_lru_node()

On Wed, Mar 9, 2022 at 10:40 PM Waiman Long <longman@...hat.com> wrote:
>
> Since commit 2c80cd57c743 ("mm/list_lru.c: fix list_lru_count_node()
> to be race free"), we are tracking the total number of lru
> entries in a list_lru_node in its nr_items field.  In the case of
> memcg_reparent_list_lru_node(), there is nothing to be done if nr_items
> is 0.  We don't even need to take the nlru->lock as no new lru entry
> could be added by a racing list_lru_add() to the draining src_idx memcg
> at this point.

Hi Waiman,

Sorry for the late reply.  Quick question: what if there is an inflight
list_lru_add()?  How about the following race?

CPU0:                               CPU1:
list_lru_add()
    spin_lock(&nlru->lock)
    l = list_lru_from_kmem(memcg)
                                    memcg_reparent_objcgs(memcg)
                                    memcg_reparent_list_lrus(memcg)
                                        memcg_reparent_list_lru()
                                            memcg_reparent_list_lru_node()
                                                if (!READ_ONCE(nlru->nr_items))
                                                    // Miss reparenting
                                                    return
    // Assume 0->1
    l->nr_items++
    // Assume 0->1
    nlru->nr_items++

IIUC, we use nlru->lock to serialise this scenario.

Thanks.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ