public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Alex Elder <alex.elder@linaro.org>
To: "Petr Mládek" <pmladek@suse.cz>, "Alex Elder" <elder@linaro.org>
Cc: akpm@linux-foundation.org, ak@linux.intel.com, bp@suse.de,
	jack@suse.cz, john.stultz@linaro.org, rostedt@goodmis.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/4] printk: miscellaneous cleanups
Date: Wed, 09 Jul 2014 11:45:49 -0500	[thread overview]
Message-ID: <53BD71BD.9010308@linaro.org> (raw)
In-Reply-To: <20140709162935.GB26508@pathway.suse.cz>

On 07/09/2014 11:29 AM, Petr Mládek wrote:
> Sending once again as a correct reply. I am sorry for the
> confusion. I think that it is high time for me to go home and sleep :-)
>
> On Wed 2014-07-09 08:04:16, Alex Elder wrote:
>> This patch contains some small cleanups to kernel/printk/printk.c.
>> None of them should cause any change in behavior.
>>    - When CONFIG_PRINTK is defined, parenthesize the value of LOG_LINE_MAX.
>>    - When CONFIG_PRINTK is *not* defined, there is an extra LOG_LINE_MAX
>>      definition; delete it.
>>    - Pull an assignment out of a conditional expression in console_setup().
>>    - Use isdigit() in console_setup() rather than open coding it.
>>    - In update_console_cmdline(), drop a NUL-termination assignment;
>>      the strlcpy() call that precedes it guarantees it's not needed.
>>    - Simplify some logic in printk_timed_ratelimit().
>>
>> Signed-off-by: Alex Elder <elder@linaro.org>
>> ---
>>   kernel/printk/printk.c | 26 +++++++++++++-------------
>>   1 file changed, 13 insertions(+), 13 deletions(-)
>>
>> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
>> index 6f75e8a..909029e 100644
>> --- a/kernel/printk/printk.c
>> +++ b/kernel/printk/printk.c

. . .

>> @@ -2611,14 +2612,13 @@ EXPORT_SYMBOL(__printk_ratelimit);
>>   bool printk_timed_ratelimit(unsigned long *caller_jiffies,
>>   			unsigned int interval_msecs)
>>   {
>> -	if (*caller_jiffies == 0
>> -			|| !time_in_range(jiffies, *caller_jiffies,
>> -					*caller_jiffies
>> -					+ msecs_to_jiffies(interval_msecs))) {
>> -		*caller_jiffies = jiffies;
>> -		return true;
>> -	}
>> -	return false;
>> +	unsigned long elapsed = jiffies - *caller_jiffies;
>

Currently, all callers pass a 0 value in *caller_jiffies
initially (using a static/BSS variable), and a value updated
by a previous call to __printk_ratelimit() thereafter.

If a caller passed something different, yes, it's possible the
result would wrap to a high unsigned value (i.e., go negative).
However the logic used here involves the same subtraction
operation as was used before--though previously that was
buried inside the time_after() macro called by time_in_range().

					-Alex

> I wondered if the deduction might be negative. Well, it should not be
> if none manipulates *caller_jiffies in a strange way. If it happens,
> the following condition will most likely fail and *caller_jiffies will
> get reset to jiffies. It looks reasonable to me.
>
> Reviewed-by: Petr Mladek <pmladek@suse.cz>
>
>> +	if (*caller_jiffies && elapsed <= msecs_to_jiffies(interval_msecs))
>> +		return false;
>> +
>> +	*caller_jiffies = jiffies;
>> +	return true;
>>   }
>>   EXPORT_SYMBOL(printk_timed_ratelimit);
>
> Best Regards,
> Petr
>


  reply	other threads:[~2014-07-09 16:45 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-09 13:04 [PATCH 0/4] printk: some minor fixups Alex Elder
2014-07-09 13:04 ` [PATCH 1/4] printk: rename DEFAULT_MESSAGE_LOGLEVEL Alex Elder
2014-07-09 15:00   ` Borislav Petkov
2014-07-09 15:10     ` Alex Elder
2014-07-09 15:13       ` Borislav Petkov
2014-07-09 15:14         ` Alex Elder
2014-07-09 15:17           ` Borislav Petkov
2014-07-09 13:04 ` [PATCH 2/4] printk: fix some comments Alex Elder
2014-07-09 15:53   ` Petr Mládek
2014-07-09 13:04 ` [PATCH 3/4] printk: use a clever macro Alex Elder
2014-07-09 15:05   ` Borislav Petkov
2014-07-09 16:19   ` Petr Mládek
2014-07-09 16:24     ` Borislav Petkov
2014-07-09 16:32       ` Petr Mládek
2014-07-09 16:40         ` Borislav Petkov
2014-07-09 17:58   ` Geert Uytterhoeven
2014-07-09 18:15     ` Alex Elder
2014-07-09 13:04 ` [PATCH 4/4] printk: miscellaneous cleanups Alex Elder
2014-07-09 16:29   ` Petr Mládek
2014-07-09 16:45     ` Alex Elder [this message]
2014-07-09 16:03 ` Alex Elder

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=53BD71BD.9010308@linaro.org \
    --to=alex.elder@linaro.org \
    --cc=ak@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=bp@suse.de \
    --cc=elder@linaro.org \
    --cc=jack@suse.cz \
    --cc=john.stultz@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmladek@suse.cz \
    --cc=rostedt@goodmis.org \
    /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