Re: [PATCH] avoid using smp_processor_id() in preemptible code(nr_iowait_cpu)

From: Sergey Senozhatsky
Date: Tue Jun 15 2010 - 11:19:49 EST


On (06/15/10 08:08), Arjan van de Ven wrote:
> On Tue, 15 Jun 2010 17:50:29 +0300
> Sergey Senozhatsky <sergey.senozhatsky@xxxxxxxxx> wrote:
> > >
> > > hmm this part is wrong
> > > you pick the current cpu, rather than the one denoted by ts.....
> > >
> >
> > Hmm. Thanks, good catch.
> > Well, there is something I'm missing. How can I match given *ts and
> > cpu in update_ts_time_stats (except for introducing
> > update_ts_time_stats(..., int cpu)) ?
>
>
> that'd be option one

We'll have problem in tick_nohz_start_idle(struct tick_sched *ts)
{
ktime_t now;
now = ktime_get();
update_ts_time_stats(ts, now, NULL);

...
So, we also will have to expand it to tick_nohz_start_idle(struct tick_sched *ts, int cpu)

That's why I prefer option #2.

> option two is to add a "cpu" member to struct tick_sched.....
>
Thought about that. Seems ok to me.


> if you go for option one, I'd replace the ts argument with the cpu
> argument.....
>
>

Hmm, I missed this one (replacing *ts to int cpu). And I like it.
Something like:

-update_ts_time_stats(struct tick_sched *ts, ktime_t now, u64 *last_update_time)
+update_ts_time_stats(int cpu, ktime_t now, u64 *last_update_time)
{
ktime_t delta;
+ struct tick_sched *ts = &per_cpu(tick_cpu_sched, cpu);

if (ts->idle_active) {
int cpu = get_cpu();
delta = ktime_sub(now, ts->idle_entrytime);
ts->idle_sleeptime = ktime_add(ts->idle_sleeptime, delta);
if (nr_iowait_cpu(cpu) > 0)
ts->iowait_sleeptime = ktime_add(ts->iowait_sleeptime, delta);
put_cpu();
ts->idle_entrytime = now;
+ ts->idle_active = 0;
}

if (last_update_time)
*last_update_time = ktime_to_us(now);

}


static void tick_nohz_stop_idle(int cpu, ktime_t now)
{
- struct tick_sched *ts = &per_cpu(tick_cpu_sched, cpu);

update_ts_time_stats(cpu, now, NULL);
- ts->idle_active = 0;

sched_clock_idle_wakeup_event(0);
}

and so on.


Sergey

Attachment: pgp00000.pgp
Description: PGP signature