1 /* SPDX-License-Identifier: GPL-2.0 */
3 * linux/cgroup-defs.h - basic definitions for cgroup
5 * This file provides basic type and interface. Include this file directly
6 * only if necessary to avoid cyclic dependencies.
8 #ifndef _LINUX_CGROUP_DEFS_H
9 #define _LINUX_CGROUP_DEFS_H
11 #include <linux/limits.h>
12 #include <linux/list.h>
13 #include <linux/idr.h>
14 #include <linux/wait.h>
15 #include <linux/mutex.h>
16 #include <linux/rcupdate.h>
17 #include <linux/refcount.h>
18 #include <linux/percpu-refcount.h>
19 #include <linux/percpu-rwsem.h>
20 #include <linux/u64_stats_sync.h>
21 #include <linux/workqueue.h>
22 #include <linux/bpf-cgroup-defs.h>
23 #include <linux/psi_types.h>
30 struct cgroup_taskset;
33 struct kernfs_open_file;
35 struct poll_table_struct;
37 #define MAX_CGROUP_TYPE_NAMELEN 32
38 #define MAX_CGROUP_ROOT_NAMELEN 64
39 #define MAX_CFTYPE_NAME 64
41 /* define the enumeration of all cgroup subsystems */
42 #define SUBSYS(_x) _x ## _cgrp_id,
43 enum cgroup_subsys_id {
44 #include <linux/cgroup_subsys.h>
49 /* bits in struct cgroup_subsys_state flags field */
51 CSS_NO_REF = (1 << 0), /* no reference counting for this css */
52 CSS_ONLINE = (1 << 1), /* between ->css_online() and ->css_offline() */
53 CSS_RELEASED = (1 << 2), /* refcnt reached zero, released */
54 CSS_VISIBLE = (1 << 3), /* css is visible to userland */
55 CSS_DYING = (1 << 4), /* css is dying */
58 /* bits in struct cgroup flags field */
60 /* Control Group requires release notifications to userspace */
61 CGRP_NOTIFY_ON_RELEASE,
63 * Clone the parent's configuration when creating a new child
64 * cpuset cgroup. For historical reasons, this option can be
65 * specified at mount time and thus is implemented here.
67 CGRP_CPUSET_CLONE_CHILDREN,
69 /* Control group has to be frozen. */
72 /* Cgroup is frozen. */
75 /* Control group has to be killed. */
79 /* cgroup_root->flags */
81 CGRP_ROOT_NOPREFIX = (1 << 1), /* mounted subsystems have no named prefix */
82 CGRP_ROOT_XATTR = (1 << 2), /* supports extended attributes */
85 * Consider namespaces as delegation boundaries. If this flag is
86 * set, controller specific interface files in a namespace root
87 * aren't writeable from inside the namespace.
89 CGRP_ROOT_NS_DELEGATE = (1 << 3),
92 * Reduce latencies on dynamic cgroup modifications such as task
93 * migrations and controller on/offs by disabling percpu operation on
94 * cgroup_threadgroup_rwsem. This makes hot path operations such as
95 * forks and exits into the slow path and more expensive.
97 * The static usage pattern of creating a cgroup, enabling controllers,
98 * and then seeding it with CLONE_INTO_CGROUP doesn't require write
99 * locking cgroup_threadgroup_rwsem and thus doesn't benefit from
102 CGRP_ROOT_FAVOR_DYNMODS = (1 << 4),
105 * Enable cpuset controller in v1 cgroup to use v2 behavior.
107 CGRP_ROOT_CPUSET_V2_MODE = (1 << 16),
110 * Enable legacy local memory.events.
112 CGRP_ROOT_MEMORY_LOCAL_EVENTS = (1 << 17),
115 * Enable recursive subtree protection
117 CGRP_ROOT_MEMORY_RECURSIVE_PROT = (1 << 18),
122 CFTYPE_ONLY_ON_ROOT = (1 << 0), /* only create on root cgrp */
123 CFTYPE_NOT_ON_ROOT = (1 << 1), /* don't create on root cgrp */
124 CFTYPE_NS_DELEGATABLE = (1 << 2), /* writeable beyond delegation boundaries */
126 CFTYPE_NO_PREFIX = (1 << 3), /* (DON'T USE FOR NEW FILES) no subsys prefix */
127 CFTYPE_WORLD_WRITABLE = (1 << 4), /* (DON'T USE FOR NEW FILES) S_IWUGO */
128 CFTYPE_DEBUG = (1 << 5), /* create when cgroup_debug */
129 CFTYPE_PRESSURE = (1 << 6), /* only if pressure feature is enabled */
131 /* internal flags, do not use outside cgroup core proper */
132 __CFTYPE_ONLY_ON_DFL = (1 << 16), /* only on default hierarchy */
133 __CFTYPE_NOT_ON_DFL = (1 << 17), /* not on default hierarchy */
134 __CFTYPE_ADDED = (1 << 18),
138 * cgroup_file is the handle for a file instance created in a cgroup which
139 * is used, for example, to generate file changed notifications. This can
140 * be obtained by setting cftype->file_offset.
143 /* do not access any fields from outside cgroup core */
144 struct kernfs_node *kn;
145 unsigned long notified_at;
146 struct timer_list notify_timer;
150 * Per-subsystem/per-cgroup state maintained by the system. This is the
151 * fundamental structural building block that controllers deal with.
153 * Fields marked with "PI:" are public and immutable and may be accessed
154 * directly without synchronization.
156 struct cgroup_subsys_state {
157 /* PI: the cgroup that this css is attached to */
158 struct cgroup *cgroup;
160 /* PI: the cgroup subsystem that this css is attached to */
161 struct cgroup_subsys *ss;
163 /* reference count - access via css_[try]get() and css_put() */
164 struct percpu_ref refcnt;
166 /* siblings list anchored at the parent's ->children */
167 struct list_head sibling;
168 struct list_head children;
170 /* flush target list anchored at cgrp->rstat_css_list */
171 struct list_head rstat_css_node;
174 * PI: Subsys-unique ID. 0 is unused and root is always 1. The
175 * matching css can be looked up using css_from_id().
182 * Monotonically increasing unique serial number which defines a
183 * uniform order among all csses. It's guaranteed that all
184 * ->children lists are in the ascending order of ->serial_nr and
185 * used to allow interrupting and resuming iterations.
190 * Incremented by online self and children. Used to guarantee that
191 * parents are not offlined before their children.
195 /* percpu_ref killing and RCU release */
196 struct work_struct destroy_work;
197 struct rcu_work destroy_rwork;
200 * PI: the parent css. Placed here for cache proximity to following
201 * fields of the containing structure.
203 struct cgroup_subsys_state *parent;
207 * A css_set is a structure holding pointers to a set of
208 * cgroup_subsys_state objects. This saves space in the task struct
209 * object and speeds up fork()/exit(), since a single inc/dec and a
210 * list_add()/del() can bump the reference count on the entire cgroup
215 * Set of subsystem states, one for each subsystem. This array is
216 * immutable after creation apart from the init_css_set during
217 * subsystem registration (at boot time).
219 struct cgroup_subsys_state *subsys[CGROUP_SUBSYS_COUNT];
221 /* reference count */
225 * For a domain cgroup, the following points to self. If threaded,
226 * to the matching cset of the nearest domain ancestor. The
227 * dom_cset provides access to the domain cgroup and its csses to
228 * which domain level resource consumptions should be charged.
230 struct css_set *dom_cset;
232 /* the default cgroup associated with this css_set */
233 struct cgroup *dfl_cgrp;
235 /* internal task count, protected by css_set_lock */
239 * Lists running through all tasks using this cgroup group.
240 * mg_tasks lists tasks which belong to this cset but are in the
241 * process of being migrated out or in. Protected by
242 * css_set_rwsem, but, during migration, once tasks are moved to
243 * mg_tasks, it can be read safely while holding cgroup_mutex.
245 struct list_head tasks;
246 struct list_head mg_tasks;
247 struct list_head dying_tasks;
249 /* all css_task_iters currently walking this cset */
250 struct list_head task_iters;
253 * On the default hierarchy, ->subsys[ssid] may point to a css
254 * attached to an ancestor instead of the cgroup this css_set is
255 * associated with. The following node is anchored at
256 * ->subsys[ssid]->cgroup->e_csets[ssid] and provides a way to
257 * iterate through all css's attached to a given cgroup.
259 struct list_head e_cset_node[CGROUP_SUBSYS_COUNT];
261 /* all threaded csets whose ->dom_cset points to this cset */
262 struct list_head threaded_csets;
263 struct list_head threaded_csets_node;
266 * List running through all cgroup groups in the same hash
267 * slot. Protected by css_set_lock
269 struct hlist_node hlist;
272 * List of cgrp_cset_links pointing at cgroups referenced from this
273 * css_set. Protected by css_set_lock.
275 struct list_head cgrp_links;
278 * List of csets participating in the on-going migration either as
279 * source or destination. Protected by cgroup_mutex.
281 struct list_head mg_src_preload_node;
282 struct list_head mg_dst_preload_node;
283 struct list_head mg_node;
286 * If this cset is acting as the source of migration the following
287 * two fields are set. mg_src_cgrp and mg_dst_cgrp are
288 * respectively the source and destination cgroups of the on-going
289 * migration. mg_dst_cset is the destination cset the target tasks
290 * on this cset should be migrated to. Protected by cgroup_mutex.
292 struct cgroup *mg_src_cgrp;
293 struct cgroup *mg_dst_cgrp;
294 struct css_set *mg_dst_cset;
296 /* dead and being drained, ignore for migration */
299 /* For RCU-protected deletion */
300 struct rcu_head rcu_head;
303 struct cgroup_base_stat {
304 struct task_cputime cputime;
306 #ifdef CONFIG_SCHED_CORE
312 * rstat - cgroup scalable recursive statistics. Accounting is done
313 * per-cpu in cgroup_rstat_cpu which is then lazily propagated up the
314 * hierarchy on reads.
316 * When a stat gets updated, the cgroup_rstat_cpu and its ancestors are
317 * linked into the updated tree. On the following read, propagation only
318 * considers and consumes the updated tree. This makes reading O(the
319 * number of descendants which have been active since last read) instead of
320 * O(the total number of descendants).
322 * This is important because there can be a lot of (draining) cgroups which
323 * aren't active and stat may be read frequently. The combination can
324 * become very expensive. By propagating selectively, increasing reading
325 * frequency decreases the cost of each read.
327 * This struct hosts both the fields which implement the above -
328 * updated_children and updated_next - and the fields which track basic
329 * resource statistics on top of it - bsync, bstat and last_bstat.
331 struct cgroup_rstat_cpu {
333 * ->bsync protects ->bstat. These are the only fields which get
334 * updated in the hot path.
336 struct u64_stats_sync bsync;
337 struct cgroup_base_stat bstat;
340 * Snapshots at the last reading. These are used to calculate the
341 * deltas to propagate to the global counters.
343 struct cgroup_base_stat last_bstat;
346 * Child cgroups with stat updates on this cpu since the last read
347 * are linked on the parent's ->updated_children through
350 * In addition to being more compact, singly-linked list pointing
351 * to the cgroup makes it unnecessary for each per-cpu struct to
352 * point back to the associated cgroup.
354 * Protected by per-cpu cgroup_rstat_cpu_lock.
356 struct cgroup *updated_children; /* terminated by self cgroup */
357 struct cgroup *updated_next; /* NULL iff not on the list */
360 struct cgroup_freezer_state {
361 /* Should the cgroup and its descendants be frozen. */
364 /* Should the cgroup actually be frozen? */
367 /* Fields below are protected by css_set_lock */
369 /* Number of frozen descendant cgroups */
370 int nr_frozen_descendants;
373 * Number of tasks, which are counted as frozen:
374 * frozen, SIGSTOPped, and PTRACEd.
380 /* self css with NULL ->ss, points back to this cgroup */
381 struct cgroup_subsys_state self;
383 unsigned long flags; /* "unsigned long" so bitops work */
386 * The depth this cgroup is at. The root is at depth zero and each
387 * step down the hierarchy increments the level. This along with
388 * ancestors[] can determine whether a given cgroup is a
389 * descendant of another without traversing the hierarchy.
393 /* Maximum allowed descent tree depth */
397 * Keep track of total numbers of visible and dying descent cgroups.
398 * Dying cgroups are cgroups which were deleted by a user,
399 * but are still existing because someone else is holding a reference.
400 * max_descendants is a maximum allowed number of descent cgroups.
402 * nr_descendants and nr_dying_descendants are protected
403 * by cgroup_mutex and css_set_lock. It's fine to read them holding
404 * any of cgroup_mutex and css_set_lock; for writing both locks
408 int nr_dying_descendants;
412 * Each non-empty css_set associated with this cgroup contributes
413 * one to nr_populated_csets. The counter is zero iff this cgroup
414 * doesn't have any tasks.
416 * All children which have non-zero nr_populated_csets and/or
417 * nr_populated_children of their own contribute one to either
418 * nr_populated_domain_children or nr_populated_threaded_children
419 * depending on their type. Each counter is zero iff all cgroups
420 * of the type in the subtree proper don't have any tasks.
422 int nr_populated_csets;
423 int nr_populated_domain_children;
424 int nr_populated_threaded_children;
426 int nr_threaded_children; /* # of live threaded child cgroups */
428 struct kernfs_node *kn; /* cgroup kernfs entry */
429 struct cgroup_file procs_file; /* handle for "cgroup.procs" */
430 struct cgroup_file events_file; /* handle for "cgroup.events" */
433 * The bitmask of subsystems enabled on the child cgroups.
434 * ->subtree_control is the one configured through
435 * "cgroup.subtree_control" while ->subtree_ss_mask is the effective
436 * one which may have more subsystems enabled. Controller knobs
437 * are made available iff it's enabled in ->subtree_control.
441 u16 old_subtree_control;
442 u16 old_subtree_ss_mask;
444 /* Private pointers for each registered subsystem */
445 struct cgroup_subsys_state __rcu *subsys[CGROUP_SUBSYS_COUNT];
447 struct cgroup_root *root;
450 * List of cgrp_cset_links pointing at css_sets with tasks in this
451 * cgroup. Protected by css_set_lock.
453 struct list_head cset_links;
456 * On the default hierarchy, a css_set for a cgroup with some
457 * susbsys disabled will point to css's which are associated with
458 * the closest ancestor which has the subsys enabled. The
459 * following lists all css_sets which point to this cgroup's css
460 * for the given subsystem.
462 struct list_head e_csets[CGROUP_SUBSYS_COUNT];
465 * If !threaded, self. If threaded, it points to the nearest
466 * domain ancestor. Inside a threaded subtree, cgroups are exempt
467 * from process granularity and no-internal-task constraint.
468 * Domain level resource consumptions which aren't tied to a
469 * specific task are charged to the dom_cgrp.
471 struct cgroup *dom_cgrp;
472 struct cgroup *old_dom_cgrp; /* used while enabling threaded */
474 /* per-cpu recursive resource statistics */
475 struct cgroup_rstat_cpu __percpu *rstat_cpu;
476 struct list_head rstat_css_list;
478 /* cgroup basic resource statistics */
479 struct cgroup_base_stat last_bstat;
480 struct cgroup_base_stat bstat;
481 struct prev_cputime prev_cputime; /* for printing out cputime */
484 * list of pidlists, up to two for each namespace (one for procs, one
485 * for tasks); created on demand.
487 struct list_head pidlists;
488 struct mutex pidlist_mutex;
490 /* used to wait for offlining of csses */
491 wait_queue_head_t offline_waitq;
493 /* used to schedule release agent */
494 struct work_struct release_agent_work;
496 /* used to track pressure stalls */
497 struct psi_group *psi;
499 /* used to store eBPF programs */
500 struct cgroup_bpf bpf;
502 /* If there is block congestion on this cgroup. */
503 atomic_t congestion_count;
505 /* Used to store internal freezer state */
506 struct cgroup_freezer_state freezer;
508 /* All ancestors including self */
509 struct cgroup *ancestors[];
513 * A cgroup_root represents the root of a cgroup hierarchy, and may be
514 * associated with a kernfs_root to form an active hierarchy. This is
515 * internal to cgroup core. Don't access directly from controllers.
518 struct kernfs_root *kf_root;
520 /* The bitmask of subsystems attached to this hierarchy */
521 unsigned int subsys_mask;
523 /* Unique id for this hierarchy. */
527 * The root cgroup. The containing cgroup_root will be destroyed on its
528 * release. cgrp->ancestors[0] will be used overflowing into the
529 * following field. cgrp_ancestor_storage must immediately follow.
533 /* must follow cgrp for cgrp->ancestors[0], see above */
534 struct cgroup *cgrp_ancestor_storage;
536 /* Number of cgroups in the hierarchy, used only for /proc/cgroups */
539 /* A list running through the active hierarchies */
540 struct list_head root_list;
542 /* Hierarchy-specific flags */
545 /* The path to use for release notifications. */
546 char release_agent_path[PATH_MAX];
548 /* The name for this hierarchy - may be empty */
549 char name[MAX_CGROUP_ROOT_NAMELEN];
553 * struct cftype: handler definitions for cgroup control files
555 * When reading/writing to a file:
556 * - the cgroup to use is file->f_path.dentry->d_parent->d_fsdata
557 * - the 'cftype' of the file is file->f_path.dentry->d_fsdata
561 * By convention, the name should begin with the name of the
562 * subsystem, followed by a period. Zero length string indicates
563 * end of cftype array.
565 char name[MAX_CFTYPE_NAME];
566 unsigned long private;
569 * The maximum length of string, excluding trailing nul, that can
570 * be passed to write. If < PAGE_SIZE-1, PAGE_SIZE-1 is assumed.
572 size_t max_write_len;
578 * If non-zero, should contain the offset from the start of css to
579 * a struct cgroup_file field. cgroup will record the handle of
580 * the created file into it. The recorded handle can be used as
581 * long as the containing css remains accessible.
583 unsigned int file_offset;
586 * Fields used for internal bookkeeping. Initialized automatically
587 * during registration.
589 struct cgroup_subsys *ss; /* NULL for cgroup core files */
590 struct list_head node; /* anchored at ss->cfts */
591 struct kernfs_ops *kf_ops;
593 int (*open)(struct kernfs_open_file *of);
594 void (*release)(struct kernfs_open_file *of);
597 * read_u64() is a shortcut for the common case of returning a
598 * single integer. Use it in place of read()
600 u64 (*read_u64)(struct cgroup_subsys_state *css, struct cftype *cft);
602 * read_s64() is a signed version of read_u64()
604 s64 (*read_s64)(struct cgroup_subsys_state *css, struct cftype *cft);
606 /* generic seq_file read interface */
607 int (*seq_show)(struct seq_file *sf, void *v);
609 /* optional ops, implement all or none */
610 void *(*seq_start)(struct seq_file *sf, loff_t *ppos);
611 void *(*seq_next)(struct seq_file *sf, void *v, loff_t *ppos);
612 void (*seq_stop)(struct seq_file *sf, void *v);
615 * write_u64() is a shortcut for the common case of accepting
616 * a single integer (as parsed by simple_strtoull) from
617 * userspace. Use in place of write(); return 0 or error.
619 int (*write_u64)(struct cgroup_subsys_state *css, struct cftype *cft,
622 * write_s64() is a signed version of write_u64()
624 int (*write_s64)(struct cgroup_subsys_state *css, struct cftype *cft,
628 * write() is the generic write callback which maps directly to
629 * kernfs write operation and overrides all other operations.
630 * Maximum write size is determined by ->max_write_len. Use
631 * of_css/cft() to access the associated css and cft.
633 ssize_t (*write)(struct kernfs_open_file *of,
634 char *buf, size_t nbytes, loff_t off);
636 __poll_t (*poll)(struct kernfs_open_file *of,
637 struct poll_table_struct *pt);
639 #ifdef CONFIG_DEBUG_LOCK_ALLOC
640 struct lock_class_key lockdep_key;
645 * Control Group subsystem type.
646 * See Documentation/admin-guide/cgroup-v1/cgroups.rst for details
648 struct cgroup_subsys {
649 struct cgroup_subsys_state *(*css_alloc)(struct cgroup_subsys_state *parent_css);
650 int (*css_online)(struct cgroup_subsys_state *css);
651 void (*css_offline)(struct cgroup_subsys_state *css);
652 void (*css_released)(struct cgroup_subsys_state *css);
653 void (*css_free)(struct cgroup_subsys_state *css);
654 void (*css_reset)(struct cgroup_subsys_state *css);
655 void (*css_rstat_flush)(struct cgroup_subsys_state *css, int cpu);
656 int (*css_extra_stat_show)(struct seq_file *seq,
657 struct cgroup_subsys_state *css);
659 int (*can_attach)(struct cgroup_taskset *tset);
660 void (*cancel_attach)(struct cgroup_taskset *tset);
661 void (*attach)(struct cgroup_taskset *tset);
662 void (*post_attach)(void);
663 int (*can_fork)(struct task_struct *task,
664 struct css_set *cset);
665 void (*cancel_fork)(struct task_struct *task, struct css_set *cset);
666 void (*fork)(struct task_struct *task);
667 void (*exit)(struct task_struct *task);
668 void (*release)(struct task_struct *task);
669 void (*bind)(struct cgroup_subsys_state *root_css);
674 * If %true, the controller, on the default hierarchy, doesn't show
675 * up in "cgroup.controllers" or "cgroup.subtree_control", is
676 * implicitly enabled on all cgroups on the default hierarchy, and
677 * bypasses the "no internal process" constraint. This is for
678 * utility type controllers which is transparent to userland.
680 * An implicit controller can be stolen from the default hierarchy
681 * anytime and thus must be okay with offline csses from previous
682 * hierarchies coexisting with csses for the current one.
684 bool implicit_on_dfl:1;
687 * If %true, the controller, supports threaded mode on the default
688 * hierarchy. In a threaded subtree, both process granularity and
689 * no-internal-process constraint are ignored and a threaded
690 * controllers should be able to handle that.
692 * Note that as an implicit controller is automatically enabled on
693 * all cgroups on the default hierarchy, it should also be
694 * threaded. implicit && !threaded is not supported.
698 /* the following two fields are initialized automatically during boot */
702 /* optional, initialized automatically during boot if not set */
703 const char *legacy_name;
705 /* link to parent, protected by cgroup_lock() */
706 struct cgroup_root *root;
708 /* idr for css->id */
712 * List of cftypes. Each entry is the first entry of an array
713 * terminated by zero length name.
715 struct list_head cfts;
718 * Base cftypes which are automatically registered. The two can
719 * point to the same array.
721 struct cftype *dfl_cftypes; /* for the default hierarchy */
722 struct cftype *legacy_cftypes; /* for the legacy hierarchies */
725 * A subsystem may depend on other subsystems. When such subsystem
726 * is enabled on a cgroup, the depended-upon subsystems are enabled
727 * together if available. Subsystems enabled due to dependency are
728 * not visible to userland until explicitly enabled. The following
729 * specifies the mask of subsystems that this one depends on.
731 unsigned int depends_on;
734 extern struct percpu_rw_semaphore cgroup_threadgroup_rwsem;
737 * cgroup_threadgroup_change_begin - threadgroup exclusion for cgroups
740 * Allows cgroup operations to synchronize against threadgroup changes
741 * using a percpu_rw_semaphore.
743 static inline void cgroup_threadgroup_change_begin(struct task_struct *tsk)
745 percpu_down_read(&cgroup_threadgroup_rwsem);
749 * cgroup_threadgroup_change_end - threadgroup exclusion for cgroups
752 * Counterpart of cgroup_threadcgroup_change_begin().
754 static inline void cgroup_threadgroup_change_end(struct task_struct *tsk)
756 percpu_up_read(&cgroup_threadgroup_rwsem);
759 #else /* CONFIG_CGROUPS */
761 #define CGROUP_SUBSYS_COUNT 0
763 static inline void cgroup_threadgroup_change_begin(struct task_struct *tsk)
768 static inline void cgroup_threadgroup_change_end(struct task_struct *tsk) {}
770 #endif /* CONFIG_CGROUPS */
772 #ifdef CONFIG_SOCK_CGROUP_DATA
775 * sock_cgroup_data is embedded at sock->sk_cgrp_data and contains
776 * per-socket cgroup information except for memcg association.
778 * On legacy hierarchies, net_prio and net_cls controllers directly
779 * set attributes on each sock which can then be tested by the network
780 * layer. On the default hierarchy, each sock is associated with the
781 * cgroup it was created in and the networking layer can match the
784 struct sock_cgroup_data {
785 struct cgroup *cgroup; /* v2 */
786 #ifdef CONFIG_CGROUP_NET_CLASSID
787 u32 classid; /* v1 */
789 #ifdef CONFIG_CGROUP_NET_PRIO
790 u16 prioidx; /* v1 */
794 static inline u16 sock_cgroup_prioidx(const struct sock_cgroup_data *skcd)
796 #ifdef CONFIG_CGROUP_NET_PRIO
797 return READ_ONCE(skcd->prioidx);
803 static inline u32 sock_cgroup_classid(const struct sock_cgroup_data *skcd)
805 #ifdef CONFIG_CGROUP_NET_CLASSID
806 return READ_ONCE(skcd->classid);
812 static inline void sock_cgroup_set_prioidx(struct sock_cgroup_data *skcd,
815 #ifdef CONFIG_CGROUP_NET_PRIO
816 WRITE_ONCE(skcd->prioidx, prioidx);
820 static inline void sock_cgroup_set_classid(struct sock_cgroup_data *skcd,
823 #ifdef CONFIG_CGROUP_NET_CLASSID
824 WRITE_ONCE(skcd->classid, classid);
828 #else /* CONFIG_SOCK_CGROUP_DATA */
830 struct sock_cgroup_data {
833 #endif /* CONFIG_SOCK_CGROUP_DATA */
835 #endif /* _LINUX_CGROUP_DEFS_H */