Skip to content

Commit 22127e9

Browse files
Christoph Lameterhtejun
authored andcommitted
time: Replace __get_cpu_var uses
Convert uses of __get_cpu_var for creating a address from a percpu offset to this_cpu_ptr. The two cases where get_cpu_var is used to actually access a percpu variable are changed to use this_cpu_read/raw_cpu_read. Reviewed-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Christoph Lameter <cl@linux.com> Signed-off-by: Tejun Heo <tj@kernel.org>
1 parent bb964a9 commit 22127e9

10 files changed

Lines changed: 29 additions & 29 deletions

File tree

‎drivers/clocksource/dummy_timer.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static void dummy_timer_set_mode(enum clock_event_mode mode,
2828
static void dummy_timer_setup(void)
2929
{
3030
int cpu = smp_processor_id();
31-
struct clock_event_device *evt = __this_cpu_ptr(&dummy_timer_evt);
31+
struct clock_event_device *evt = raw_cpu_ptr(&dummy_timer_evt);
3232

3333
evt->name = "dummy_timer";
3434
evt->features = CLOCK_EVT_FEAT_PERIODIC |

‎kernel/irq_work.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,11 @@ bool irq_work_queue(struct irq_work *work)
9595

9696
/* If the work is "lazy", handle it from next tick if any */
9797
if (work->flags & IRQ_WORK_LAZY) {
98-
if (llist_add(&work->llnode, &__get_cpu_var(lazy_list)) &&
98+
if (llist_add(&work->llnode, this_cpu_ptr(&lazy_list)) &&
9999
tick_nohz_tick_stopped())
100100
arch_irq_work_raise();
101101
} else {
102-
if (llist_add(&work->llnode, &__get_cpu_var(raised_list)))
102+
if (llist_add(&work->llnode, this_cpu_ptr(&raised_list)))
103103
arch_irq_work_raise();
104104
}
105105

@@ -113,8 +113,8 @@ bool irq_work_needs_cpu(void)
113113
{
114114
struct llist_head *raised, *lazy;
115115

116-
raised = &__get_cpu_var(raised_list);
117-
lazy = &__get_cpu_var(lazy_list);
116+
raised = this_cpu_ptr(&raised_list);
117+
lazy = this_cpu_ptr(&lazy_list);
118118
if (llist_empty(raised) && llist_empty(lazy))
119119
return false;
120120

@@ -166,8 +166,8 @@ static void irq_work_run_list(struct llist_head *list)
166166
*/
167167
void irq_work_run(void)
168168
{
169-
irq_work_run_list(&__get_cpu_var(raised_list));
170-
irq_work_run_list(&__get_cpu_var(lazy_list));
169+
irq_work_run_list(this_cpu_ptr(&raised_list));
170+
irq_work_run_list(this_cpu_ptr(&lazy_list));
171171
}
172172
EXPORT_SYMBOL_GPL(irq_work_run);
173173

‎kernel/sched/clock.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ static DEFINE_PER_CPU_SHARED_ALIGNED(struct sched_clock_data, sched_clock_data);
134134

135135
static inline struct sched_clock_data *this_scd(void)
136136
{
137-
return &__get_cpu_var(sched_clock_data);
137+
return this_cpu_ptr(&sched_clock_data);
138138
}
139139

140140
static inline struct sched_clock_data *cpu_sdc(int cpu)

‎kernel/softirq.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ static void tasklet_action(struct softirq_action *a)
485485
local_irq_disable();
486486
list = __this_cpu_read(tasklet_vec.head);
487487
__this_cpu_write(tasklet_vec.head, NULL);
488-
__this_cpu_write(tasklet_vec.tail, &__get_cpu_var(tasklet_vec).head);
488+
__this_cpu_write(tasklet_vec.tail, this_cpu_ptr(&tasklet_vec.head));
489489
local_irq_enable();
490490

491491
while (list) {
@@ -521,7 +521,7 @@ static void tasklet_hi_action(struct softirq_action *a)
521521
local_irq_disable();
522522
list = __this_cpu_read(tasklet_hi_vec.head);
523523
__this_cpu_write(tasklet_hi_vec.head, NULL);
524-
__this_cpu_write(tasklet_hi_vec.tail, &__get_cpu_var(tasklet_hi_vec).head);
524+
__this_cpu_write(tasklet_hi_vec.tail, this_cpu_ptr(&tasklet_hi_vec.head));
525525
local_irq_enable();
526526

527527
while (list) {

‎kernel/time/hrtimer.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,7 +1144,7 @@ static void __hrtimer_init(struct hrtimer *timer, clockid_t clock_id,
11441144

11451145
memset(timer, 0, sizeof(struct hrtimer));
11461146

1147-
cpu_base = &__raw_get_cpu_var(hrtimer_bases);
1147+
cpu_base = raw_cpu_ptr(&hrtimer_bases);
11481148

11491149
if (clock_id == CLOCK_REALTIME && mode != HRTIMER_MODE_ABS)
11501150
clock_id = CLOCK_MONOTONIC;
@@ -1187,7 +1187,7 @@ int hrtimer_get_res(const clockid_t which_clock, struct timespec *tp)
11871187
struct hrtimer_cpu_base *cpu_base;
11881188
int base = hrtimer_clockid_to_base(which_clock);
11891189

1190-
cpu_base = &__raw_get_cpu_var(hrtimer_bases);
1190+
cpu_base = raw_cpu_ptr(&hrtimer_bases);
11911191
*tp = ktime_to_timespec(cpu_base->clock_base[base].resolution);
11921192

11931193
return 0;
@@ -1376,7 +1376,7 @@ static void __hrtimer_peek_ahead_timers(void)
13761376
if (!hrtimer_hres_active())
13771377
return;
13781378

1379-
td = &__get_cpu_var(tick_cpu_device);
1379+
td = this_cpu_ptr(&tick_cpu_device);
13801380
if (td && td->evtdev)
13811381
hrtimer_interrupt(td->evtdev);
13821382
}

‎kernel/time/tick-broadcast.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ int tick_resume_broadcast_oneshot(struct clock_event_device *bc)
554554
void tick_check_oneshot_broadcast_this_cpu(void)
555555
{
556556
if (cpumask_test_cpu(smp_processor_id(), tick_broadcast_oneshot_mask)) {
557-
struct tick_device *td = &__get_cpu_var(tick_cpu_device);
557+
struct tick_device *td = this_cpu_ptr(&tick_cpu_device);
558558

559559
/*
560560
* We might be in the middle of switching over from

‎kernel/time/tick-common.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ static void tick_setup_device(struct tick_device *td,
224224

225225
void tick_install_replacement(struct clock_event_device *newdev)
226226
{
227-
struct tick_device *td = &__get_cpu_var(tick_cpu_device);
227+
struct tick_device *td = this_cpu_ptr(&tick_cpu_device);
228228
int cpu = smp_processor_id();
229229

230230
clockevents_exchange_device(td->evtdev, newdev);
@@ -374,14 +374,14 @@ void tick_shutdown(unsigned int *cpup)
374374

375375
void tick_suspend(void)
376376
{
377-
struct tick_device *td = &__get_cpu_var(tick_cpu_device);
377+
struct tick_device *td = this_cpu_ptr(&tick_cpu_device);
378378

379379
clockevents_shutdown(td->evtdev);
380380
}
381381

382382
void tick_resume(void)
383383
{
384-
struct tick_device *td = &__get_cpu_var(tick_cpu_device);
384+
struct tick_device *td = this_cpu_ptr(&tick_cpu_device);
385385
int broadcast = tick_resume_broadcast();
386386

387387
clockevents_set_mode(td->evtdev, CLOCK_EVT_MODE_RESUME);

‎kernel/time/tick-oneshot.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ void tick_setup_oneshot(struct clock_event_device *newdev,
5959
*/
6060
int tick_switch_to_oneshot(void (*handler)(struct clock_event_device *))
6161
{
62-
struct tick_device *td = &__get_cpu_var(tick_cpu_device);
62+
struct tick_device *td = this_cpu_ptr(&tick_cpu_device);
6363
struct clock_event_device *dev = td->evtdev;
6464

6565
if (!dev || !(dev->features & CLOCK_EVT_FEAT_ONESHOT) ||

‎kernel/time/tick-sched.c‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ static void tick_nohz_restart_sched_tick(struct tick_sched *ts, ktime_t now);
205205
*/
206206
void __tick_nohz_full_check(void)
207207
{
208-
struct tick_sched *ts = &__get_cpu_var(tick_cpu_sched);
208+
struct tick_sched *ts = this_cpu_ptr(&tick_cpu_sched);
209209

210210
if (tick_nohz_full_cpu(smp_processor_id())) {
211211
if (ts->tick_stopped && !is_idle_task(current)) {
@@ -545,7 +545,7 @@ static ktime_t tick_nohz_stop_sched_tick(struct tick_sched *ts,
545545
unsigned long seq, last_jiffies, next_jiffies, delta_jiffies;
546546
ktime_t last_update, expires, ret = { .tv64 = 0 };
547547
unsigned long rcu_delta_jiffies;
548-
struct clock_event_device *dev = __get_cpu_var(tick_cpu_device).evtdev;
548+
struct clock_event_device *dev = __this_cpu_read(tick_cpu_device.evtdev);
549549
u64 time_delta;
550550

551551
time_delta = timekeeping_max_deferment();
@@ -813,7 +813,7 @@ void tick_nohz_idle_enter(void)
813813

814814
local_irq_disable();
815815

816-
ts = &__get_cpu_var(tick_cpu_sched);
816+
ts = this_cpu_ptr(&tick_cpu_sched);
817817
ts->inidle = 1;
818818
__tick_nohz_idle_enter(ts);
819819

@@ -831,7 +831,7 @@ EXPORT_SYMBOL_GPL(tick_nohz_idle_enter);
831831
*/
832832
void tick_nohz_irq_exit(void)
833833
{
834-
struct tick_sched *ts = &__get_cpu_var(tick_cpu_sched);
834+
struct tick_sched *ts = this_cpu_ptr(&tick_cpu_sched);
835835

836836
if (ts->inidle)
837837
__tick_nohz_idle_enter(ts);
@@ -846,7 +846,7 @@ void tick_nohz_irq_exit(void)
846846
*/
847847
ktime_t tick_nohz_get_sleep_length(void)
848848
{
849-
struct tick_sched *ts = &__get_cpu_var(tick_cpu_sched);
849+
struct tick_sched *ts = this_cpu_ptr(&tick_cpu_sched);
850850

851851
return ts->sleep_length;
852852
}
@@ -959,7 +959,7 @@ static int tick_nohz_reprogram(struct tick_sched *ts, ktime_t now)
959959
*/
960960
static void tick_nohz_handler(struct clock_event_device *dev)
961961
{
962-
struct tick_sched *ts = &__get_cpu_var(tick_cpu_sched);
962+
struct tick_sched *ts = this_cpu_ptr(&tick_cpu_sched);
963963
struct pt_regs *regs = get_irq_regs();
964964
ktime_t now = ktime_get();
965965

@@ -979,7 +979,7 @@ static void tick_nohz_handler(struct clock_event_device *dev)
979979
*/
980980
static void tick_nohz_switch_to_nohz(void)
981981
{
982-
struct tick_sched *ts = &__get_cpu_var(tick_cpu_sched);
982+
struct tick_sched *ts = this_cpu_ptr(&tick_cpu_sched);
983983
ktime_t next;
984984

985985
if (!tick_nohz_enabled)
@@ -1115,7 +1115,7 @@ early_param("skew_tick", skew_tick);
11151115
*/
11161116
void tick_setup_sched_timer(void)
11171117
{
1118-
struct tick_sched *ts = &__get_cpu_var(tick_cpu_sched);
1118+
struct tick_sched *ts = this_cpu_ptr(&tick_cpu_sched);
11191119
ktime_t now = ktime_get();
11201120

11211121
/*
@@ -1184,7 +1184,7 @@ void tick_clock_notify(void)
11841184
*/
11851185
void tick_oneshot_notify(void)
11861186
{
1187-
struct tick_sched *ts = &__get_cpu_var(tick_cpu_sched);
1187+
struct tick_sched *ts = this_cpu_ptr(&tick_cpu_sched);
11881188

11891189
set_bit(0, &ts->check_clocks);
11901190
}
@@ -1199,7 +1199,7 @@ void tick_oneshot_notify(void)
11991199
*/
12001200
int tick_check_oneshot_change(int allow_nohz)
12011201
{
1202-
struct tick_sched *ts = &__get_cpu_var(tick_cpu_sched);
1202+
struct tick_sched *ts = this_cpu_ptr(&tick_cpu_sched);
12031203

12041204
if (!test_and_clear_bit(0, &ts->check_clocks))
12051205
return 0;

‎kernel/time/timer.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ static inline void debug_assert_init(struct timer_list *timer)
655655
static void do_init_timer(struct timer_list *timer, unsigned int flags,
656656
const char *name, struct lock_class_key *key)
657657
{
658-
struct tvec_base *base = __raw_get_cpu_var(tvec_bases);
658+
struct tvec_base *base = raw_cpu_read(tvec_bases);
659659

660660
timer->entry.next = NULL;
661661
timer->base = (void *)((unsigned long)base | flags);

0 commit comments

Comments
 (0)