netoptimizer / prototype-kernel

Prototyping kernel development work outside mainline
GNU General Public License v2.0
300 stars 106 forks source link

header issues `unaligned pointer value`? #22

Closed aalemayhu closed 7 years ago

aalemayhu commented 7 years ago

Wanted to try out the new monitor but seeing the compilation issues below. Am I missing something?

/lib/modules/4.12.8-300.fc26.x86_64/build//arch/x86/include/asm/processor.h:527:30: error: taking address of packed member 'sp0' of class or structure 'x86_hw_tss' may result in an unaligned pointer value
      [-Werror,-Waddress-of-packed-member]
        return this_cpu_read_stable(cpu_tss.x86_tss.sp0);
                                    ^~~~~~~~~~~~~~~~~~~
/lib/modules/4.12.8-300.fc26.x86_64/build//arch/x86/include/asm/percpu.h:391:59: note: expanded from macro 'this_cpu_read_stable'
#define this_cpu_read_stable(var)       percpu_stable_op("mov", var)
                                                                ^~~
/lib/modules/4.12.8-300.fc26.x86_64/build//arch/x86/include/asm/percpu.h:218:16: note: expanded from macro 'percpu_stable_op'
                    : "p" (&(var)));                    \
                             ^~~
In file included from napi_monitor_kern.c:7:
In file included from /lib/modules/4.12.8-300.fc26.x86_64/build//include/linux/netdevice.h:28:
In file included from /lib/modules/4.12.8-300.fc26.x86_64/build//include/linux/timer.h:5:
In file included from /lib/modules/4.12.8-300.fc26.x86_64/build//include/linux/ktime.h:24:
In file included from /lib/modules/4.12.8-300.fc26.x86_64/build//include/linux/time.h:5:
In file included from /lib/modules/4.12.8-300.fc26.x86_64/build//include/linux/seqlock.h:35:
In file included from /lib/modules/4.12.8-300.fc26.x86_64/build//include/linux/spinlock.h:50:
In file included from /lib/modules/4.12.8-300.fc26.x86_64/build//include/linux/preempt.h:80:
In file included from /lib/modules/4.12.8-300.fc26.x86_64/build//arch/x86/include/asm/preempt.h:6:
In file included from /lib/modules/4.12.8-300.fc26.x86_64/build//include/linux/thread_info.h:37:
In file included from /lib/modules/4.12.8-300.fc26.x86_64/build//arch/x86/include/asm/thread_info.h:52:
In file included from /lib/modules/4.12.8-300.fc26.x86_64/build//arch/x86/include/asm/cpufeature.h:4:
/lib/modules/4.12.8-300.fc26.x86_64/build//arch/x86/include/asm/processor.h:527:30: error: taking address of packed member 'sp0' of class or structure 'x86_hw_tss' may result in an unaligned pointer value
      [-Werror,-Waddress-of-packed-member]
        return this_cpu_read_stable(cpu_tss.x86_tss.sp0);
                                    ^~~~~~~~~~~~~~~~~~~
/lib/modules/4.12.8-300.fc26.x86_64/build//arch/x86/include/asm/percpu.h:391:59: note: expanded from macro 'this_cpu_read_stable'
#define this_cpu_read_stable(var)       percpu_stable_op("mov", var)
                                                                ^~~
/lib/modules/4.12.8-300.fc26.x86_64/build//arch/x86/include/asm/percpu.h:223:16: note: expanded from macro 'percpu_stable_op'
                    : "p" (&(var)));                    \
                             ^~~
In file included from napi_monitor_kern.c:7:
In file included from /lib/modules/4.12.8-300.fc26.x86_64/build//include/linux/netdevice.h:28:
In file included from /lib/modules/4.12.8-300.fc26.x86_64/build//include/linux/timer.h:5:
In file included from /lib/modules/4.12.8-300.fc26.x86_64/build//include/linux/ktime.h:24:
In file included from /lib/modules/4.12.8-300.fc26.x86_64/build//include/linux/time.h:5:
In file included from /lib/modules/4.12.8-300.fc26.x86_64/build//include/linux/seqlock.h:35:
In file included from /lib/modules/4.12.8-300.fc26.x86_64/build//include/linux/spinlock.h:50:
In file included from /lib/modules/4.12.8-300.fc26.x86_64/build//include/linux/preempt.h:80:
In file included from /lib/modules/4.12.8-300.fc26.x86_64/build//arch/x86/include/asm/preempt.h:6:
In file included from /lib/modules/4.12.8-300.fc26.x86_64/build//include/linux/thread_info.h:37:
In file included from /lib/modules/4.12.8-300.fc26.x86_64/build//arch/x86/include/asm/thread_info.h:52:
In file included from /lib/modules/4.12.8-300.fc26.x86_64/build//arch/x86/include/asm/cpufeature.h:4:
/lib/modules/4.12.8-300.fc26.x86_64/build//arch/x86/include/asm/processor.h:527:30: error: taking address of packed member 'sp0' of class or structure 'x86_hw_tss' may result in an unaligned pointer value
      [-Werror,-Waddress-of-packed-member]
        return this_cpu_read_stable(cpu_tss.x86_tss.sp0);
                                    ^~~~~~~~~~~~~~~~~~~
/lib/modules/4.12.8-300.fc26.x86_64/build//arch/x86/include/asm/percpu.h:391:59: note: expanded from macro 'this_cpu_read_stable'
#define this_cpu_read_stable(var)       percpu_stable_op("mov", var)
                                                                ^~~
/lib/modules/4.12.8-300.fc26.x86_64/build//arch/x86/include/asm/percpu.h:228:16: note: expanded from macro 'percpu_stable_op'
                    : "p" (&(var)));                    \
                             ^~~
In file included from napi_monitor_kern.c:7:
In file included from /lib/modules/4.12.8-300.fc26.x86_64/build//include/linux/netdevice.h:28:
In file included from /lib/modules/4.12.8-300.fc26.x86_64/build//include/linux/timer.h:5:
In file included from /lib/modules/4.12.8-300.fc26.x86_64/build//include/linux/ktime.h:24:
In file included from /lib/modules/4.12.8-300.fc26.x86_64/build//include/linux/time.h:5:
In file included from /lib/modules/4.12.8-300.fc26.x86_64/build//include/linux/seqlock.h:35:
In file included from /lib/modules/4.12.8-300.fc26.x86_64/build//include/linux/spinlock.h:50:
In file included from /lib/modules/4.12.8-300.fc26.x86_64/build//include/linux/preempt.h:80:
In file included from /lib/modules/4.12.8-300.fc26.x86_64/build//arch/x86/include/asm/preempt.h:6:
In file included from /lib/modules/4.12.8-300.fc26.x86_64/build//include/linux/thread_info.h:37:
In file included from /lib/modules/4.12.8-300.fc26.x86_64/build//arch/x86/include/asm/thread_info.h:52:
In file included from /lib/modules/4.12.8-300.fc26.x86_64/build//arch/x86/include/asm/cpufeature.h:4:
/lib/modules/4.12.8-300.fc26.x86_64/build//arch/x86/include/asm/processor.h:527:30: error: taking address of packed member 'sp0' of class or structure 'x86_hw_tss' may result in an unaligned pointer value
      [-Werror,-Waddress-of-packed-member]
        return this_cpu_read_stable(cpu_tss.x86_tss.sp0);
                                    ^~~~~~~~~~~~~~~~~~~
/lib/modules/4.12.8-300.fc26.x86_64/build//arch/x86/include/asm/percpu.h:391:59: note: expanded from macro 'this_cpu_read_stable'
#define this_cpu_read_stable(var)       percpu_stable_op("mov", var)
                                                                ^~~
/lib/modules/4.12.8-300.fc26.x86_64/build//arch/x86/include/asm/percpu.h:233:16: note: expanded from macro 'percpu_stable_op'
                    : "p" (&(var)));                    \
                             ^~~
4 errors generated.
make: *** [Makefile:175: napi_monitor_kern.o] Error 1
netoptimizer commented 7 years ago

I've not seen this on my system.

What compiler version are you using? (for compiling napi_monitor_kern.c)

It seems it is "only" a warning, which is treated as an error. It says "may":

[...] may result in an unaligned pointer value

I speculate that it doesn't like how the struct napi_bulk_histogram is constructed. On 32-bit machine this might get another alignment. See structs in napi_monitor.h

aalemayhu commented 7 years ago
clang --version
clang version 4.0.0 (tags/RELEASE_400/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

not seeing the warning issue with older clang.

So commenting out EXTRA_CFLAGS make's it build for me. Cool demo, thanks!