[SPAM]Re: [Bug] Race condition between CPU hotplug off flow and __sched_setscheduler()

Jing-Ting Wu jing-ting.wu at mediatek.com
Mon May 23 00:12:54 PDT 2022


On Thu, 2022-05-19 at 15:47 +0200, Peter Zijlstra wrote:
> On Thu, May 19, 2022 at 08:53:15PM +0800, Jing-Ting Wu wrote:
> > Hi all
> > 
> > 
> > There is a race condition between CPU hotplug off flow and
> > __sched_setscheduler(), which will cause hang-up in CPU hotplug off
> > flow.
> 
> How easy can you reproduce; does the below hack make it better?


The issue can be reproduced in about 48 hours when hotplug up/down
frequently.

Thanks for your suggestion.
I think the hack patch could stay the rq->balance_callback when rq-
>callback = &balance_push_callback.
We can add hack patch to the stability test.


> 
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 95bac3b094b3..f18ee22b29bc 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -4763,20 +4763,30 @@ struct callback_head balance_push_callback =
> {
>  	.func = (void (*)(struct callback_head *))balance_push,
>  };
>  
> -static inline struct callback_head *splice_balance_callbacks(struct
> rq *rq)
> +static inline struct callback_head *
> +__splice_balance_callbacks(struct rq *rq, bool foo)
>  {
>  	struct callback_head *head = rq->balance_callback;
>  
>  	lockdep_assert_rq_held(rq);
> -	if (head)
> -		rq->balance_callback = NULL;
> +	if (head) {
> +		if (foo && head == &balance_push_callback)
> +			head = NULL;
> +		else
> +			rq->balance_callback = NULL;
> +	}
>  
>  	return head;
>  }
>  
> +static inline struct callback_head *splice_balance_callbacks(struct
> rq *rq)
> +{
> +	return __splice_balance_callbacks(rq, true);
> +}
> +
>  static void __balance_callbacks(struct rq *rq)
>  {
> -	do_balance_callbacks(rq, splice_balance_callbacks(rq));
> +	do_balance_callbacks(rq, __splice_balance_callbacks(rq,
> false));
>  }
>  
>  static inline void balance_callbacks(struct rq *rq, struct
> callback_head *head)
> 








More information about the linux-arm-kernel mailing list