lkml.org 
[lkml]   [2017]   [Aug]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH v4] printk: Add monotonic, boottime, and realtime timestamps
    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?

    [..]
    > + 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.


    > + } 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.


    > + return -EINVAL;
    > + }
    > +
    > + printk_time = _printk_time;
    > + pr_info("printk: timestamp set to %s\n", printk_time_str[printk_time]);

    ditto.


    [..]

    > +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...

    > +static int printk_time;
    > +static int printk_time_setting;

    how about s/printk_time_setting/printk_time_source/? or something similar?

    -ss

    \
     
     \ /
      Last update: 2017-08-08 02:19    [W:4.151 / U:0.008 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site