Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 89A13C636D7 for ; Tue, 21 Feb 2023 05:17:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233204AbjBUFRp (ORCPT ); Tue, 21 Feb 2023 00:17:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232556AbjBUFRm (ORCPT ); Tue, 21 Feb 2023 00:17:42 -0500 Received: from out-31.mta1.migadu.com (out-31.mta1.migadu.com [IPv6:2001:41d0:203:375::1f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D3C425B9F for ; Mon, 20 Feb 2023 21:17:40 -0800 (PST) Content-Type: text/plain; charset=utf-8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1676956658; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jHA4ShwNMc6Yko4CbZnfjUYJ3+IEBFc/U9IHl1ydyHU=; b=SXSZebXV3YlaL4vWyE/804yKeFVfemiAG1+03DjJ6qxJkRSrXnmU0+PShEqj3GjAY5zPiX wMvdyP9wVBiSDcdKGvCTvpXtS5z5qfbZaGs+tWTsPwwuZJoE7vUsH7Pufzko8fAojReXSK MUzlB4qxYLsDXsDQEHUlhfdQs6bkSsQ= Content-Transfer-Encoding: quoted-printable X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Roman Gushchin MIME-Version: 1.0 Subject: Re: [PATCH] mm: change memcg->oom_group access with atomic operations Date: Mon, 20 Feb 2023 21:17:25 -0800 Message-Id: <6563189C-7765-4FFA-A8F2-A5CC4860A1EF@linux.dev> References: <20230220230624.lkobqeagycx7bi7p@google.com> Cc: Yue Zhao , linux-mm@kvack.org, akpm@linux-foundation.org, hannes@cmpxchg.org, mhocko@kernel.org, muchun.song@linux.dev, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230220230624.lkobqeagycx7bi7p@google.com> To: Shakeel Butt X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Feb 20, 2023, at 3:06 PM, Shakeel Butt wrote: >=20 > =EF=BB=BFOn Mon, Feb 20, 2023 at 01:09:44PM -0800, Roman Gushchin wrote: >>> On Mon, Feb 20, 2023 at 11:16:38PM +0800, Yue Zhao wrote: >>> The knob for cgroup v2 memory controller: memory.oom.group >>> will be read and written simultaneously by user space >>> programs, thus we'd better change memcg->oom_group access >>> with atomic operations to avoid concurrency problems. >>>=20 >>> Signed-off-by: Yue Zhao >>=20 >> Hi Yue! >>=20 >> I'm curious, have any seen any real issues which your patch is solving? >> Can you, please, provide a bit more details. >>=20 >=20 > IMHO such details are not needed. oom_group is being accessed > concurrently and one of them can be a write access. At least > READ_ONCE/WRITE_ONCE is needed here. Needed for what? I mean it=E2=80=99s obviously not a big deal to put READ_ONCE()/WRITE_ONCE()= here, but I struggle to imagine a scenario when it will make any difference= . IMHO it=E2=80=99s easier to justify a proper atomic operation here, even i= f it=E2=80=99s most likely an overkill. My question is very simple: the commit log mentions =E2=80=9C=E2=80=A6 to av= oid concurrency problems=E2=80=9D, so I wonder what problems are these. Also there are other similar cgroup interfaces without READ_ONCE()/WRITE_ONC= E(). Thanks!=