Skip to content

Core scheduling

Joel Fernandes (Google) lkml 1 version Applied

Status from this message: I applied the entire series and just find a related patch to report the

Get series with b4
b4 am [email protected]

Versions newest first

  1. v8 Latest26 patches 67 repliesApplied

Changes in v8 from the cover letter

=============
- New interface/API implementation
- Joel
- Revised kernel protection patch
- Joel
- Revised Hotplug fixes
- Joel
- Minor bug fixes and address review comments
- Vineeth

Patches in v8 Applied

#Subject and filesSizeRepliesApplied
1/26sched: Wrap rq::lock accesskernel/sched/core.c kernel/sched/cpuacct.c kernel/sched/deadline.c +7 more+122 -1190 replies
2/26sched: Introduce sched_class::pick_task()kernel/sched/deadline.c kernel/sched/fair.c kernel/sched/idle.c +3 more+79 -713 replies
3/26sched: Core-wide rq->lockkernel/Kconfig.preempt kernel/sched/core.c kernel/sched/sched.h+146 -02 replies
4/26sched/fair: Add a few assertionskernel/sched/fair.c+10 -20 replies
5/26sched: Basic tracking of matching tasksinclude/linux/sched.h kernel/sched/core.c kernel/sched/fair.c +1 more+208 -470 replies
6/26sched: Add core wide task selection and scheduling.kernel/sched/core.c kernel/sched/sched.h+305 -212 replies
7/26sched/fair: Fix forced idle sibling starvation corner casekernel/sched/core.c kernel/sched/fair.c kernel/sched/sched.h+49 -80 replies
8/26sched/fair: Snapshot the min_vruntime of CPUs on force idlekernel/sched/core.c kernel/sched/fair.c kernel/sched/sched.h+65 -1310 replies
9/26sched: Trivial forced-newidle balancerinclude/linux/sched.h kernel/sched/core.c kernel/sched/idle.c +1 more+137 -10 replies
10/26sched: migration changes for core schedulingkernel/sched/fair.c kernel/sched/sched.h+88 -50 replies
11/26irq_work: Cleanupdrivers/gpu/drm/i915/i915_request.c include/linux/irq_work.h include/linux/irqflags.h +6 more+41 -370 replies
12/26arch/x86: Add a new TIF flag for untrusted tasksarch/x86/include/asm/thread_info.h kernel/sched/sched.h+8 -00 replies
13/26kernel/entry: Add support for core-wide protection of kernel-modeDocumentation/admin-guide/kernel-parameters.txt include/linux/entry-common.h include/linux/sched.h +3 more+275 -314 replies
14/26entry/idle: Enter and exit kernel protection during idle entry and exitinclude/linux/entry-common.h kernel/sched/idle.c+24 -50 replies
15/26entry/kvm: Protect the kernel when entering from guestarch/x86/kvm/x86.c include/linux/entry-kvm.h kernel/entry/kvm.c+28 -00 replies
16/26sched: cgroup tagging interface for core schedulingkernel/sched/core.c kernel/sched/sched.h+181 -60 replies
17/26sched: Split the cookie and setup per-task cookie on forkinclude/linux/sched.h kernel/sched/core.c kernel/sched/debug.c+236 -113 replies
18/26sched: Add a per-thread core scheduling interfaceinclude/linux/sched.h include/uapi/linux/prctl.h kernel/sched/core.c +2 more+58 -40 replies
19/26sched: Add a second-level tag for nested CGroup usecasekernel/sched/core.c kernel/sched/sched.h+158 -263 replies
20/26sched: Release references to the per-task cookie on exitinclude/linux/sched.h kernel/fork.c kernel/sched/core.c+11 -02 replies
21/26sched: Handle task addition to CGroupkernel/sched/core.c+10 -50 replies
22/26sched/debug: Add CGroup node for printing group cookie if SCHED_DEBUGkernel/sched/core.c+23 -00 replies
23/26kselftest: Add tests for core-sched interfacetools/testing/selftests/sched/.gitignore tools/testing/selftests/sched/Makefile tools/testing/selftests/sched/config +1 more+856 -01 reply
24/26sched: Move core-scheduler interfacing code to a new filekernel/sched/Makefile kernel/sched/core.c kernel/sched/coretag.c +1 more+523 -4832 replies
25/26Documentation: Add core scheduling documentationDocumentation/admin-guide/hw-vuln/core-scheduling.rst Documentation/admin-guide/hw-vuln/index.rst+313 -02 replies
26/26sched: Debug bits...kernel/sched/core.c+36 -10 replies

Reviews trailers per patch

2 of 26 patches have a Reviewed-by or Acked-by.

