On Wed, Apr 17, 2019 at 12:39:19PM -0400, Waiman Long wrote:
> On 04/17/2019 04:05 AM, Peter Zijlstra wrote:
> > So what is wrong with the below?
> >
> > --- a/include/linux/sched/wake_q.h
> > +++ b/include/linux/sched/wake_q.h
> > @@ -51,6 +51,11 @@ static inline void wake_q_init(struct wa
> >
On 04/17/2019 04:05 AM, Peter Zijlstra wrote:
> On Tue, Apr 16, 2019 at 02:16:11PM -0400, Waiman Long wrote:
>
@@ -608,56 +687,63 @@ __rwsem_down_write_failed_common(struct rw_semaphore
*sem, int state)
*/
waiter.task = current;
waiter.type = RWSEM_WAITING_FOR_WR
On 04/17/2019 03:35 AM, Peter Zijlstra wrote:
> On Tue, Apr 16, 2019 at 02:16:11PM -0400, Waiman Long wrote:
>
@@ -324,6 +364,12 @@ static void __rwsem_mark_wake(struct rw_semaphore
*sem,
adjustment -= RWSEM_FLAG_WAITERS;
}
+ /*
+ * Clear the h
On 04/17/2019 03:13 AM, Peter Zijlstra wrote:
> On Tue, Apr 16, 2019 at 05:07:26PM -0400, Waiman Long wrote:
>
>> Thinking about it again. I think I will just change its definition to
>> "((HZ + 249)/250)" for now to make sure that it is at least 1. The
> DIV_ROUND_UP()
Sure.
Thanks,
Longman
On Sat, Apr 13, 2019 at 01:22:50PM -0400, Waiman Long wrote:
> +/*
> + * This is safe to be called without holding the wait_lock.
Because @waiter is *our* waiter and it's not going anywhere. So when
it's first, it stays first until we do something about it.
> + */
> +static inline bool
> +rws
On Tue, Apr 16, 2019 at 02:16:11PM -0400, Waiman Long wrote:
> >> @@ -608,56 +687,63 @@ __rwsem_down_write_failed_common(struct rw_semaphore
> >> *sem, int state)
> >> */
> >>waiter.task = current;
> >>waiter.type = RWSEM_WAITING_FOR_WRITE;
> >> + waiter.timeout = jiffies + RWSEM_WAI
On Tue, Apr 16, 2019 at 02:16:11PM -0400, Waiman Long wrote:
> >> @@ -324,6 +364,12 @@ static void __rwsem_mark_wake(struct rw_semaphore
> >> *sem,
> >>adjustment -= RWSEM_FLAG_WAITERS;
> >>}
> >>
> >> + /*
> >> + * Clear the handoff flag
> >> + */
> > Right, but that is a
On Tue, Apr 16, 2019 at 05:07:26PM -0400, Waiman Long wrote:
> Thinking about it again. I think I will just change its definition to
> "((HZ + 249)/250)" for now to make sure that it is at least 1. The
DIV_ROUND_UP()
On 04/16/2019 04:26 PM, Waiman Long wrote:
> On 04/16/2019 10:12 AM, Peter Zijlstra wrote:
>> On Sat, Apr 13, 2019 at 01:22:50PM -0400, Waiman Long wrote:
>>> +/*
>>> + * The typical HZ value is either 250 or 1000. So set the minimum waiting
>>> + * time to 4ms in the wait queue before initiating t
On 04/16/2019 10:12 AM, Peter Zijlstra wrote:
> On Sat, Apr 13, 2019 at 01:22:50PM -0400, Waiman Long wrote:
>> +/*
>> + * The typical HZ value is either 250 or 1000. So set the minimum waiting
>> + * time to 4ms in the wait queue before initiating the handoff protocol.
>> + */
>> +#define RWSEM_WA
On 04/16/2019 12:15 PM, Peter Zijlstra wrote:
> On Tue, Apr 16, 2019 at 05:49:37PM +0200, Peter Zijlstra wrote:
>> See, if you first write that function in the form:
>>
>> long new;
>>
>> do {
>> new = count | RWSEM_WRITER_LOCKED;
>>
>> if (count & RWSEM_LOCK_MAS
On Tue, Apr 16, 2019 at 02:16:11PM -0400, Waiman Long wrote:
> >> @@ -665,9 +751,34 @@ __rwsem_down_write_failed_common(struct rw_semaphore
> >> *sem, int state)
> >>lockevent_inc(rwsem_sleep_writer);
> >>set_current_state(state);
> >>co
On 04/16/2019 11:49 AM, Peter Zijlstra wrote:
> On Sat, Apr 13, 2019 at 01:22:50PM -0400, Waiman Long wrote:
>
>> +#define RWSEM_COUNT_HANDOFF(c) ((c) & RWSEM_FLAG_HANDOFF)
>> +#define RWSEM_COUNT_LOCKED_OR_HANDOFF(c)\
>> +((c) & (RWSEM_LOCK_MASK|RWSEM_FLAG_HANDOFF))
> Like said before
On Tue, Apr 16, 2019 at 05:49:37PM +0200, Peter Zijlstra wrote:
> See, if you first write that function in the form:
>
> long new;
>
> do {
> new = count | RWSEM_WRITER_LOCKED;
>
> if (count & RWSEM_LOCK_MASK)
> return false;
>
>
On Sat, Apr 13, 2019 at 01:22:50PM -0400, Waiman Long wrote:
> +#define RWSEM_COUNT_HANDOFF(c) ((c) & RWSEM_FLAG_HANDOFF)
> +#define RWSEM_COUNT_LOCKED_OR_HANDOFF(c) \
> + ((c) & (RWSEM_LOCK_MASK|RWSEM_FLAG_HANDOFF))
Like said before, I also made these go away.
> @@ -245,6 +274,8 @
On Sat, Apr 13, 2019 at 01:22:50PM -0400, Waiman Long wrote:
> +/*
> + * The typical HZ value is either 250 or 1000. So set the minimum waiting
> + * time to 4ms in the wait queue before initiating the handoff protocol.
> + */
> +#define RWSEM_WAIT_TIMEOUT (HZ/250)
That seems equally unfortunate
Because of writer lock stealing, it is possible that a constant
stream of incoming writers will cause a waiting writer or reader to
wait indefinitely leading to lock starvation.
This patch implements a lock handoff mechanism to disable lock stealing
and force lock handoff to the first waiter or wa
17 matches
Mail list logo