Re: [patch] sched: add locking when update the task_group's cfs_rq[] array.

From: Ken Chen
Date: Wed Nov 19 2008 - 03:22:38 EST


On Tue, Nov 18, 2008 at 11:53 PM, Ingo Molnar <mingo@xxxxxxx> wrote:
>
> * Ken Chen <kenchen@xxxxxxxxxx> wrote:
>
>> @@ -1513,8 +1513,12 @@ static int tg_shares_up
>> unsigned long weight, rq_weight = 0;
>> unsigned long shares = 0;
>> struct sched_domain *sd = data;
>> + unsigned long flags;
>> int i;
>>
>> + if (!spin_trylock_irqsave(&tg->tg_lock, flags))
>> + return 0;
>
> hm, why trylock?

I'm paranoid about potential lock contention. Considering calls to
tg_shares_up() are more or less sample based, I opt to skip updating
if there is a lock contention. Though kernel only walks tg tree every
sysctl_sched_shares_ratelimit. Maybe chances of running into lock
contention isn't that high anyway, in which case trylock will mostly
able to get the lock.

- Ken
--
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/