Skip to content

Commit b74b8a9

Browse files
nickalcockNick Alcock
authored andcommitted
dtrace: reintroduce one old typedef for userspace ABI compatibility
The conversion of all struct typedefs to typedefs triggered a problem: DTrace userspace declares the type of the built-in variable curcpu to be "vmlinux`cpuinfo_t *". This declaration is hardwired into the source code: changing it would produce a DTrace that didn't work with older (non-de-typedeffed) kernels. These kernels *do* contain a reference to 'struct cpuinfo', but unfortunately there is no pointer to it declared in the DWARF, only a pointer to its typedef, so declaring curcpu to be of type "vmlinux`struct cpuinfo *" doesn't work. So reintroduce this typedef, and force a pointer to it to be used in one place in vmlinux (in dtrace_cpu_init()) to ensure that it gets emitted into the DWARF. The typedef is not used anywhere else in the kernel: everything else uses struct cpuinfo, as it should. Signed-off-by: Nick Alcock <[email protected]>
1 parent 800e672 commit b74b8a9

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

include/linux/dtrace_cpu.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ struct cpuinfo {
4444

4545
DECLARE_PER_CPU_SHARED_ALIGNED(struct cpuinfo, dtrace_cpu_info);
4646

47+
/* ABI requirement: type names compiled into DTrace userspace. */
48+
typedef struct cpuinfo cpuinfo_t;
49+
4750
extern void dtrace_cpu_init(void);
4851

4952
#endif /* CONFIG_DTRACE */

kernel/dtrace/dtrace_cpu.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ void dtrace_cpu_init(void)
3030
{
3131
int cpu;
3232

33+
/*
34+
* Force this type into the CTF for the sake of userspace's
35+
* ABI requirements.
36+
*/
37+
cpuinfo_t *dummy __attribute__((__unused__)) = NULL;
38+
3339
for_each_present_cpu(cpu) {
3440
cpuinfo_arch_t *ci = &cpu_data(cpu);
3541
struct cpuinfo *cpui = per_cpu_info(cpu);

0 commit comments

Comments
 (0)