All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] cgroup, cpuset: add cpuset.remap_cpus
@ 2016-12-22 15:07 ` Wolfgang Bumiller
  0 siblings, 0 replies; 8+ messages in thread
From: Wolfgang Bumiller @ 2016-12-22 15:07 UTC (permalink / raw)
  To: Li Zefan; +Cc: cgroups, linux-kernel, lxc-devel, Serge Hallyn

Changes a cpuset, recursively remapping all its descendants
to the new range.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
---
Currently once a cpuset cgroup has a subdirectory it's impossible to
remove cpu without manually recursing through the cgroup file system.
The problem gets worse if you want to remap cpus of a larger subtree.
This is particularly useful with containers and problematic in that
the recursion might race against the creation of new subdirectories.

I'm not sure why this functionality isn't there yet and thought I'd
give it a try and send an RFC patch. I'm sure there's a reason though,
given how surprisingly small/simple the patch turned out to be and
I'm rarely the first to think of a feature like that ;-)

I hope this is something we could add one way or another, if possible
required changes to the patch are within the scope of my abilities.

 include/linux/cpumask.h | 17 ++++++++++++++++
 kernel/cpuset.c         | 54 +++++++++++++++++++++++++++++++++++++++----------
 2 files changed, 60 insertions(+), 11 deletions(-)

diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index 59915ea..f5487c8 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -514,6 +514,23 @@ static inline void cpumask_copy(struct cpumask *dstp,
 }
 
 /**
+ * cpumask_remap - *dstp = map(old, new)(*srcp)
+ * @dstp: the result
+ * @srcp: the input cpumask
+ * @oldp: the old mask
+ * @newp: the new mask
+ */
+static inline void cpumask_remap(struct cpumask *dstp,
+				 const struct cpumask *srcp,
+				 const struct cpumask *oldp,
+				 const struct cpumask *newp)
+{
+	bitmap_remap(cpumask_bits(dstp), cpumask_bits(srcp),
+		     cpumask_bits(oldp), cpumask_bits(newp),
+		     nr_cpumask_bits);
+}
+
+/**
  * cpumask_any - pick a "random" cpu from *srcp
  * @srcp: the input cpumask
  *
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 02a8ea5..22d0cb2 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -450,7 +450,8 @@ static void free_trial_cpuset(struct cpuset *trial)
  * Return 0 if valid, -errno if not.
  */
 
-static int validate_change(struct cpuset *cur, struct cpuset *trial)
+static int validate_change(struct cpuset *cur, struct cpuset *trial,
+			   bool remap)
 {
 	struct cgroup_subsys_state *css;
 	struct cpuset *c, *par;
@@ -458,11 +459,13 @@ static int validate_change(struct cpuset *cur, struct cpuset *trial)
 
 	rcu_read_lock();
 
-	/* Each of our child cpusets must be a subset of us */
-	ret = -EBUSY;
-	cpuset_for_each_child(c, css, cur)
-		if (!is_cpuset_subset(c, trial))
-			goto out;
+	if (!remap) {
+		/* Each of our child cpusets must be a subset of us */
+		ret = -EBUSY;
+		cpuset_for_each_child(c, css, cur)
+			if (!is_cpuset_subset(c, trial))
+				goto out;
+	}
 
 	/* Remaining checks don't apply to root cpuset */
 	ret = 0;
@@ -925,11 +928,15 @@ static void update_cpumasks_hier(struct cpuset *cs, struct cpumask *new_cpus)
  * @cs: the cpuset to consider
  * @trialcs: trial cpuset
  * @buf: buffer of cpu numbers written to this cpuset
+ * @remap: recursively remap all child nodes
  */
 static int update_cpumask(struct cpuset *cs, struct cpuset *trialcs,
-			  const char *buf)
+			  const char *buf, bool remap)
 {
 	int retval;
+	struct cpuset *cp;
+	struct cgroup_subsys_state *pos_css;
+	struct cpumask tempmask;
 
 	/* top_cpuset.cpus_allowed tracks cpu_online_mask; it's read-only */
 	if (cs == &top_cpuset)
@@ -957,11 +964,25 @@ static int update_cpumask(struct cpuset *cs, struct cpuset *trialcs,
 	if (cpumask_equal(cs->cpus_allowed, trialcs->cpus_allowed))
 		return 0;
 
-	retval = validate_change(cs, trialcs);
+	retval = validate_change(cs, trialcs, remap);
 	if (retval < 0)
 		return retval;
 
 	spin_lock_irq(&callback_lock);
+	if (remap) {
+		rcu_read_lock();
+		cpuset_for_each_descendant_pre(cp, pos_css, cs) {
+			/* skip empty subtrees */
+			if (cpumask_empty(cp->cpus_allowed)) {
+				pos_css = css_rightmost_descendant(pos_css);
+				continue;
+			}
+			cpumask_copy(&tempmask, cp->cpus_allowed);
+			cpumask_remap(cp->cpus_allowed, &tempmask,
+				      cs->cpus_allowed, trialcs->cpus_allowed);
+		}
+		rcu_read_unlock();
+	}
 	cpumask_copy(cs->cpus_allowed, trialcs->cpus_allowed);
 	spin_unlock_irq(&callback_lock);
 
@@ -1217,7 +1238,7 @@ static int update_nodemask(struct cpuset *cs, struct cpuset *trialcs,
 		retval = 0;		/* Too easy - nothing to do */
 		goto done;
 	}
-	retval = validate_change(cs, trialcs);
+	retval = validate_change(cs, trialcs, false);
 	if (retval < 0)
 		goto done;
 
@@ -1304,7 +1325,7 @@ static int update_flag(cpuset_flagbits_t bit, struct cpuset *cs,
 	else
 		clear_bit(bit, &trialcs->flags);
 
-	err = validate_change(cs, trialcs);
+	err = validate_change(cs, trialcs, false);
 	if (err < 0)
 		goto out;
 
@@ -1563,6 +1584,7 @@ static void cpuset_attach(struct cgroup_taskset *tset)
 typedef enum {
 	FILE_MEMORY_MIGRATE,
 	FILE_CPULIST,
+	FILE_REMAP_CPULIST,
 	FILE_MEMLIST,
 	FILE_EFFECTIVE_CPULIST,
 	FILE_EFFECTIVE_MEMLIST,
@@ -1695,7 +1717,10 @@ static ssize_t cpuset_write_resmask(struct kernfs_open_file *of,
 
 	switch (of_cft(of)->private) {
 	case FILE_CPULIST:
-		retval = update_cpumask(cs, trialcs, buf);
+		retval = update_cpumask(cs, trialcs, buf, false);
+		break;
+	case FILE_REMAP_CPULIST:
+		retval = update_cpumask(cs, trialcs, buf, true);
 		break;
 	case FILE_MEMLIST:
 		retval = update_nodemask(cs, trialcs, buf);
@@ -1811,6 +1836,13 @@ static struct cftype files[] = {
 	},
 
 	{
+		.name = "remap_cpus",
+		.write = cpuset_write_resmask,
+		.max_write_len = (100U + 6 * NR_CPUS),
+		.private = FILE_REMAP_CPULIST,
+	},
+
+	{
 		.name = "mems",
 		.seq_show = cpuset_common_seq_show,
 		.write = cpuset_write_resmask,
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [RFC PATCH] cgroup, cpuset: add cpuset.remap_cpus
@ 2016-12-22 15:07 ` Wolfgang Bumiller
  0 siblings, 0 replies; 8+ messages in thread