PatchJulien DesfossezPaul E. McKenneyPeter Zijlstra (Intel)Alexandre Chartre
1/26T-b
2/26T-b
3/26T-b
4/26T-b
5/26T-b
6/26T-b
7/26T-b
8/26T-b
9/26T-b A-b
10/26T-b
11/26T-b
12/26T-b
13/26T-b T-b R-b
14/26T-b
15/26T-b
16/26T-b
17/26T-b
18/26T-b
19/26T-b
20/26T-b
21/26T-b
22/26T-b
23/26T-b
24/26T-b
25/26T-b T-b
26/26T-b Not-Signed-off-by

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.

Read the v8 thread

Cover letter [PATCH v8 -tip 00/26] Core scheduling

Eighth iteration of the Core-Scheduling feature.

Core scheduling is a feature that allows only trusted tasks to run concurrently on cpus sharing compute resources (eg: hyperthreads on a core). The goal is to mitigate the core-level side-channel attacks without requiring to disable SMT (which has a significant impact on performance in some situations). Core scheduling (as of v7) mitigates user-space to user-space attacks and user to kernel attack when one of the siblings enters the kernel via interrupts or system call.

By default, the feature doesn't change any of the current scheduler behavior. The user decides which tasks can run simultaneously on the same core (for now by having them in the same tagged cgroup). When a tag is enabled in a cgroup and a task from that cgroup is running on a hardware thread, the scheduler ensures that only idle or trusted tasks run on the other sibling(s). Besides security concerns, this feature can also be beneficial for RT and performance applications where we want to control how tasks make use of SMT dynamically.

This iteration focuses on the the following stuff:
- Redesigned API.
- Rework of Kernel Protection feature based on Thomas's entry work.
- Rework of hotplug fixes.
- Address review comments in v7

Joel: Both a CGroup and Per-task interface via prctl(2) are provided for configuring core sharing. More details are provided in documentation patch. Kselftests are provided to verify the correctness/rules of the interface.

Julien: TPCC tests showed improvements with core-scheduling. With kernel protection enabled, it does not show any regression. Possibly ASI will improve the performance for those who choose kernel protection (can be toggled through sched_core_protect_kernel sysctl). Results:
v8 average stdev diff
baseline (SMT on) 1197.272 44.78312824
core sched ( kernel protect) 412.9895 45.42734343 -65.51%
core sched (no kernel protect) 686.6515 71.77756931 -42.65%
nosmt 408.667 39.39042872 -65.87%

v8 is rebased on tip/master.

Future work
===========
- Load balancing/Migration fixes for core scheduling. With v6, Load balancing is partially coresched aware, but has some issues w.r.t process/taskgroup weights:
https://lwn.net/ml/linux-kernel/20200225034438.GA617271@z...
- Core scheduling test framework: kselftests, torture tests etc

Changes in v8
=============
- New interface/API implementation
- Joel
- Revised kernel protection patch
- Joel
- Revised Hotplug fixes
- Joel
- Minor bug fixes and address review comments
- Vineeth

Changes in v7
=============
- Kernel protection from untrusted usermode tasks
- Joel, Vineeth
- Fix for hotplug crashes and hangs
- Joel, Vineeth

Changes in v6
=============
- Documentation
- Joel
- Pause siblings on entering nmi/irq/softirq
- Joel, Vineeth
- Fix for RCU crash
- Joel
- Fix for a crash in pick_next_task
- Yu Chen, Vineeth
- Minor re-write of core-wide vruntime comparison
- Aaron Lu
- Cleanup: Address Review comments
- Cleanup: Remove hotplug support (for now)
- Build fixes: 32 bit, SMT=n, AUTOGROUP=n etc
- Joel, Vineeth

Changes in v5
=============
- Fixes for cgroup/process tagging during corner cases like cgroup destroy, task moving across cgroups etc
- Tim Chen
- Coresched aware task migrations
- Aubrey Li
- Other minor stability fixes.

Changes in v4
=============
- Implement a core wide min_vruntime for vruntime comparison of tasks across cpus in a core.
- Aaron Lu
- Fixes a typo bug in setting the forced_idle cpu.
- Aaron Lu

Changes in v3
=============
- Fixes the issue of sibling picking up an incompatible task
- Aaron Lu
- Vineeth Pillai
- Julien Desfossez
- Fixes the issue of starving threads due to forced idle
- Peter Zijlstra
- Fixes the refcounting issue when deleting a cgroup with tag
- Julien Desfossez
- Fixes a crash during cpu offline/online with coresched enabled
- Vineeth Pillai
- Fixes a comparison logic issue in sched_core_find
- Aaron Lu

