Skip to content
This repository was archived by the owner on Apr 13, 2023. It is now read-only.

Commit

Permalink
sched_ext: Add sysrq-S which disables the BPF scheduler
Browse files Browse the repository at this point in the history
This enables the admin to abort the BPF scheduler and revert to CFS anytime.

Signed-off-by: Tejun Heo <[email protected]>
Reviewed-by: David Vernet <[email protected]>
Acked-by: Josh Don <[email protected]>
Acked-by: Hao Luo <[email protected]>
Acked-by: Barret Rhoden <[email protected]>
  • Loading branch information
htejun committed Apr 13, 2023
1 parent 247c051 commit 99e6b10
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions drivers/tty/sysrq.c
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@ static const struct sysrq_key_op *sysrq_key_table[62] = {
NULL, /* P */
NULL, /* Q */
NULL, /* R */
/* S: May be registered by sched_ext for resetting */
NULL, /* S */
NULL, /* T */
NULL, /* U */
Expand Down
1 change: 1 addition & 0 deletions include/linux/sched/ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ enum scx_exit_type {
SCX_EXIT_DONE,

SCX_EXIT_UNREG = 64, /* BPF unregistration */
SCX_EXIT_SYSRQ, /* requested by 'S' sysrq */

SCX_EXIT_ERROR = 1024, /* runtime error, error msg contains details */
SCX_EXIT_ERROR_BPF, /* ERROR but triggered through scx_bpf_error() */
Expand Down
1 change: 1 addition & 0 deletions kernel/sched/build_policy.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <linux/suspend.h>
#include <linux/tsacct_kern.h>
#include <linux/vtime.h>
#include <linux/sysrq.h>
#include <linux/percpu-rwsem.h>

#include <uapi/linux/sched/types.h>
Expand Down
20 changes: 20 additions & 0 deletions kernel/sched/ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -1930,6 +1930,9 @@ static void scx_ops_disable_workfn(struct kthread_work *work)
case SCX_EXIT_UNREG:
reason = "BPF scheduler unregistered";
break;
case SCX_EXIT_SYSRQ:
reason = "disabled by sysrq-S";
break;
case SCX_EXIT_ERROR:
reason = "runtime error";
break;
Expand Down Expand Up @@ -2533,6 +2536,21 @@ struct bpf_struct_ops bpf_sched_ext_ops = {
.name = "sched_ext_ops",
};

static void sysrq_handle_sched_ext_reset(int key)
{
if (scx_ops_helper)
scx_ops_disable(SCX_EXIT_SYSRQ);
else
pr_info("sched_ext: BPF scheduler not yet used\n");
}

static const struct sysrq_key_op sysrq_sched_ext_reset_op = {
.handler = sysrq_handle_sched_ext_reset,
.help_msg = "reset-sched-ext(S)",
.action_msg = "Disable sched_ext and revert all tasks to CFS",
.enable_mask = SYSRQ_ENABLE_RTNICE,
};

void __init init_sched_ext_class(void)
{
int cpu;
Expand All @@ -2556,6 +2574,8 @@ void __init init_sched_ext_class(void)

init_dsq(&rq->scx.local_dsq, SCX_DSQ_LOCAL);
}

register_sysrq_key('S', &sysrq_sched_ext_reset_op);
}


Expand Down

0 comments on commit 99e6b10

Please sign in to comment.