Re: [PATCH v2] softlockup: remove hung_task_check_count

From: Ingo Molnar
Date: Thu Jan 22 2009 - 03:35:27 EST



* Mandeep Singh Baines <msb@xxxxxxxxxx> wrote:

> > do the need_resched() check first (it's very lighweight) - and thus
> > only do the heavy ops (get-task-struct & tasklist_lock unlock) if that
> > is set?
>
> Wanted to upper-bound the amount of time the lock is held. In order to
> give others a chance to write_lock the tasklist, released the lock
> regardless of whether a re-schedule is need.

but this:

> +static void check_hung_reschedule(struct task_struct *t)
> +{
> + get_task_struct(t);
> + read_unlock(&tasklist_lock);
> + if (need_resched())
> + schedule();
> + read_lock(&tasklist_lock);
> + put_task_struct(t);
> +}

does not actually achieve that. Releasing a lock does not mean that other
CPUs will immediately be able to get it - if the ex-owner quickly
re-acquires it then it will often succeed in doing so. Perhaps adding a
cpu_relax() would increase the chance ... but still, it looks a bit weird.

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