Commit b53202e6 authored by Oleg Nesterov's avatar Oleg Nesterov Committed by Tejun Heo

cgroup: kill cgrp_ss_priv[CGROUP_CANFORK_COUNT] and friends

Now that nobody use the "priv" arg passed to can_fork/cancel_fork/fork we can
kill CGROUP_CANFORK_COUNT/SUBSYS_TAG/etc and cgrp_ss_priv[] in copy_process().
Signed-off-by: default avatarOleg Nesterov <oleg@redhat.com>
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
parent 8075b542
...@@ -34,17 +34,12 @@ struct seq_file; ...@@ -34,17 +34,12 @@ struct seq_file;
/* define the enumeration of all cgroup subsystems */ /* define the enumeration of all cgroup subsystems */
#define SUBSYS(_x) _x ## _cgrp_id, #define SUBSYS(_x) _x ## _cgrp_id,
#define SUBSYS_TAG(_t) CGROUP_ ## _t, \
__unused_tag_ ## _t = CGROUP_ ## _t - 1,
enum cgroup_subsys_id { enum cgroup_subsys_id {
#include <linux/cgroup_subsys.h> #include <linux/cgroup_subsys.h>
CGROUP_SUBSYS_COUNT, CGROUP_SUBSYS_COUNT,
}; };
#undef SUBSYS_TAG
#undef SUBSYS #undef SUBSYS
#define CGROUP_CANFORK_COUNT (CGROUP_CANFORK_END - CGROUP_CANFORK_START)
/* bits in struct cgroup_subsys_state flags field */ /* bits in struct cgroup_subsys_state flags field */
enum { enum {
CSS_NO_REF = (1 << 0), /* no reference counting for this css */ CSS_NO_REF = (1 << 0), /* no reference counting for this css */
...@@ -424,9 +419,9 @@ struct cgroup_subsys { ...@@ -424,9 +419,9 @@ struct cgroup_subsys {
int (*can_attach)(struct cgroup_taskset *tset); int (*can_attach)(struct cgroup_taskset *tset);
void (*cancel_attach)(struct cgroup_taskset *tset); void (*cancel_attach)(struct cgroup_taskset *tset);
void (*attach)(struct cgroup_taskset *tset); void (*attach)(struct cgroup_taskset *tset);
int (*can_fork)(struct task_struct *task, void **priv_p); int (*can_fork)(struct task_struct *task);
void (*cancel_fork)(struct task_struct *task, void *priv); void (*cancel_fork)(struct task_struct *task);
void (*fork)(struct task_struct *task, void *priv); void (*fork)(struct task_struct *task);
void (*exit)(struct task_struct *task); void (*exit)(struct task_struct *task);
void (*free)(struct task_struct *task); void (*free)(struct task_struct *task);
void (*bind)(struct cgroup_subsys_state *root_css); void (*bind)(struct cgroup_subsys_state *root_css);
...@@ -512,7 +507,6 @@ static inline void cgroup_threadgroup_change_end(struct task_struct *tsk) ...@@ -512,7 +507,6 @@ static inline void cgroup_threadgroup_change_end(struct task_struct *tsk)
#else /* CONFIG_CGROUPS */ #else /* CONFIG_CGROUPS */
#define CGROUP_CANFORK_COUNT 0
#define CGROUP_SUBSYS_COUNT 0 #define CGROUP_SUBSYS_COUNT 0
static inline void cgroup_threadgroup_change_begin(struct task_struct *tsk) {} static inline void cgroup_threadgroup_change_begin(struct task_struct *tsk) {}
......
...@@ -96,12 +96,9 @@ int proc_cgroup_show(struct seq_file *m, struct pid_namespace *ns, ...@@ -96,12 +96,9 @@ int proc_cgroup_show(struct seq_file *m, struct pid_namespace *ns,
struct pid *pid, struct task_struct *tsk); struct pid *pid, struct task_struct *tsk);
void cgroup_fork(struct task_struct *p); void cgroup_fork(struct task_struct *p);
extern int cgroup_can_fork(struct task_struct *p, extern int cgroup_can_fork(struct task_struct *p);
void *ss_priv[CGROUP_CANFORK_COUNT]); extern void cgroup_cancel_fork(struct task_struct *p);
extern void cgroup_cancel_fork(struct task_struct *p, extern void cgroup_post_fork(struct task_struct *p);
void *ss_priv[CGROUP_CANFORK_COUNT]);
extern void cgroup_post_fork(struct task_struct *p,
void *old_ss_priv[CGROUP_CANFORK_COUNT]);
void cgroup_exit(struct task_struct *p); void cgroup_exit(struct task_struct *p);
void cgroup_free(struct task_struct *p); void cgroup_free(struct task_struct *p);
...@@ -539,13 +536,9 @@ static inline int cgroupstats_build(struct cgroupstats *stats, ...@@ -539,13 +536,9 @@ static inline int cgroupstats_build(struct cgroupstats *stats,
struct dentry *dentry) { return -EINVAL; } struct dentry *dentry) { return -EINVAL; }
static inline void cgroup_fork(struct task_struct *p) {} static inline void cgroup_fork(struct task_struct *p) {}
static inline int cgroup_can_fork(struct task_struct *p, static inline int cgroup_can_fork(struct task_struct *p) { return 0; }
void *ss_priv[CGROUP_CANFORK_COUNT]) static inline void cgroup_cancel_fork(struct task_struct *p) {}
{ return 0; } static inline void cgroup_post_fork(struct task_struct *p) {}
static inline void cgroup_cancel_fork(struct task_struct *p,
void *ss_priv[CGROUP_CANFORK_COUNT]) {}
static inline void cgroup_post_fork(struct task_struct *p,
void *ss_priv[CGROUP_CANFORK_COUNT]) {}
static inline void cgroup_exit(struct task_struct *p) {} static inline void cgroup_exit(struct task_struct *p) {}
static inline void cgroup_free(struct task_struct *p) {} static inline void cgroup_free(struct task_struct *p) {}
......
...@@ -6,14 +6,8 @@ ...@@ -6,14 +6,8 @@
/* /*
* This file *must* be included with SUBSYS() defined. * This file *must* be included with SUBSYS() defined.
* SUBSYS_TAG() is a noop if undefined.
*/ */
#ifndef SUBSYS_TAG
#define __TMP_SUBSYS_TAG
#define SUBSYS_TAG(_x)
#endif
#if IS_ENABLED(CONFIG_CPUSETS) #if IS_ENABLED(CONFIG_CPUSETS)
SUBSYS(cpuset) SUBSYS(cpuset)
#endif #endif
...@@ -58,17 +52,10 @@ SUBSYS(net_prio) ...@@ -58,17 +52,10 @@ SUBSYS(net_prio)
SUBSYS(hugetlb) SUBSYS(hugetlb)
#endif #endif
/*
* Subsystems that implement the can_fork() family of callbacks.
*/
SUBSYS_TAG(CANFORK_START)
#if IS_ENABLED(CONFIG_CGROUP_PIDS) #if IS_ENABLED(CONFIG_CGROUP_PIDS)
SUBSYS(pids) SUBSYS(pids)
#endif #endif
SUBSYS_TAG(CANFORK_END)
/* /*
* The following subsystems are not supported on the default hierarchy. * The following subsystems are not supported on the default hierarchy.
*/ */
...@@ -76,11 +63,6 @@ SUBSYS_TAG(CANFORK_END) ...@@ -76,11 +63,6 @@ SUBSYS_TAG(CANFORK_END)
SUBSYS(debug) SUBSYS(debug)
#endif #endif
#ifdef __TMP_SUBSYS_TAG
#undef __TMP_SUBSYS_TAG
#undef SUBSYS_TAG
#endif
/* /*
* DO NOT ADD ANY SUBSYSTEM WITHOUT EXPLICIT ACKS FROM CGROUP MAINTAINERS. * DO NOT ADD ANY SUBSYSTEM WITHOUT EXPLICIT ACKS FROM CGROUP MAINTAINERS.
*/ */
...@@ -5488,19 +5488,6 @@ static const struct file_operations proc_cgroupstats_operations = { ...@@ -5488,19 +5488,6 @@ static const struct file_operations proc_cgroupstats_operations = {
.release = single_release, .release = single_release,
}; };
static void **subsys_canfork_priv_p(void *ss_priv[CGROUP_CANFORK_COUNT], int i)
{
if (CGROUP_CANFORK_START <= i && i < CGROUP_CANFORK_END)
return &ss_priv[i - CGROUP_CANFORK_START];
return NULL;
}
static void *subsys_canfork_priv(void *ss_priv[CGROUP_CANFORK_COUNT], int i)
{
void **private = subsys_canfork_priv_p(ss_priv, i);
return private ? *private : NULL;
}
/** /**
* cgroup_fork - initialize cgroup related fields during copy_process() * cgroup_fork - initialize cgroup related fields during copy_process()
* @child: pointer to task_struct of forking parent process. * @child: pointer to task_struct of forking parent process.
...@@ -5523,14 +5510,13 @@ void cgroup_fork(struct task_struct *child) ...@@ -5523,14 +5510,13 @@ void cgroup_fork(struct task_struct *child)
* returns an error, the fork aborts with that error code. This allows for * returns an error, the fork aborts with that error code. This allows for
* a cgroup subsystem to conditionally allow or deny new forks. * a cgroup subsystem to conditionally allow or deny new forks.
*/ */
int cgroup_can_fork(struct task_struct *child, int cgroup_can_fork(struct task_struct *child)
void *ss_priv[CGROUP_CANFORK_COUNT])
{ {
struct cgroup_subsys *ss; struct cgroup_subsys *ss;
int i, j, ret; int i, j, ret;
for_each_subsys_which(ss, i, &have_canfork_callback) { for_each_subsys_which(ss, i, &have_canfork_callback) {
ret = ss->can_fork(child, subsys_canfork_priv_p(ss_priv, i)); ret = ss->can_fork(child);
if (ret) if (ret)
goto out_revert; goto out_revert;
} }
...@@ -5542,7 +5528,7 @@ int cgroup_can_fork(struct task_struct *child, ...@@ -5542,7 +5528,7 @@ int cgroup_can_fork(struct task_struct *child,
if (j >= i) if (j >= i)
break; break;
if (ss->cancel_fork) if (ss->cancel_fork)
ss->cancel_fork(child, subsys_canfork_priv(ss_priv, j)); ss->cancel_fork(child);
} }
return ret; return ret;
...@@ -5555,15 +5541,14 @@ int cgroup_can_fork(struct task_struct *child, ...@@ -5555,15 +5541,14 @@ int cgroup_can_fork(struct task_struct *child,
* This calls the cancel_fork() callbacks if a fork failed *after* * This calls the cancel_fork() callbacks if a fork failed *after*
* cgroup_can_fork() succeded. * cgroup_can_fork() succeded.
*/ */
void cgroup_cancel_fork(struct task_struct *child, void cgroup_cancel_fork(struct task_struct *child)
void *ss_priv[CGROUP_CANFORK_COUNT])
{ {
struct cgroup_subsys *ss; struct cgroup_subsys *ss;
int i; int i;
for_each_subsys(ss, i) for_each_subsys(ss, i)
if (ss->cancel_fork) if (ss->cancel_fork)
ss->cancel_fork(child, subsys_canfork_priv(ss_priv, i)); ss->cancel_fork(child);
} }
/** /**
...@@ -5576,8 +5561,7 @@ void cgroup_cancel_fork(struct task_struct *child, ...@@ -5576,8 +5561,7 @@ void cgroup_cancel_fork(struct task_struct *child,
* cgroup_task_iter_start() - to guarantee that the new task ends up on its * cgroup_task_iter_start() - to guarantee that the new task ends up on its
* list. * list.
*/ */
void cgroup_post_fork(struct task_struct *child, void cgroup_post_fork(struct task_struct *child)
void *old_ss_priv[CGROUP_CANFORK_COUNT])
{ {
struct cgroup_subsys *ss; struct cgroup_subsys *ss;
int i; int i;
...@@ -5621,7 +5605,7 @@ void cgroup_post_fork(struct task_struct *child, ...@@ -5621,7 +5605,7 @@ void cgroup_post_fork(struct task_struct *child,
* and addition to css_set. * and addition to css_set.
*/ */
for_each_subsys_which(ss, i, &have_fork_callback) for_each_subsys_which(ss, i, &have_fork_callback)
ss->fork(child, subsys_canfork_priv(old_ss_priv, i)); ss->fork(child);
} }
/** /**
......
...@@ -200,7 +200,7 @@ static void freezer_attach(struct cgroup_taskset *tset) ...@@ -200,7 +200,7 @@ static void freezer_attach(struct cgroup_taskset *tset)
* to do anything as freezer_attach() will put @task into the appropriate * to do anything as freezer_attach() will put @task into the appropriate
* state. * state.
*/ */
static void freezer_fork(struct task_struct *task, void *private) static void freezer_fork(struct task_struct *task)
{ {
struct freezer *freezer; struct freezer *freezer;
......
...@@ -209,7 +209,7 @@ static void pids_cancel_attach(struct cgroup_taskset *tset) ...@@ -209,7 +209,7 @@ static void pids_cancel_attach(struct cgroup_taskset *tset)
* task_css_check(true) in pids_can_fork() and pids_cancel_fork() relies * task_css_check(true) in pids_can_fork() and pids_cancel_fork() relies
* on threadgroup_change_begin() held by the copy_process(). * on threadgroup_change_begin() held by the copy_process().
*/ */
static int pids_can_fork(struct task_struct *task, void **priv_p) static int pids_can_fork(struct task_struct *task)
{ {
struct cgroup_subsys_state *css; struct cgroup_subsys_state *css;
struct pids_cgroup *pids; struct pids_cgroup *pids;
...@@ -219,7 +219,7 @@ static int pids_can_fork(struct task_struct *task, void **priv_p) ...@@ -219,7 +219,7 @@ static int pids_can_fork(struct task_struct *task, void **priv_p)
return pids_try_charge(pids, 1); return pids_try_charge(pids, 1);
} }
static void pids_cancel_fork(struct task_struct *task, void *priv) static void pids_cancel_fork(struct task_struct *task)
{ {
struct cgroup_subsys_state *css; struct cgroup_subsys_state *css;
struct pids_cgroup *pids; struct pids_cgroup *pids;
......
...@@ -1249,7 +1249,6 @@ static struct task_struct *copy_process(unsigned long clone_flags, ...@@ -1249,7 +1249,6 @@ static struct task_struct *copy_process(unsigned long clone_flags,
{ {
int retval; int retval;
struct task_struct *p; struct task_struct *p;
void *cgrp_ss_priv[CGROUP_CANFORK_COUNT] = {};
if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS)) if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
...@@ -1526,7 +1525,7 @@ static struct task_struct *copy_process(unsigned long clone_flags, ...@@ -1526,7 +1525,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
* between here and cgroup_post_fork() if an organisation operation is in * between here and cgroup_post_fork() if an organisation operation is in
* progress. * progress.
*/ */
retval = cgroup_can_fork(p, cgrp_ss_priv); retval = cgroup_can_fork(p);
if (retval) if (retval)
goto bad_fork_free_pid; goto bad_fork_free_pid;
...@@ -1608,7 +1607,7 @@ static struct task_struct *copy_process(unsigned long clone_flags, ...@@ -1608,7 +1607,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
write_unlock_irq(&tasklist_lock); write_unlock_irq(&tasklist_lock);
proc_fork_connector(p); proc_fork_connector(p);
cgroup_post_fork(p, cgrp_ss_priv); cgroup_post_fork(p);
threadgroup_change_end(current); threadgroup_change_end(current);
perf_event_fork(p); perf_event_fork(p);
...@@ -1618,7 +1617,7 @@ static struct task_struct *copy_process(unsigned long clone_flags, ...@@ -1618,7 +1617,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
return p; return p;
bad_fork_cancel_cgroup: bad_fork_cancel_cgroup:
cgroup_cancel_fork(p, cgrp_ss_priv); cgroup_cancel_fork(p);
bad_fork_free_pid: bad_fork_free_pid:
if (pid != &init_struct_pid) if (pid != &init_struct_pid)
free_pid(pid); free_pid(pid);
......
...@@ -8212,7 +8212,7 @@ static void cpu_cgroup_css_offline(struct cgroup_subsys_state *css) ...@@ -8212,7 +8212,7 @@ static void cpu_cgroup_css_offline(struct cgroup_subsys_state *css)
sched_offline_group(tg); sched_offline_group(tg);
} }
static void cpu_cgroup_fork(struct task_struct *task, void *private) static void cpu_cgroup_fork(struct task_struct *task)
{ {
sched_move_task(task); sched_move_task(task);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment