From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from canpmsgout02.his.huawei.com (canpmsgout02.his.huawei.com [113.46.200.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D395A3E44E7 for ; Wed, 5 Aug 2026 10:08:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.217 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785924541; cv=none; b=WcuuGYE5b9sH/qre6WkYaKkgAsjdMGC4VzaCWz80lDoGiG3gBSPNwfOsPCU6/T7POxifd6385OUkSWL6KND9Rp2yG1jZA35bfiRjkZ3aZ569ULzQRgI4hvdoBthq/vXJ0HRRLeiK1TiH2GG9xgpN2wJHseoxtiIJb8Y+IHywiMY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785924541; c=relaxed/simple; bh=nX6bbRGbyIC1xtXUqQlZakowtf8K0Nz4nHxicR66+9k=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=PwYaGdRmga9mUw2Hi1U/5mYqxBTUbytKjUgvEpXDF+AfRfpl7R2OOmIOwGHrf0iqmIT5VOHLLY7yQ7lTHaHtivz6UqoJLljMxja7q56Vj3Y8qt34JZboqP3E23QKHdY5a+0BUa9jzNb0G+gV5ekazhakCbeP/xlgxS2gfL2OQqI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=kasW4hQU; arc=none smtp.client-ip=113.46.200.217 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="kasW4hQU" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=/o2pQOvcPeP6gfmiICVK8A/+Wn+M/nmvh+iZ13rkvCg=; b=kasW4hQUl1I3sVVstSoNyyL+Fo82gXGKumsY5ROG9lIRt4v0BdGOgZo5lySmcg5j5NpOmE5qp A6NUICwlXg+Vl5zgyLwlb8M7cp8pNVlEyzRVrN8dZqM5kaZMqED5piNR9mak/8RchpGJjjvvxka 1Pov2MFtCQiyV8qEJKKAq4E= Received: from mail.maildlp.com (unknown [172.19.162.197]) by canpmsgout02.his.huawei.com (SkyGuard) with ESMTPS id 4hFQpx4sXJzcb0f; Wed, 5 Aug 2026 17:58:49 +0800 (CST) Received: from dggpemf500011.china.huawei.com (unknown [7.185.36.131]) by mail.maildlp.com (Postfix) with ESMTPS id 236644057D; Wed, 5 Aug 2026 18:08:44 +0800 (CST) Received: from [10.67.109.254] (10.67.109.254) by dggpemf500011.china.huawei.com (7.185.36.131) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Wed, 5 Aug 2026 18:08:43 +0800 Message-ID: Date: Wed, 5 Aug 2026 18:08:42 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 2/6] sched: dynamic: Simplify {cond,might}_resched() To: Mark Rutland , CC: , , , , , , , , , References: <20260803191731.3244294-1-mark.rutland@arm.com> <20260803191731.3244294-3-mark.rutland@arm.com> From: Jinjie Ruan In-Reply-To: <20260803191731.3244294-3-mark.rutland@arm.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-ClientProxiedBy: kwepems500002.china.huawei.com (7.221.188.17) To dggpemf500011.china.huawei.com (7.185.36.131) 在 2026/8/4 3:17, Mark Rutland 写道: > PREEMPT_DYNAMIC is now limited to the FULL and LAZY preemption models. > In either model, both cond_resched() and might_resched() are always > disabled and do nothing. > > Remove the unnecessary code for these when PREEMPT_DYNAMIC is selected. > > Signed-off-by: Mark Rutland > Reviewed-by: Shrikanth Hegde > Cc: Frederic Weisbecker > Cc: Ingo Molnar > Cc: John Stultz > Cc: Juri Lelli > Cc: Peter Zijlstra > Cc: Shrikanth Hegde > Cc: Thomas Gleixner > Cc: Valentin Schneider > Cc: Vincent Guittot > --- > include/linux/kernel.h | 20 ------------------- > include/linux/sched.h | 31 +++-------------------------- > kernel/sched/core.c | 44 +----------------------------------------- > 3 files changed, 4 insertions(+), 91 deletions(-) > > diff --git a/include/linux/kernel.h b/include/linux/kernel.h > index e5570a16cbb1a..533ee1e6e1cb7 100644 > --- a/include/linux/kernel.h > +++ b/include/linux/kernel.h > @@ -43,30 +43,10 @@ struct completion; > struct user; > > #ifdef CONFIG_PREEMPT_VOLUNTARY_BUILD > - > extern int __cond_resched(void); > # define might_resched() __cond_resched() > - > -#elif defined(CONFIG_PREEMPT_DYNAMIC) && defined(CONFIG_HAVE_PREEMPT_DYNAMIC_CALL) > - > -extern int __cond_resched(void); > - > -DECLARE_STATIC_CALL(might_resched, __cond_resched); > - > -static __always_inline void might_resched(void) > -{ > - static_call_mod(might_resched)(); > -} > - > -#elif defined(CONFIG_PREEMPT_DYNAMIC) && defined(CONFIG_HAVE_PREEMPT_DYNAMIC_KEY) > - > -extern int dynamic_might_resched(void); > -# define might_resched() dynamic_might_resched() > - > #else > - > # define might_resched() do { } while (0) > - > #endif /* CONFIG_PREEMPT_* */ > > #ifdef CONFIG_DEBUG_ATOMIC_SLEEP > diff --git a/include/linux/sched.h b/include/linux/sched.h > index 373bcc0598d10..1a44c5261c2dd 100644 > --- a/include/linux/sched.h > +++ b/include/linux/sched.h > @@ -2119,44 +2119,19 @@ static inline void set_need_resched_current(void) > * value indicates whether a reschedule was done in fact. > * cond_resched_lock() will drop the spinlock before scheduling, > */ > -#if !defined(CONFIG_PREEMPTION) || defined(CONFIG_PREEMPT_DYNAMIC) > +#if !defined(CONFIG_PREEMPTION) > extern int __cond_resched(void); > > -#if defined(CONFIG_PREEMPT_DYNAMIC) && defined(CONFIG_HAVE_PREEMPT_DYNAMIC_CALL) > - > -DECLARE_STATIC_CALL(cond_resched, __cond_resched); > - > -static __always_inline int _cond_resched(void) > -{ > - return static_call_mod(cond_resched)(); > -} > - > -#elif defined(CONFIG_PREEMPT_DYNAMIC) && defined(CONFIG_HAVE_PREEMPT_DYNAMIC_KEY) > - > -extern int dynamic_cond_resched(void); > - > -static __always_inline int _cond_resched(void) > -{ > - return dynamic_cond_resched(); > -} > - > -#else /* !CONFIG_PREEMPTION */ > - > static inline int _cond_resched(void) > { > return __cond_resched(); > } > - > -#endif /* PREEMPT_DYNAMIC && CONFIG_HAVE_PREEMPT_DYNAMIC_CALL */ > - > -#else /* CONFIG_PREEMPTION && !CONFIG_PREEMPT_DYNAMIC */ > - > +#else > static inline int _cond_resched(void) > { > return 0; > } > - > -#endif /* !CONFIG_PREEMPTION || CONFIG_PREEMPT_DYNAMIC */ > +#endif > > #define cond_resched() ({ \ > __might_resched(__FILE__, __LINE__, 0); \ > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > index 2db78826a484b..84ec93694d718 100644 > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -7733,7 +7733,7 @@ void rt_mutex_setprio(struct task_struct *p, struct task_struct *pi_task) > } > #endif /* CONFIG_RT_MUTEXES */ > > -#if !defined(CONFIG_PREEMPTION) || defined(CONFIG_PREEMPT_DYNAMIC) > +#if !defined(CONFIG_PREEMPTION) > int __sched __cond_resched(void) > { > if (should_resched(0) && !irqs_disabled()) { > @@ -7761,38 +7761,6 @@ int __sched __cond_resched(void) > EXPORT_SYMBOL(__cond_resched); > #endif > > -#ifdef CONFIG_PREEMPT_DYNAMIC > -# ifdef CONFIG_HAVE_PREEMPT_DYNAMIC_CALL > -# define cond_resched_dynamic_enabled __cond_resched > -# define cond_resched_dynamic_disabled ((void *)&__static_call_return0) > -DEFINE_STATIC_CALL_RET0(cond_resched, __cond_resched); > -EXPORT_STATIC_CALL_TRAMP(cond_resched); > - > -# define might_resched_dynamic_enabled __cond_resched > -# define might_resched_dynamic_disabled ((void *)&__static_call_return0) > -DEFINE_STATIC_CALL_RET0(might_resched, __cond_resched); > -EXPORT_STATIC_CALL_TRAMP(might_resched); > -# elif defined(CONFIG_HAVE_PREEMPT_DYNAMIC_KEY) > -static DEFINE_STATIC_KEY_FALSE(sk_dynamic_cond_resched); > -int __sched dynamic_cond_resched(void) > -{ > - if (!static_branch_unlikely(&sk_dynamic_cond_resched)) > - return 0; > - return __cond_resched(); > -} > -EXPORT_SYMBOL(dynamic_cond_resched); > - > -static DEFINE_STATIC_KEY_FALSE(sk_dynamic_might_resched); > -int __sched dynamic_might_resched(void) > -{ > - if (!static_branch_unlikely(&sk_dynamic_might_resched)) > - return 0; > - return __cond_resched(); > -} > -EXPORT_SYMBOL(dynamic_might_resched); > -# endif > -#endif /* CONFIG_PREEMPT_DYNAMIC */ > - > /* > * __cond_resched_lock() - if a reschedule is pending, drop the given lock, > * call schedule, and on return reacquire the lock. > @@ -7862,8 +7830,6 @@ EXPORT_SYMBOL(__cond_resched_rwlock_write); > # endif > > /* > - * SC:cond_resched > - * SC:might_resched > * SC:preempt_schedule > * SC:preempt_schedule_notrace > * SC:irqentry_exit_cond_resched > @@ -7876,16 +7842,12 @@ EXPORT_SYMBOL(__cond_resched_rwlock_write); > * (unselectable) > * > * FULL: > - * cond_resched <- RET0 > - * might_resched <- RET0 > * preempt_schedule <- preempt_schedule > * preempt_schedule_notrace <- preempt_schedule_notrace > * irqentry_exit_cond_resched <- irqentry_exit_cond_resched > * dynamic_preempt_lazy <- false > * > * LAZY: > - * cond_resched <- RET0 > - * might_resched <- RET0 > * preempt_schedule <- preempt_schedule > * preempt_schedule_notrace <- preempt_schedule_notrace > * irqentry_exit_cond_resched <- irqentry_exit_cond_resched > @@ -7932,8 +7894,6 @@ static void __sched_dynamic_update(int mode) > { > switch (mode) { > case preempt_dynamic_full: > - preempt_dynamic_disable(cond_resched); > - preempt_dynamic_disable(might_resched); > preempt_dynamic_enable(preempt_schedule); > preempt_dynamic_enable(preempt_schedule_notrace); > preempt_dynamic_enable(irqentry_exit_cond_resched); > @@ -7943,8 +7903,6 @@ static void __sched_dynamic_update(int mode) > break; > > case preempt_dynamic_lazy: > - preempt_dynamic_disable(cond_resched); > - preempt_dynamic_disable(might_resched); Reviewed-by: Jinjie Ruan > preempt_dynamic_enable(preempt_schedule); > preempt_dynamic_enable(preempt_schedule_notrace); > preempt_dynamic_enable(irqentry_exit_cond_resched);