Re: cgroup sysfs entry

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



于 2013/4/26 3:39, David Shwatrz 写道:
> Hello,
> 
> I have a question about cgroup implementation:
> 
> The /sys/fs/cgroup entry is created in kernel/cgroup.c:
> 
> static struct kobject *cgroup_kobj;
> 
> cgroup_init(void) {
> ...
> cgroup_kobj = kobject_create_and_add("cgroup", fs_kobj);
>   if (!cgroup_kobj) {
>   err = -ENOMEM;
>   goto out;
>   }
> 
> }
> 
> I wondered about this two points:
> 1) why is the /sys/fs/cgroup entry created at all?
> 2) why is this done as a sysfs entry.
> 
> The cgroup_kobj is not used anywhere in this module apart from
> its creation above (and destroying if we later fail with
> register_filesystem() in this same method). I don't see anywhere usage
> of syfs API to create files underneath
> it. In fact, the entries beneath it are created by mkdir of admin or
> systemd code. so what's the point of it being a sysfs entry ? wouldn't
> simply mkdir be ok ? and why under /sys/fs?
> 
> Since cgroups can be mounted by definition on every path, why this is needed?
> 

It's supposed to be the standard place to mount cgroupfs.

commit 676db4af043014e852f67ba0349dae0071bd11f3
Author: Greg KH <gregkh@xxxxxxx>
Date:   Thu Aug 5 13:53:35 2010 -0700

    cgroupfs: create /sys/fs/cgroup to mount cgroupfs on

    We really shouldn't be asking userspace to create new root filesystems.
    So follow along with all of the other in-kernel filesystems, and provide
    a mount point in sysfs.

    For cgroupfs, this should be in /sys/fs/cgroup/  This change provides
    that mount point when the cgroup filesystem is registered in the kernel.

    Acked-by: Paul Menage <menage@xxxxxxxxxx>
    Acked-by: Dhaval Giani <dhaval.giani@xxxxxxxxx>
    Cc: Li Zefan <lizf@xxxxxxxxxxxxxx>
    Cc: Lennart Poettering <lennart@xxxxxxxxxxxxxx>
    Cc: Kay Sievers <kay.sievers@xxxxxxxx>
    Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxx>

--
To unsubscribe from this list: send the line "unsubscribe cgroups" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [Monitors]

  Powered by Linux