Re: [RFC PATCH] checkpatch: Attempt to find unnecessary 'out of memory' messages

From: Joe Perches
Date: Wed Jun 18 2014 - 15:49:54 EST


On Wed, 2014-06-18 at 12:33 -0700, Paul E. McKenney wrote:
> On Sat, Jun 14, 2014 at 11:51:41AM +0200, Julia Lawall wrote:
> > On Sat, 14 Jun 2014, Julia Lawall wrote:
> > > With a semantic patch that searches for the various calls and then a
> > > string containing the letters "emory", I get removals of the messages
> > > below. Do any of these messages look useful? For example, some are
> > > generated with specific functions, such as IRDA_ERROR or BT_ERR. If none
> > > of the messages look useful, should just one big patch go to trivial, or
> > > should the patches go to the individual maintainers?
> >
> > Sorry, I left out all the strings...
>
> I would like the rcu-torture message to stay:
>
> > - pr_err("rcu-torture: Out of memory, need: %d", size);
>
> This is in a module that is not loaded into any reasonable production
> kernel, and has helped me to catch typos.

I believe the function doesn't work well.

static void
rcu_torture_stats_print(void)
{
int size = nr_cpu_ids * 200 + 8192;
char *buf;

buf = kmalloc(size, GFP_KERNEL);
if (!buf) {
pr_err("rcu-torture: Out of memory, need: %d\n", size);
return;
}
rcu_torture_printk(buf);
pr_alert("%s", buf);
kfree(buf);
}

rcu_torture_printk simply fills buf

btw: I believe the arguments should pass size and
rcu_torture_printk should use snprintf/size

but all printks are limited to a maximum of 1024
bytes so the large allocation is senseless and
would even if it worked, would likely need to be
vmalloc/vfree



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/