Skip to content

Commit ad8f63f

Browse files
ubizjakakpm00
authored andcommitted
perf/hw_breakpoint: use ERR_PTR_PCPU(), IS_ERR_PCPU() and PTR_ERR_PCPU() macros
Use ERR_PTR_PCPU() when returning error pointer in the percpu address space. Use IS_ERR_PCPU() and PTR_ERR_PCPU() when returning the error pointer from the percpu address space. These macros add intermediate cast to unsigned long when switching named address spaces. The patch will avoid future build errors due to pointer address space mismatch with enabled strict percpu address space checks. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Uros Bizjak <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: "Liang, Kan" <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 1bb5d66 commit ad8f63f

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

kernel/events/hw_breakpoint.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@ register_wide_hw_breakpoint(struct perf_event_attr *attr,
849849

850850
cpu_events = alloc_percpu(typeof(*cpu_events));
851851
if (!cpu_events)
852-
return (void __percpu __force *)ERR_PTR(-ENOMEM);
852+
return ERR_PTR_PCPU(-ENOMEM);
853853

854854
cpus_read_lock();
855855
for_each_online_cpu(cpu) {
@@ -868,7 +868,7 @@ register_wide_hw_breakpoint(struct perf_event_attr *attr,
868868
return cpu_events;
869869

870870
unregister_wide_hw_breakpoint(cpu_events);
871-
return (void __percpu __force *)ERR_PTR(err);
871+
return ERR_PTR_PCPU(err);
872872
}
873873
EXPORT_SYMBOL_GPL(register_wide_hw_breakpoint);
874874

samples/hw_breakpoint/data_breakpoint.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ static int __init hw_break_module_init(void)
5252
attr.bp_type = HW_BREAKPOINT_W;
5353

5454
sample_hbp = register_wide_hw_breakpoint(&attr, sample_hbp_handler, NULL);
55-
if (IS_ERR((void __force *)sample_hbp)) {
56-
ret = PTR_ERR((void __force *)sample_hbp);
55+
if (IS_ERR_PCPU(sample_hbp)) {
56+
ret = PTR_ERR_PCPU(sample_hbp);
5757
goto fail;
5858
}
5959

0 commit comments

Comments
 (0)