Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

sched_ext: Put event_stats_cpu in struct scx_sched_pcpu

scx_sched.event_stats_cpu is the percpu counters that are used to track
stats. Introduce struct scx_sched_pcpu and move the counters inside. This
will ease adding more per-cpu fields. No functional changes.

Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Andrea Righi <arighi@nvidia.com>

Tejun Heo bcb7c230 0c2b8356

+19 -16
+9 -9
kernel/sched/ext.c
··· 635 635 * This can be used when preemption is not disabled. 636 636 */ 637 637 #define scx_add_event(sch, name, cnt) do { \ 638 - this_cpu_add((sch)->event_stats_cpu->name, (cnt)); \ 638 + this_cpu_add((sch)->pcpu->event_stats.name, (cnt)); \ 639 639 trace_sched_ext_event(#name, (cnt)); \ 640 640 } while(0) 641 641 ··· 648 648 * This should be used only when preemption is disabled. 649 649 */ 650 650 #define __scx_add_event(sch, name, cnt) do { \ 651 - __this_cpu_add((sch)->event_stats_cpu->name, (cnt)); \ 651 + __this_cpu_add((sch)->pcpu->event_stats.name, (cnt)); \ 652 652 trace_sched_ext_event(#name, cnt); \ 653 653 } while(0) 654 654 ··· 3543 3543 int node; 3544 3544 3545 3545 kthread_stop(sch->helper->task); 3546 - free_percpu(sch->event_stats_cpu); 3546 + free_percpu(sch->pcpu); 3547 3547 3548 3548 for_each_node_state(node, N_POSSIBLE) 3549 3549 kfree(sch->global_dsqs[node]); ··· 4444 4444 sch->global_dsqs[node] = dsq; 4445 4445 } 4446 4446 4447 - sch->event_stats_cpu = alloc_percpu(struct scx_event_stats); 4448 - if (!sch->event_stats_cpu) 4447 + sch->pcpu = alloc_percpu(struct scx_sched_pcpu); 4448 + if (!sch->pcpu) 4449 4449 goto err_free_gdsqs; 4450 4450 4451 4451 sch->helper = kthread_run_worker(0, "sched_ext_helper"); 4452 4452 if (!sch->helper) 4453 - goto err_free_event_stats; 4453 + goto err_free_pcpu; 4454 4454 sched_set_fifo(sch->helper->task); 4455 4455 4456 4456 atomic_set(&sch->exit_kind, SCX_EXIT_NONE); ··· 4468 4468 4469 4469 err_stop_helper: 4470 4470 kthread_stop(sch->helper->task); 4471 - err_free_event_stats: 4472 - free_percpu(sch->event_stats_cpu); 4471 + err_free_pcpu: 4472 + free_percpu(sch->pcpu); 4473 4473 err_free_gdsqs: 4474 4474 for_each_node_state(node, N_POSSIBLE) 4475 4475 kfree(sch->global_dsqs[node]); ··· 6493 6493 /* Aggregate per-CPU event counters into @events. */ 6494 6494 memset(events, 0, sizeof(*events)); 6495 6495 for_each_possible_cpu(cpu) { 6496 - e_cpu = per_cpu_ptr(sch->event_stats_cpu, cpu); 6496 + e_cpu = &per_cpu_ptr(sch->pcpu, cpu)->event_stats; 6497 6497 scx_agg_event(events, e_cpu, SCX_EV_SELECT_CPU_FALLBACK); 6498 6498 scx_agg_event(events, e_cpu, SCX_EV_DISPATCH_LOCAL_DSQ_OFFLINE); 6499 6499 scx_agg_event(events, e_cpu, SCX_EV_DISPATCH_KEEP_LAST);
+10 -7
kernel/sched/ext_internal.h
··· 846 846 s64 SCX_EV_BYPASS_ACTIVATE; 847 847 }; 848 848 849 + struct scx_sched_pcpu { 850 + /* 851 + * The event counters are in a per-CPU variable to minimize the 852 + * accounting overhead. A system-wide view on the event counter is 853 + * constructed when requested by scx_bpf_events(). 854 + */ 855 + struct scx_event_stats event_stats; 856 + }; 857 + 849 858 struct scx_sched { 850 859 struct sched_ext_ops ops; 851 860 DECLARE_BITMAP(has_op, SCX_OPI_END); ··· 869 860 */ 870 861 struct rhashtable dsq_hash; 871 862 struct scx_dispatch_q **global_dsqs; 872 - 873 - /* 874 - * The event counters are in a per-CPU variable to minimize the 875 - * accounting overhead. A system-wide view on the event counter is 876 - * constructed when requested by scx_bpf_events(). 877 - */ 878 - struct scx_event_stats __percpu *event_stats_cpu; 863 + struct scx_sched_pcpu __percpu *pcpu; 879 864 880 865 bool warned_zero_slice; 881 866