aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-01-12 22:20:32 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2016-01-12 22:20:32 -0500
commit34a9304a96d6351c2d35dcdc9293258378fc0bd8 (patch)
tree8727c1177b86ca29e107c2e0972bbd956f2dee77 /kernel
parentaee3bfa3307cd0da2126bdc0ea359dabea5ee8f7 (diff)
parent6255c46fa03798cbd8addd98929aff7eef86ae02 (diff)
Merge branch 'for-4.5' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup
Pull cgroup updates from Tejun Heo: - cgroup v2 interface is now official. It's no longer hidden behind a devel flag and can be mounted using the new cgroup2 fs type. Unfortunately, cpu v2 interface hasn't made it yet due to the discussion around in-process hierarchical resource distribution and only memory and io controllers can be used on the v2 interface at the moment. - The existing documentation which has always been a bit of mess is relocated under Documentation/cgroup-v1/. Documentation/cgroup-v2.txt is added as the authoritative documentation for the v2 interface. - Some features are added through for-4.5-ancestor-test branch to enable netfilter xt_cgroup match to use cgroup v2 paths. The actual netfilter changes will be merged through the net tree which pulled in the said branch. - Various cleanups * 'for-4.5' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup: cgroup: rename cgroup documentations cgroup: fix a typo. cgroup: Remove resource_counter.txt in Documentation/cgroup-legacy/00-INDEX. cgroup: demote subsystem init messages to KERN_DEBUG cgroup: Fix uninitialized variable warning cgroup: put controller Kconfig options in meaningful order cgroup: clean up the kernel configuration menu nomenclature cgroup_pids: fix a typo. Subject: cgroup: Fix incomplete dd command in blkio documentation cgroup: kill cgrp_ss_priv[CGROUP_CANFORK_COUNT] and friends cpuset: Replace all instances of time_t with time64_t cgroup: replace unified-hierarchy.txt with a proper cgroup v2 documentation cgroup: rename Documentation/cgroups/ to Documentation/cgroup-legacy/ cgroup: replace __DEVEL__sane_behavior with cgroup2 fs type
Diffstat (limited to 'kernel')
-rw-r--r--kernel/cgroup.c81
-rw-r--r--kernel/cgroup_freezer.c2
-rw-r--r--kernel/cgroup_pids.c6
-rw-r--r--kernel/cpuset.c12
-rw-r--r--kernel/fork.c7
-rw-r--r--kernel/sched/core.c2
6 files changed, 48 insertions, 62 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index fe95970b1f79..c03a640ef6da 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -211,6 +211,7 @@ static unsigned long have_free_callback __read_mostly;
211/* Ditto for the can_fork callback. */ 211/* Ditto for the can_fork callback. */
212static unsigned long have_canfork_callback __read_mostly; 212static unsigned long have_canfork_callback __read_mostly;
213 213
214static struct file_system_type cgroup2_fs_type;
214static struct cftype cgroup_dfl_base_files[]; 215static struct cftype cgroup_dfl_base_files[];
215static struct cftype cgroup_legacy_base_files[]; 216static struct cftype cgroup_legacy_base_files[];
216 217
@@ -1623,10 +1624,6 @@ static int parse_cgroupfs_options(char *data, struct cgroup_sb_opts *opts)
1623 all_ss = true; 1624 all_ss = true;
1624 continue; 1625 continue;
1625 } 1626 }
1626 if (!strcmp(token, "__DEVEL__sane_behavior")) {
1627 opts->flags |= CGRP_ROOT_SANE_BEHAVIOR;
1628 continue;
1629 }
1630 if (!strcmp(token, "noprefix")) { 1627 if (!strcmp(token, "noprefix")) {
1631 opts->flags |= CGRP_ROOT_NOPREFIX; 1628 opts->flags |= CGRP_ROOT_NOPREFIX;
1632 continue; 1629 continue;
@@ -1693,15 +1690,6 @@ static int parse_cgroupfs_options(char *data, struct cgroup_sb_opts *opts)
1693 return -ENOENT; 1690 return -ENOENT;
1694 } 1691 }
1695 1692
1696 if (opts->flags & CGRP_ROOT_SANE_BEHAVIOR) {
1697 pr_warn("sane_behavior: this is still under development and its behaviors will change, proceed at your own risk\n");
1698 if (nr_opts != 1) {
1699 pr_err("sane_behavior: no other mount options allowed\n");
1700 return -EINVAL;
1701 }
1702 return 0;
1703 }
1704
1705 /* 1693 /*
1706 * If the 'all' option was specified select all the subsystems, 1694 * If the 'all' option was specified select all the subsystems,
1707 * otherwise if 'none', 'name=' and a subsystem name options were 1695 * otherwise if 'none', 'name=' and a subsystem name options were
@@ -1981,6 +1969,7 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type,
1981 int flags, const char *unused_dev_name, 1969 int flags, const char *unused_dev_name,
1982 void *data) 1970 void *data)
1983{ 1971{
1972 bool is_v2 = fs_type == &cgroup2_fs_type;
1984 struct super_block *pinned_sb = NULL; 1973 struct super_block *pinned_sb = NULL;
1985 struct cgroup_subsys *ss; 1974 struct cgroup_subsys *ss;
1986 struct cgroup_root *root; 1975 struct cgroup_root *root;
@@ -1997,6 +1986,17 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type,
1997 if (!use_task_css_set_links) 1986 if (!use_task_css_set_links)
1998 cgroup_enable_task_cg_lists(); 1987 cgroup_enable_task_cg_lists();
1999 1988
1989 if (is_v2) {
1990 if (data) {
1991 pr_err("cgroup2: unknown option \"%s\"\n", (char *)data);
1992 return ERR_PTR(-EINVAL);
1993 }
1994 cgrp_dfl_root_visible = true;
1995 root = &cgrp_dfl_root;
1996 cgroup_get(&root->cgrp);
1997 goto out_mount;
1998 }
1999
2000 mutex_lock(&cgroup_mutex); 2000 mutex_lock(&cgroup_mutex);
2001 2001
2002 /* First find the desired set of subsystems */ 2002 /* First find the desired set of subsystems */
@@ -2004,15 +2004,6 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type,
2004 if (ret) 2004 if (ret)
2005 goto out_unlock; 2005 goto out_unlock;
2006 2006
2007 /* look for a matching existing root */
2008 if (opts.flags & CGRP_ROOT_SANE_BEHAVIOR) {
2009 cgrp_dfl_root_visible = true;
2010 root = &cgrp_dfl_root;
2011 cgroup_get(&root->cgrp);
2012 ret = 0;
2013 goto out_unlock;
2014 }
2015
2016 /* 2007 /*
2017 * Destruction of cgroup root is asynchronous, so subsystems may 2008 * Destruction of cgroup root is asynchronous, so subsystems may
2018 * still be dying after the previous unmount. Let's drain the 2009 * still be dying after the previous unmount. Let's drain the
@@ -2123,9 +2114,10 @@ out_free:
2123 2114
2124 if (ret) 2115 if (ret)
2125 return ERR_PTR(ret); 2116 return ERR_PTR(ret);
2126 2117out_mount:
2127 dentry = kernfs_mount(fs_type, flags, root->kf_root, 2118 dentry = kernfs_mount(fs_type, flags, root->kf_root,
2128 CGROUP_SUPER_MAGIC, &new_sb); 2119 is_v2 ? CGROUP2_SUPER_MAGIC : CGROUP_SUPER_MAGIC,
2120 &new_sb);
2129 if (IS_ERR(dentry) || !new_sb) 2121 if (IS_ERR(dentry) || !new_sb)
2130 cgroup_put(&root->cgrp); 2122 cgroup_put(&root->cgrp);
2131 2123
@@ -2168,6 +2160,12 @@ static struct file_system_type cgroup_fs_type = {
2168 .kill_sb = cgroup_kill_sb, 2160 .kill_sb = cgroup_kill_sb,
2169}; 2161};
2170 2162
2163static struct file_system_type cgroup2_fs_type = {
2164 .name = "cgroup2",
2165 .mount = cgroup_mount,
2166 .kill_sb = cgroup_kill_sb,
2167};
2168
2171/** 2169/**
2172 * task_cgroup_path - cgroup path of a task in the first cgroup hierarchy 2170 * task_cgroup_path - cgroup path of a task in the first cgroup hierarchy
2173 * @task: target task 2171 * @task: target task
@@ -4039,7 +4037,7 @@ int cgroup_transfer_tasks(struct cgroup *to, struct cgroup *from)
4039 goto out_err; 4037 goto out_err;
4040 4038
4041 /* 4039 /*
4042 * Migrate tasks one-by-one until @form is empty. This fails iff 4040 * Migrate tasks one-by-one until @from is empty. This fails iff
4043 * ->can_attach() fails. 4041 * ->can_attach() fails.
4044 */ 4042 */
4045 do { 4043 do {
@@ -5171,7 +5169,7 @@ static void __init cgroup_init_subsys(struct cgroup_subsys *ss, bool early)
5171{ 5169{
5172 struct cgroup_subsys_state *css; 5170 struct cgroup_subsys_state *css;
5173 5171
5174 printk(KERN_INFO "Initializing cgroup subsys %s\n", ss->name); 5172 pr_debug("Initializing cgroup subsys %s\n", ss->name);
5175 5173
5176 mutex_lock(&cgroup_mutex); 5174 mutex_lock(&cgroup_mutex);
5177 5175
@@ -5329,6 +5327,7 @@ int __init cgroup_init(void)
5329 5327
5330 WARN_ON(sysfs_create_mount_point(fs_kobj, "cgroup")); 5328 WARN_ON(sysfs_create_mount_point(fs_kobj, "cgroup"));
5331 WARN_ON(register_filesystem(&cgroup_fs_type)); 5329 WARN_ON(register_filesystem(&cgroup_fs_type));
5330 WARN_ON(register_filesystem(&cgroup2_fs_type));
5332 WARN_ON(!proc_create("cgroups", 0, NULL, &proc_cgroupstats_operations)); 5331 WARN_ON(!proc_create("cgroups", 0, NULL, &proc_cgroupstats_operations));
5333 5332
5334 return 0; 5333 return 0;
@@ -5472,19 +5471,6 @@ static const struct file_operations proc_cgroupstats_operations = {
5472 .release = single_release, 5471 .release = single_release,
5473}; 5472};
5474 5473
5475static void **subsys_canfork_priv_p(void *ss_priv[CGROUP_CANFORK_COUNT], int i)
5476{
5477 if (CGROUP_CANFORK_START <= i && i < CGROUP_CANFORK_END)
5478 return &ss_priv[i - CGROUP_CANFORK_START];
5479 return NULL;
5480}
5481
5482static void *subsys_canfork_priv(void *ss_priv[CGROUP_CANFORK_COUNT], int i)
5483{
5484 void **private = subsys_canfork_priv_p(ss_priv, i);
5485 return private ? *private : NULL;
5486}
5487
5488/** 5474/**
5489 * cgroup_fork - initialize cgroup related fields during copy_process() 5475 * cgroup_fork - initialize cgroup related fields during copy_process()
5490 * @child: pointer to task_struct of forking parent process. 5476 * @child: pointer to task_struct of forking parent process.
@@ -5507,14 +5493,13 @@ void cgroup_fork(struct task_struct *child)
5507 * returns an error, the fork aborts with that error code. This allows for 5493 * returns an error, the fork aborts with that error code. This allows for
5508 * a cgroup subsystem to conditionally allow or deny new forks. 5494 * a cgroup subsystem to conditionally allow or deny new forks.
5509 */ 5495 */
5510int cgroup_can_fork(struct task_struct *child, 5496int cgroup_can_fork(struct task_struct *child)
5511 void *ss_priv[CGROUP_CANFORK_COUNT])
5512{ 5497{
5513 struct cgroup_subsys *ss; 5498 struct cgroup_subsys *ss;
5514 int i, j, ret; 5499 int i, j, ret;
5515 5500
5516 for_each_subsys_which(ss, i, &have_canfork_callback) { 5501 for_each_subsys_which(ss, i, &have_canfork_callback) {
5517 ret = ss->can_fork(child, subsys_canfork_priv_p(ss_priv, i)); 5502 ret = ss->can_fork(child);
5518 if (ret) 5503 if (ret)
5519 goto out_revert; 5504 goto out_revert;
5520 } 5505 }
@@ -5526,7 +5511,7 @@ out_revert:
5526 if (j >= i) 5511 if (j >= i)
5527 break; 5512 break;
5528 if (ss->cancel_fork) 5513 if (ss->cancel_fork)
5529 ss->cancel_fork(child, subsys_canfork_priv(ss_priv, j)); 5514 ss->cancel_fork(child);
5530 } 5515 }
5531 5516
5532 return ret; 5517 return ret;
@@ -5539,15 +5524,14 @@ out_revert:
5539 * This calls the cancel_fork() callbacks if a fork failed *after* 5524 * This calls the cancel_fork() callbacks if a fork failed *after*
5540 * cgroup_can_fork() succeded. 5525 * cgroup_can_fork() succeded.
5541 */ 5526 */
5542void cgroup_cancel_fork(struct task_struct *child, 5527void cgroup_cancel_fork(struct task_struct *child)
5543 void *ss_priv[CGROUP_CANFORK_COUNT])
5544{ 5528{
5545 struct cgroup_subsys *ss; 5529 struct cgroup_subsys *ss;
5546 int i; 5530 int i;
5547 5531
5548 for_each_subsys(ss, i) 5532 for_each_subsys(ss, i)
5549 if (ss->cancel_fork) 5533 if (ss->cancel_fork)
5550 ss->cancel_fork(child, subsys_canfork_priv(ss_priv, i)); 5534 ss->cancel_fork(child);
5551} 5535}
5552 5536
5553/** 5537/**
@@ -5560,8 +5544,7 @@ void cgroup_cancel_fork(struct task_struct *child,
5560 * cgroup_task_iter_start() - to guarantee that the new task ends up on its 5544 * cgroup_task_iter_start() - to guarantee that the new task ends up on its
5561 * list. 5545 * list.
5562 */ 5546 */
5563void cgroup_post_fork(struct task_struct *child, 5547void cgroup_post_fork(struct task_struct *child)
5564 void *old_ss_priv[CGROUP_CANFORK_COUNT])
5565{ 5548{
5566 struct cgroup_subsys *ss; 5549 struct cgroup_subsys *ss;
5567 int i; 5550 int i;
@@ -5605,7 +5588,7 @@ void cgroup_post_fork(struct task_struct *child,
5605 * and addition to css_set. 5588 * and addition to css_set.
5606 */ 5589 */
5607 for_each_subsys_which(ss, i, &have_fork_callback) 5590 for_each_subsys_which(ss, i, &have_fork_callback)
5608 ss->fork(child, subsys_canfork_priv(old_ss_priv, i)); 5591 ss->fork(child);
5609} 5592}
5610 5593
5611/** 5594/**
diff --git a/kernel/cgroup_freezer.c b/kernel/cgroup_freezer.c
index 2d3df82c54f2..1b72d56edce5 100644
--- a/kernel/cgroup_freezer.c
+++ b/kernel/cgroup_freezer.c
@@ -200,7 +200,7 @@ static void freezer_attach(struct cgroup_taskset *tset)
200 * to do anything as freezer_attach() will put @task into the appropriate 200 * to do anything as freezer_attach() will put @task into the appropriate
201 * state. 201 * state.
202 */ 202 */
203static void freezer_fork(struct task_struct *task, void *private) 203static void freezer_fork(struct task_struct *task)
204{ 204{
205 struct freezer *freezer; 205 struct freezer *freezer;
206 206
diff --git a/kernel/cgroup_pids.c b/kernel/cgroup_pids.c
index b50d5a167fda..303097b37429 100644
--- a/kernel/cgroup_pids.c
+++ b/kernel/cgroup_pids.c
@@ -134,7 +134,7 @@ static void pids_charge(struct pids_cgroup *pids, int num)
134 * 134 *
135 * This function follows the set limit. It will fail if the charge would cause 135 * This function follows the set limit. It will fail if the charge would cause
136 * the new value to exceed the hierarchical limit. Returns 0 if the charge 136 * the new value to exceed the hierarchical limit. Returns 0 if the charge
137 * succeded, otherwise -EAGAIN. 137 * succeeded, otherwise -EAGAIN.
138 */ 138 */
139static int pids_try_charge(struct pids_cgroup *pids, int num) 139static int pids_try_charge(struct pids_cgroup *pids, int num)
140{ 140{
@@ -209,7 +209,7 @@ static void pids_cancel_attach(struct cgroup_taskset *tset)
209 * task_css_check(true) in pids_can_fork() and pids_cancel_fork() relies 209 * task_css_check(true) in pids_can_fork() and pids_cancel_fork() relies
210 * on threadgroup_change_begin() held by the copy_process(). 210 * on threadgroup_change_begin() held by the copy_process().
211 */ 211 */
212static int pids_can_fork(struct task_struct *task, void **priv_p) 212static int pids_can_fork(struct task_struct *task)
213{ 213{
214 struct cgroup_subsys_state *css; 214 struct cgroup_subsys_state *css;
215 struct pids_cgroup *pids; 215 struct pids_cgroup *pids;
@@ -219,7 +219,7 @@ static int pids_can_fork(struct task_struct *task, void **priv_p)
219 return pids_try_charge(pids, 1); 219 return pids_try_charge(pids, 1);
220} 220}
221 221
222static void pids_cancel_fork(struct task_struct *task, void *priv) 222static void pids_cancel_fork(struct task_struct *task)
223{ 223{
224 struct cgroup_subsys_state *css; 224 struct cgroup_subsys_state *css;
225 struct pids_cgroup *pids; 225 struct pids_cgroup *pids;
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 02a8ea5c9963..3e945fcd8179 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -51,6 +51,7 @@
51#include <linux/stat.h> 51#include <linux/stat.h>
52#include <linux/string.h> 52#include <linux/string.h>
53#include <linux/time.h> 53#include <linux/time.h>
54#include <linux/time64.h>
54#include <linux/backing-dev.h> 55#include <linux/backing-dev.h>
55#include <linux/sort.h> 56#include <linux/sort.h>
56 57
@@ -68,7 +69,7 @@ struct static_key cpusets_enabled_key __read_mostly = STATIC_KEY_INIT_FALSE;
68struct fmeter { 69struct fmeter {
69 int cnt; /* unprocessed events count */ 70 int cnt; /* unprocessed events count */
70 int val; /* most recent output value */ 71 int val; /* most recent output value */
71 time_t time; /* clock (secs) when val computed */ 72 time64_t time; /* clock (secs) when val computed */
72 spinlock_t lock; /* guards read or write of above */ 73 spinlock_t lock; /* guards read or write of above */
73}; 74};
74 75
@@ -1374,7 +1375,7 @@ out:
1374 */ 1375 */
1375 1376
1376#define FM_COEF 933 /* coefficient for half-life of 10 secs */ 1377#define FM_COEF 933 /* coefficient for half-life of 10 secs */
1377#define FM_MAXTICKS ((time_t)99) /* useless computing more ticks than this */ 1378#define FM_MAXTICKS ((u32)99) /* useless computing more ticks than this */
1378#define FM_MAXCNT 1000000 /* limit cnt to avoid overflow */ 1379#define FM_MAXCNT 1000000 /* limit cnt to avoid overflow */
1379#define FM_SCALE 1000 /* faux fixed point scale */ 1380#define FM_SCALE 1000 /* faux fixed point scale */
1380 1381
@@ -1390,8 +1391,11 @@ static void fmeter_init(struct fmeter *fmp)
1390/* Internal meter update - process cnt events and update value */ 1391/* Internal meter update - process cnt events and update value */
1391static void fmeter_update(struct fmeter *fmp) 1392static void fmeter_update(struct fmeter *fmp)
1392{ 1393{
1393 time_t now = get_seconds(); 1394 time64_t now;
1394 time_t ticks = now - fmp->time; 1395 u32 ticks;
1396
1397 now = ktime_get_seconds();
1398 ticks = now - fmp->time;
1395 1399
1396 if (ticks == 0) 1400 if (ticks == 0)
1397 return; 1401 return;
diff --git a/kernel/fork.c b/kernel/fork.c
index 291b08cc817b..6774e6b2e96d 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1250,7 +1250,6 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1250{ 1250{
1251 int retval; 1251 int retval;
1252 struct task_struct *p; 1252 struct task_struct *p;
1253 void *cgrp_ss_priv[CGROUP_CANFORK_COUNT] = {};
1254 1253
1255 if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS)) 1254 if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
1256 return ERR_PTR(-EINVAL); 1255 return ERR_PTR(-EINVAL);
@@ -1527,7 +1526,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1527 * between here and cgroup_post_fork() if an organisation operation is in 1526 * between here and cgroup_post_fork() if an organisation operation is in
1528 * progress. 1527 * progress.
1529 */ 1528 */
1530 retval = cgroup_can_fork(p, cgrp_ss_priv); 1529 retval = cgroup_can_fork(p);
1531 if (retval) 1530 if (retval)
1532 goto bad_fork_free_pid; 1531 goto bad_fork_free_pid;
1533 1532
@@ -1609,7 +1608,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1609 write_unlock_irq(&tasklist_lock); 1608 write_unlock_irq(&tasklist_lock);
1610 1609
1611 proc_fork_connector(p); 1610 proc_fork_connector(p);
1612 cgroup_post_fork(p, cgrp_ss_priv); 1611 cgroup_post_fork(p);
1613 threadgroup_change_end(current); 1612 threadgroup_change_end(current);
1614 perf_event_fork(p); 1613 perf_event_fork(p);
1615 1614
@@ -1619,7 +1618,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1619 return p; 1618 return p;
1620 1619
1621bad_fork_cancel_cgroup: 1620bad_fork_cancel_cgroup:
1622 cgroup_cancel_fork(p, cgrp_ss_priv); 1621 cgroup_cancel_fork(p);
1623bad_fork_free_pid: 1622bad_fork_free_pid:
1624 if (pid != &init_struct_pid) 1623 if (pid != &init_struct_pid)
1625 free_pid(pid); 1624 free_pid(pid);
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 77d97a6fc715..44253adb3c36 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -8342,7 +8342,7 @@ static void cpu_cgroup_css_offline(struct cgroup_subsys_state *css)
8342 sched_offline_group(tg); 8342 sched_offline_group(tg);
8343} 8343}
8344 8344
8345static void cpu_cgroup_fork(struct task_struct *task, void *private) 8345static void cpu_cgroup_fork(struct task_struct *task)
8346{ 8346{
8347 sched_move_task(task); 8347 sched_move_task(task);
8348} 8348}