Re: [PATCH v3] sched_ext: Reject NMI calls to lock-taking kfuncs

From: liwanwu

Date: Wed Sep 02 2026 - 21:46:53 EST


Thanks for the correction and the guidance. I'll send a follow-up
patch to fix the remaining issues.

在 2026/9/3 07:05, Tejun Heo 写道:
Hello,

On Wed, Sep 02, 2026 at 05:36:11PM +0800, Wanwu Li wrote:
+#define scx_kf_allowed_ctx(sch) \
+({ \
+ bool __allowed = true; \

Applied to sched_ext/for-7.4 with the following changes:

- "No need to wrap" in my v2 reply was about the line wrap of the function
signature. Restored the inline function + macro wrapper form:

static __always_inline bool __scx_kf_allowed_ctx(struct scx_sched *sch, const char *who)
{
if (unlikely(in_nmi())) {
scx_error(sch, "%s called from NMI", who);
return false;
}
return true;
}

#define scx_kf_allowed_ctx(sch) __scx_kf_allowed_ctx((sch), __func__)

- struct_ops don't run in task context (e.g. ops.tick() runs from the tick
interrupt). They just never run in NMI. Updated the last paragraph of the
description accordingly.

Thanks.

--
tejun