Commit 6aee5aed authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull cgroup updates from Tejun Heo:

 - Allow css_rstat_updated() in NMI context to enable memory accounting
   for allocations in NMI context.

 - /proc/cgroups doesn't contain useful information for cgroup2 and was
   updated to only show v1 controllers. This unfortunately broke
   something in the wild. Add an option to bring back the old behavior
   to ease transition.

 - selftest updates and other cleanups.

* tag 'cgroup-for-6.17' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup:
  cgroup: Add compatibility option for content of /proc/cgroups
  selftests/cgroup: fix cpu.max tests
  cgroup: llist: avoid memory tears for llist_node
  selftests: cgroup: Fix missing newline in test_zswap_writeback_one
  selftests: cgroup: Allow longer timeout for kmem_dead_cgroups cleanup
  memcg: cgroup: call css_rstat_updated irrespective of in_nmi()
  cgroup: remove per-cpu per-subsystem locks
  cgroup: make css_rstat_updated nmi safe
  cgroup: support to enable nmi-safe css_rstat_updated
  selftests: cgroup: Fix compilation on pre-cgroupns kernels
  selftests: cgroup: Optionally set up v1 environment
  selftests: cgroup: Add support for named v1 hierarchies in test_core
  selftests: cgroup_util: Add helpers for testing named v1 hierarchies
  Documentation: cgroup: add section explaining controller availability
  cgroup: Drop sock_cgroup_classid() dummy implementation
parents af5b2619 646faf36
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -435,6 +435,15 @@ both cgroups.
Controlling Controllers
-----------------------

Availablity
~~~~~~~~~~~

A controller is available in a cgroup when it is supported by the kernel (i.e.,
compiled in, not disabled and not attached to a v1 hierarchy) and listed in the
"cgroup.controllers" file. Availability means the controller's interface files
are exposed in the cgroup’s directory, allowing the distribution of the target
resource to be observed or controlled within that cgroup.

Enabling and Disabling
~~~~~~~~~~~~~~~~~~~~~~

+8 −0
Original line number Diff line number Diff line
@@ -633,6 +633,14 @@
			named mounts. Specifying both "all" and "named" disables
			all v1 hierarchies.

	cgroup_v1_proc=	[KNL] Show also missing controllers in /proc/cgroups
			Format: { "true" | "false" }
			/proc/cgroups lists only v1 controllers by default.
			This compatibility option enables listing also v2
			controllers (whose v1 code is not compiled!), so that
			semi-legacy software can check this file to decide
			about usage of v2 (sic) controllers.

	cgroup_favordynmods= [KNL] Enable or Disable favordynmods.
			Format: { "true" | "false" }
			Defaults to the value of CONFIG_CGROUP_FAVOR_DYNMODS.
+8 −13
Original line number Diff line number Diff line
@@ -375,15 +375,12 @@ struct css_rstat_cpu {
	 * Child cgroups with stat updates on this cpu since the last read
	 * are linked on the parent's ->updated_children through
	 * ->updated_next. updated_children is terminated by its container css.
	 *
	 * In addition to being more compact, singly-linked list pointing to
	 * the css makes it unnecessary for each per-cpu struct to point back
	 * to the associated css.
	 *
	 * Protected by per-cpu css->ss->rstat_ss_cpu_lock.
	 */
	struct cgroup_subsys_state *updated_children;
	struct cgroup_subsys_state *updated_next;	/* NULL if not on the list */

	struct llist_node lnode;		/* lockless list for update */
	struct cgroup_subsys_state *owner;	/* back pointer */
};

/*
@@ -821,7 +818,7 @@ struct cgroup_subsys {
	unsigned int depends_on;

	spinlock_t rstat_ss_lock;
	raw_spinlock_t __percpu *rstat_ss_cpu_lock;
	struct llist_head __percpu *lhead; /* lockless update list head */
};

