login
Login
/
Register
Search
Search this site:
Forums
News
Blogs
Features
Site
Home
»
Mailing list archives
»
linux-kernel
»
2010
»
August
»
6
Re: [PATCH] cgroups: fix API thinko
view
thread
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
[view in full thread]
From: Alex Williamson
Subject:
Re: [PATCH] cgroups: fix API thinko
Date: Friday, August 6, 2010 - 8:09 am
On Fri, 2010-08-06 at 01:59 +0300, Michael S. Tsirkin wrote:
quoted text
> cgroup_attach_task_current_cg API that have upstream is backwards: we > really need an API to attach to the cgroups from another process A to > the current one. > > In our case (vhost), a priveledged user wants to attach it's task to cgroups > from a less priveledged one, the API makes us run it in the other > task's context, and this fails. > > So let's make the API generic and just pass in 'from' and 'to' tasks. > Add an inline wrapper for cgroup_attach_task_current_cg to avoid > breaking bisect. > > Signed-off-by: Michael S. Tsirkin <mst@redhat.com> > --- > > Paul, Li, Sridhar, could you please review the following > patch? > > I only compile-tested it due to travel, but looks > straight-forward to me. > Alex Williamson volunteered to test and report the results. > Sending out now for review as I might be offline for a bit. > Will only try to merge when done, obviously.
This does seem to be working here, so please review and let us know if this looks like a suitable interface. Thanks, Alex
quoted text
> If OK, I would like to merge this through -net tree, > together with the patch fixing vhost-net. > Let me know if that sounds ok. > > Thanks! > > This patch is on top of net-next, it is needed for fix > vhost-net regression in net-next, where a non-priveledged > process can't enable the device anymore: > > when qemu uses vhost, inside the ioctl call it > creates a thread, and tries to add > this thread to the groups of current, and it fails. > But we control the thread, so to solve the problem, > we really should tell it 'connect to out cgroups'. > > What this patch does is add an API for that. > > include/linux/cgroup.h | 11 ++++++++++- > kernel/cgroup.c | 9 +++++---- > 2 files changed, 15 insertions(+), 5 deletions(-) > > diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h > index 43b2072..b38ec60 100644 > --- a/include/linux/cgroup.h > +++ b/include/linux/cgroup.h > @@ -525,7 +525,11 @@ struct task_struct *cgroup_iter_next(struct cgroup *cgrp, > void cgroup_iter_end(struct cgroup *cgrp, struct cgroup_iter *it); > int cgroup_scan_tasks(struct cgroup_scanner *scan); > int cgroup_attach_task(struct cgroup *, struct task_struct *); > -int cgroup_attach_task_current_cg(struct task_struct *); > +int cgroup_attach_task_all(struct task_struct *from, struct task_struct *); > +static inline int cgroup_attach_task_current_cg(struct task_struct *tsk) > +{ > + return cgroup_attach_task_all(current, tsk); > +} > > /* > * CSS ID is ID for cgroup_subsys_state structs under subsys. This only works > @@ -583,6 +587,11 @@ static inline int cgroupstats_build(struct cgroupstats *stats, > } > > /* No cgroups - nothing to do */ > +static inline int cgroup_attach_task_all(struct task_struct *from, > + struct task_struct *t) > +{ > + return 0; > +} > static inline int cgroup_attach_task_current_cg(struct task_struct *t) > { > return 0; > diff --git a/kernel/cgroup.c b/kernel/cgroup.c > index dce8ebc..e6293b8 100644 > --- a/kernel/cgroup.c > +++ b/kernel/cgroup.c > @@ -1606,10 +1606,11 @@ int cgroup_attach_task(struct cgroup *cgrp, struct task_struct *tsk) > } > > /** > - * cgroup_attach_task_current_cg - attach task 'tsk' to current task's cgroup > + * cgroup_attach_task_all - attach task 'tsk' to all cgroups of task 'from' > + * @from: attach to all cgroups of a given task > * @tsk: the task to be attached > */ > -int cgroup_attach_task_current_cg(struct task_struct *tsk) > +int cgroup_attach_task_all(struct task_struct *from, struct task_struct *tsk) > { > struct cgroupfs_root *root; > struct cgroup *cur_cg; > @@ -1617,7 +1618,7 @@ int cgroup_attach_task_current_cg(struct task_struct *tsk) > > cgroup_lock(); > for_each_active_root(root) { > - cur_cg = task_cgroup_from_root(current, root); > + cur_cg = task_cgroup_from_root(from, root); > retval = cgroup_attach_task(cur_cg, tsk); > if (retval) > break; > @@ -1626,7 +1627,7 @@ int cgroup_attach_task_current_cg(struct task_struct *tsk) > > return retval; > } > -EXPORT_SYMBOL_GPL(cgroup_attach_task_current_cg); > +EXPORT_SYMBOL_GPL(cgroup_attach_task_all); > > /* > * Attach task with pid 'pid' to cgroup 'cgrp'. Call with cgroup_mutex
--
unsubscribe notice
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to
majordomo@vger.kernel.org
More majordomo info at
http://vger.kernel.org/majordomo-info.html
Please read the FAQ at
http://www.tux.org/lkml/
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
Messages in current thread:
[PATCH] cgroups: fix API thinko
, Michael S. Tsirkin
, (Thu Aug 5, 3:59 pm)
Re: [PATCH] cgroups: fix API thinko
, Alex Williamson
, (Fri Aug 6, 8:09 am)
Re: [PATCH] cgroups: fix API thinko
, Sridhar Samudrala
, (Fri Aug 6, 9:34 am)
Re: [PATCH] cgroups: fix API thinko
, Alex Williamson
, (Fri Aug 6, 9:38 am)
Re: [PATCH] cgroups: fix API thinko
, Li Zefan
, (Tue Aug 17, 12:19 am)
Re: [PATCH] cgroups: fix API thinko
, Andrew Morton
, (Wed Aug 25, 2:35 pm)
Re: [PATCH] cgroups: fix API thinko
, Paul Menage
, (Wed Aug 25, 7:08 pm)
Re: [PATCH] cgroups: fix API thinko
, Michael S. Tsirkin
, (Tue Aug 31, 7:57 am)
Navigation
Mailing list archives
Recent posts
Popular discussions
linux-kernel
:
Ken Chen
[patch] sched: fix inconsistency when redistribute per-cpu tg->cfs_rq shares.
Ingo Molnar
Re: [PATCH v3] x86: merge the simple bitops and move them to bitops.h
Paul Turner
[tg_shares_up rewrite v4 11/11] sched: update tg->shares after cpu.shares write
Andi Kleen
Re: - romsignature-checksum-cleanup-2.patch removed from -mm tree
Stefano Stabellini
Re: [PATCH 09/22] xen: Find an unbound irq number in reverse order (high to low).
git
:
Junio C Hamano
Re: Teach "git checkout" to use git-show-ref
Christian Jaeger
Re: Problem with Git.pm bidi_pipe methods
Linus Torvalds
[PATCH 1/7] Make unpack_trees_options bit flags actual bitfields
Jon Smirl
stgit: managing signed-off-by lines
Junio C Hamano
GIT 1.4.3-rc2
git-commits-head
:
Linux Kernel Mailing List
MIPS: Bonito64: Make Loongson independent from Bonito64 code.
Linux Kernel Mailing List
iwlwifi: initialize spinlock before use
Linux Kernel Mailing List
i2c-i801: Add Intel Cougar Point device IDs
Linux Kernel Mailing List
drm/i915: Add information on pinning and fencing to the i915 list debug.
Linux Kernel Mailing List
cirrusfb: GD5434 (aka SD64) support fixed
linux-netdev
:
Gerrit Renker
v2 [PATCH 1/4] dccp: Limit feature negotiation to connection setup phase
Richard Cochran
Re: [PATCH v3 3/3] ptp: Added a clock that uses the eTSEC found on the MPC85xx.
Inaky Perez-Gonzalez
[PATCH 40/40] wimax/i2400m: add CREDITS and MAINTAINERS entries
Sathya Perla
[PATCH net-next-2.6] be2net: add multiple RX queue support
Changli Gao
Re: [PATCH 3/3] ifb: move tq from ifb_private
freebsd-current
:
Boris Samorodov
Re: twa + dump = sbwait
韓家標 Bill Hacker
Re: ZFS honesty
Bjoern A. Zeeb
Re: Can not boot 7.0-BETA3 with IPSEC
rmgls
man usb2_core(4)
Sam Leffler
Re: Lots of "ath0: bad series0 hwrate 0x1b" in 8.0-BETA2
Colocation donated by:
Syndicate