lkml.org 
[lkml]   [2014]   [Aug]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH 2/2] fault-inject: add ratelimit option
From
2014-08-20 21:54 GMT+09:00 Dmitry Monakhov <dmonakhov@openvz.org>:
> @@ -40,10 +40,25 @@ EXPORT_SYMBOL_GPL(setup_fault_attr);
>
> static void fail_dump(struct fault_attr *attr)
> {
> - if (attr->verbose > 0)
> - printk(KERN_NOTICE "FAULT_INJECTION: forcing a failure\n");
> - if (attr->verbose > 1)
> - dump_stack();
> + if (attr->verbose > 0 &&
> + ___ratelimit(&attr->ratelimit_state, __func__)) {

You can use __ratelimit(state) instead of ___ratelimit(state, __func__).

> + if (attr->dname)
> + printk(KERN_NOTICE "FAULT_INJECTION: forcing a failure."
> + "name %pd, interval %lu, probability %lu, "
> + "space %d, times %d\n", attr->dname,
> + attr->probability, attr->interval,
> + atomic_read(&attr->space),
> + atomic_read(&attr->times));
> + else
> + printk(KERN_NOTICE "FAULT_INJECTION: forcing a "
> + "failure, interval %lu, probability %lu, "
> + "space %d, times %d\n", attr->probability,
> + attr->interval, atomic_read(&attr->space),
> + atomic_read(&attr->times));

This looks a bit redundant. NULL pointer to "%pd" format produces
"(null)" string, so this printk and if-else can be removed.

Also, this message line is a bit longer than usual kernel message.
Should we put '\n' after "forcing a failure."?

This patch looks good to me. Please feel free to add my ACK.


\
 
 \ /
  Last update: 2014-08-20 16:41    [W:0.085 / U:0.060 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site