Re: [RFC][PATCH 2/2] add a counter for writers spinning on a rwlock

From: Frédéric Weisbecker
Date: Mon Jan 26 2009 - 10:25:59 EST


2009/1/26 Peter Zijlstra <peterz@xxxxxxxxxxxxx>:
> On Sun, 2009-01-25 at 12:50 -0800, Frederic Weisbecker wrote:
>> This patch adds a counter for writers that enter a rwlock slow path.
>> For example it can be useful for slow background tasks which perform some jobs
>> on the tasklist, such as the hung_task detector (kernel/hung_task.c).
>>
>> It adds a inc/dec pair on the slow path and 4 bytes for each rwlocks, so the overhead
>> is not null.
>>
>> Only x86 is supported for now, writers_spinning_lock() will return 0 on other archs (which
>> is perhaps not a good idea).
>>
>> Comments?
>
> _why_ ?

The hung task detector runs a periodic loop through the task_list, and
currently it doesn't run
over an arbitrary threshold of tasks to not hold the task_list lock
for too long.

So we thought about a way to detect if there are some writers waiting
for the lock, anf if so, release
the lock, schedule and retry.

I'm not sure this is something easy to measure, since this is more
about small latency gains (if there are).
--
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/