public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Vivek Goyal <vgoyal@redhat.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Fengguang Wu <fengguang.wu@intel.com>,
	John Stultz <john.stultz@linaro.org>,
	Ingo Molnar <mingo@kernel.org>,
	linux-kernel@vger.kernel.org, Jens Axboe <axboe@kernel.dk>,
	Tejun Heo <tj@kernel.org>
Subject: Re: [seqcount] INFO: trying to register non-static key.
Date: Tue, 12 Nov 2013 10:46:44 -0500	[thread overview]
Message-ID: <20131112154643.GA26632@redhat.com> (raw)
In-Reply-To: <20131112152956.GY5056@laptop.programming.kicks-ass.net>

On Tue, Nov 12, 2013 at 04:29:56PM +0100, Peter Zijlstra wrote:
> On Tue, Nov 12, 2013 at 10:15:41AM -0500, Vivek Goyal wrote:
> > I see that we allocate per cpu stats but don't do any initializations.
> > 
> > static void tg_stats_alloc_fn(struct work_struct *work)
> > {
> >         static struct tg_stats_cpu *stats_cpu;  /* this fn is non-reentrant */
> >         struct delayed_work *dwork = to_delayed_work(work);
> >         bool empty = false;
> > 
> > alloc_stats:
> >         if (!stats_cpu) {
> >                 stats_cpu = alloc_percpu(struct tg_stats_cpu);
> >                 if (!stats_cpu) {
> >                         /* allocation failed, try again after some time */
> >                         schedule_delayed_work(dwork, msecs_to_jiffies(10));
> >                         return;
> >                 }
> >         }
> > 
> >         spin_lock_irq(&tg_stats_alloc_lock);
> 
> Absolutely!
> 
> Something like this perhaps? Did I miss more blkg_[rw]stats? If I read
> the git grep output right, this was the last one.

Looks good to me.

This should be the last one. There are only two users of stats right
now. blk-throttle and cfq-iosched.

Thanks
Vivek

> 
> ---
>  block/blk-throttle.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/block/blk-throttle.c b/block/blk-throttle.c
> index 8331aba9426f..fd743d98c41d 100644
> --- a/block/blk-throttle.c
> +++ b/block/blk-throttle.c
> @@ -256,6 +256,12 @@ static struct throtl_data *sq_to_td(struct throtl_service_queue *sq)
>  	}								\
>  } while (0)
>  
> +static void tg_stats_init(struct tg_stats_cpu *tg_stats)
> +{
> +	blkg_rwstat_init(&tg_stats->service_bytes);
> +	blkg_rwstat_init(&tg_stats->serviced);
> +}
> +
>  /*
>   * Worker for allocating per cpu stat for tgs. This is scheduled on the
>   * system_wq once there are some groups on the alloc_list waiting for
> @@ -269,12 +275,16 @@ static void tg_stats_alloc_fn(struct work_struct *work)
>  
>  alloc_stats:
>  	if (!stats_cpu) {
> +		int cpu;
> +
>  		stats_cpu = alloc_percpu(struct tg_stats_cpu);
>  		if (!stats_cpu) {
>  			/* allocation failed, try again after some time */
>  			schedule_delayed_work(dwork, msecs_to_jiffies(10));
>  			return;
>  		}
> +		for_each_possible_cpu(cpu)
> +			tg_stats_init(per_cpu(stats_cpu, cpu));
>  	}
>  
>  	spin_lock_irq(&tg_stats_alloc_lock);

  reply	other threads:[~2013-11-12 15:47 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-11  1:29 [seqcount] INFO: trying to register non-static key Fengguang Wu
2013-11-11 15:45 ` Peter Zijlstra
2013-11-11 16:03   ` Vivek Goyal
2013-11-12  9:41   ` Fengguang Wu
2013-11-12  9:50     ` Ingo Molnar
2013-11-12 10:01     ` Peter Zijlstra
2013-11-12 15:03       ` Fengguang Wu
2013-11-12 15:18         ` Fengguang Wu
2013-11-12 15:15       ` Vivek Goyal
2013-11-12 15:29         ` Peter Zijlstra
2013-11-12 15:46           ` Vivek Goyal [this message]
2013-11-13  3:35           ` Fengguang Wu
2013-11-13  3:35           ` John Stultz

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=20131112154643.GA26632@redhat.com \
    --to=vgoyal@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=fengguang.wu@intel.com \
    --cc=john.stultz@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tj@kernel.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