]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
sched_ext: Convert scx_dump_state() spinlock to raw spinlock
authorTejun Heo <tj@kernel.org>
Fri, 6 Mar 2026 17:58:04 +0000 (07:58 -1000)
committerTejun Heo <tj@kernel.org>
Fri, 6 Mar 2026 17:58:04 +0000 (07:58 -1000)
The scx_dump_state() function uses a regular spinlock to serialize
access. In a subsequent patch, this function will be called while
holding scx_sched_lock, which is a raw spinlock, creating a lock
nesting violation.

Convert the dump_lock to a raw spinlock and use the guard macro for
cleaner lock management.

Signed-off-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Andrea Righi <arighi@nvidia.com>
kernel/sched/ext.c

index 1452c20b6483e2a76b3fd74962379e96459328d1..0e8f5a62ff1c8f78972e0c45d7c83847afbf8407 100644 (file)
@@ -5220,7 +5220,7 @@ static void scx_dump_task(struct seq_buf *s, struct scx_dump_ctx *dctx,
 
 static void scx_dump_state(struct scx_exit_info *ei, size_t dump_len)
 {
-       static DEFINE_SPINLOCK(dump_lock);
+       static DEFINE_RAW_SPINLOCK(dump_lock);
        static const char trunc_marker[] = "\n\n~~~~ TRUNCATED ~~~~\n";
        struct scx_sched *sch = scx_root;
        struct scx_dump_ctx dctx = {
@@ -5232,11 +5232,10 @@ static void scx_dump_state(struct scx_exit_info *ei, size_t dump_len)
        };
        struct seq_buf s;
        struct scx_event_stats events;
-       unsigned long flags;
        char *buf;
        int cpu;
 
-       spin_lock_irqsave(&dump_lock, flags);
+       guard(raw_spinlock_irqsave)(&dump_lock);
 
        seq_buf_init(&s, ei->dump, dump_len);
 
@@ -5361,8 +5360,6 @@ static void scx_dump_state(struct scx_exit_info *ei, size_t dump_len)
        if (seq_buf_has_overflowed(&s) && dump_len >= sizeof(trunc_marker))
                memcpy(ei->dump + dump_len - sizeof(trunc_marker),
                       trunc_marker, sizeof(trunc_marker));
-
-       spin_unlock_irqrestore(&dump_lock, flags);
 }
 
 static void scx_error_irq_workfn(struct irq_work *irq_work)