Skip to content

Commit 99c37d1

Browse files
Sebastian Andrzej Siewiorrostedt
authored andcommitted
tracing: Replace deprecated CPU-hotplug functions.
The functions get_online_cpus() and put_online_cpus() have been deprecated during the CPU hotplug rework. They map directly to cpus_read_lock() and cpus_read_unlock(). Replace deprecated CPU-hotplug functions with the official version. The behavior remains unchanged. Link: https://lkml.kernel.org/r/[email protected] Cc: Peter Zijlstra <[email protected]> Cc: Ingo Molnar <[email protected]> Acked-by: Daniel Bristot de Oliveira <[email protected]> Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Steven Rostedt (VMware) <[email protected]>
1 parent db396be commit 99c37d1

File tree

3 files changed

+26
-26
lines changed

3 files changed

+26
-26
lines changed

kernel/trace/ring_buffer.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2111,7 +2111,7 @@ int ring_buffer_resize(struct trace_buffer *buffer, unsigned long size,
21112111
}
21122112
}
21132113

2114-
get_online_cpus();
2114+
cpus_read_lock();
21152115
/*
21162116
* Fire off all the required work handlers
21172117
* We can't schedule on offline CPUs, but it's not necessary
@@ -2143,7 +2143,7 @@ int ring_buffer_resize(struct trace_buffer *buffer, unsigned long size,
21432143
cpu_buffer->nr_pages_to_update = 0;
21442144
}
21452145

2146-
put_online_cpus();
2146+
cpus_read_unlock();
21472147
} else {
21482148
cpu_buffer = buffer->buffers[cpu_id];
21492149

@@ -2171,7 +2171,7 @@ int ring_buffer_resize(struct trace_buffer *buffer, unsigned long size,
21712171
goto out_err;
21722172
}
21732173

2174-
get_online_cpus();
2174+
cpus_read_lock();
21752175

21762176
/* Can't run something on an offline CPU. */
21772177
if (!cpu_online(cpu_id))
@@ -2183,7 +2183,7 @@ int ring_buffer_resize(struct trace_buffer *buffer, unsigned long size,
21832183
}
21842184

21852185
cpu_buffer->nr_pages_to_update = 0;
2186-
put_online_cpus();
2186+
cpus_read_unlock();
21872187
}
21882188

21892189
out:

kernel/trace/trace_hwlat.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -325,10 +325,10 @@ static void move_to_next_cpu(void)
325325
if (!cpumask_equal(current_mask, current->cpus_ptr))
326326
goto change_mode;
327327

328-
get_online_cpus();
328+
cpus_read_lock();
329329
cpumask_and(current_mask, cpu_online_mask, tr->tracing_cpumask);
330330
next_cpu = cpumask_next(raw_smp_processor_id(), current_mask);
331-
put_online_cpus();
331+
cpus_read_unlock();
332332

333333
if (next_cpu >= nr_cpu_ids)
334334
next_cpu = cpumask_first(current_mask);
@@ -398,7 +398,7 @@ static void stop_single_kthread(void)
398398
struct hwlat_kthread_data *kdata = get_cpu_data();
399399
struct task_struct *kthread;
400400

401-
get_online_cpus();
401+
cpus_read_lock();
402402
kthread = kdata->kthread;
403403

404404
if (!kthread)
@@ -408,7 +408,7 @@ static void stop_single_kthread(void)
408408
kdata->kthread = NULL;
409409

410410
out_put_cpus:
411-
put_online_cpus();
411+
cpus_read_unlock();
412412
}
413413

414414

@@ -425,14 +425,14 @@ static int start_single_kthread(struct trace_array *tr)
425425
struct task_struct *kthread;
426426
int next_cpu;
427427

428-
get_online_cpus();
428+
cpus_read_lock();
429429
if (kdata->kthread)
430430
goto out_put_cpus;
431431

432432
kthread = kthread_create(kthread_fn, NULL, "hwlatd");
433433
if (IS_ERR(kthread)) {
434434
pr_err(BANNER "could not start sampling thread\n");
435-
put_online_cpus();
435+
cpus_read_unlock();
436436
return -ENOMEM;
437437
}
438438

@@ -452,7 +452,7 @@ static int start_single_kthread(struct trace_array *tr)
452452
wake_up_process(kthread);
453453

454454
out_put_cpus:
455-
put_online_cpus();
455+
cpus_read_unlock();
456456
return 0;
457457
}
458458

