mirror of
https://github.com/JakeHillion/scx.git
synced 2024-11-26 03:20:24 +00:00
scx_layered: Add helper function to access cpumask within bpf_cpumask
Before passing "nodec->cpumas" and "cachec->cpumask" into "bpf_cpumask_test_cpu()", type conversion should be done first. Implement "cast_mask()" to convert "struct bpf_cpumask *" into "const struct cpumask *". Reference from https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/testing/selftests/bpf/progs/cpumask_common.h#n63 Signed-off-by: I Hsin Cheng <richard120310@gmail.com>
This commit is contained in:
parent
e4bb99efc5
commit
7799b94f07
@ -254,6 +254,14 @@ static struct cpumask *lookup_layer_cpumask(int idx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Access a cpumask in read-only mode (typically to check bits).
|
||||||
|
*/
|
||||||
|
static const struct cpumask *cast_mask(struct bpf_cpumask *mask)
|
||||||
|
{
|
||||||
|
return (const struct cpumask *)mask;
|
||||||
|
}
|
||||||
|
|
||||||
static void refresh_cpumasks(int idx)
|
static void refresh_cpumasks(int idx)
|
||||||
{
|
{
|
||||||
struct layer_cpumask_wrapper *cpumaskw;
|
struct layer_cpumask_wrapper *cpumaskw;
|
||||||
@ -1313,12 +1321,12 @@ void BPF_STRUCT_OPS(layered_running, struct task_struct *p)
|
|||||||
if (!(nodec = lookup_node_ctx(cctx->node_idx)))
|
if (!(nodec = lookup_node_ctx(cctx->node_idx)))
|
||||||
return;
|
return;
|
||||||
if (nodec->cpumask &&
|
if (nodec->cpumask &&
|
||||||
!bpf_cpumask_test_cpu(tctx->last_cpu, nodec->cpumask))
|
!bpf_cpumask_test_cpu(tctx->last_cpu, cast_mask(nodec->cpumask)))
|
||||||
lstat_inc(LSTAT_XNUMA_MIGRATION, layer, cctx);
|
lstat_inc(LSTAT_XNUMA_MIGRATION, layer, cctx);
|
||||||
if (!(cachec = lookup_cache_ctx(cctx->cache_idx)))
|
if (!(cachec = lookup_cache_ctx(cctx->cache_idx)))
|
||||||
return;
|
return;
|
||||||
if (cachec->cpumask &&
|
if (cachec->cpumask &&
|
||||||
!bpf_cpumask_test_cpu(tctx->last_cpu, cachec->cpumask))
|
!bpf_cpumask_test_cpu(tctx->last_cpu, cast_mask(cachec->cpumask)))
|
||||||
lstat_inc(LSTAT_XLLC_MIGRATION, layer, cctx);
|
lstat_inc(LSTAT_XLLC_MIGRATION, layer, cctx);
|
||||||
}
|
}
|
||||||
tctx->last_cpu = task_cpu;
|
tctx->last_cpu = task_cpu;
|
||||||
|
Loading…
Reference in New Issue
Block a user