extern struct percpu_rw_semaphore cgroup_threadgroup_rwsem;
@@ -898,14 +895,12 @@ static inline u16 sock_cgroup_prioidx(const struct sock_cgroup_data *skcd)
#endif
}

#ifdef CONFIG_CGROUP_NET_CLASSID
static inline u32 sock_cgroup_classid(const struct sock_cgroup_data *skcd)
{
#ifdef CONFIG_CGROUP_NET_CLASSID
	return READ_ONCE(skcd->classid);
#else
	return 0;
#endif
}
#endif

static inline void sock_cgroup_set_prioidx(struct sock_cgroup_data *skcd,
					   u16 prioidx)
@@ -915,13 +910,13 @@ static inline void sock_cgroup_set_prioidx(struct sock_cgroup_data *skcd,
#endif
}

#ifdef CONFIG_CGROUP_NET_CLASSID
static inline void sock_cgroup_set_classid(struct sock_cgroup_data *skcd,
					   u32 classid)
{
#ifdef CONFIG_CGROUP_NET_CLASSID
	WRITE_ONCE(skcd->classid, classid);
#endif
}
#endif

#else	/* CONFIG_SOCK_CGROUP_DATA */

+3 −3
Original line number Diff line number Diff line
@@ -83,7 +83,7 @@ static inline void init_llist_head(struct llist_head *list)
 */
static inline void init_llist_node(struct llist_node *node)
{
	node->next = node;
	WRITE_ONCE(node->next, node);
}

/**
@@ -97,7 +97,7 @@ static inline void init_llist_node(struct llist_node *node)
 */
static inline bool llist_on_list(const struct llist_node *node)
{
	return node->next != node;
	return READ_ONCE(node->next) != node;
}

/**
@@ -220,7 +220,7 @@ static inline bool llist_empty(const struct llist_head *head)

static inline struct llist_node *llist_next(struct llist_node *node)
{
	return node->next;
	return READ_ONCE(node->next);
}

/**
+0 −47
Original line number Diff line number Diff line
@@ -257,53 +257,6 @@ DEFINE_EVENT(cgroup_rstat, cgroup_rstat_unlock,
	TP_ARGS(cgrp, cpu, contended)
);

/*
 * Related to per CPU locks:
 * global rstat_base_cpu_lock for base stats
 * cgroup_subsys::rstat_ss_cpu_lock for subsystem stats
 */
DEFINE_EVENT(cgroup_rstat, cgroup_rstat_cpu_lock_contended,

	TP_PROTO(struct cgroup *cgrp, int cpu, bool contended),

	TP_ARGS(cgrp, cpu, contended)
);

DEFINE_EVENT(cgroup_rstat, cgroup_rstat_cpu_lock_contended_fastpath,

	TP_PROTO(struct cgroup *cgrp, int cpu, bool contended),

	TP_ARGS(cgrp, cpu, contended)
);

DEFINE_EVENT(cgroup_rstat, cgroup_rstat_cpu_locked,

	TP_PROTO(struct cgroup *cgrp, int cpu, bool contended),

	TP_ARGS(cgrp, cpu, contended)
);

DEFINE_EVENT(cgroup_rstat, cgroup_rstat_cpu_locked_fastpath,

	TP_PROTO(struct cgroup *cgrp, int cpu, bool contended),

	TP_ARGS(cgrp, cpu, contended)
);

DEFINE_EVENT(cgroup_rstat, cgroup_rstat_cpu_unlock,

	TP_PROTO(struct cgroup *cgrp, int cpu, bool contended),

	TP_ARGS(cgrp, cpu, contended)
);

DEFINE_EVENT(cgroup_rstat, cgroup_rstat_cpu_unlock_fastpath,

	TP_PROTO(struct cgroup *cgrp, int cpu, bool contended),

	TP_ARGS(cgrp, cpu, contended)
);

#endif /* _TRACE_CGROUP_H */

/* This part must be outside protection */
Loading