From: Chris Down <chris@chrisdown.name>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: linux-kernel@vger.kernel.org, Petr Mladek <pmladek@suse.com>,
Jessica Yu <jeyu@kernel.org>,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
John Ogness <john.ogness@linutronix.de>,
Steven Rostedt <rostedt@goodmis.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Johannes Weiner <hannes@cmpxchg.org>,
Kees Cook <keescook@chromium.org>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
kernel-team@fb.com
Subject: Re: [PATCH v6 3/4] printk: Userspace format indexing support
Date: Tue, 18 May 2021 15:07:44 +0100 [thread overview]
Message-ID: <YKPKMCNz2hccaXfR@chrisdown.name> (raw)
In-Reply-To: <YKPBk+7lTzs8WFAk@smile.fi.intel.com>
Hey Andy,
Thanks for the detailed feedback! All points not explicitly replied to here are
acked and will be improved. :-)
Andy Shevchenko writes:
>> +static const char *pi_get_module_name(struct module *mod)
>> +{
>> + return mod ? mod->name : "vmlinux";
>
>First of all, you have several occurrences of the "vmlinux" literal.
>Second, can't you get it from somewhere else? Is it even guaranteed that the
>name is always the same?
Hmm, I don't know if it's guaranteed, but we already have similar logic in (as
one example) livepatch, which seems to suggest it's not obviously wrong:
% grep -R '"vmlinux"' kernel/livepatch/
kernel/livepatch/core.c: sympos, name, objname ? objname : "vmlinux");
kernel/livepatch/core.c: bool sec_vmlinux = !strcmp(sec_objname, "vmlinux");
kernel/livepatch/core.c: sym_vmlinux = !strcmp(sym_objname, "vmlinux");
kernel/livepatch/core.c: if (strcmp(objname ? objname : "vmlinux", sec_objname))
kernel/livepatch/core.c: name = klp_is_module(obj) ? obj->name : "vmlinux";
kernel/livepatch/core.c: klp_is_module(obj) ? obj->name : "vmlinux");
kernel/livepatch/core.c: klp_is_module(obj) ? obj->name : "vmlinux");
kernel/livepatch/core.c: if (!strcmp(mod->name, "vmlinux")) {
Is there another name or method you'd prefer? :-)
As for the literals, are you saying that you prefer that it's symbolised as a
macro or static char, or do you know of an API where this kind of name can be
canonically accessed?
>> +#define seq_escape_printf_format(s, src) \
>> + seq_escape_str(s, src, ESCAPE_ANY | ESCAPE_NAP | ESCAPE_APPEND, "\"\\")
>
>Hmm... But after your ESCAPE_SPECIAL update why " is in @only?
>Not sure about back slash either.
Good question! It's because ESCAPE_NAP (used to reduce scope of ESCAPE_OCTAL)
will cause double quote and backslash to be ignored for quoting otherwise, even
with ESCAPE_SPECIAL from ESCAPE_ANY.
I touched on this briefly in the changelog for the patch adding the quote to
ESCAPE_SPECIAL:
From "string_helpers: Escape double quotes in escape_special":
> One can of course, alternatively, use ESCAPE_APPEND with a quote in
> @only, but without this patch quotes are coerced into hex or octal which
> can hurt readability quite significantly.
Maybe you know of a more intuitive way to deal with this? :-)
>> +static int __init pi_init(void)
>> +{
>> + struct dentry *dfs_root = debugfs_create_dir("printk", NULL);
>> +
>> + dfs_index = debugfs_create_dir("index", dfs_root);
>> + pi_setup_module_notifier();
>> + pi_create_file(NULL);
>> +
>> + return 0;
>> +}
>
>No __exit? (There is a corresponding call for exit)
Hmm, can't printk only be built in to the kernel, so it can't be unloaded? At
least it looks that way from Kconfig. Maybe I'm missing something and there's
some other way that might be invoked?
Thanks a lot for the feedback! :-)
next prev parent reply other threads:[~2021-05-18 14:07 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-18 12:00 [PATCH v6 0/4] printk: Userspace format indexing support Chris Down
2021-05-18 12:00 ` [PATCH v6 1/4] string_helpers: Escape double quotes in escape_special Chris Down
2021-05-18 13:10 ` Andy Shevchenko
2021-05-18 14:10 ` Chris Down
2021-05-25 10:17 ` Petr Mladek
2021-05-18 12:00 ` [PATCH v6 2/4] printk: Straighten out log_flags into printk_info_flags Chris Down
2021-05-25 10:33 ` Petr Mladek
2021-05-25 11:35 ` John Ogness
2021-05-26 7:31 ` Petr Mladek
2021-05-26 8:39 ` John Ogness
2021-05-26 9:25 ` Petr Mladek
2021-06-01 15:16 ` Chris Down
2021-05-18 12:00 ` [PATCH v6 3/4] printk: Userspace format indexing support Chris Down
2021-05-18 13:30 ` Andy Shevchenko
2021-05-18 14:07 ` Chris Down [this message]
2021-05-18 16:00 ` Andy Shevchenko
2021-05-18 16:28 ` Chris Down
2021-05-18 16:59 ` Chris Down
2021-05-19 6:59 ` Rasmus Villemoes
2021-05-20 9:25 ` Andy Shevchenko
2021-05-25 15:19 ` Petr Mladek
2021-05-25 15:06 ` Petr Mladek
2021-06-01 15:15 ` Chris Down
2021-06-04 10:19 ` Petr Mladek
2021-06-04 11:50 ` Chris Down
2021-05-18 12:00 ` [PATCH v6 4/4] printk: index: Add indexing support to dev_printk Chris Down
2021-05-26 8:57 ` Petr Mladek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YKPKMCNz2hccaXfR@chrisdown.name \
--to=chris@chrisdown.name \
--cc=andriy.shevchenko@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=hannes@cmpxchg.org \
--cc=jeyu@kernel.org \
--cc=john.ogness@linutronix.de \
--cc=keescook@chromium.org \
--cc=kernel-team@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=sergey.senozhatsky@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox