Re: [PATCH 3/3] kbuild: introduce KERNEL_VERSION2 and LINUX_VERSION_CODE2

From: Sasha Levin
Date: Sat Feb 06 2021 - 09:32:05 EST


On Sat, Feb 06, 2021 at 09:45:44PM +0900, Masahiro Yamada wrote:
On Sat, Feb 6, 2021 at 12:50 PM Sasha Levin <sashal@xxxxxxxxxx> wrote:
- ((c) > 255 ? 255 : (c)))'
+ ((c) > 255 ? 255 : (c)))'; \
+ echo \#define LINUX_VERSION_CODE2 $(shell \
+ expr $(VERSION) \* 16777216 + 0$(PATCHLEVEL) \* 65536 + 0$(SUBLEVEL)); \


Is this needed?
No one in this patch uses LINUX_VERSION_CODE2.

The in-kernel code can use
LINUX_VERSION_MAJOR/PATCHLEVEL/SUBLEVEL directly.


Userspace does not need LINUX_VERSION_CODE2 either.

Your comment in 2/3 states that
userspace only decodes MAJOR and PATCHLEVEL fields,
so LINUX_VERSION_CODE will still do well.

Yes, that's fair. I wanted to have that to make it easy for out of tree
code to handle in-kernel ABI changes but as we don't care about such
code there's no strict need for LINUX_VERSION_CODE2. I'll drop it.

index ab4b98b3165db..a56bf381335e9 100644
--- a/tools/perf/tests/bpf-script-example.c
+++ b/tools/perf/tests/bpf-script-example.c
@@ -5,7 +5,7 @@
*/
#ifndef LINUX_VERSION_CODE
# error Need LINUX_VERSION_CODE
-# error Example: for 4.2 kernel, put 'clang-opt="-DLINUX_VERSION_CODE=0x40200" into llvm section of ~/.perfconfig'
+# error Example: for 4.2 kernel, put 'clang-opt="-DLINUX_VERSION_CODE=0x4020000" into llvm section of ~/.perfconfig'


Is this change needed?

Good point, no. I'll resend.

--
Thanks,
Sasha