Changes in v2
=============
- Fixes for couple of NULL pointer dereference crashes
- Subhra Mazumdar
- Tim Chen
- Improves priority comparison logic for process in different cpus
- Peter Zijlstra
- Aaron Lu
- Fixes a hard lockup in rq locking
- Vineeth Pillai
- Julien Desfossez
- Fixes a performance issue seen on IO heavy workloads
- Vineeth Pillai
- Julien Desfossez
- Fix for 32bit build
- Aubrey Li

Aubrey Li (1):
sched: migration changes for core scheduling

Joel Fernandes (Google) (13):
sched/fair: Snapshot the min_vruntime of CPUs on force idle arch/x86: Add a new TIF flag for untrusted tasks kernel/entry: Add support for core-wide protection of kernel-mode entry/idle: Enter and exit kernel protection during idle entry and exit
sched: Split the cookie and setup per-task cookie on fork
sched: Add a per-thread core scheduling interface
sched: Add a second-level tag for nested CGroup usecase
sched: Release references to the per-task cookie on exit
sched: Handle task addition to CGroup
sched/debug: Add CGroup node for printing group cookie if SCHED_DEBUG
kselftest: Add tests for core-sched interface
sched: Move core-scheduler interfacing code to a new file
Documentation: Add core scheduling documentation

Peter Zijlstra (10):
sched: Wrap rq::lock access
sched: Introduce sched_class::pick_task()
sched: Core-wide rq->lock
sched/fair: Add a few assertions
sched: Basic tracking of matching tasks
sched: Add core wide task selection and scheduling.
sched: Trivial forced-newidle balancer
irq_work: Cleanup
sched: cgroup tagging interface for core scheduling
sched: Debug bits...

Vineeth Pillai (2):
sched/fair: Fix forced idle sibling starvation corner case entry/kvm: Protect the kernel when entering from guest

.../admin-guide/hw-vuln/core-scheduling.rst   |  312 +++++
Documentation/admin-guide/hw-vuln/index.rst   |    1 +
.../admin-guide/kernel-parameters.txt         |    7 +
arch/x86/include/asm/thread_info.h            |    2 +
arch/x86/kvm/x86.c                            |    3 +
drivers/gpu/drm/i915/i915_request.c           |    4 +-
include/linux/entry-common.h                  |   20 +-
include/linux/entry-kvm.h                     |   12 +
include/linux/irq_work.h                      |   33 +-
include/linux/irqflags.h                      |    4 +-
include/linux/sched.h                         |   27 +-
include/uapi/linux/prctl.h                    |    3 +
kernel/Kconfig.preempt                        |    6 +
kernel/bpf/stackmap.c                         |    2 +-
kernel/entry/common.c                         |   25 +-
kernel/entry/kvm.c                            |   13 +
kernel/fork.c                                 |    1 +
kernel/irq_work.c                             |   18 +-
kernel/printk/printk.c                        |    6 +-
kernel/rcu/tree.c                             |    3 +-
kernel/sched/Makefile                         |    1 +
kernel/sched/core.c                           | 1135 ++++++++++++++++-
kernel/sched/coretag.c                        |  468 +++++++
kernel/sched/cpuacct.c                        |   12 +-
kernel/sched/deadline.c                       |   34 +-
kernel/sched/debug.c                          |    8 +-
kernel/sched/fair.c                           |  272 ++--
kernel/sched/idle.c                           |   24 +-
kernel/sched/pelt.h                           |    2 +-
kernel/sched/rt.c                             |   22 +-
kernel/sched/sched.h                          |  302 ++++-
kernel/sched/stop_task.c                      |   13 +-
kernel/sched/topology.c                       |    4 +-
kernel/sys.c                                  |    3 +
kernel/time/tick-sched.c                      |    6 +-
kernel/trace/bpf_trace.c                      |    2 +-
tools/include/uapi/linux/prctl.h              |    3 +
tools/testing/selftests/sched/.gitignore      |    1 +
tools/testing/selftests/sched/Makefile        |   14 +
tools/testing/selftests/sched/config          |    1 +
.../testing/selftests/sched/test_coresched.c  |  840 ++++++++++++
41 files changed, 3437 insertions(+), 232 deletions(-)

create mode 100644 Documentation/admin-guide/hw-vuln/core-scheduling.rst create mode 100644 kernel/sched/coretag.c
create mode 100644 tools/testing/selftests/sched/.gitignore create mode 100644 tools/testing/selftests/sched/Makefile create mode 100644 tools/testing/selftests/sched/config create mode 100644 tools/testing/selftests/sched/test_coresched.c

--
2.29.0.rc1.297.gfa9743e501-goog