Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

cgroup: split namespace into separate header

We have dedicated headers for all namespace types. Add one for the
cgroup namespace as well. Now it's consistent for all namespace types
and easy to figure out what to include.

Acked-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner <brauner@kernel.org>

+57 -50
+1 -50
include/linux/cgroup.h
··· 27 27 #include <linux/kernel_stat.h> 28 28 29 29 #include <linux/cgroup-defs.h> 30 + #include <linux/cgroup_namespace.h> 30 31 31 32 struct kernel_clone_args; 32 33 ··· 784 783 785 784 #endif /* CONFIG_CGROUP_DATA */ 786 785 787 - struct cgroup_namespace { 788 - struct ns_common ns; 789 - struct user_namespace *user_ns; 790 - struct ucounts *ucounts; 791 - struct css_set *root_cset; 792 - }; 793 - 794 - extern struct cgroup_namespace init_cgroup_ns; 795 - 796 - #ifdef CONFIG_CGROUPS 797 - 798 - static inline struct cgroup_namespace *to_cg_ns(struct ns_common *ns) 799 - { 800 - return container_of(ns, struct cgroup_namespace, ns); 801 - } 802 - 803 - void free_cgroup_ns(struct cgroup_namespace *ns); 804 - 805 - struct cgroup_namespace *copy_cgroup_ns(unsigned long flags, 806 - struct user_namespace *user_ns, 807 - struct cgroup_namespace *old_ns); 808 - 809 - int cgroup_path_ns(struct cgroup *cgrp, char *buf, size_t buflen, 810 - struct cgroup_namespace *ns); 811 - 812 - static inline void get_cgroup_ns(struct cgroup_namespace *ns) 813 - { 814 - refcount_inc(&ns->ns.count); 815 - } 816 - 817 - static inline void put_cgroup_ns(struct cgroup_namespace *ns) 818 - { 819 - if (refcount_dec_and_test(&ns->ns.count)) 820 - free_cgroup_ns(ns); 821 - } 822 - 823 - #else /* !CONFIG_CGROUPS */ 824 - 825 - static inline void free_cgroup_ns(struct cgroup_namespace *ns) { } 826 - static inline struct cgroup_namespace * 827 - copy_cgroup_ns(unsigned long flags, struct user_namespace *user_ns, 828 - struct cgroup_namespace *old_ns) 829 - { 830 - return old_ns; 831 - } 832 - 833 - static inline void get_cgroup_ns(struct cgroup_namespace *ns) { } 834 - static inline void put_cgroup_ns(struct cgroup_namespace *ns) { } 835 - 836 - #endif /* !CONFIG_CGROUPS */ 837 786 838 787 #ifdef CONFIG_CGROUPS 839 788
+56
include/linux/cgroup_namespace.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + #ifndef _LINUX_CGROUP_NAMESPACE_H 3 + #define _LINUX_CGROUP_NAMESPACE_H 4 + 5 + struct cgroup_namespace { 6 + struct ns_common ns; 7 + struct user_namespace *user_ns; 8 + struct ucounts *ucounts; 9 + struct css_set *root_cset; 10 + }; 11 + 12 + extern struct cgroup_namespace init_cgroup_ns; 13 + 14 + #ifdef CONFIG_CGROUPS 15 + 16 + static inline struct cgroup_namespace *to_cg_ns(struct ns_common *ns) 17 + { 18 + return container_of(ns, struct cgroup_namespace, ns); 19 + } 20 + 21 + void free_cgroup_ns(struct cgroup_namespace *ns); 22 + 23 + struct cgroup_namespace *copy_cgroup_ns(unsigned long flags, 24 + struct user_namespace *user_ns, 25 + struct cgroup_namespace *old_ns); 26 + 27 + int cgroup_path_ns(struct cgroup *cgrp, char *buf, size_t buflen, 28 + struct cgroup_namespace *ns); 29 + 30 + static inline void get_cgroup_ns(struct cgroup_namespace *ns) 31 + { 32 + refcount_inc(&ns->ns.count); 33 + } 34 + 35 + static inline void put_cgroup_ns(struct cgroup_namespace *ns) 36 + { 37 + if (refcount_dec_and_test(&ns->ns.count)) 38 + free_cgroup_ns(ns); 39 + } 40 + 41 + #else /* !CONFIG_CGROUPS */ 42 + 43 + static inline void free_cgroup_ns(struct cgroup_namespace *ns) { } 44 + static inline struct cgroup_namespace * 45 + copy_cgroup_ns(unsigned long flags, struct user_namespace *user_ns, 46 + struct cgroup_namespace *old_ns) 47 + { 48 + return old_ns; 49 + } 50 + 51 + static inline void get_cgroup_ns(struct cgroup_namespace *ns) { } 52 + static inline void put_cgroup_ns(struct cgroup_namespace *ns) { } 53 + 54 + #endif /* !CONFIG_CGROUPS */ 55 + 56 + #endif /* _LINUX_CGROUP_NAMESPACE_H */