Skip to content

Commit 0e9b4c1

Browse files
arighihtejun
authored andcommitted
sched_ext: idle: Introduce scx_bpf_nr_node_ids()
Similarly to scx_bpf_nr_cpu_ids(), introduce a new kfunc scx_bpf_nr_node_ids() to expose the maximum number of NUMA nodes in the system. BPF schedulers can use this information together with the new node-aware kfuncs, for example to create per-node DSQs, validate node IDs, etc. Signed-off-by: Andrea Righi <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent 0105921 commit 0e9b4c1

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

kernel/sched/ext.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7113,6 +7113,16 @@ __bpf_kfunc void scx_bpf_cpuperf_set(s32 cpu, u32 perf)
71137113
}
71147114
}
71157115

7116+
/**
7117+
* scx_bpf_nr_node_ids - Return the number of possible node IDs
7118+
*
7119+
* All valid node IDs in the system are smaller than the returned value.
7120+
*/
7121+
__bpf_kfunc u32 scx_bpf_nr_node_ids(void)
7122+
{
7123+
return nr_node_ids;
7124+
}
7125+
71167126
/**
71177127
* scx_bpf_nr_cpu_ids - Return the number of possible CPU IDs
71187128
*
@@ -7325,6 +7335,7 @@ BTF_ID_FLAGS(func, scx_bpf_dump_bstr, KF_TRUSTED_ARGS)
73257335
BTF_ID_FLAGS(func, scx_bpf_cpuperf_cap)
73267336
BTF_ID_FLAGS(func, scx_bpf_cpuperf_cur)
73277337
BTF_ID_FLAGS(func, scx_bpf_cpuperf_set)
7338+
BTF_ID_FLAGS(func, scx_bpf_nr_node_ids)
73287339
BTF_ID_FLAGS(func, scx_bpf_nr_cpu_ids)
73297340
BTF_ID_FLAGS(func, scx_bpf_get_possible_cpumask, KF_ACQUIRE)
73307341
BTF_ID_FLAGS(func, scx_bpf_get_online_cpumask, KF_ACQUIRE)

tools/sched_ext/include/scx/common.bpf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ void scx_bpf_dump_bstr(char *fmt, unsigned long long *data, u32 data_len) __ksym
7070
u32 scx_bpf_cpuperf_cap(s32 cpu) __ksym __weak;
7171
u32 scx_bpf_cpuperf_cur(s32 cpu) __ksym __weak;
7272
void scx_bpf_cpuperf_set(s32 cpu, u32 perf) __ksym __weak;
73+
u32 scx_bpf_nr_node_ids(void) __ksym __weak;
7374
u32 scx_bpf_nr_cpu_ids(void) __ksym __weak;
7475
int scx_bpf_cpu_node(s32 cpu) __ksym __weak;
7576
const struct cpumask *scx_bpf_get_possible_cpumask(void) __ksym __weak;

tools/sched_ext/include/scx/compat.bpf.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,10 @@ static inline bool __COMPAT_is_enq_cpu_selected(u64 enq_flags)
189189
*
190190
* Preserve the following __COMPAT_scx_*_node macros until v6.17.
191191
*/
192+
#define __COMPAT_scx_bpf_nr_node_ids() \
193+
(bpf_ksym_exists(scx_bpf_nr_node_ids) ? \
194+
scx_bpf_nr_node_ids() : 1U)
195+
192196
#define __COMPAT_scx_bpf_cpu_node(cpu) \
193197
(bpf_ksym_exists(scx_bpf_cpu_node) ? \
194198
scx_bpf_cpu_node(cpu) : 0)

0 commit comments

Comments
 (0)