On 26/06/20 13:38, Patrick Bellasi wrote:
> On Thu, Jun 25, 2020 at 17:43:52 +0200, Qais Yousef <qais.you...@arm.com> 
> wrote...
>> @@ -994,9 +1013,16 @@ static inline void uclamp_rq_dec_id(struct rq *rq, 
>> struct task_struct *p,
>>      lockdep_assert_held(&rq->lock);
>>
>>      bucket = &uc_rq->bucket[uc_se->bucket_id];
>> -    SCHED_WARN_ON(!bucket->tasks);
>> -    if (likely(bucket->tasks))
>> -            bucket->tasks--;
>> +
>> +    /*
>> +     * This could happen if sched_uclamp_used was enabled while the
>> +     * current task was running, hence we could end up with unbalanced call
>> +     * to uclamp_rq_dec_id().
>> +     */
>> +    if (unlikely(!bucket->tasks))
>> +            return;
>> +
>> +    bucket->tasks--;
>>      uc_se->active = false;
>
> In this chunk you are indeed changing the code.
>
> Are we sure there are not issues with patterns like:
>
>   enqueue(taskA)
>   // uclamp gets enabled
>   enqueue(taskB)
>   dequeue(taskA)
>   // bucket->tasks is now 0
>   dequeue(taskB)
>
> TaskB has been enqueued with with uclamp enabled, thus it
> has got uc_se->active=True and enforced its clamp value at RQ level.
>
> But with your change above we don't reset that anymore.
>

Harumph indeed...

> As per my previous proposal: why not just removing the SCHED_WARN_ON?
> That's the only real problem in the code above, since now we are not
> more granted to have balanced inc/dec.
>

The SCHED_WARN_ON is gone, were you thinking of something else?

Reply via email to