The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: David Vernet <void@manifault.com>,
	Andrea Righi <arighi@nvidia.com>,
	Changwoo Min <changwoo@igalia.com>
Cc: Emil Tsalapatis <emil@etsalapatis.com>,
	sched-ext@lists.linux.dev, linux-kernel@vger.kernel.org,
	Tejun Heo <tj@kernel.org>
Subject: [PATCH 1/3] sched_ext: Order single-cid cmask helpers as (cid, mask)
Date: Wed,  3 Jun 2026 07:21:51 -1000	[thread overview]
Message-ID: <20260603172153.3081861-2-tj@kernel.org> (raw)
In-Reply-To: <20260603172153.3081861-1-tj@kernel.org>

__scx_cmask_set(), __scx_cmask_contains() and __scx_cmask_word() take the
cmask first and the cid second. The kernel's bit and cpumask predicates put
the index first: test_bit(nr, addr), cpumask_test_cpu(cpu, mask). Reorder
the cmask helpers to (cid, mask) for consistency, ahead of new single-cid
ops added next. Mask-level ops (and/or/andnot/copy/subset/intersects) keep
(dst, src).

Signed-off-by: Tejun Heo <tj@kernel.org>
---
 kernel/sched/ext_cid.c |  2 +-
 kernel/sched/ext_cid.h | 10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/kernel/sched/ext_cid.c b/kernel/sched/ext_cid.c
index 808c6390da5a..66944a7ef79d 100644
--- a/kernel/sched/ext_cid.c
+++ b/kernel/sched/ext_cid.c
@@ -267,7 +267,7 @@ void scx_cpumask_to_cmask(const struct cpumask *src, struct scx_cmask *dst)
 		s32 cid = __scx_cpu_to_cid(cpu);
 
 		if (cid >= 0)
-			__scx_cmask_set(dst, cid);
+			__scx_cmask_set(cid, dst);
 	}
 }
 
diff --git a/kernel/sched/ext_cid.h b/kernel/sched/ext_cid.h
index abea22ba2cc2..46fd8eda0443 100644
--- a/kernel/sched/ext_cid.h
+++ b/kernel/sched/ext_cid.h
@@ -147,13 +147,13 @@ static inline bool scx_is_cid_type(void)
 	return static_branch_unlikely(&__scx_is_cid_type);
 }
 
-static inline bool __scx_cmask_contains(const struct scx_cmask *m, u32 cid)
+static inline bool __scx_cmask_contains(u32 cid, const struct scx_cmask *m)
 {
 	return likely(cid >= m->base && cid < m->base + m->nr_cids);
 }
 
 /* Word in bits[] covering @cid. @cid must satisfy __scx_cmask_contains(). */
-static inline u64 *__scx_cmask_word(const struct scx_cmask *m, u32 cid)
+static inline u64 *__scx_cmask_word(u32 cid, const struct scx_cmask *m)
 {
 	return (u64 *)&m->bits[cid / 64 - m->base / 64];
 }
@@ -218,11 +218,11 @@ static inline void scx_cmask_reframe(struct scx_cmask *m, u32 base, u32 nr_cids)
 	m->nr_cids = nr_cids;
 }
 
-static inline void __scx_cmask_set(struct scx_cmask *m, u32 cid)
+static inline void __scx_cmask_set(u32 cid, struct scx_cmask *m)
 {
-	if (!__scx_cmask_contains(m, cid))
+	if (!__scx_cmask_contains(cid, m))
 		return;
-	*__scx_cmask_word(m, cid) |= BIT_U64(cid & 63);
+	*__scx_cmask_word(cid, m) |= BIT_U64(cid & 63);
 }
 
 #endif /* _KERNEL_SCHED_EXT_CID_H */
-- 
2.54.0


  reply	other threads:[~2026-06-03 17:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-03 17:21 [PATCHSET sched_ext/for-7.2] sched_ext: cid/cmask interface prep Tejun Heo
2026-06-03 17:21 ` Tejun Heo [this message]
2026-06-03 17:21 ` [PATCH 2/3] sched_ext: Add scx_cmask_test() and scx_cmask_for_each_cid() Tejun Heo
2026-06-03 17:21 ` [PATCH 3/3] sched_ext: Make scx_bpf_kick_cid() return s32 Tejun Heo
2026-06-03 18:38   ` Andrea Righi
2026-06-03 18:41 ` [PATCHSET sched_ext/for-7.2] sched_ext: cid/cmask interface prep Andrea Righi

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=20260603172153.3081861-2-tj@kernel.org \
    --to=tj@kernel.org \
    --cc=arighi@nvidia.com \
    --cc=changwoo@igalia.com \
    --cc=emil@etsalapatis.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sched-ext@lists.linux.dev \
    --cc=void@manifault.com \
    /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