From mboxrd@z Thu Jan 1 00:00:00 1970 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1D8CC636D7 for ; Tue, 21 Feb 2023 18:03:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8DCF66B0072; Tue, 21 Feb 2023 13:03:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 88D6D6B0073; Tue, 21 Feb 2023 13:03:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 77C336B0074; Tue, 21 Feb 2023 13:03:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 6B3326B0072 for ; Tue, 21 Feb 2023 13:03:15 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 2F31080A71 for ; Tue, 21 Feb 2023 18:03:15 +0000 (UTC) X-FDA: 80492070750.26.D601FDD Received: from out-54.mta1.migadu.com (out-54.mta1.migadu.com [95.215.58.54]) by imf20.hostedemail.com (Postfix) with ESMTP id CC3EB1C0012 for ; Tue, 21 Feb 2023 18:03:11 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=SHxsvZwy; spf=pass (imf20.hostedemail.com: domain of roman.gushchin@linux.dev designates 95.215.58.54 as permitted sender) smtp.mailfrom=roman.gushchin@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1677002592; h=from:from:sender: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:dkim-signature; bh=sMsd45Umu3YuXLOVUwNN2b4uIloC4nQS/PME1ZUx4QY=; b=Fpad6BV7553P627la6BMilKs8JKX1+1n8J7bLHe4ByJk33d1LdqvKoK3cSKT9L+WU95xYP Ou3Nf8NEPpnsAu4VW3UvYLjaCJZo9zZ7NPeyL4wEyUZxOVjKkUdJeDclX8cfq3lf2NN6eA b/czI/bM61XM9nwhbF1GUP6NtwhzEn0= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=SHxsvZwy; spf=pass (imf20.hostedemail.com: domain of roman.gushchin@linux.dev designates 95.215.58.54 as permitted sender) smtp.mailfrom=roman.gushchin@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677002592; a=rsa-sha256; cv=none; b=aRkU1lzVQN+gsix7IGJVgooo9cOYFwsHDTNlq91gnO/nQnJebRyQQpAatktIXV4bnQHnLo FaFdeo7G2VUXiy4YhB2ePWH5SyMnm+Tum6iHZfODrK1nc+eeWl7s5nZZKQ+MnzOt+3zIgG gDQCGparKV/t0UNbG/NJIjIzRNkinaI= Date: Tue, 21 Feb 2023 10:02:51 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1677002589; 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=sMsd45Umu3YuXLOVUwNN2b4uIloC4nQS/PME1ZUx4QY=; b=SHxsvZwyD5BmnUlPUsuusjZp3+TIl7ZqP0jdYYQwCKbWrkJ5vCHsFzPZQfPOB9oXXIDMOY YDC9T3cOn/usAilO1GAUxTsMoEZsSW9jal21ISKN04+sEI1olhWLV+lwwVv3QF5kklCJF+ Q210mi7PR6nlOH1EM4T9+fTSiLRE8gA= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Roman Gushchin To: Martin Zhao Cc: Shakeel Butt , 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, tangyeechou@gmail.com Subject: Re: [PATCH] mm: change memcg->oom_group access with atomic operations Message-ID: References: <20230220230624.lkobqeagycx7bi7p@google.com> <6563189C-7765-4FFA-A8F2-A5CC4860A1EF@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Stat-Signature: is8onuspm5cgtkkq8osomzsuyprwhjtp X-Rspam-User: X-Rspamd-Queue-Id: CC3EB1C0012 X-Rspamd-Server: rspam06 X-HE-Tag: 1677002591-22021 X-HE-Meta: U2FsdGVkX19RvxpTb2o9IBM4gY+zHbOzVTswCn6dx3lv+wkur8r0rxRl1uh4CVuGzHcWlCr/70VGd2u84zNvAhIkj7KJMqh3GhSiNXEJTiwCIEYEONyz6IJC2yZCBHzTO49KtCyVxcjPMSmfe+LyVp5t/579FLGno0ajf267BcDxDHMSYfZtkIy4Trve5WJAHJx2c4p+azV0WW/tJiEfCLDb6WqqmIK+FbcC8SvIhRRid0xzHpi0ZtBXUVvPApMP0mnpONjOstMB8KLXHXVra/KKbjDbePBlk2ApwsMla7dR/fTNEykmaiPF88Wd/auSsCkPrLfdITSB5EVZ0r1KOtKadjBdWlbIxsyFgh/97XlErlVclVfnIV9KbGmV+kqaphsPmPn/TDkgpvoLaJDSZrzl2BydKbD5qgWCsHw76z+RY0UjsjfyQEBDwvoolFcxModNT7+a5ZrFHlgVABnNO0X2qRR6r/mvcDdOZwTSN7awyCGAiyc5wypUBSH3ZRwjw4IFdTOMe1hFUOSjD5gKFMtOCKcGqrPe9z05OUvMlwhGx9zTobnDQdaOEacsgorcAeGZ3g98CA8ZGHBzfRwAZoOC8RWFWDAh+1EN7rU99nKzhXEJyxNkXtbFCO43jsbk6Hcfp7rr2QBrUzhk7aG4IgXLyHW/CrXp/ZvCcu5Ffw2fAvRJgR8fqi0x4RHGsJiU7grigFPrZ8pgg7qG5PQ8m2WmnHmbS5fAxuzmdjQmKi4jIkK80u1PJ2ybrKpdWBAY9RU+VB6qeeUjHYcyNFJnbp316qFfUDG/KJDvH6tFsrcnq2NUzHSv97X7mztyFzFKYRySY4Z+JftfoyoB/EZigrAA1wHqZoUnnn6sh7J9RM+UUKqNbyY34AABSrj8OMR3OZv0UTnPKgjWssh4qGp5q6dFwh8CE3T7CLmGbNoD2SGnRelutmGf6AMAsVXsTbUlcsi7PyCasSTruKTexeL rQKnFYij bype0LHYUd3bfky782NHGDi2CoqLVV9IflhKT0O10DUilmaiRMYJSgKVG9JVbGL1a62KFSLthM+zmWvPTQmd7C7Uv3Xv3AOO34ePsgWvkVF4weyS11ktZBB6KCD53D69TOlWUQmxnIcW0far0paxl/wXgfRXEbOvu9stnrG4Lt4QPfPpWRACoPznu0VoJsq7prFAWROOAugW7v9/atl05mpWLquISJzxAfOnj7bM96KzYKZjy5dHI4nU7izbmwtYSXrcx X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Feb 22, 2023 at 01:00:00AM +0800, Martin Zhao wrote: > On Tue, Feb 21, 2023 at 1:17 PM Roman Gushchin wrote: > > > > > On Feb 20, 2023, at 3:06 PM, Shakeel Butt wrote: > > > > > > On 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. > > >>> > > >>> Signed-off-by: Yue Zhao > > >> > > >> Hi Yue! > > >> > > >> I'm curious, have any seen any real issues which your patch is solving? > > >> Can you, please, provide a bit more details. > > >> > > > > > > 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’s 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’s easier to justify a proper atomic operation here, even if it’s most likely an overkill. > > > > My question is very simple: the commit log mentions “… to avoid concurrency problems”, so I wonder what problems are these. > > Thanks for your watching! > This topic is found in code review by coincidence, so no real issues > recorded for now. I checked other read/write callbacks about other knobs, > most of them use READ_ONCE/WRITE_ONCE on the user setting variable. Sorry, which knobs are you talking about? I actually don't see any user knobs in mm/memcontrol.c which are using WRITE_ONCE(). I see some of them using xchg(), but it's a different thing. > Actually I am curious as well why this interface doesn't use > READ_ONCE/WRITE_ONCE, is there any other synchronization mechanism I > didn't notice yet? Because nobody saw any issues with the current code? And again if it's something that makes any automated verifiers/tooling unhappy, I'm totally fine for fixing it, just let make it clear (and also fix the commit title, which is not true). Thanks!