Configuring cgroups

1,748 views
Skip to first unread message

DK

unread,
May 28, 2012, 3:26:45 AM5/28/12
to Android Linux Kernel Development
Hi,

I have trouble configuring cgroups, please help! When I issue the
following command I get the error "mount: Device or resource busy"

# mount -t cgroup -ocpu none /dev/cpuctl

These are the configurations options that I have enabled.

CONFIG_GROUP_SCHED=y
CONFIG_FAIR_GROUP_SCHED=y
CONFIG_RT_GROUP_SCHED=y
# CONFIG_USER_SCHED is not set
CONFIG_CGROUP_SCHED=y
CONFIG_CGROUPS=y
CONFIG_CGROUP_DEBUG=y
CONFIG_CGROUP_NS=y
CONFIG_CGROUP_FREEZER=y
CONFIG_CGROUP_DEVICE=y
CONFIG_CGROUP_CPUACCT=y
CONFIG_RESOURCE_COUNTERS=y
CONFIG_CGROUP_MEM_RES_CTLR=y
CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y
CONFIG_MM_OWNER=y

Why is mount saying device busy?

note: I was following the steps in the documentation(sched-design-
CFS.txt)

Regards,
Kanishka

Kanishka Ariyapala

unread,
May 28, 2012, 9:55:27 AM5/28/12
to Android Linux Kernel Development
after some googling came to know that android framework is it self using cgroups. Is it the reason for the device or resource busy error?
Dose it mean that I won't be able to use cgroups?


Ken Chen

unread,
May 29, 2012, 7:17:12 PM5/29/12
to android...@googlegroups.com
Currently, Android dalvik VM leverages cpu cgroup to determine whether to use kernel scheduler policies, /dev/cpuctl is mounted in init.rc by default. You can create a sub-cpu cgroup under /dev/cpuctl, and control the priorization of processes there as long as your process is granted with CAP_SYS_NICE capability or running as root.

Ken
--


-- Ken Chen

Kanishka Ariyapala

unread,
May 30, 2012, 6:56:50 AM5/30/12
to android...@googlegroups.com
Thank you Ken for the reply. I created a cgroup under /dev/cpuctl and added a process to the tasks file. using echo PID > tasks. however it wont get registered there, of course the PID changes every time when the application is re-started. In my case I was testing with browser and the music player. Once you exit and come back the PID is gone.

Since NAME of the app is constant(ex - com.android.browser) I will have to get the PID from the task_struct I guess, and assign the PID. How ever what is the mechanism to make a process change between two cgroups? In a programmatical manner with out issuing echo PID. (can it be hard coded in the source..)

I don't know if this is a stupid Q anyways, normal applications have the user name as something like app_XX is there any way of changing that to a root? through capabilities may be?
CAP_SYS_NICE is defined in capability.h how do I know if it is granted to my process? if not granting it. (in the kernel space as well as inside the app)

Ken Chen

unread,
May 31, 2012, 1:47:26 PM5/31/12
to android...@googlegroups.com
On Wed, May 30, 2012 at 3:56 AM, Kanishka Ariyapala <kanis...@gmail.com> wrote:
Thank you Ken for the reply. I created a cgroup under /dev/cpuctl and added a process to the tasks file. using echo PID > tasks. however it wont get registered there, of course the PID changes every time when the application is re-started. In my case I was testing with browser and the music player. Once you exit and come back the PID is gone.

<Ken>That's expected behavior of cgroup.

Since NAME of the app is constant(ex - com.android.browser) I will have to get the PID from the task_struct I guess, and assign the PID. How ever what is the mechanism to make a process change between two cgroups? In a programmatical manner with out issuing echo PID. (can it be hard coded in the source..)

<Ken> Simply echo PID to new cgroup, it will be moved out from the previous one automatically.
 
I don't know if this is a stupid Q anyways, normal applications have the user name as something like app_XX is there any way of changing that to a root? through capabilities may be?
CAP_SYS_NICE is defined in capability.h how do I know if it is granted to my process? if not granting it. (in the kernel space as well as inside the app)

<Ken> You can not changing app_xx to root, but root can grant CAP_SYS_NICE to app_xx.  



--


-- Ken Chen

San Mehat

unread,
May 31, 2012, 1:52:03 PM5/31/12
to android...@googlegroups.com
Make sure you have http://git.android-x86.org/?p=kernel/common.git;a=commit;h=5038d42d2e60c855cf5b097197d95adaa1269d32

The code-change also should make it somewhat clearer on how the checks end up happening.

Cheers,

-san
San Mehat | Staff Software Engineer | s...@google.com | 415-366-6172

Kanishka Ariyapala

unread,
May 31, 2012, 9:15:28 PM5/31/12
to android...@googlegroups.com
Thank you Ken & San for the replies. I want to make a process move between two cgroups depending on a value from a sensor(GPS) So I need to automate it, with out user issuing echo. How to get around this? kernel module or hard coding it in sched.c or cgroup.c..

DK

unread,
May 31, 2012, 9:18:34 PM5/31/12
to Android Linux Kernel Development


On May 31, 10:47 am, Ken Chen <ken.chen....@gmail.com> wrote:
> On Wed, May 30, 2012 at 3:56 AM, Kanishka Ariyapala
> <kanishka...@gmail.com>wrote:
>
> > Thank you Ken for the reply. I created a cgroup under /dev/cpuctl and
> > added a process to the tasks file. using echo PID > tasks. however it wont
> > get registered there, of course the PID changes every time when the
> > application is re-started. In my case I was testing with browser and the
> > music player. Once you exit and come back the PID is gone.
>
> > <Ken>That's expected behavior of cgroup.
>
> Since NAME of the app is constant(ex - com.android.browser) I will have to> get the PID from the task_struct I guess, and assign the PID. How ever what
> > is the mechanism to make a process change between two cgroups? In a
> > programmatical manner with out issuing echo PID. (can it be hard coded in
> > the source..)
>
> > <Ken> Simply echo PID to new cgroup, it will be moved out from the
>
> previous one automatically.
>
> > I don't know if this is a stupid Q anyways, normal applications have the
> > user name as something like app_XX is there any way of changing that to a
> > root? through capabilities may be?
> > CAP_SYS_NICE is defined in capability.h how do I know if it is granted to
> > my process? if not granting it. (in the kernel space as well as inside the
> > app)
>
> <Ken> You can not changing app_xx to root, but root can grant CAP_SYS_NICE
> to app_xx.
>
> <DK> How can this be done? in the kernel source or in side the application
>
>
>
> > On Tue, May 29, 2012 at 4:17 PM, Ken Chen <ken.chen....@gmail.com> wrote:
>
> >> Currently, Android dalvik VM leverages cpu cgroup to determine whether to
> >> use kernel scheduler policies, /dev/cpuctl is mounted in init.rc by
> >> default. You can create a sub-cpu cgroup under /dev/cpuctl, and control the
> >> priorization of processes there as long as your process is granted with
> >> CAP_SYS_NICE capability or running as root.
>
> >> Ken
>
> >> On Mon, May 28, 2012 at 6:55 AM, Kanishka Ariyapala <
> >> kanishka...@gmail.com> wrote:
>
> >>> after some googling came to know that android framework is it self using
> >>> cgroups. Is it the reason for the device or resource busy error?
> >>> Dose it mean that I won't be able to use cgroups?
>
Reply all
Reply to author
Forward
0 new messages