linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Tejun Heo <tj@kernel.org>
Cc: cgroups@vger.kernel.org, linux-mm@kvack.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Zefan Li <lizefan.x@bytedance.com>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: [PATCH] cgroup: Add a comment to cgroup_rstat_flush_locked().
Date: Wed, 2 Mar 2022 15:46:16 +0100	[thread overview]
Message-ID: <Yh+DOK73hfVV5ThX@linutronix.de> (raw)
In-Reply-To: <Yh8Q+wjgk6dkDphR@slm.duckdns.org>

Add a comment why spin_lock_irq() -> raw_spin_lock_irqsave() is needed.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
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;
-- 
2.35.1


  reply	other threads:[~2022-03-02 14:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <[PATCH 0/2] Correct locking assumption on PREEMPT_RT>
     [not found] ` <20220301122143.1521823-1-bigeasy@linutronix.de>
2022-03-01 12:21   ` [PATCH 1/2] cgroup: Use irqsave in cgroup_rstat_flush_locked() Sebastian Andrzej Siewior
2022-03-02  6:38     ` Tejun Heo
2022-03-02 14:46       ` Sebastian Andrzej Siewior [this message]
2022-03-02 15:47         ` [PATCH] cgroup: Add a comment to cgroup_rstat_flush_locked() Tejun Heo
2022-03-01 12:21   ` [PATCH 2/2] mm: workingset: Replace IRQ-off check with a lockdep assert Sebastian Andrzej Siewior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Yh+DOK73hfVV5ThX@linutronix.de \
    --to=bigeasy@linutronix.de \
    --cc=akpm@linux-foundation.org \
    --cc=cgroups@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-mm@kvack.org \
    --cc=lizefan.x@bytedance.com \
    --cc=tglx@linutronix.de \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox