Skip to content

Commit 080b5c6

Browse files
Frederic WeisbeckerThomas Gleixner
authored andcommitted
sched/cputime: Remove superfluous and error prone kcpustat_field() parameter
The first parameter to kcpustat_field() is a pointer to the cpu kcpustat to be fetched from. This parameter is error prone because a copy to a kcpustat could be passed by accident instead of the original one. Also the kcpustat structure can already be retrieved with the help of the mandatory CPU argument. Remove the needless parameter. Signed-off-by: Frederic Weisbecker <frederic@kernel.org> Signed-off-by: Thomas Gleixner <tglx@kernel.org> Tested-by: Shrikanth Hegde <sshegde@linux.ibm.com> Reviewed-by: Shrikanth Hegde <sshegde@linux.ibm.com> Link: https://patch.msgid.link/20260508131647.43868-4-frederic@kernel.org
1 parent 0236aaf commit 080b5c6

6 files changed

Lines changed: 15 additions & 22 deletions

File tree

drivers/cpufreq/cpufreq_governor.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ void gov_update_cpu_data(struct dbs_data *dbs_data)
105105
j_cdbs->prev_cpu_idle = get_cpu_idle_time(j, &j_cdbs->prev_update_time,
106106
dbs_data->io_is_busy);
107107
if (dbs_data->ignore_nice_load)
108-
j_cdbs->prev_cpu_nice = kcpustat_field(&kcpustat_cpu(j), CPUTIME_NICE, j);
108+
j_cdbs->prev_cpu_nice = kcpustat_field(CPUTIME_NICE, j);
109109
}
110110
}
111111
}
@@ -165,7 +165,7 @@ unsigned int dbs_update(struct cpufreq_policy *policy)
165165
j_cdbs->prev_cpu_idle = cur_idle_time;
166166

167167
if (ignore_nice) {
168-
u64 cur_nice = kcpustat_field(&kcpustat_cpu(j), CPUTIME_NICE, j);
168+
u64 cur_nice = kcpustat_field(CPUTIME_NICE, j);
169169

170170
idle_time += div_u64(cur_nice - j_cdbs->prev_cpu_nice, NSEC_PER_USEC);
171171
j_cdbs->prev_cpu_nice = cur_nice;
@@ -539,7 +539,7 @@ int cpufreq_dbs_governor_start(struct cpufreq_policy *policy)
539539
j_cdbs->prev_load = 0;
540540

541541
if (ignore_nice)
542-
j_cdbs->prev_cpu_nice = kcpustat_field(&kcpustat_cpu(j), CPUTIME_NICE, j);
542+
j_cdbs->prev_cpu_nice = kcpustat_field(CPUTIME_NICE, j);
543543
}
544544

545545
gov->start(policy);

drivers/macintosh/rack-meter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ static inline u64 get_cpu_idle_time(unsigned int cpu)
8787
kcpustat->cpustat[CPUTIME_IOWAIT];
8888

8989
if (rackmeter_ignore_nice)
90-
retval += kcpustat_field(kcpustat, CPUTIME_NICE, cpu);
90+
retval += kcpustat_field(CPUTIME_NICE, cpu);
9191

9292
return retval;
9393
}

include/linux/kernel_stat.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,12 @@ static inline unsigned long kstat_cpu_irqs_sum(unsigned int cpu)
100100
}
101101

102102
#ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
103-
extern u64 kcpustat_field(struct kernel_cpustat *kcpustat,
104-
enum cpu_usage_stat usage, int cpu);
103+
extern u64 kcpustat_field(enum cpu_usage_stat usage, int cpu);
105104
extern void kcpustat_cpu_fetch(struct kernel_cpustat *dst, int cpu);
106105
#else
107-
static inline u64 kcpustat_field(struct kernel_cpustat *kcpustat,
108-
enum cpu_usage_stat usage, int cpu)
106+
static inline u64 kcpustat_field(enum cpu_usage_stat usage, int cpu)
109107
{
110-
return kcpustat->cpustat[usage];
108+
return kcpustat_cpu(cpu).cpustat[usage];
111109
}
112110

