public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Gautham R Shenoy <ego@in.ibm.com>
Cc: linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org,
	mingo@elte.hu, akpm@linux-foundation.org, dipankar@in.ibm.com,
	josht@linux.vnet.ibm.com, tytso@us.ibm.com, dvhltc@us.ibm.com,
	tglx@linutronix.de
Subject: Re: [PATCH RFC] Priority boosting for preemptible RCU
Date: Thu, 23 Aug 2007 01:54:56 -0700	[thread overview]
Message-ID: <20070823085456.GA18627@linux.vnet.ibm.com> (raw)
In-Reply-To: <20070823042639.GA28026@in.ibm.com>

On Thu, Aug 23, 2007 at 09:56:39AM +0530, Gautham R Shenoy wrote:
> Hi Paul, 
> On Wed, Aug 22, 2007 at 12:02:54PM -0700, Paul E. McKenney wrote:
> > +/*
> > + * Print out RCU booster task statistics at the specified interval.
> > + */
> > +static void rcu_boost_dat_stat_print(void)
> > +{
> > +	/* Three decimal digits per byte plus spacing per number and line. */
> > +	char buf[N_RCU_BOOST_STATE * (sizeof(long) * 3 + 2) + 2];
> > +	int cpu;
> > +	int event;
> > +	int i;
> > +	static time_t lastprint = 0;
> > +	struct rcu_boost_dat *rbdp;
> > +	int state;
> > +	struct rcu_boost_dat sum;
> > +
> > +	/* Wait a graceful interval between printk spamming. */
> > +
> > +	if (xtime.tv_sec - lastprint <
> > +	    CONFIG_PREEMPT_RCU_BOOST_STATS_INTERVAL)
> > +		return;
> > +
> > +	/* Sum up the state/event-independent counters. */
> > +
> > +	sum.rbs_blocked = 0;
> > +	sum.rbs_boost_attempt = 0;
> > +	sum.rbs_boost = 0;
> > +	sum.rbs_unlock = 0;
> > +	sum.rbs_unboosted = 0;
> > +	for_each_possible_cpu(cpu)
> > +		for (i = 0; i < RCU_BOOST_ELEMENTS; i++) {
> > +			rbdp = per_cpu(rcu_boost_dat, cpu);
> > +			sum.rbs_blocked += rbdp[i].rbs_blocked;
> > +			sum.rbs_boost_attempt += rbdp[i].rbs_boost_attempt;
> > +			sum.rbs_boost += rbdp[i].rbs_boost;
> > +			sum.rbs_unlock += rbdp[i].rbs_unlock;
> > +			sum.rbs_unboosted += rbdp[i].rbs_unboosted;
> > +		}
> 
> I feel we should still be able to use for_each_online_cpu(cpu) instead
> of for_each_possible_cpu. Again, there's a good chance that I might
> be mistaken!
> 
> How about the following ?
> 
> 	preempt_disable(); /* We Dont want cpus going down here */
> 	for_each_online_cpu(cpu) 
> 		for (i = 0; i < RCU_BOOST_ELEMENTS; i++) {
> 			rbdp = per_cpu(rcu_boost_dat, cpu);
> 			sum.rbs_blocked += rbdp[i].rbs_blocked;
> 			sum.rbs_boost_attempt += rbdp[i].rbs_boost_attempt;
> 			sum.rbs_boost += rbdp[i].rbs_boost;
> 			sum.rbs_unlock += rbdp[i].rbs_unlock;
> 			sum.rbs_unboosted += rbdp[i].rbs_unboosted;
> 		}
> 	preempt_enable(); 
> 
> 
> 	static int rcu_boost_cpu_callback(struct notifier_bloack *nb, 
> 					unsigned long action, void *hcpu) 
> 	{
> 		int this_cpu, cpu;
> 		rcu_boost_data *rbdp, *this_rbdp;
> 
> 		switch (action) {
> 		case CPU_DEAD:
> 			this_cpu = get_cpu();
> 			cpu = (long)hcpu;
> 			this_cpu = smp_processor_id();
> 			rbdp = per_cpu(rcu_boost_dat, cpu);
> 			this_rbdp = per_cpu(rcu_boost_dat, cpu);
> 			/* 
> 			 *  Transfer all of rbdp's statistics to
> 			 *  this_rbdp here.
> 			 */	
> 			 put_cpu();
> 	
> 			return NOTIFY_OK;
> 		}
> 	}
> 
> 
> Won't this work in this case?

Hello, Gautham,

We could do something similar.  If there was a global rcu_boost_data
variable that held the sums of the fields of the rcu_boost_data
structures for all offline CPUs, and if we used a new lock to protect
that global rcu_boost data variable (both when reading and when
CPU hotplugging), then we could indeed scan only the online CPUs'
rcu_boost_data elements.

We would also have to maintain a cpumask_t for this purpose, and
we would need to add a CPU's contribution when it went offline and
subtract it when that CPU came back online.

The lock should not be a problem even on very large systems because
of the low frequency of statistics printing -- and of hotplug operations,
for that matter.

						Thanx, Paul

  reply	other threads:[~2007-08-23  8:55 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-22 19:02 [PATCH RFC] Priority boosting for preemptible RCU Paul E. McKenney
2007-08-22 19:43 ` Andrew Morton
2007-08-22 20:23   ` Josh Triplett
2007-08-22 21:22   ` Paul E. McKenney
2007-08-22 21:41     ` Andrew Morton
2007-08-22 22:00       ` Paul E. McKenney
2007-08-24 10:09   ` Andy Whitcroft
2007-08-23  4:26 ` Gautham R Shenoy
2007-08-23  8:54   ` Paul E. McKenney [this message]
2007-08-23 10:14     ` Gautham R Shenoy
2007-08-23 13:15       ` Paul E. McKenney
2007-08-23 14:22         ` Gautham R Shenoy
2007-08-23 15:55           ` Paul E. McKenney
2007-08-24  8:21             ` Gautham R Shenoy
2007-08-24 17:27               ` Paul E. McKenney

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=20070823085456.GA18627@linux.vnet.ibm.com \
    --to=paulmck@linux.vnet.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=dipankar@in.ibm.com \
    --cc=dvhltc@us.ibm.com \
    --cc=ego@in.ibm.com \
    --cc=josht@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    --cc=tytso@us.ibm.com \
    /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