-
Notifications
You must be signed in to change notification settings - Fork 481
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
Linux: Fix kmsg f-strings #1502
Conversation
@@ -166,7 +166,7 @@ def get_caller(self, obj): | |||
|
|||
def get_caller_text(self, caller_id): | |||
caller_name = "CPU" if caller_id & 0x80000000 else "Task" | |||
caller = f"{caller_name}({caller_id & ~0x80000000:u})" | |||
caller = f"{caller_name}({int(caller_id & ~0x80000000)})" |
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.
the int() is redundant here
hm this bug was introduced in this commit, in the context of @ikelos If you want to use an f-string, your changes look good. However, I'd recommend removing the unnecessary int() call for simplicity. |
@c0rydoras I wonder if this bug was a ruff suggestion or you included this later? |
Thanks for checking this! The unnecessary |
@ikelos sorry, hold on. I double-checked this using the example I used in that method comment, and it turns out this doesn't work as expected. Unfortunately, we introduced another bug here. def nsec_to_sec_str(self, nsec: int) -> str:
# See kernel/printk/printk.c:print_time()
# Here, we could simply do:
# "%.6f" % (nsec / 1000000000.0)
# However, that will cause a roundoff error. For instance, using
# 17110365556 as input, the above will result in 17.110366.
# While the kernel print_time function will result in 17.110365.
# This might seem insignificant but it could cause some issues
# when compared with userland tool results or when used in
# timelines. >>> nsec=17110365556; "%lu.%06lu" % (nsec / 1000000000, (nsec % 1000000000) / 1000)
'17.110365'
>>> nsec=17110365556; f"{nsec / 1000000000}.{(nsec % 1000000000) / 1000:06}"
'17.110365556.110365.556' Using // should get the same results and fix this issue: >>> nsec=17110365556; f"{nsec // 1000000000}.{(nsec % 1000000000) // 1000:06}"
'17.110365' Another test: >>> nsec=17000365556; "%lu.%06lu" % (nsec / 1000000000, (nsec % 1000000000) / 1000)
'17.000365'
>>> nsec=17000365556; f"{nsec // 1000000000}.{(nsec % 1000000000) // 1000:06}"
'17.000365' The only potential issue would be if >>> nsec=17000365556.3; "%lu.%06lu" % (nsec / 1000000000, (nsec % 1000000000) / 1000)
'17.000365'
>>> nsec=17000365556.3; f"{nsec // 1000000000}.{(nsec % 1000000000) // 1000:06}"
'17.0.0365.0' |
linux: kmsg plugin: Fix f'string bug introduced in #1502
Closes #1496