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:   Tue, 3 Aug 2021 07:13:35 +0000
From:   Roman Gushchin <guro@...com>
To:     Michal Hocko <mhocko@...e.com>
CC:     Miaohe Lin <linmiaohe@...wei.com>,
        "hannes@...xchg.org" <hannes@...xchg.org>,
        "vdavydov.dev@...il.com" <vdavydov.dev@...il.com>,
        "akpm@...ux-foundation.org" <akpm@...ux-foundation.org>,
        "shakeelb@...gle.com" <shakeelb@...gle.com>,
        "willy@...radead.org" <willy@...radead.org>,
        "alexs@...nel.org" <alexs@...nel.org>,
        "richard.weiyang@...il.com" <richard.weiyang@...il.com>,
        "songmuchun@...edance.com" <songmuchun@...edance.com>,
        "linux-mm@...ck.org" <linux-mm@...ck.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "cgroups@...r.kernel.org" <cgroups@...r.kernel.org>
Subject: Re: [PATCH 2/5] mm, memcg: narrow the scope of percpu_charge_mutex

I’d go with atomic_dec().

Sent from my iPhone

> On Aug 3, 2021, at 00:11, Michal Hocko <mhocko@...e.com> wrote:
> 
> On Tue 03-08-21 14:29:13, Miaohe Lin wrote:
> [...]
>> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
>> index 616d1a72ece3..6210b1124929 100644
>> --- a/mm/memcontrol.c
>> +++ b/mm/memcontrol.c
>> @@ -2208,11 +2208,11 @@ static void refill_stock(struct mem_cgroup *memcg, unsigned int nr_pages)
>>  */
>> static void drain_all_stock(struct mem_cgroup *root_memcg)
>> {
>> -       static DEFINE_MUTEX(percpu_charge_mutex);
>>        int cpu, curcpu;
>> +       static atomic_t drainer = ATOMIC_INIT(0);
>> 
>>        /* If someone's already draining, avoid adding running more workers. */
>> -       if (!mutex_trylock(&percpu_charge_mutex))
>> +       if (atomic_cmpxchg(&drainer, 0, 1) != 0)
>>                return;
>>        /*
>>         * Notify other cpus that system-wide "drain" is running
>> @@ -2244,7 +2244,7 @@ static void drain_all_stock(struct mem_cgroup *root_memcg)
>>                }
>>        }
>>        put_cpu();
>> -       mutex_unlock(&percpu_charge_mutex);
>> +       atomic_set(&drainer, 0);
> 
> atomic_set doesn't imply memory barrier IIRC. Is this safe?
> 
> -- 
> Michal Hocko
> SUSE Labs

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