From patchwork Wed Mar 2 14:46:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Sewior X-Patchwork-Id: 12766202 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 6453CC433F5 for ; Wed, 2 Mar 2022 14:46:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DF5CE8D0002; Wed, 2 Mar 2022 09:46:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DA44F8D0001; Wed, 2 Mar 2022 09:46:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C94498D0002; Wed, 2 Mar 2022 09:46:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0183.hostedemail.com [216.40.44.183]) by kanga.kvack.org (Postfix) with ESMTP id B5F7C8D0001 for ; Wed, 2 Mar 2022 09:46:21 -0500 (EST) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 73AE79D27E for ; Wed, 2 Mar 2022 14:46:21 +0000 (UTC) X-FDA: 79199721762.24.C052963 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf21.hostedemail.com (Postfix) with ESMTP id CEAC01C0015 for ; Wed, 2 Mar 2022 14:46:20 +0000 (UTC) Date: Wed, 2 Mar 2022 15:46:16 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1646232378; 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=PpxvpaW7wGw/ZOsSQfgwEFQcmBDCMW9CjHzv6C/1/8s=; b=VAqsDfA05L/UKHxCLqWaMOIvNQh4FjZfmAqtPhVH65b1wOk4T3tV4WAmK7XY+1gAdk4qJg hr64GyLFSRmleqCMpjurxIdzY5xmsZRCF0iGlB/bXhM+xyJKU/R3AJk4M04DGsCWtu/b5V RqHDY0xXJkbe6I9f6/BAvqaQFqb/fKjnm+0DIT0hKsgfCBi+mQ9Mfw0ynrFC8EBevtWk2o /a/E8s6ozK7O8kK4ifEWpNx8w0Z7BFj7CrTZzVJp6FJZddvmrjLQ9CZUbcg28UbvqKKBOj Fq16Dq0ptToFuHv2KtH1F/C3vfU2FoYdX6ytpkL28y1Zmu2XeM4aqV/cdxz5Lw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1646232378; 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=PpxvpaW7wGw/ZOsSQfgwEFQcmBDCMW9CjHzv6C/1/8s=; b=4fKvI7QRhukl8Z2nIjFhR4UnkZXhUnIctHZf2n93YEcuHLFPDrGOejNEwmnME6IaTinIND UhA5AooQA+/4iJCg== From: Sebastian Andrzej Siewior To: Tejun Heo Cc: cgroups@vger.kernel.org, linux-mm@kvack.org, Andrew Morton , Johannes Weiner , Zefan Li , Thomas Gleixner Subject: [PATCH] cgroup: Add a comment to cgroup_rstat_flush_locked(). Message-ID: References: <[PATCH0/2]CorrectlockingassumptiononPREEMPT_RT> <20220301122143.1521823-1-bigeasy@linutronix.de> <20220301122143.1521823-2-bigeasy@linutronix.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam10 X-Rspam-User: X-Stat-Signature: a83rhjc15kpnficjrnwho696hrfr8azc Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=VAqsDfA0; dkim=pass header.d=linutronix.de header.s=2020e header.b=4fKvI7QR; spf=pass (imf21.hostedemail.com: domain of bigeasy@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=bigeasy@linutronix.de; dmarc=pass (policy=none) header.from=linutronix.de X-Rspamd-Queue-Id: CEAC01C0015 X-HE-Tag: 1646232380-458510 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: Add a comment why spin_lock_irq() -> raw_spin_lock_irqsave() is needed. Signed-off-by: Sebastian Andrzej Siewior Acked-by: Tejun Heo --- On 2022-03-01 20:38:51 [-1000], Tejun Heo wrote: > Hello, Hello Tejun, > Can you please add a comment explaining why irqsave is being used? As it > stands, it just looks spurious. Something like this? kernel/cgroup/rstat.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/kernel/cgroup/rstat.c b/kernel/cgroup/rstat.c index 53b771c20ee50..ba7a660184e41 100644 --- a/kernel/cgroup/rstat.c +++ b/kernel/cgroup/rstat.c @@ -155,6 +155,14 @@ static void cgroup_rstat_flush_locked(struct cgroup *cgrp, bool may_sleep) struct cgroup *pos = NULL; unsigned long flags; + /* + * The _irqsave() is needed because cgroup_rstat_lock is + * spinlock_t which is a sleeping lock on PREEMPT_RT. Acquiring + * this lock with the _irq() suffix only disables interrupts on + * a non-PREEMPT_RT kernel. The raw_spinlock_t below disables + * interrupts on both configurations. The _irqsave() ensures + * that interrupts are always disabled and later restored. + */ raw_spin_lock_irqsave(cpu_lock, flags); while ((pos = cgroup_rstat_cpu_pop_updated(pos, cgrp, cpu))) { struct cgroup_subsys_state *css;