From: Wolfgang Bumiller @ 2016-12-22 15:07 UTC (permalink / raw)
  To: Li Zefan
  Cc: cgroups-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	lxc-devel-cunTk1MwBs9qMoObBWhMNEqPaTDuhLve2LY78lusg7I

Changes a cpuset, recursively remapping all its descendants
to the new range.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
---
Currently once a cpuset cgroup has a subdirectory it's impossible to
remove cpu without manually recursing through the cgroup file system.
The problem gets worse if you want to remap cpus of a larger subtree.
This is particularly useful with containers and problematic in that
the recursion might race against the creation of new subdirectories.

I'm not sure why this functionality isn't there yet and thought I'd
give it a try and send an RFC patch. I'm sure there's a reason though,
given how surprisingly small/simple the patch turned out to be and
I'm rarely the first to think of a feature like that ;-)

I hope this is something we could add one way or another, if possible
required changes to the patch are within the scope of my abilities.

 include/linux/cpumask.h | 17 ++++++++++++++++
 kernel/cpuset.c         | 54 +++++++++++++++++++++++++++++++++++++++----------
 2 files changed, 60 insertions(+), 11 deletions(-)

diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index 59915ea..f5487c8 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -514,6 +514,23 @@ static inline void cpumask_copy(struct cpumask *dstp,
 }
 
 /**
+ * cpumask_remap - *dstp = map(old, new)(*srcp)
+ * @dstp: the result
+ * @srcp: the input cpumask
+ * @oldp: the old mask
+ * @newp: the new mask
+ */
+static inline void cpumask_remap(struct cpumask *dstp,
+				 const struct cpumask *srcp,
+				 const struct cpumask *oldp,
+				 const struct cpumask *newp)
+{
+	bitmap_remap(cpumask_bits(dstp), cpumask_bits(srcp),
+		     cpumask_bits(oldp), cpumask_bits(newp),
+		     nr_cpumask_bits);
+}
+
+/**
  * cpumask_any - pick a "random" cpu from *srcp
  * @srcp: the input cpumask
  *
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 02a8ea5..22d0cb2 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -450,7 +450,8 @@ static void free_trial_cpuset(struct cpuset *trial)
  * Return 0 if valid, -errno if not.
  */
 
-static int validate_change(struct cpuset *cur, struct cpuset *trial)
+static int validate_change(struct cpuset *cur, struct cpuset *trial,
+			   bool remap)
 {
 	struct cgroup_subsys_state *css;
 	struct cpuset *c, *par;
@@ -458,11 +459,13 @@ static int validate_change(struct cpuset *cur, struct cpuset *trial)
 
 	rcu_read_lock();
 
-	/* Each of our child cpusets must be a subset of us */
-	ret = -EBUSY;
-	cpuset_for_each_child(c, css, cur)
-		if (!is_cpuset_subset(c, trial))
-			goto out;
+	if (!remap) {
+		/* Each of our child cpusets must be a subset of us */
+		ret = -EBUSY;
+		cpuset_for_each_child(c, css, cur)
+			if (!is_cpuset_subset(c, trial))
+				goto out;
+	}
 
 	/* Remaining checks don't apply to root cpuset */
 	ret = 0;
@@ -925,11 +928,15 @@ static void update_cpumasks_hier(struct cpuset *cs, struct cpumask *new_cpus)
  * @cs: the cpuset to consider
  * @trialcs: trial cpuset
  * @buf: buffer of cpu numbers written to this cpuset
+ * @remap: recursively remap all child nodes
  */
 static int update_cpumask(struct cpuset *cs, struct cpuset *trialcs,
-			  const char *buf)
+			  const char *buf, bool remap)
 {
 	int retval;
+	struct cpuset *cp;
+	struct cgroup_subsys_state *pos_css;
+	struct cpumask tempmask;
 
 	/* top_cpuset.cpus_allowed tracks cpu_online_mask; it's read-only */
 	if (cs == &top_cpuset)
@@ -957,11 +964,25 @@ static int update_cpumask(struct cpuset *cs, struct cpuset *trialcs,
 	if (cpumask_equal(cs->cpus_allowed, trialcs->cpus_allowed))
 		return 0;
 
-	retval = validate_change(cs, trialcs);
+	retval = validate_change(cs, trialcs, remap);
 	if (retval < 0)
 		return retval;
 
 	spin_lock_irq(&callback_lock);
+	if (remap) {
+		rcu_read_lock();
+		cpuset_for_each_descendant_pre(cp, pos_css, cs) {
+			/* skip empty subtrees */
+			if (cpumask_empty(cp->cpus_allowed)) {
+				pos_css = css_rightmost_descendant(pos_css);
+				continue;
+			}
+			cpumask_copy(&tempmask, cp->cpus_allowed);
+			cpumask_remap(cp->cpus_allowed, &tempmask,
+				      cs->cpus_allowed, trialcs->cpus_allowed);
+		}
+		rcu_read_unlock();
+	}
 	cpumask_copy(cs->cpus_allowed, trialcs->cpus_allowed);
 	spin_unlock_irq(&callback_lock);
 
@@ -1217,7 +1238,7 @@ static int update_nodemask(struct cpuset *cs, struct cpuset *trialcs,
 		retval = 0;		/* Too easy - nothing to do */
 		goto done;
 	}
-	retval = validate_change(cs, trialcs);
+	retval = validate_change(cs, trialcs, false);
 	if (retval < 0)
 		goto done;
 
@@ -1304,7 +1325,7 @@ static int update_flag(cpuset_flagbits_t bit, struct cpuset *cs,
 	else
 		clear_bit(bit, &trialcs->flags);
 
-	err = validate_change(cs, trialcs);
+	err = validate_change(cs, trialcs, false);
 	if (err < 0)
 		goto out;
 
@@ -1563,6 +1584,7 @@ static void cpuset_attach(struct cgroup_taskset *tset)
 typedef enum {
 	FILE_MEMORY_MIGRATE,
 	FILE_CPULIST,
+	FILE_REMAP_CPULIST,
 	FILE_MEMLIST,
 	FILE_EFFECTIVE_CPULIST,
 	FILE_EFFECTIVE_MEMLIST,
@@ -1695,7 +1717,10 @@ static ssize_t cpuset_write_resmask(struct kernfs_open_file *of,
 
 	switch (of_cft(of)->private) {
 	case FILE_CPULIST:
-		retval = update_cpumask(cs, trialcs, buf);
+		retval = update_cpumask(cs, trialcs, buf, false);
+		break;
+	case FILE_REMAP_CPULIST:
+		retval = update_cpumask(cs, trialcs, buf, true);
 		break;
 	case FILE_MEMLIST:
 		retval = update_nodemask(cs, trialcs, buf);
@@ -1811,6 +1836,13 @@ static struct cftype files[] = {
 	},
 
 	{
+		.name = "remap_cpus",
+		.write = cpuset_write_resmask,
+		.max_write_len = (100U + 6 * NR_CPUS),
+		.private = FILE_REMAP_CPULIST,
+	},
+
+	{
 		.name = "mems",
 		.seq_show = cpuset_common_seq_show,
 		.write = cpuset_write_resmask,
-- 
2.1.4


_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [lxc-devel] [RFC PATCH] cgroup, cpuset: add cpuset.remap_cpus
  2016-12-22 15:07 ` Wolfgang Bumiller
  (?)
@ 2017-08-30 13:27 ` Christian Brauner
  2017-08-31  0:41     ` Tejun Heo
  -1 siblings, 1 reply; 8+ messages in thread
From: Christian Brauner @ 2017-08-30 13:27 UTC (permalink / raw)
  To: Li Zefan, cgroups, linux-kernel, tj, w.bumiller; +Cc: stgraber, serge

Hi,

The following patch was sent a while back by Wolfgang Bumiller to remap cpusets
for a whole subtree in a cgroup v1 cpuset hierarchy. The fact that currently
this is not possible in a non-racy why is a pretty big limitation. This is
especially true for nested containers. Where the nested containers often create
additional subcgroups in the cpuset controller at will. The fact that you can't
*easily* and in a non-racy way tighten the restriction on them after having
created the parent container's cpuset cgroup seems really troubling.

Here's a more concrete use case:
Let's say you started out with handing over all cores to container "c1". You
then create a nested container "c2" inside of "c1". This will - since the advent
of cgroup namespaces - usually mean that "c2"'s cpuset cgroup is a subcgroup in
"c1"'s cpuset cgroup. Usually, "c2"'s cpuset cgroup will also allocate all cores
or at least a subset of them made available to it by "c1"'s cpuset cgroup. When
the host now decides to restrict "c1"'s cpuset by removing some of the cores
that it shares with "c2"'s cpuset subcgroup the host will fail to do this giving
EBUSY. This leaves the container's open to consume the hosts cpu resources. The
only option I see right now is to kill the containers and redo the whole cpuset
layout for the whole subtree. This is usually not something you'd want to do
when critical processes are running. The other option is to implement an
algorithm for a container manager that does the remapping by walking the
relevant cpuset subtree and first removing any cpus from the lowest node that
uses these cpus and then adding all cpus it wants to add walking the tree top
down. But that is - as I said - racy since the nested container's might create
subcgroups thereby preventing he host from successfully performing the
remapping. So an in-kernel approach seems to be a good idea. But maybe I'm just
not seeing the obvious userspace solution to this which is entirely possible. I
just thought I ping about this patch since I didn't see a discussion of this
patch. Maybe it just got lost over Christmas. I take it that Wolfgang is still
willing to pick up that patch but if he doesn't want to or can't I'm happy to
step up. I just couldn't reach him today.

Thanks!
Christian

On Thu, Dec 22, 2016 at 04:07:51PM +0100, Wolfgang Bumiller wrote:
> Changes a cpuset, recursively remapping all its descendants
> to the new range.
> 
> Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
> ---
> Currently once a cpuset cgroup has a subdirectory it's impossible to
> remove cpu without manually recursing through the cgroup file system.
> The problem gets worse if you want to remap cpus of a larger subtree.
> This is particularly useful with containers and problematic in that
> the recursion might race against the creation of new subdirectories.
> 
> I'm not sure why this functionality isn't there yet and thought I'd
> give it a try and send an RFC patch. I'm sure there's a reason though,
> given how surprisingly small/simple the patch turned out to be and
> I'm rarely the first to think of a feature like that ;-)
> 
> I hope this is something we could add one way or another, if possible
> required changes to the patch are within the scope of my abilities.
> 
>  include/linux/cpumask.h | 17 ++++++++++++++++
>  kernel/cpuset.c         | 54 +++++++++++++++++++++++++++++++++++++++----------
>  2 files changed, 60 insertions(+), 11 deletions(-)
> 
> diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
> index 59915ea..f5487c8 100644
> --- a/include/linux/cpumask.h
> +++ b/include/linux/cpumask.h
> @@ -514,6 +514,23 @@ static inline void cpumask_copy(struct cpumask *dstp,
>  }
>  
>  /**
> + * cpumask_remap - *dstp = map(old, new)(*srcp)
> + * @dstp: the result
> + * @srcp: the input cpumask
> + * @oldp: the old mask
> + * @newp: the new mask
> + */
> +static inline void cpumask_remap(struct cpumask *dstp,
> +				 const struct cpumask *srcp,
> +				 const struct cpumask *oldp,
> +				 const struct cpumask *newp)
> +{
> +	bitmap_remap(cpumask_bits(dstp), cpumask_bits(srcp),
> +		     cpumask_bits(oldp), cpumask_bits(newp),
> +		     nr_cpumask_bits);
> +}
> +
> +/**
>   * cpumask_any - pick a "random" cpu from *srcp
>   * @srcp: the input cpumask
>   *
> diff --git a/kernel/cpuset.c b/kernel/cpuset.c
> index 02a8ea5..22d0cb2 100644
> --- a/kernel/cpuset.c
> +++ b/kernel/cpuset.c
> @@ -450,7 +450,8 @@ static void free_trial_cpuset(struct cpuset *trial)
>   * Return 0 if valid, -errno if not.
>   */
>  
> -static int validate_change(struct cpuset *cur, struct cpuset *trial)
> +static int validate_change(struct cpuset *cur, struct cpuset *trial,
> +			   bool remap)
>  {
>  	struct cgroup_subsys_state *css;
>  	struct cpuset *c, *par;
> @@ -458,11 +459,13 @@ static int validate_change(struct cpuset *cur, struct cpuset *trial)
>  
>  	rcu_read_lock();
>  
> -	/* Each of our child cpusets must be a subset of us */
> -	ret = -EBUSY;
> -	cpuset_for_each_child(c, css, cur)
> -		if (!is_cpuset_subset(c, trial))
> -			goto out;
> +	if (!remap) {
> +		/* Each of our child cpusets must be a subset of us */
> +		ret = -EBUSY;
> +		cpuset_for_each_child(c, css, cur)
> +			if (!is_cpuset_subset(c, trial))
> +				goto out;
> +	}
>  
>  	/* Remaining checks don't apply to root cpuset */
>  	ret = 0;
> @@ -925,11 +928,15 @@ static void update_cpumasks_hier(struct cpuset *cs, struct cpumask *new_cpus)
>   * @cs: the cpuset to consider
>   * @trialcs: trial cpuset
>   * @buf: buffer of cpu numbers written to this cpuset
> + * @remap: recursively remap all child nodes
>   */
>  static int update_cpumask(struct cpuset *cs, struct cpuset *trialcs,
> -			  const char *buf)
> +			  const char *buf, bool remap)
>  {
>  	int retval;
> +	struct cpuset *cp;
> +	struct cgroup_subsys_state *pos_css;
> +	struct cpumask tempmask;
>  
>  	/* top_cpuset.cpus_allowed tracks cpu_online_mask; it's read-only */
>  	if (cs == &top_cpuset)
> @@ -957,11 +964,25 @@ static int update_cpumask(struct cpuset *cs, struct cpuset *trialcs,
>  	if (cpumask_equal(cs->cpus_allowed, trialcs->cpus_allowed))
>  		return 0;
>  
> -	retval = validate_change(cs, trialcs);
> +	retval = validate_change(cs, trialcs, remap);
>  	if (retval < 0)
>  		return retval;
>  
>  	spin_lock_irq(&callback_lock);
> +	if (remap) {
> +		rcu_read_lock();
> +		cpuset_for_each_descendant_pre(cp, pos_css, cs) {
> +			/* skip empty subtrees */
> +			if (cpumask_empty(cp->cpus_allowed)) {
> +				pos_css = css_rightmost_descendant(pos_css);
> +				continue;
> +			}
> +			cpumask_copy(&tempmask, cp->cpus_allowed);
> +			cpumask_remap(cp->cpus_allowed, &tempmask,
> +				      cs->cpus_allowed, trialcs->cpus_allowed);
> +		}
> +		rcu_read_unlock();
> +	}
>  	cpumask_copy(cs->cpus_allowed, trialcs->cpus_allowed);
>  	spin_unlock_irq(&callback_lock);
>  
> @@ -1217,7 +1238,7 @@ static int update_nodemask(struct cpuset *cs, struct cpuset *trialcs,
>  		retval = 0;		/* Too easy - nothing to do */
>  		goto done;
>  	}
> -	retval = validate_change(cs, trialcs);
> +	retval = validate_change(cs, trialcs, false);
>  	if (retval < 0)
>  		goto done;
>  
> @@ -1304,7 +1325,7 @@ static int update_flag(cpuset_flagbits_t bit, struct cpuset *cs,
>  	else
>  		clear_bit(bit, &trialcs->flags);
>  
> -	err = validate_change(cs, trialcs);
> +	err = validate_change(cs, trialcs, false);
>  	if (err < 0)
>  		goto out;
>  
> @@ -1563,6 +1584,7 @@ static void cpuset_attach(struct cgroup_taskset *tset)
>  typedef enum {
>  	FILE_MEMORY_MIGRATE,
>  	FILE_CPULIST,
> +	FILE_REMAP_CPULIST,
>  	FILE_MEMLIST,
>  	FILE_EFFECTIVE_CPULIST,
>  	FILE_EFFECTIVE_MEMLIST,
> @@ -1695,7 +1717,10 @@ static ssize_t cpuset_write_resmask(struct kernfs_open_file *of,
>  
>  	switch (of_cft(of)->private) {
>  	case FILE_CPULIST:
> -		retval = update_cpumask(cs, trialcs, buf);
> +		retval = update_cpumask(cs, trialcs, buf, false);
> +		break;
> +	case FILE_REMAP_CPULIST:
> +		retval = update_cpumask(cs, trialcs, buf, true);
>  		break;
>  	case FILE_MEMLIST:
>  		retval = update_nodemask(cs, trialcs, buf);
> @@ -1811,6 +1836,13 @@ static struct cftype files[] = {
>  	},
>  
>  	{
> +		.name = "remap_cpus",
> +		.write = cpuset_write_resmask,
> +		.max_write_len = (100U + 6 * NR_CPUS),
> +		.private = FILE_REMAP_CPULIST,
> +	},
> +
> +	{
>  		.name = "mems",
>  		.seq_show = cpuset_common_seq_show,
>  		.write = cpuset_write_resmask,
> -- 
> 2.1.4
> 
> 
> _______________________________________________
> lxc-devel mailing list
> lxc-devel@lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [lxc-devel] [RFC PATCH] cgroup, cpuset: add cpuset.remap_cpus
@ 2017-08-31  0:41     ` Tejun Heo
  0 siblings, 0 replies; 8+ messages in thread
From: Tejun Heo @ 2017-08-31  0:41 UTC (permalink / raw)
  To: christian.brauner
  Cc: Li Zefan, cgroups, linux-kernel, w.bumiller, stgraber, serge

Hello,

On Wed, Aug 30, 2017 at 03:27:55PM +0200, Christian Brauner wrote:
> The following patch was sent a while back by Wolfgang Bumiller to remap cpusets
> for a whole subtree in a cgroup v1 cpuset hierarchy. The fact that currently
> this is not possible in a non-racy why is a pretty big limitation. This is
> especially true for nested containers. Where the nested containers often create
> additional subcgroups in the cpuset controller at will. The fact that you can't
> *easily* and in a non-racy way tighten the restriction on them after having
> created the parent container's cpuset cgroup seems really troubling.

There was a recent patch to enable v2 behavior on v1, which feels like
the better approach at this point.  I'm not sure about adding a whole
new interface for this.

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [lxc-devel] [RFC PATCH] cgroup, cpuset: add cpuset.remap_cpus
@ 2017-08-31  0:41     ` Tejun Heo
  0 siblings, 0 replies; 8+ messages in thread
From: Tejun Heo @ 2017-08-31  0:41 UTC (permalink / raw)
  To: christian.brauner-GeWIH/nMZzLQT0dZR+AlfA
  Cc: Li Zefan, cgroups-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	w.bumiller-YTcQvvOqK21BDgjK7y7TUQ,
	stgraber-GeWIH/nMZzLQT0dZR+AlfA, serge-A9i7LUbDfNHQT0dZR+AlfA

Hello,

On Wed, Aug 30, 2017 at 03:27:55PM +0200, Christian Brauner wrote:
> The following patch was sent a while back by Wolfgang Bumiller to remap cpusets
> for a whole subtree in a cgroup v1 cpuset hierarchy. The fact that currently
> this is not possible in a non-racy why is a pretty big limitation. This is
> especially true for nested containers. Where the nested containers often create
> additional subcgroups in the cpuset controller at will. The fact that you can't
> *easily* and in a non-racy way tighten the restriction on them after having
> created the parent container's cpuset cgroup seems really troubling.

There was a recent patch to enable v2 behavior on v1, which feels like
the better approach at this point.  I'm not sure about adding a whole
new interface for this.

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [lxc-devel] [RFC PATCH] cgroup, cpuset: add cpuset.remap_cpus
  2017-08-31  0:41     ` Tejun Heo
  (?)
@ 2017-08-31  9:41     ` Christian Brauner
  2017-08-31 13:50         ` Tejun Heo
  -1 siblings, 1 reply; 8+ messages in thread
From: Christian Brauner @ 2017-08-31  9:41 UTC (permalink / raw)
  To: Tejun Heo
  Cc: christian.brauner, Li Zefan, cgroups, linux-kernel, w.bumiller,
	stgraber, serge

On Wed, Aug 30, 2017 at 05:41:31PM -0700, Tejun Heo wrote:
> Hello,
> 
> On Wed, Aug 30, 2017 at 03:27:55PM +0200, Christian Brauner wrote:
> > The following patch was sent a while back by Wolfgang Bumiller to remap cpusets
> > for a whole subtree in a cgroup v1 cpuset hierarchy. The fact that currently
> > this is not possible in a non-racy why is a pretty big limitation. This is
> > especially true for nested containers. Where the nested containers often create
> > additional subcgroups in the cpuset controller at will. The fact that you can't
> > *easily* and in a non-racy way tighten the restriction on them after having
> > created the parent container's cpuset cgroup seems really troubling.
> 
> There was a recent patch to enable v2 behavior on v1, which feels like
> the better approach at this point.  I'm not sure about adding a whole
> new interface for this.

Cool. If it can be done easier and less invasive I'm all for it. Did the patch
already make it into your branch and - only if you happen to have the reference
flying around - could you point me to it.

Thanks!
Christian

> 
> Thanks.
> 
> -- 
> tejun

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [lxc-devel] [RFC PATCH] cgroup, cpuset: add cpuset.remap_cpus
@ 2017-08-31 13:50         ` Tejun Heo
  0 siblings, 0 replies; 8+ messages in thread
From: Tejun Heo @ 2017-08-31 13:50 UTC (permalink / raw)
  To: Christian Brauner
  Cc: christian.brauner, Li Zefan, cgroups, linux-kernel, w.bumiller,
	stgraber, serge

On Thu, Aug 31, 2017 at 11:41:47AM +0200, Christian Brauner wrote:
> On Wed, Aug 30, 2017 at 05:41:31PM -0700, Tejun Heo wrote:
> > Hello,
> > 
> > On Wed, Aug 30, 2017 at 03:27:55PM +0200, Christian Brauner wrote:
> > > The following patch was sent a while back by Wolfgang Bumiller to remap cpusets
> > > for a whole subtree in a cgroup v1 cpuset hierarchy. The fact that currently
> > > this is not possible in a non-racy why is a pretty big limitation. This is
> > > especially true for nested containers. Where the nested containers often create
> > > additional subcgroups in the cpuset controller at will. The fact that you can't
> > > *easily* and in a non-racy way tighten the restriction on them after having
> > > created the parent container's cpuset cgroup seems really troubling.
> > 
> > There was a recent patch to enable v2 behavior on v1, which feels like
> > the better approach at this point.  I'm not sure about adding a whole
> > new interface for this.
> 
> Cool. If it can be done easier and less invasive I'm all for it. Did the patch
> already make it into your branch and - only if you happen to have the reference
> flying around - could you point me to it.

https://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup.git/commit/?h=for-4.14&id=b8d1b8ee93df8ffbabbeadd65d39853cfad6d698

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [lxc-devel] [RFC PATCH] cgroup, cpuset: add cpuset.remap_cpus
@ 2017-08-31 13:50         ` Tejun Heo
  0 siblings, 0 replies; 8+ messages in thread
From: Tejun Heo @ 2017-08-31 13:50 UTC (permalink / raw)
  To: Christian Brauner
  Cc: christian.brauner-GeWIH/nMZzLQT0dZR+AlfA, Li Zefan,
	cgroups-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	w.bumiller-YTcQvvOqK21BDgjK7y7TUQ,
	stgraber-GeWIH/nMZzLQT0dZR+AlfA, serge-A9i7LUbDfNHQT0dZR+AlfA

On Thu, Aug 31, 2017 at 11:41:47AM +0200, Christian Brauner wrote:
> On Wed, Aug 30, 2017 at 05:41:31PM -0700, Tejun Heo wrote:
> > Hello,
> > 
> > On Wed, Aug 30, 2017 at 03:27:55PM +0200, Christian Brauner wrote:
> > > The following patch was sent a while back by Wolfgang Bumiller to remap cpusets
> > > for a whole subtree in a cgroup v1 cpuset hierarchy. The fact that currently
> > > this is not possible in a non-racy why is a pretty big limitation. This is
> > > especially true for nested containers. Where the nested containers often create
> > > additional subcgroups in the cpuset controller at will. The fact that you can't
> > > *easily* and in a non-racy way tighten the restriction on them after having
> > > created the parent container's cpuset cgroup seems really troubling.
> > 
> > There was a recent patch to enable v2 behavior on v1, which feels like
> > the better approach at this point.  I'm not sure about adding a whole
> > new interface for this.
> 
> Cool. If it can be done easier and less invasive I'm all for it. Did the patch
> already make it into your branch and - only if you happen to have the reference
> flying around - could you point me to it.

https://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup.git/commit/?h=for-4.14&id=b8d1b8ee93df8ffbabbeadd65d39853cfad6d698

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-08-31 13:50 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-22 15:07 [RFC PATCH] cgroup, cpuset: add cpuset.remap_cpus Wolfgang Bumiller
2016-12-22 15:07 ` Wolfgang Bumiller
2017-08-30 13:27 ` [lxc-devel] " Christian Brauner
2017-08-31  0:41   ` Tejun Heo
2017-08-31  0:41     ` Tejun Heo
2017-08-31  9:41     ` Christian Brauner
2017-08-31 13:50       ` Tejun Heo
2017-08-31 13:50         ` Tejun Heo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.