Static local reworks#1054
Conversation
| } | ||
| #endif | ||
|
|
||
| static bool kpatch_changed_child_needs_parent_profiling(struct symbol *sym) |
There was a problem hiding this comment.
It might be helpful to add a comment somewhere explaining that .cold children don't have fentry but that .part children often do.
BTW, the terms 'parent' and 'child' in this context have always bothered me because they're so ambigious. What do you think? Any ideas for better naming? Superfunction/subfunction?
There was a problem hiding this comment.
I'll add the comment.
Superfunction sounds a bit odd. But subfunction definitely sounds better than child.
Maybe Top function?
Otherwise I actually like the "part" terminology (without being a direct references to the .part. in the name of the symbol). So I would suggest e.g. "function_parts" and "part_of" .
There was a problem hiding this comment.
I'm not sure about function_parts/part_of. Maybe parent/child is ok.
|
A unit test (or tests) for this PR would be good too. |
This is a test for dynup/kpatch#1054. The following patch was used with a RHEL-8.0 kernel: diff --git a/kernel/audit.c b/kernel/audit.c index e7478cb..ed2546a 100644 --- a/kernel/audit.c +++ b/kernel/audit.c @@ -325,6 +325,12 @@ void audit_panic(const char *message) } } +void kpatch_audit_foo(void) +{ + if (!jiffies) + printk("kpatch audit foo\n"); +} + static inline int audit_rate_check(void) { static unsigned long last_check = 0; @@ -335,6 +341,7 @@ static inline int audit_rate_check(void) unsigned long elapsed; int retval = 0; + kpatch_audit_foo(); if (!audit_rate_limit) return 1; spin_lock_irqsave(&lock, flags); @@ -354,6 +361,11 @@ static inline int audit_rate_check(void) return retval; } +noinline void kpatch_audit_check(void) +{ + audit_rate_check(); +} + /** * audit_log_lost - conditionally log lost audit message event * @message: the message stating reason for lost audit message @@ -400,6 +412,8 @@ static int audit_log_config_change(char *function_name, u32 new, u32 old, struct audit_buffer *ab; int rc = 0; + kpatch_audit_check(); + ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_CONFIG_CHANGE); if (unlikely(!ab)) return rc; Signed-off-by: Julien Thierry <jthierry@redhat.com>
This is a test for dynup/kpatch#1054. The following patch was used with a RHEL-8.0 kernel: diff --git a/kernel/audit.c b/kernel/audit.c index e7478cb..ed2546a 100644 --- a/kernel/audit.c +++ b/kernel/audit.c @@ -325,6 +325,12 @@ void audit_panic(const char *message) } } +void kpatch_audit_foo(void) +{ + if (!jiffies) + printk("kpatch audit foo\n"); +} + static inline int audit_rate_check(void) { static unsigned long last_check = 0; @@ -335,6 +341,7 @@ static inline int audit_rate_check(void) unsigned long elapsed; int retval = 0; + kpatch_audit_foo(); if (!audit_rate_limit) return 1; spin_lock_irqsave(&lock, flags); @@ -354,6 +361,11 @@ static inline int audit_rate_check(void) return retval; } +noinline void kpatch_audit_check(void) +{ + audit_rate_check(); +} + /** * audit_log_lost - conditionally log lost audit message event * @message: the message stating reason for lost audit message @@ -400,6 +412,8 @@ static int audit_log_config_change(char *function_name, u32 new, u32 old, struct audit_buffer *ab; int rc = 0; + kpatch_audit_check(); + ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_CONFIG_CHANGE); if (unlikely(!ab)) return rc; Signed-off-by: Julien Thierry <jthierry@redhat.com>
This is supposedly fixed by dynup#1054 and should be reinabled once that is merged. Signed-off-by: Artem Savkov <asavkov@redhat.com>
This is supposedly fixed by dynup#1054 and should be reinabled once that is merged. Signed-off-by: Artem Savkov <asavkov@redhat.com>
This is supposedly fixed by dynup#1054 and should be reinabled once that is merged. Signed-off-by: Artem Savkov <asavkov@redhat.com>
|
/bump. According to the review comment conversation, @julien-thierry is waiting on @jpoimboe for a few follow ups to his suggestions? And that a unit test has been merged in the meantime. |
ab34c8a to
396f7e5
Compare
sm00th
left a comment
There was a problem hiding this comment.
This also needs a commit re-enabling gcc-static-local-var-5 tests across all distros.
Otherwise looks ok.
|
|
||
| /* | ||
| * Child functions with "*.cold" names don't have _fentry_ calls, but "*.part", | ||
| * often don't. In the later case, it is not necessary to include the parent |
There was a problem hiding this comment.
| * often don't. In the later case, it is not necessary to include the parent | |
| * often do. In the later case, it is not necessary to include the parent |
When a child symbol has changed, the parent symbol is only needed in the output object if the child symbol is unpatchable on its own. This is the case when the child symbol does not have its own profiling call. Only include unchanged parent symbols if their child has changed and the child does not have a function profiling call. Signed-off-by: Julien Thierry <jthierry@redhat.com>
A symbol associated to a function can be split into multiple sub-functions. Currently, kpatch only supports one child per function. Extend this to support an arbitrary number of sub-function per function. Signed-off-by: Julien Thierry <jthierry@redhat.com>
Consider symbols containing .part. in their names as sub-function of the symbols they are derived from (if such symbol still exists in the object file). Signed-off-by: Julien Thierry <jthierry@redhat.com>
A symbol in the original object might get split in several sub-functions in the patched object, which can themselves be bundled (and use a separate rela section). References to local static variables from the original function, might have been moved in one of the sub-functions in the patched object. Look for references to local static variables in the rela section of child symbols in the patched object. Signed-off-by: Julien Thierry <jthierry@redhat.com>
Signed-off-by: Julien Thierry <jthierry@redhat.com>
Reenable previously failing test gcc-static-local-var-5. Signed-off-by: Julien Thierry <jthierry@redhat.com>
396f7e5 to
24fc731
Compare
|
I've added the enablement of gcc-static-local-var-5. |
|
Taking a look as well at the moment. Will merge later today if it's OK :-) |
This fixes the error on RHEL8.0 test gcc-static-local-var-5:
ERROR: audit.o: reference to static local variable lock.65414 in audit_log_end was removed
/root/kpatch/kpatch-build/create-diff-object: unreconcilable difference
Mentioned in PR #993 .