mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-26 14:17:26 -04:00
livepatch,sched: Add livepatch task switching to cond_resched()
There have been reports [1][2] of live patches failing to complete within a reasonable amount of time due to CPU-bound kthreads. Fix it by patching tasks in cond_resched(). There are four different flavors of cond_resched(), depending on the kernel configuration. Hook into all of them. A more elegant solution might be to use a preempt notifier. However, non-ORC unwinders can't unwind a preempted task reliably. [1] https://lore.kernel.org/lkml/20220507174628.2086373-1-song@kernel.org/ [2] https://lkml.kernel.org/lkml/20230120-vhost-klp-switching-v1-0-7c2b65519c43@kernel.org Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Petr Mladek <pmladek@suse.com> Tested-by: Seth Forshee (DigitalOcean) <sforshee@kernel.org> Link: https://lore.kernel.org/r/4ae981466b7814ec221014fc2554b2f86f3fb70b.1677257135.git.jpoimboe@kernel.org
This commit is contained in:
parent
383439d3d4
commit
e3ff7c609f
6 changed files with 194 additions and 28 deletions
29
include/linux/livepatch_sched.h
Normal file
29
include/linux/livepatch_sched.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
#ifndef _LINUX_LIVEPATCH_SCHED_H_
|
||||
#define _LINUX_LIVEPATCH_SCHED_H_
|
||||
|
||||
#include <linux/jump_label.h>
|
||||
#include <linux/static_call_types.h>
|
||||
|
||||
#ifdef CONFIG_LIVEPATCH
|
||||
|
||||
void __klp_sched_try_switch(void);
|
||||
|
||||
#if !defined(CONFIG_PREEMPT_DYNAMIC) || !defined(CONFIG_HAVE_PREEMPT_DYNAMIC_CALL)
|
||||
|
||||
DECLARE_STATIC_KEY_FALSE(klp_sched_try_switch_key);
|
||||
|
||||
static __always_inline void klp_sched_try_switch(void)
|
||||
{
|
||||
if (static_branch_unlikely(&klp_sched_try_switch_key))
|
||||
__klp_sched_try_switch();
|
||||
}
|
||||
|
||||
#endif /* !CONFIG_PREEMPT_DYNAMIC || !CONFIG_HAVE_PREEMPT_DYNAMIC_CALL */
|
||||
|
||||
#else /* !CONFIG_LIVEPATCH */
|
||||
static inline void klp_sched_try_switch(void) {}
|
||||
static inline void __klp_sched_try_switch(void) {}
|
||||
#endif /* CONFIG_LIVEPATCH */
|
||||
|
||||
#endif /* _LINUX_LIVEPATCH_SCHED_H_ */
|
Loading…
Add table
Add a link
Reference in a new issue