Skip to content

Commit ba1924b

Browse files
committed
Prepare rust side for l3 awareness
1 parent 0c3c7bb commit ba1924b

File tree

6 files changed

+504
-25
lines changed

6 files changed

+504
-25
lines changed

scheds/rust/scx_mitosis/src/bpf/intf.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ enum cell_stat_idx {
4646
NR_CSTATS,
4747
};
4848

49+
/* Function invocation counters */
50+
enum counter_idx {
51+
COUNTER_SELECT_CPU,
52+
COUNTER_ENQUEUE,
53+
COUNTER_DISPATCH,
54+
NR_COUNTERS,
55+
};
56+
4957
struct cpu_ctx {
5058
u64 cstats[MAX_CELLS][NR_CSTATS];
5159
u64 cell_cycles[MAX_CELLS];

scheds/rust/scx_mitosis/src/bpf/mitosis.bpf.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ UEI_DEFINE(uei);
4949
*/
5050
struct cpu_to_l3_map cpu_to_l3 SEC(".maps");
5151
struct l3_to_cpus_map l3_to_cpus SEC(".maps");
52+
53+
/*
54+
* Maps for statistics
55+
*/
56+
struct function_counters_map function_counters SEC(".maps");
5257
struct steal_stats_map steal_stats SEC(".maps");
5358

5459
/*

scheds/rust/scx_mitosis/src/bpf/mitosis.bpf.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,16 @@
3737
*/
3838
#define MAX_CPUMASK_ENTRIES (4)
3939

40-
extern const volatile u32 nr_l3;
41-
4240
/*
4341
* We don't know how big struct cpumask is at compile time, so just allocate a
4442
* large space and check that it is big enough at runtime
43+
* TODO: This should be deduplicated with the rust code and put in intf.h
4544
*/
4645
#define CPUMASK_LONG_ENTRIES (128)
4746
#define CPUMASK_SIZE (sizeof(long) * CPUMASK_LONG_ENTRIES)
4847

48+
extern const volatile u32 nr_l3;
49+
4950
enum mitosis_constants {
5051
/* Invalid/unset L3 value */
5152
INVALID_L3_ID = -1,
@@ -102,3 +103,11 @@ struct task_ctx {
102103
// These could go in mitosis.bpf.h, but we'll cross that bridge when we get
103104
static inline struct cell *lookup_cell(int idx);
104105
static inline const struct cpumask *lookup_cell_cpumask(int idx);
106+
107+
/* MAP TYPES */
108+
struct function_counters_map {
109+
__uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
110+
__type(key, u32);
111+
__type(value, u64);
112+
__uint(max_entries, NR_COUNTERS);
113+
};

0 commit comments

Comments
 (0)