[Ksummit-2013-discuss] [ATTEND] insane cgroups, unfair rwlocks

Lai Jiangshan laijs at cn.fujitsu.com
Tue Jul 23 08:40:13 UTC 2013


On 07/23/2013 02:32 PM, Michel Lespinasse wrote:
> On Mon, Jul 22, 2013 at 8:54 PM, Lai Jiangshan <laijs at cn.fujitsu.com> wrote:
>> On 07/23/2013 11:32 AM, Li Zefan wrote:
>>>>> (2) unfair rwlocks
>>>>>
>>>>> This is connected to Srivatsa S. Bhat's proposed topic, which he
>>>>> thoughtfully copied me in (thanks!).
>>>>>
>>>>> We sometimes hit issues that can be traced down to rwlock unfairness
>>>>> (mostly with tasklist_lock); I have been taking an interest towards
>>>>> solving these. Recently there has been more activity than usual about
>>>>> locking schemes and I have been trying to steer people away from
>>>>> introducing new unfair locks where possible. I'm actually not entirely
>>>>> sure if this warrants a KS discussion (as I understand KS nowadays is
>>>>> more about management than technical issues); however if such
>>>>> discussions do take place at KS I would like to participate (and if
>>>>> not, I am always interested to discuss this informally).
>>>>
>>>> In the kernel community, people prefer performance to fairness.
>>>> (but I prefer to fairness.)
>>>
>>> I don't think this is fair. Didn't we implement ticket spinlock because
>>> the old implementation was unfair?
>>>
>>> And we sometimes change rwlock to spinlock because the write side is
>>> unfairly starved.
>>
>> rwlock is read-preference, sometimes we need this ability and sacrifice
>> the fairness.
> 
>>From what I've seen, the main reason here is when we require a
> reentrant read side.
> 
>>>> I think performance VS fairness is always a big topic which I'm also
>>>> interesting in. What traded-off should we chose to pay?
>>>> I hope people continue to find fairness solution which hurts
>>>> performance very very small.
>>>>
>>>> BTW, current rwsem is not unfair too, is it right?
>>>
>>> I guess you meant resem is unfair?
>>
>> Sorry, I do mean "resem is unfair" due to recently changes.
> 
> Recent changes allow writers to steal the lock from another writer
> that is pending wakeup. However, there is still fairness between
> readers and writers.
> 

No, there is no fairness between readers and writers.

A new writer and steal lock from the first waiter(reader/writer).
So the all the waiters of the list are affected by this stealing,
it is unfair for readers-VS-writers and writers-VS-writers.

Even worse, readers or writers of current rwsem can be starved
by continuous stealing writers.

I think adaptive-spin is one of the more proper solution to fix
the problem as ce6711f3d196f09ca0ed29a24dfad42d83912b20 said.
adaptive-spin don't hurts the fairness.

Even we use lock-stealing, can we add a tag/integer to the waiters
to remove the possibility of starvation?
(we can force every waiter's ownership can be only stolen
limited times with the help by the tag/integer)

Thanks,
Lai





More information about the Ksummit-2013-discuss mailing list