Skip to content

Commit 8581ae1

Browse files
committed
Merge tag 'riscv-for-linus-6.11-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux
Pull RISC-V fixes from Palmer Dabbelt: - Two fixes for smp_processor_id() calls in preemptible sections: one if the perf driver, and one in the fence.i prctl. * tag 'riscv-for-linus-6.11-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: riscv: Disable preemption while handling PR_RISCV_CTX_SW_FENCEI_OFF drivers: perf: Fix smp_processor_id() use in preemptible code
2 parents 5abfdfd + 7c1e5b9 commit 8581ae1

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

arch/riscv/mm/cacheflush.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ void __init riscv_init_cbo_blocksizes(void)
158158
#ifdef CONFIG_SMP
159159
static void set_icache_stale_mask(void)
160160
{
161+
int cpu = get_cpu();
161162
cpumask_t *mask;
162163
bool stale_cpu;
163164

@@ -168,10 +169,11 @@ static void set_icache_stale_mask(void)
168169
* concurrently on different harts.
169170
*/
170171
mask = &current->mm->context.icache_stale_mask;
171-
stale_cpu = cpumask_test_cpu(smp_processor_id(), mask);
172+
stale_cpu = cpumask_test_cpu(cpu, mask);
172173

173174
cpumask_setall(mask);
174-
cpumask_assign_cpu(smp_processor_id(), mask, stale_cpu);
175+
cpumask_assign_cpu(cpu, mask, stale_cpu);
176+
put_cpu();
175177
}
176178
#endif
177179

@@ -239,14 +241,12 @@ int riscv_set_icache_flush_ctx(unsigned long ctx, unsigned long scope)
239241
case PR_RISCV_CTX_SW_FENCEI_OFF:
240242
switch (scope) {
241243
case PR_RISCV_SCOPE_PER_PROCESS:
242-
current->mm->context.force_icache_flush = false;
243-
244244
set_icache_stale_mask();
245+
current->mm->context.force_icache_flush = false;
245246
break;
246247
case PR_RISCV_SCOPE_PER_THREAD:
247-
current->thread.force_icache_flush = false;
248-
249248
set_icache_stale_mask();
249+
current->thread.force_icache_flush = false;
250250
break;
251251
default:
252252
return -EINVAL;

drivers/perf/riscv_pmu_sbi.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1373,11 +1373,15 @@ static int pmu_sbi_device_probe(struct platform_device *pdev)
13731373

13741374
/* SBI PMU Snapsphot is only available in SBI v2.0 */
13751375
if (sbi_v2_available) {
1376+
int cpu;
1377+
13761378
ret = pmu_sbi_snapshot_alloc(pmu);
13771379
if (ret)
13781380
goto out_unregister;
13791381

1380-
ret = pmu_sbi_snapshot_setup(pmu, smp_processor_id());
1382+
cpu = get_cpu();
1383+
1384+
ret = pmu_sbi_snapshot_setup(pmu, cpu);
13811385
if (ret) {
13821386
/* Snapshot is an optional feature. Continue if not available */
13831387
pmu_sbi_snapshot_free(pmu);
@@ -1391,6 +1395,7 @@ static int pmu_sbi_device_probe(struct platform_device *pdev)
13911395
*/
13921396
static_branch_enable(&sbi_pmu_snapshot_available);
13931397
}
1398+
put_cpu();
13941399
}
13951400

13961401
register_sysctl("kernel", sbi_pmu_sysctl_table);

0 commit comments

Comments
 (0)