-
Notifications
You must be signed in to change notification settings - Fork 302
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
kpatch-build error with 5.19 kernel #1277
Comments
The kernel commit that cause the issue is
I guess we should either revert this, or ship some fix in kpatch-build. |
Hi @liu-song-6 : Sorry for the late reply, I saw the same error yesterday, but haven't had a chance to take a closer look. I haven't had to touch the ancestor logic in a few years, so I'll have to spend a some time remembering how it all worked (IIRC there was a caching mechanism or shortcut method of sorts?) Anyway, since upstream has motivation for the change, not just touching things for aesthetic reasons, I think kpatch will have to cope with the shorter .o filenames. |
Something like this should fix it. Or, maybe we only need to grep for the short name? |
Unfortunately I think that patch won't be precise enough, since there can be duplicate file names across the tree, it might find the wrong one when doing a deep find. |
With basename grepping like @liu-song-6 proposed here, what if the deep find worked it's way back to the root of the source tree, searching along the way? (At the moment I believe it starts at the top.) This way we're not looking for something generic like init.o across the entire tree, but in gradually higher directories (ie, a/b/c/d/, then a/b/c/, a/b/, etc.) |
Do we have an example patch that may break kpatch-build due to the duplicated name? I tried with some changes in fs/autofs/init.c, it fails for some other reasons. |
I don't have one at hand (I only used "init.c" an example of a filename that could feasibly be duplicated). Perhaps another way to look at the problem would be to feed the original vs. new implementation a kernel tree full of .o files and see if any incorrect parent objects are generated. |
I found an issue with the original version: we may match But I guess it is still not 100% accurate? |
I ran two experiments for all object files from v5.19-rc7 and a .config similar to rhel-9:
A few observations:
See attached test script and results (lmk if I can explain them further). In the end, the new find_parent_obj() seems to run faster and finds more ancestors, however are a few inaccurate results. I'm not sure how to easily test the same for the existing algorithm to compare. I wonder since we're already wrapping ld with kpatch-ld, if we could somehow dump .o -> .ko / vmlinux mappings in this step? (It's late, so I'm only brainstorming here :) |
I haven't figured out how to run the test script. I got many invalid_ancestor:
Did I miss something?
Are we using kpatch-ld? I didn't find it. |
Sorry it was hacked together, I had find_parent_obj() copied from the original and then find_parent_obj_new() for the new version and just manually adjusted their calls for each case. Here is a version of the script with the function from a4287fb: And I ran it from the top of my kernel build like:
Right, the new find_parent_obj() finds a few more ancestors while missing ones like this. Does this patch work with this PR? diff --git a/drivers/md/md.c b/drivers/md/md.c
index c7ecb0bff..1ca189ec2 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -213,6 +213,7 @@ void mddev_create_serial_pool(struct mddev *mddev, struct md_rdev *rdev,
{
int ret = 0;
+ nop();
if (rdev && !rdev_need_serial(rdev) &&
!test_bit(CollisionCheck, &rdev->flags))
return; I get the same invalid ancestor error as you pointed out.
Oops, I thought we had a separate wrapper script for the linker, but it's all included in kpatch-build/kpatch-cc. Originally I thought we might be able to catch a single ld invocation for vmlinux and then for modules to which we could snarf for ancestor data, but that is not the case. It might be possible to work backwards from here somehow, but unfortunately it doesn't look straightforward to me. |
This happens because we have
where |
Ah, I see. Word regexp prevents |
I hacked this up this morning to try and special-case the new format: Not really tested and not really proud of the hack, but I think these functions could be refactored at some point in the future. Trying to regex or grep flag our way out of this feels very brittle. There's gotta be a better way. (Maybe if we wrap edit: that branch may work for vmlinux and foo.o -> foo.ko, but doesn't work for files like crypto/ecdh_helper.o -> crypto/ecdh_generic.ko. I'll need to wrap my brain around filter_parent_obj() first. |
I think this version of |
(Sorry for belated reply, I was on PTO.) Unfortunately I realized that shortly after posting it last week. We should enumerate all the potential cases across kernel releases to come up with a better solution. It feels like whack-a-mole at the moment. In the meantime, liu-song-6@b52499b should be reasonably accurate for you if you can manually sanity check its results? |
I guess it works for short term. It is not top priority for our production at the moment. But we do plan to use 5.19 as our next production kernel. |
Because the file names in the .cmd files are relative to the current directory, I think there's a more precise way to do this. We can detect whether the filenames are relative to the kernel root (old way) or current directory (new way) and adjust the algorithm accordingly. Let me try to come up with something (time willing). |
Rewrite kobj_find() to deal with Linux 5.19, where the .cmd files use file paths relative to the .cmd file rather than relative to the root of the kernel tree. Fixes dynup#1277. Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Rewrite kobj_find() to deal with Linux 5.19, where the .cmd files use file paths relative to the .cmd file rather than relative to the root of the kernel tree. Fixes dynup#1277. Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
I think I've got it working with jpoimboe/kpatch@f108002. I tested with @joe-lawrence 's script on 5.18 and 5.19. Any more testing would be welcome. |
Rewrite kobj_find() to deal with Linux 5.19, where the .cmd files use file paths relative to the .cmd file rather than relative to the root of the kernel tree. Fixes dynup#1277. Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
jpoimboe@f108002 failed with
liu-song-6@b52499b worked for me |
@androw That looks like something wrong with your setup. I don't see how it could be related to my patch. Did you have a file at /usr/libexec/kpatch/kpatch-cc? Maybe something went wrong with your install. Instead try running with /git/path/to/kpatch-build directly from the git tree. |
Rewrite kobj_find() to deal with Linux 5.19, where the .cmd files use object file paths relative to the .cmd file rather than relative to the root of the kernel tree. Fixes dynup#1277. Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Rewrite kobj_find() to deal with Linux 5.19, where the .cmd files use object file paths relative to the .cmd file rather than relative to the root of the kernel tree. Fixes dynup#1277. Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Yes a file is present here.
|
Can you run with the '-d' option and share the output (at least up until the first error)? |
Rewrite kobj_find() to deal with Linux 5.19, where the .cmd files use object file paths relative to the .cmd file rather than relative to the root of the kernel tree. While at it, add several performance enhancements to prevent all currently known deep finds. This is all quite fiddly. But it works. Fixes dynup#1277. Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
@androw I wonder if your version of 'realpath' is old? what does |
Maybe it would be better with the coreutils one. |
Hm, for older and alternative toolchains I guess we need a bash alternative to |
Rewrite kobj_find() to deal with Linux 5.19, where the .cmd files use object file paths relative to the .cmd file rather than relative to the root of the kernel tree. While at it, add several performance enhancements to prevent all currently known deep finds. This is all quite fiddly. But it works. Fixes dynup#1277. Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Rewrite kobj_find() to deal with Linux 5.19, where the .cmd files use object file paths relative to the .cmd file rather than relative to the root of the kernel tree. While at it, add several performance enhancements to prevent all currently known deep finds. This is all quite fiddly. But it works. Fixes dynup#1277. Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com> tweaked quoting to pass 'make check' Signed-off-by: Pete Swain <swine@google.com>
Rewrite kobj_find() to deal with Linux 5.19, where the .cmd files use object file paths relative to the .cmd file rather than relative to the root of the kernel tree. While at it, add several performance enhancements to prevent all currently known deep finds. This is all quite fiddly. But it works. Fixes dynup#1277. Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Rewrite kobj_find() to deal with Linux 5.19, where the .cmd files use object file paths relative to the .cmd file rather than relative to the root of the kernel tree. While at it, add several performance enhancements to prevent all currently known deep finds. This is all quite fiddly. But it works. Fixes dynup#1277. Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Rewrite kobj_find() to deal with Linux 5.19, where the .cmd files use object file paths relative to the .cmd file rather than relative to the root of the kernel tree. While at it, add several performance enhancements to prevent all currently known deep finds. This is all quite fiddly. But it works. Fixes dynup#1277. Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Rewrite kobj_find() to deal with Linux 5.19, where the .cmd files use object file paths relative to the .cmd file rather than relative to the root of the kernel tree. While at it, add several performance enhancements to prevent all currently known deep finds. This is all quite fiddly. But it works. Fixes dynup#1277. Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
I hit kpatch-build error like
with 5.19 kernel. Some debugging shows that this is caused by changes in .cmd files, i.e., array.o (in 5.19) instead of fs/proc/array.o (in 5.18). However, I haven't figured out what change in the kernel caused this change in .cmd files.
Something like this commit, fixes the issue. But I am not quite sure that's the right fix. Actually, I wonder whether we should fix it in the kernel.
The text was updated successfully, but these errors were encountered: