forked from torvalds/linux
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sched, padata: Bound max threads with max_cfs_bandwidth_cpus()
Helpers are currently not bound by the main thread's CFS bandwidth limits because they're kernel threads that run on the root runqueues, so a multithreaded job could cause a task group to consume more quota than it's configured for. As a starting point for helpers honoring these limits, restrict a job to only as many helpers as there are CPUs allowed by these limits. Helpers are generally CPU-bound, so starting more helpers than this would likely exceed the group's entire quota. Max CFS bandwidth CPUs are calculated conservatively with integer division (quota / period). This restriction ignores other tasks in the group that might also be consuming quota, so it doesn't strictly prevent a group from exceeding its limits. However, this may be the right tradeoff between simplicity and absolutely correct resource control, given that VFIO page pinning typically happens during guest initialization when there's not much other CPU activity in the group. There's also a prototype for an absolutely correct approach later in the series should that be preferred. Signed-off-by: Daniel Jordan <daniel.m.jordan@oracle.com>
- Loading branch information
1 parent
e7a5d19
commit 44b2a69
Showing
3 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
#ifndef _LINUX_SCHED_CGROUP_H | ||
#define _LINUX_SCHED_CGROUP_H | ||
|
||
#include <linux/cgroup-defs.h> | ||
#include <linux/cpumask.h> | ||
|
||
#ifdef CONFIG_CFS_BANDWIDTH | ||
|
||
int max_cfs_bandwidth_cpus(struct cgroup_subsys_state *css); | ||
|
||
#else /* CONFIG_CFS_BANDWIDTH */ | ||
|
||
static inline int max_cfs_bandwidth_cpus(struct cgroup_subsys_state *css) | ||
{ | ||
return nr_cpu_ids; | ||
} | ||
|
||
#endif /* CONFIG_CFS_BANDWIDTH */ | ||
|
||
#endif /* _LINUX_SCHED_CGROUP_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters