Re: [PATCH 1/4] Extend notifier_call_chain to count nr_calls made.

Andrew Morton
2006-11-21T06:20:22Z

On Tue, 14 Nov 2006 17:50:51 +0530
Gautham R Shenoy <ego@in.ibm.com> wrote:

> Provide notifier_call_chain with an option to call only a specified number of
> notifiers and also record the number of call to notifiers made.
>
> The need for this enhancement was identified in the post entitled
> "Slab - Eliminate lock_cpu_hotplug from slab"
> (http://lkml.org/lkml/2006/10/28/92) by Ravikiran G Thirumalai and
> Andrew Morton.
>
> This patch adds two additional parameters to notifier_call_chain API namely
> - int nr_to_calls : Number of notifier_functions to be called.
> The don't care value is -1.
>
> - unsigned int *nr_calls : Records the total number of notifier_funtions
> called by notifier_call_chain. The don't care
> value is NULL.
>
> ...
>
> +
> static int __kprobes notifier_call_chain(struct notifier_block **nl,
> - unsigned long val, void *v)
> + unsigned long val, void *v,
> + int nr_to_call, unsigned int *nr_calls)
> {
> int ret = NOTIFY_DONE;
> struct notifier_block *nb, *next_nb;
>
> nb = rcu_dereference(*nl);
> - while (nb) {
> +
> + while (nb && nr_to_call) {
> next_nb = rcu_dereference(nb->next);
> ret = nb->notifier_call(nb, val, v);
> +
> + if (nr_calls)
> + *nr_calls ++;

This gets

kernel/sys.c: In function 'notifier_call_chain':
kernel/sys.c:164: warning: value computed is not used

And indeed, this code doesn't work.

What happened?