diff options
| -rw-r--r-- | kernel/sched/core.c | 24 | 
1 files changed, 9 insertions, 15 deletions
| diff --git a/kernel/sched/core.c b/kernel/sched/core.c index dd69e85b7879..c703d177f62d 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -873,15 +873,11 @@ static inline void hrtick_rq_init(struct rq *rq)  	({								\  		typeof(ptr) _ptr = (ptr);				\  		typeof(mask) _mask = (mask);				\ -		typeof(*_ptr) _old, _val = *_ptr;			\ +		typeof(*_ptr) _val = *_ptr;				\  									\ -		for (;;) {						\ -			_old = cmpxchg(_ptr, _val, _val | _mask);	\ -			if (_old == _val)				\ -				break;					\ -			_val = _old;					\ -		}							\ -	_old;								\ +		do {							\ +		} while (!try_cmpxchg(_ptr, &_val, _val | _mask));	\ +	_val;								\  })  #if defined(CONFIG_SMP) && defined(TIF_POLLING_NRFLAG) @@ -890,7 +886,7 @@ static inline void hrtick_rq_init(struct rq *rq)   * this avoids any races wrt polling state changes and thereby avoids   * spurious IPIs.   */ -static bool set_nr_and_not_polling(struct task_struct *p) +static inline bool set_nr_and_not_polling(struct task_struct *p)  {  	struct thread_info *ti = task_thread_info(p);  	return !(fetch_or(&ti->flags, _TIF_NEED_RESCHED) & _TIF_POLLING_NRFLAG); @@ -905,30 +901,28 @@ static bool set_nr_and_not_polling(struct task_struct *p)  static bool set_nr_if_polling(struct task_struct *p)  {  	struct thread_info *ti = task_thread_info(p); -	typeof(ti->flags) old, val = READ_ONCE(ti->flags); +	typeof(ti->flags) val = READ_ONCE(ti->flags);  	for (;;) {  		if (!(val & _TIF_POLLING_NRFLAG))  			return false;  		if (val & _TIF_NEED_RESCHED)  			return true; -		old = cmpxchg(&ti->flags, val, val | _TIF_NEED_RESCHED); -		if (old == val) +		if (try_cmpxchg(&ti->flags, &val, val | _TIF_NEED_RESCHED))  			break; -		val = old;  	}  	return true;  }  #else -static bool set_nr_and_not_polling(struct task_struct *p) +static inline bool set_nr_and_not_polling(struct task_struct *p)  {  	set_tsk_need_resched(p);  	return true;  }  #ifdef CONFIG_SMP -static bool set_nr_if_polling(struct task_struct *p) +static inline bool set_nr_if_polling(struct task_struct *p)  {  	return false;  } | 