@@ -479,10 +479,10 @@ static void stop_per_cpu_kthreads(void)
479479
{
480480
unsigned int cpu;
481481

482-
get_online_cpus();
482+
cpus_read_lock();
483483
for_each_online_cpu(cpu)
484484
stop_cpu_kthread(cpu);
485-
put_online_cpus();
485+
cpus_read_unlock();
486486
}
487487

488488
/*
@@ -515,7 +515,7 @@ static void hwlat_hotplug_workfn(struct work_struct *dummy)
515515

516516
mutex_lock(&trace_types_lock);
517517
mutex_lock(&hwlat_data.lock);
518-
get_online_cpus();
518+
cpus_read_lock();
519519

520520
if (!hwlat_busy || hwlat_data.thread_mode != MODE_PER_CPU)
521521
goto out_unlock;
@@ -526,7 +526,7 @@ static void hwlat_hotplug_workfn(struct work_struct *dummy)
526526
start_cpu_kthread(cpu);
527527

528528
out_unlock:
529-
put_online_cpus();
529+
cpus_read_unlock();
530530
mutex_unlock(&hwlat_data.lock);
531531
mutex_unlock(&trace_types_lock);
532532
}
@@ -582,7 +582,7 @@ static int start_per_cpu_kthreads(struct trace_array *tr)
582582
unsigned int cpu;
583583
int retval;
584584

585-
get_online_cpus();
585+
cpus_read_lock();
586586
/*
587587
* Run only on CPUs in which hwlat is allowed to run.
588588
*/
@@ -596,12 +596,12 @@ static int start_per_cpu_kthreads(struct trace_array *tr)
596596
if (retval)
597597
goto out_error;
598598
}
599-
put_online_cpus();
599+
cpus_read_unlock();
600600

601601
return 0;
602602

603603
out_error:
604-
put_online_cpus();
604+
cpus_read_unlock();
605605
stop_per_cpu_kthreads();
606606
return retval;
607607
}

kernel/trace/trace_osnoise.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,12 +1498,12 @@ static void stop_per_cpu_kthreads(void)
14981498
{
14991499
int cpu;
15001500

1501-
get_online_cpus();
1501+
cpus_read_lock();
15021502

15031503
for_each_online_cpu(cpu)
15041504
stop_kthread(cpu);
15051505

1506-
put_online_cpus();
1506+
cpus_read_unlock();
15071507
}
15081508

15091509
/*
@@ -1551,7 +1551,7 @@ static int start_per_cpu_kthreads(struct trace_array *tr)
15511551
int retval;
15521552
int cpu;
15531553

1554-
get_online_cpus();
1554+
cpus_read_lock();
15551555
/*
15561556
* Run only on CPUs in which trace and osnoise are allowed to run.
15571557
*/
@@ -1572,7 +1572,7 @@ static int start_per_cpu_kthreads(struct trace_array *tr)
15721572
}
15731573
}
15741574

1575-
put_online_cpus();
1575+
cpus_read_unlock();
15761576

15771577
return 0;
15781578
}
@@ -1590,7 +1590,7 @@ static void osnoise_hotplug_workfn(struct work_struct *dummy)
15901590
goto out_unlock_trace;
15911591

15921592
mutex_lock(&interface_lock);
1593-
get_online_cpus();
1593+
cpus_read_lock();
15941594

15951595
if (!cpumask_test_cpu(cpu, &osnoise_cpumask))
15961596
goto out_unlock;
@@ -1601,7 +1601,7 @@ static void osnoise_hotplug_workfn(struct work_struct *dummy)
16011601
start_kthread(cpu);
16021602

16031603
out_unlock:
1604-
put_online_cpus();
1604+
cpus_read_unlock();
16051605
mutex_unlock(&interface_lock);
16061606
out_unlock_trace:
16071607
mutex_unlock(&trace_types_lock);
@@ -1743,11 +1743,11 @@ osnoise_cpus_write(struct file *filp, const char __user *ubuf, size_t count,
17431743
/*
17441744
* osnoise_cpumask is read by CPU hotplug operations.
17451745
*/
1746-
get_online_cpus();
1746+
cpus_read_lock();
17471747

17481748
cpumask_copy(&osnoise_cpumask, osnoise_cpumask_new);
17491749

1750-
put_online_cpus();
1750+
cpus_read_unlock();
17511751
mutex_unlock(&interface_lock);
17521752

17531753
if (running)

0 commit comments

Comments
 (0)