Skip to content

Support CONFIG_PRINTK_INDEX#1207

Merged
sm00th merged 3 commits intodynup:masterfrom
jpoimboe:config-printk-index
Aug 17, 2021
Merged

Support CONFIG_PRINTK_INDEX#1207
sm00th merged 3 commits intodynup:masterfrom
jpoimboe:config-printk-index

Conversation

@jpoimboe
Copy link
Member

As described in #1206. See the commit messages for more info. Will post unit tests momentarily.

…e to bool

Make kpatch_line_macro_change_only()'s usage more clear by changing its
return type to bool.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Copy link
Contributor

@sm00th sm00th left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving given this PR contains a commit updating unit-test objectfiles submodule pointer.

CONFIG_PRINTK_INDEX creates a static local struct variable named
`_entry` for every call site to printk().  The initializer for that
struct assigns the `__LINE__` macro to one of its fields.

Similarly to the WARN macro's usage [1] of `__LINE__`, it causes
problems because it results in the line number getting directly embedded
in the struct.  If a line is added or removed higher up in the source
file, the `_entry` struct changes accordingly due to a change in the
printk() call site line number.

`_entry` is similar to other "special" static locals, in that we don't
need to correlate the patched version with the original version.  We can
instead just ignore any changes to it.

Any substantial (non-line-number) change to the `_entry` struct would be
a second-order (dependent) effect of a first-order code change, which
would be detected using other means.  In that case the patched version
of `_entry` will be included, due to being referenced by the changed
function.

Fixes: dynup#1206

[1] See kpatch_line_macro_change_only()

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
For each printk() call site, CONFIG_PRINTK_INDEX makes a static local
struct named `_entry`, and then adds a pointer to it in the
`.printk_index` section.

When regenerating the `.printk_index` section for the patch module, we
only need to include those entries which are referenced by included
functions.  Luckily this is a common pattern already used by several
other "special" sections.  Add `.printk_index` to the special section
handling logic.

Fixes: dynup#1206

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
@jpoimboe jpoimboe force-pushed the config-printk-index branch from 8bf5ec2 to 56471ff Compare August 11, 2021 15:47
@jpoimboe
Copy link
Member Author

v2: add unit test reference

@liu-song-6
Copy link
Contributor

It works great in my tests. Thanks!

@sm00th sm00th merged commit edf6613 into dynup:master Aug 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants