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 F3CF4C677C4 for ; Tue, 10 Jun 2025 23:28:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 15B316B007B; Tue, 10 Jun 2025 19:28:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 10C176B0088; Tue, 10 Jun 2025 19:28:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 021F06B0089; Tue, 10 Jun 2025 19:28:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id D801F6B007B for ; Tue, 10 Jun 2025 19:28:33 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 7418EBCB07 for ; Tue, 10 Jun 2025 23:28:33 +0000 (UTC) X-FDA: 83541082506.02.742CE76 Received: from out-178.mta0.migadu.com (out-178.mta0.migadu.com [91.218.175.178]) by imf30.hostedemail.com (Postfix) with ESMTP id A099C80004 for ; Tue, 10 Jun 2025 23:28:31 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=RfMwful8; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf30.hostedemail.com: domain of shakeel.butt@linux.dev designates 91.218.175.178 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1749598111; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=EqVyj4QmrQUHnNz4aolJa1B8A00baXtmiLbQJA7wgSY=; b=DjPhQE9Wnp/SvyJ7D0ZLg6x3BmCKW2GLggPyHODQibJtxcHp8/5py9otGsqclecvedhh6W V41jMEIfNT9KeOPIJUbiJS5dADJEdCETLefbsLOogVPtFUEn/XAGbRvJj7HB38gkHKjvLJ zCIX4VnmUfN2sNcA02LcZ3Vp2lov6Wk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1749598111; a=rsa-sha256; cv=none; b=DeEbNsYuLdRdY3UdLzMrPV7U2gTLpHCU8dk5jM2FAWUqvp9n5zwtzu8MBOd1y0caVIYraE YkNdoV4uiW8gE2zqZO8HqNZUzrlyDumlJKQp4ymY/Os7HxG3n+aBnZ5qO0N1ZghwalEwkN 4hT5BUOSkxcMUjsvn+j+udWRfTfGUaw= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=RfMwful8; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf30.hostedemail.com: domain of shakeel.butt@linux.dev designates 91.218.175.178 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev Date: Tue, 10 Jun 2025 16:28:23 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1749598109; 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: in-reply-to:in-reply-to:references:references; bh=EqVyj4QmrQUHnNz4aolJa1B8A00baXtmiLbQJA7wgSY=; b=RfMwful8cDyssomCxR8rs9ARmx4/O++2QaXVOwIeiQHtYXhwJ332yE+ueeGB0JfFjar4ts NEIHwXfrGliMnasA2I1p59YCoi5mh/wF+BXG95/FNGlSsMGY5YxjLWqFCzqWwj5CwLO0lq cLL7ZhnqmgyAgoTK38UDesZD7cbkmu0= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Shakeel Butt To: Tejun Heo Cc: Andrew Morton , Johannes Weiner , Michal Hocko , Roman Gushchin , Muchun Song , Vlastimil Babka , Alexei Starovoitov , Sebastian Andrzej Siewior , Michal =?utf-8?Q?Koutn=C3=BD?= , Harry Yoo , Yosry Ahmed , bpf@vger.kernel.org, linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Meta kernel team Subject: Re: [PATCH 2/3] cgroup: make css_rstat_updated nmi safe Message-ID: References: <20250609225611.3967338-1-shakeel.butt@linux.dev> <20250609225611.3967338-3-shakeel.butt@linux.dev> <35ppn2muk4bsyosca4nxnbv5l6qv4ov2cxg5ksypst5ldf5zc4@vwrpziws4wjy> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Stat-Signature: 6j6a85d3dk5y1c4wjtx6hoa115p91bu3 X-Rspamd-Queue-Id: A099C80004 X-Rspam-User: X-Rspamd-Server: rspam06 X-HE-Tag: 1749598111-765250 X-HE-Meta: U2FsdGVkX192Xadz7sQdJDSR+EhW2EY0AJ1Zl1/cKUMH+SkHK/Qr9/j2MkQ1ry/jN8NAeRSM75Ncob5WGubmJNulYou0/wXbB30XzSQKGZTHsA9E8JQFJ+Oyfq4aRi4vPLwODaYOFTgW2mnNbcZDyiwyLduNQQkUW/otkJHZq3VWxU1NPsWKbevs2rEw1CvH1GpJSRXUNBelSUe/E+vDKirm2lU3lDGHyBsOqei8OajA7YWS4vaSg9Ak0jsq3MU/IPyut9KmjYIgDgYtT9v5sAyRyMpvc/D5tzJmpZXTtJKYeDsKSWAsfuyxlErsNHiX9eef01gjDSZe++lGQJGGqaNvBgqKJ9gwj5mGlEmOvhSthppL+i/dp0de1kOvfqeAKU9wFph4vOOYwn3VpSLsnE2eeAdA8HvIs+qDXzosGAEKTlBMeEduY+/n20+kR44VASo1TACOTgdASNeEkQShOESr/B+p0L6ovuyZVkabLwsQxSYR6F5aXD7p7z3afPn7e2QLSbXGRWicdtaMwKrTRTFnUL+N69npstwhv3gYWgxnk2BdGuwiFsGaFbSMNlAh5enSQzv61zgSJetta5R+SDusMOIV+KtxMG8iPOOiu2VO8iSQJ3Mqq5ctaaV56TPOYdR0U03jKpy6uY4UpMcwVubRgEtYqIfgPUWM+ri2NeH9MwqCC0FemJmMsUX01AB/jll82HfDAAZfbiLa3q07z+qGo80Mp7pYqZxn0IEoQfXLDLjRdufSAI6zb8m18MUlniAAk6TLJDBe37Kczelqu9Sk4HNmFu4H4cEPrQqpMhMqGuCKbZZS3G980qb7TORu6P7Ps50l/jO85juqJLNPlFnlibzkIe0UEaBeBXwLPnjHjb6/P8BJKDvLRoFszbA7d9yUms51qEaAalhIuNWF65991aoQjpXIRQhnIuwMAoLRRkiaEMuxdiqkBVwjnhv6h+7RpwllJ2RhnI/PUHl VpR2FQFF Ailwvh8Wd+M2/Q5BEG0NMtgsJcTU6s8NVZ6OMcO/lFyhCEoMJAPPrYxNg+QFy6+2wf0Qxq/tWI2ISOTFr83cJ+d01NfOtC7nOlqJguC80gJ5wM2r85ASCRh1L3oDxvSuSiiRO9tPyMJCOlzAnLQykYy4vu+aRvNNGE6o4z4Sjn2Y3oG0GQFdz+ZPaMTqBfMrUtKgLxn+onZT+1zmQxFfmNfJx0wULA/OIOX+FktGh3E8hxKoiWtYcS2RH9ypz9HPuFf4kQHXdgqypPaE= 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: List-Subscribe: List-Unsubscribe: On Tue, Jun 10, 2025 at 12:39:18PM -1000, Tejun Heo wrote: > Hello, > > On Tue, Jun 10, 2025 at 03:31:03PM -0700, Shakeel Butt wrote: > ... > > Couple of lines above I have llist_on_list(&rstatc->lnode) check which > > should be as cheap as data_race(css_rstat_cpu(css, cpu)->updated_next). > > Ah, I missed that. > > > So, I can add lnode for nmi and non-nmi contexts (with irqs disabled) > > but I think that is not needed. Actually I ran the netperf benchmark (36 > > parallel instances) and I see no significant differences with and > > without the patch. > > Yeah, as long as the hot path doesn't hit the extra cmpxchg, I think it > should be fine. Can you fortify the comments a bit that the synchronization > is against the stacking contexts on the same CPU. The use of cmpxchg for > something like this is a bit unusual and it'd be nice to have explanation on > why it's done this way and why the overhead doesn't matter. I was actually thinking of using this_cpu_cmpxchg but then I need to also check for CONFIG_ARCH_HAS_NMI_SAFE_THIS_CPU_OPS. However if you prefer that, I can try this_cpu_cmpxchg in the next version. I will also fix the comment with additional information about stacking context.