113111
static inline void kcpustat_cpu_fetch(struct kernel_cpustat *dst, int cpu)

kernel/rcu/tree.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -969,14 +969,11 @@ static int rcu_watching_snap_recheck(struct rcu_data *rdp)
969969
if (rcu_cpu_stall_cputime && rdp->snap_record.gp_seq != rdp->gp_seq) {
970970
int cpu = rdp->cpu;
971971
struct rcu_snap_record *rsrp;
972-
struct kernel_cpustat *kcsp;
973-
974-
kcsp = &kcpustat_cpu(cpu);
975972

976973
rsrp = &rdp->snap_record;
977-
rsrp->cputime_irq = kcpustat_field(kcsp, CPUTIME_IRQ, cpu);
978-
rsrp->cputime_softirq = kcpustat_field(kcsp, CPUTIME_SOFTIRQ, cpu);
979-
rsrp->cputime_system = kcpustat_field(kcsp, CPUTIME_SYSTEM, cpu);
974+
rsrp->cputime_irq = kcpustat_field(CPUTIME_IRQ, cpu);
975+
rsrp->cputime_softirq = kcpustat_field(CPUTIME_SOFTIRQ, cpu);
976+
rsrp->cputime_system = kcpustat_field(CPUTIME_SYSTEM, cpu);
980977
rsrp->nr_hardirqs = kstat_cpu_irqs_sum(cpu) + arch_irq_stat_cpu(cpu);
981978
rsrp->nr_softirqs = kstat_cpu_softirqs_sum(cpu);
982979
rsrp->nr_csw = nr_context_switches_cpu(cpu);

kernel/rcu/tree_stall.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,6 @@ static void print_cpu_stat_info(int cpu)
479479
{
480480
struct rcu_snap_record rsr, *rsrp;
481481
struct rcu_data *rdp = per_cpu_ptr(&rcu_data, cpu);
482-
struct kernel_cpustat *kcsp = &kcpustat_cpu(cpu);
483482

484483
if (!rcu_cpu_stall_cputime)
485484
return;
@@ -488,9 +487,9 @@ static void print_cpu_stat_info(int cpu)
488487
if (rsrp->gp_seq != rdp->gp_seq)
489488
return;
490489

491-
rsr.cputime_irq = kcpustat_field(kcsp, CPUTIME_IRQ, cpu);
492-
rsr.cputime_softirq = kcpustat_field(kcsp, CPUTIME_SOFTIRQ, cpu);
493-
rsr.cputime_system = kcpustat_field(kcsp, CPUTIME_SYSTEM, cpu);
490+
rsr.cputime_irq = kcpustat_field(CPUTIME_IRQ, cpu);
491+
rsr.cputime_softirq = kcpustat_field(CPUTIME_SOFTIRQ, cpu);
492+
rsr.cputime_system = kcpustat_field(CPUTIME_SYSTEM, cpu);
494493

495494
pr_err("\t hardirqs softirqs csw/system\n");
496495
pr_err("\t number: %8lld %10d %12lld\n",

kernel/sched/cputime.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -975,10 +975,9 @@ static int kcpustat_field_vtime(u64 *cpustat,
975975
return 0;
976976
}
977977

978-
u64 kcpustat_field(struct kernel_cpustat *kcpustat,
979-
enum cpu_usage_stat usage, int cpu)
978+
u64 kcpustat_field(enum cpu_usage_stat usage, int cpu)
980979
{
981-
u64 *cpustat = kcpustat->cpustat;
980+
u64 *cpustat = kcpustat_cpu(cpu).cpustat;
982981
u64 val = cpustat[usage];
983982
struct rq *rq;
984983
int err;

0 commit comments

Comments
 (0)