Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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/20240924090813.1353586-1-ubizjak@gmail.com
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: "Liang, Kan" <kan.liang@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Uros Bizjak and committed by
Andrew Morton
ad8f63f9 1bb5d660

+4 -4
+2 -2
kernel/events/hw_breakpoint.c
··· 849 849 850 850 cpu_events = alloc_percpu(typeof(*cpu_events)); 851 851 if (!cpu_events) 852 - return (void __percpu __force *)ERR_PTR(-ENOMEM); 852 + return ERR_PTR_PCPU(-ENOMEM); 853 853 854 854 cpus_read_lock(); 855 855 for_each_online_cpu(cpu) { ··· 868 868 return cpu_events; 869 869 870 870 unregister_wide_hw_breakpoint(cpu_events); 871 - return (void __percpu __force *)ERR_PTR(err); 871 + return ERR_PTR_PCPU(err); 872 872 } 873 873 EXPORT_SYMBOL_GPL(register_wide_hw_breakpoint); 874 874
+2 -2
samples/hw_breakpoint/data_breakpoint.c
··· 52 52 attr.bp_type = HW_BREAKPOINT_W; 53 53 54 54 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); 57 57 goto fail; 58 58 } 59 59