From: Prarit Bhargava <prarit@redhat.com>
To: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Cc: linux-kernel@vger.kernel.org, Mark Salyzyn <salyzyn@android.com>,
Jonathan Corbet <corbet@lwn.net>, Petr Mladek <pmladek@suse.com>,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
Steven Rostedt <rostedt@goodmis.org>,
John Stultz <john.stultz@linaro.org>,
Thomas Gleixner <tglx@linutronix.de>,
Stephen Boyd <sboyd@codeaurora.org>,
Andrew Morton <akpm@linux-foundation.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
Christoffer Dall <cdall@linaro.org>,
Deepa Dinamani <deepa.kernel@gmail.com>,
Ingo Molnar <mingo@kernel.org>,
Joel Fernandes <joelaf@google.com>,
Kees Cook <keescook@chromium.org>,
Peter Zijlstra <peterz@infradead.org>,
Geert Uytterhoeven <geert+renesas@glider.be>,
"Luis R. Rodriguez" <mcgrof@kernel.org>,
Nicholas Piggin <npiggin@gmail.com>,
"Jason A. Donenfeld" <Jason@zx2c4.com>,
Olof Johansson <olof@lixom.net>,
Josh Poimboeuf <jpoimboe@redhat.com>,
linux-doc@vger.kernel.org
Subject: Re: [PATCH v4] printk: Add monotonic, boottime, and realtime timestamps
Date: Tue, 8 Aug 2017 08:32:12 -0400 [thread overview]
Message-ID: <53f82948-b688-645e-bb2e-155e99241054@redhat.com> (raw)
In-Reply-To: <20170808001908.GA7765@jagdpanzerIV.localdomain>
On 08/07/2017 08:19 PM, Sergey Senozhatsky wrote:
> On (08/07/17 11:52), Prarit Bhargava wrote:
> [..]
>> +/**
>> + * enum printk_time_type - Timestamp types for printk() messages.
>> + * @PRINTK_TIME_DISABLE: No time stamp.
>> + * @PRINTK_TIME_LOCAL: Local hardware clock timestamp.
>> + * @PRINTK_TIME_BOOT: Boottime clock timestamp.
>> + * @PRINTK_TIME_MONO: Monotonic clock timestamp.
>> + * @PRINTK_TIME_REAL: Realtime clock timestamp. On 32-bit
>> + * systems selecting the real clock printk timestamp may lead to unlikely
>> + * situations where a timestamp is wrong because the real time offset is read
>> + * without the protection of a sequence lock in the call to ktime_get_log_ts()
>> + * in printk_get_ts() below.
>> + */
>> +enum printk_time_type {
>> + PRINTK_TIME_DISABLE = 0,
>> + PRINTK_TIME_LOCAL = 1,
>> + PRINTK_TIME_BOOT = 2,
>> + PRINTK_TIME_MONO = 3,
>> + PRINTK_TIME_REAL = 4,
>> +};
>
> may be call the entire thing 'timestamp surces' or something?
Done.
>
> [..]
>> + if (strlen(param) == 1) {
>> + /* Preserve legacy boolean settings */
>> + if (!strcmp("0", param) || !strcmp("n", param) ||
>> + !strcmp("N", param))
>> + _printk_time = PRINTK_TIME_DISABLE;
>> + if (!strcmp("1", param) || !strcmp("y", param) ||
>> + !strcmp("Y", param))
>> + _printk_time = PRINTK_TIME_LOCAL;
>> + }
>> + if (_printk_time == -1) {
>> + for (stamp = 0; stamp <= 4; stamp++) {
>> + if (!strncmp(printk_time_str[stamp], param,
>> + strlen(param))) {
>> + _printk_time = stamp;
>> + break;
>> + }
>> + }
>> + }
>
> you can use match_string() here.
>
>> + if (_printk_time == -1) {
>> + pr_warn("printk: invalid timestamp value %s\n", param);
>> + return -EINVAL;
>> + }
>
> `invalid timestamp value' is confusing.
I can't think of anything better than 'invalid timestamp option'. If you find
that confusing, please explain why.
>
>
>> + } else if ((printk_time_setting != _printk_time) &&
>> + (_printk_time != 0)) {
>> + pr_warn("printk: timestamp can only be set to 0(disabled) or %s\n",
>> + printk_time_str[printk_time_setting]);
>
> ditto.
Changed to 'timestamp can only e set to 0, disabled, or <string>'.
>
>
>> + return -EINVAL;
>> + }
>> +
>> + printk_time = _printk_time;
>> + pr_info("printk: timestamp set to %s\n", printk_time_str[printk_time]);
>
> ditto.
I don't find this confusing _at all_. Please offer an explanation of why you
think that message is confusing.
>
>
> [..]
>
>> +static u64 printk_get_ts(void)
>> +{
>> + u64 mono, offset_real;
>> +
>> + if (printk_time <= PRINTK_TIME_LOCAL)
>> + return local_clock();
>> +
>> + if (printk_time == PRINTK_TIME_BOOT)
>> + return ktime_get_boot_log_ts();
>> +
>> + mono = ktime_get_real_log_ts(&offset_real);
>> +
>> + if (printk_time == PRINTK_TIME_MONO)
>> + return mono;
>> +
>> + return mono + offset_real;
>> +}
>
> this looks hard...
See previous suggestion from peterz to switch to a fn ptr.
>
>> +static int printk_time;
>> +static int printk_time_setting;
>
> how about s/printk_time_setting/printk_time_source/? or something similar?
Sure.
P.
>
> -ss
>
next prev parent reply other threads:[~2017-08-08 12:32 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-07 15:52 Prarit Bhargava
2017-08-07 16:52 ` John Stultz
2017-08-07 17:15 ` Peter Zijlstra
2017-08-07 18:04 ` Prarit Bhargava
2017-08-07 18:47 ` John Stultz
2017-08-07 20:06 ` Prarit Bhargava
2017-08-07 20:36 ` Paul E. McKenney
2017-08-08 8:28 ` Peter Zijlstra
2017-08-08 23:08 ` Prarit Bhargava
2017-08-09 17:28 ` Paul E. McKenney
2017-08-07 16:58 ` Mark Salyzyn
2017-08-07 18:07 ` Prarit Bhargava
2017-08-07 17:18 ` Peter Zijlstra
2017-08-08 0:19 ` Sergey Senozhatsky
2017-08-08 12:32 ` Prarit Bhargava [this message]
2017-08-08 13:46 ` Prarit Bhargava
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=53f82948-b688-645e-bb2e-155e99241054@redhat.com \
--to=prarit@redhat.com \
--cc=Jason@zx2c4.com \
--cc=akpm@linux-foundation.org \
--cc=cdall@linaro.org \
--cc=corbet@lwn.net \
--cc=deepa.kernel@gmail.com \
--cc=geert+renesas@glider.be \
--cc=gregkh@linuxfoundation.org \
--cc=joelaf@google.com \
--cc=john.stultz@linaro.org \
--cc=jpoimboe@redhat.com \
--cc=keescook@chromium.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=mingo@kernel.org \
--cc=npiggin@gmail.com \
--cc=olof@lixom.net \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=salyzyn@android.com \
--cc=sboyd@codeaurora.org \
--cc=sergey.senozhatsky.work@gmail.com \
--cc=sergey.senozhatsky@gmail.com \
--cc=tglx@linutronix.de \
/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
all inboxes | Powered by JetHome®