Commit b6bb70f9 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull cgroup updates from Tejun Heo:
 "Several core optimizations:

   - threadgroup_rwsem write locking is skipped when configuring
     controllers in empty subtrees.

     Combined with CLONE_INTO_CGROUP, this allows the common static
     usage pattern to not grab threadgroup_rwsem at all (glibc still
     doesn't seem ready for CLONE_INTO_CGROUP unfortunately).

   - threadgroup_rwsem used to be put into non-percpu mode by default
     due to latency concerns in specific use cases. There's no reason
     for everyone else to pay for it. Make the behavior optional.

   - psi no longer allocates memory when disabled.

  ... along with some code cleanups"

* tag 'cgroup-for-5.20' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup:
  cgroup: Skip subtree root in cgroup_update_dfl_csses()
  cgroup: remove "no" prefixed mount options
  cgroup: Make !percpu threadgroup_rwsem operations optional
  cgroup: Add "no" prefixed mount options
  cgroup: Elide write-locking threadgroup_rwsem when updating csses on an empty subtree
  cgroup.c: remove redundant check for mixable cgroup in cgroup_migrate_vet_dst
  cgroup.c: add helper __cset_cgroup_from_root to cleanup duplicated codes
  psi: dont alloc memory for psi by default
parents e2b54210 265792d0
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -184,6 +184,14 @@ cgroup v2 currently supports the following mount options.
	ignored on non-init namespace mounts.  Please refer to the
	Delegation section for details.

  favordynmods
        Reduce the latencies of dynamic cgroup modifications such as
        task migrations and controller on/offs at the cost of making
        hot path operations such as forks and exits more expensive.
        The static usage pattern of creating a cgroup, enabling
        controllers, and then seeding it with CLONE_INTO_CGROUP is
        not affected by this option.

  memory_localevents
        Only populate memory.events with data for the current cgroup,
        and not any subtrees. This is legacy behaviour, the default
+17 −4
Original line number Diff line number Diff line
@@ -88,20 +88,33 @@ enum {
	 */
	CGRP_ROOT_NS_DELEGATE	= (1 << 3),

	/*
	 * Reduce latencies on dynamic cgroup modifications such as task
	 * migrations and controller on/offs by disabling percpu operation on
	 * cgroup_threadgroup_rwsem. This makes hot path operations such as
	 * forks and exits into the slow path and more expensive.
	 *
	 * The static usage pattern of creating a cgroup, enabling controllers,
	 * and then seeding it with CLONE_INTO_CGROUP doesn't require write
	 * locking cgroup_threadgroup_rwsem and thus doesn't benefit from
	 * favordynmod.
	 */
	CGRP_ROOT_FAVOR_DYNMODS = (1 << 4),

	/*
	 * Enable cpuset controller in v1 cgroup to use v2 behavior.
	 */
	CGRP_ROOT_CPUSET_V2_MODE = (1 << 4),
	CGRP_ROOT_CPUSET_V2_MODE = (1 << 16),

	/*
	 * Enable legacy local memory.events.
	 */
	CGRP_ROOT_MEMORY_LOCAL_EVENTS = (1 << 5),
	CGRP_ROOT_MEMORY_LOCAL_EVENTS = (1 << 17),

	/*
	 * Enable recursive subtree protection
	 */
	CGRP_ROOT_MEMORY_RECURSIVE_PROT = (1 << 6),
	CGRP_ROOT_MEMORY_RECURSIVE_PROT = (1 << 18),
};

/* cftype->flags */
@@ -480,7 +493,7 @@ struct cgroup {
	struct work_struct release_agent_work;

	/* used to track pressure stalls */
	struct psi_group psi;
	struct psi_group *psi;

	/* used to store eBPF programs */
	struct cgroup_bpf bpf;
+1 −1
Original line number Diff line number Diff line
@@ -674,7 +674,7 @@ static inline void pr_cont_cgroup_path(struct cgroup *cgrp)

static inline struct psi_group *cgroup_psi(struct cgroup *cgrp)
{
	return &cgrp->psi;
	return cgrp->psi;
}

bool cgroup_psi_enabled(void);
+10 −0
Original line number Diff line number Diff line
@@ -945,6 +945,16 @@ if CGROUPS
config PAGE_COUNTER
	bool

config CGROUP_FAVOR_DYNMODS
        bool "Favor dynamic modification latency reduction by default"
        help
          This option enables the "favordynmods" mount option by default
          which reduces the latencies of dynamic cgroup modifications such
          as task migrations and controller on/offs at the cost of making
          hot path operations such as forks and exits more expensive.

          Say N if unsure.

config MEMCG
	bool "Memory controller"
	select PAGE_COUNTER
+1 −0
Original line number Diff line number Diff line
@@ -233,6 +233,7 @@ void cgroup_kn_unlock(struct kernfs_node *kn);
int cgroup_path_ns_locked(struct cgroup *cgrp, char *buf, size_t buflen,
			  struct cgroup_namespace *ns);

void cgroup_favor_dynmods(struct cgroup_root *root, bool favor);
void cgroup_free_root(struct cgroup_root *root);
void init_cgroup_root(struct cgroup_fs_context *ctx);
int cgroup_setup_root(struct cgroup_root *root, u16 ss_mask);
Loading