New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sysfs: runtime byteorder detection #1872
Conversation
39bcedd
to
9e55845
Compare
I like it :-) |
@@ -639,9 +651,9 @@ static void load_xinfo_from_proc_inet_L3(ino_t netns_inode, const char *proc_fil | |||
sock->class = class; | |||
sock->inode = (ino_t)inode; | |||
sock->netns_inode = netns_inode; | |||
inet->local_addr = local_addr; | |||
inet->local_addr = kernel32_to_cpu(byteorder, local_addr); | |||
tcp->local_port = local_port; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need kernel16_to_cpu(byteorder, local_port);
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It actually works without it.
IIRC the kernel always uses network-endianness for the port.
The inconsistency between address and port feels very much like a bug. But there's nothing to be done about it.
OK, if I good understand, we need to wait for changes in Linus' tree. |
Indeed. For now I dropped the alternative filesystem specification as it is an unnecessary burden to carry around during the coordination process with the kernel. FYI the file has now moved to |
The kernelpatch has been picked up by Greg and should end up in Linux 6.2 |
@karelzak To adapt the tests for lscpu all the dumps need the file The alternative would be to move from archives to plain directories. This would make the diffs cleaner. |
I guess the change is backwardly compatible ;-), so the tests without We need to update the script tests/ts/lscpu/mk-input.sh to gather cpu_byteorder too. |
Yes it will work without the file. Do we want to update a bunch of binary archives or unpack them first? |
The dumps already contain obsolete things but want to be compatible with these old kernels/dumps, so it makes sense to keep the old dumps unchanged. It would be better to create a new dump with the new kernel and add it as x86_64-linux-6.2.tar.gz or so (or something more exotic if you have ...). |
This can be used to read the file /sys/kernel/cpu_byteorder from an alternative root-directory.
193ad8a
to
bc37e1d
Compare
This can be used to skip tests that require that the machine executing the tests has the same byteorder as the test executable. Useful for tests emulated with qemu-user.
It contains the new file /sys/kernel/cpu_byteorder that lscpu will use to read the actual byteorder.
bc37e1d
to
c47031e
Compare
The necessary kernel changes have been merged as https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/kernel/ksysfs.c?id=d3d76fbde1c456a6d19991baa99ea8c2d6e6696f |
This is a proof-of-concept that makes use of a new procfs file[0] to detect the byteorder of a running kernel at runtime.
The advantage is that
lsfd
andlscpu
work correctly even in the face of emulation.Cc @karelzak @masatake
[0] https://git.sr.ht/~t-8ch/linux/log/proc-byteorder