The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/kernel/cgroup_debug.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * kernel/cgroup_debug.c - Example cgroup subsystem that
    3  * exposes debug info
    4  *
    5  * Copyright (C) Google Inc, 2007
    6  *
    7  * Developed by Paul Menage (menage@google.com)
    8  *
    9  */
   10 
   11 #include <linux/cgroup.h>
   12 #include <linux/fs.h>
   13 #include <linux/slab.h>
   14 #include <linux/rcupdate.h>
   15 
   16 #include <asm/atomic.h>
   17 
   18 static struct cgroup_subsys_state *debug_create(struct cgroup_subsys *ss,
   19                                                    struct cgroup *cont)
   20 {
   21         struct cgroup_subsys_state *css = kzalloc(sizeof(*css), GFP_KERNEL);
   22 
   23         if (!css)
   24                 return ERR_PTR(-ENOMEM);
   25 
   26         return css;
   27 }
   28 
   29 static void debug_destroy(struct cgroup_subsys *ss, struct cgroup *cont)
   30 {
   31         kfree(cont->subsys[debug_subsys_id]);
   32 }
   33 
   34 static u64 cgroup_refcount_read(struct cgroup *cont, struct cftype *cft)
   35 {
   36         return atomic_read(&cont->count);
   37 }
   38 
   39 static u64 taskcount_read(struct cgroup *cont, struct cftype *cft)
   40 {
   41         u64 count;
   42 
   43         cgroup_lock();
   44         count = cgroup_task_count(cont);
   45         cgroup_unlock();
   46         return count;
   47 }
   48 
   49 static u64 current_css_set_read(struct cgroup *cont, struct cftype *cft)
   50 {
   51         return (u64)(long)current->cgroups;
   52 }
   53 
   54 static u64 current_css_set_refcount_read(struct cgroup *cont,
   55                                            struct cftype *cft)
   56 {
   57         u64 count;
   58 
   59         rcu_read_lock();
   60         count = atomic_read(&current->cgroups->refcount);
   61         rcu_read_unlock();
   62         return count;
   63 }
   64 
   65 static u64 releasable_read(struct cgroup *cgrp, struct cftype *cft)
   66 {
   67         return test_bit(CGRP_RELEASABLE, &cgrp->flags);
   68 }
   69 
   70 static struct cftype files[] =  {
   71         {
   72                 .name = "cgroup_refcount",
   73                 .read_u64 = cgroup_refcount_read,
   74         },
   75         {
   76                 .name = "taskcount",
   77                 .read_u64 = taskcount_read,
   78         },
   79 
   80         {
   81                 .name = "current_css_set",
   82                 .read_u64 = current_css_set_read,
   83         },
   84 
   85         {
   86                 .name = "current_css_set_refcount",
   87                 .read_u64 = current_css_set_refcount_read,
   88         },
   89 
   90         {
   91                 .name = "releasable",
   92                 .read_u64 = releasable_read,
   93         },
   94 };
   95 
   96 static int debug_populate(struct cgroup_subsys *ss, struct cgroup *cont)
   97 {
   98         return cgroup_add_files(cont, ss, files, ARRAY_SIZE(files));
   99 }
  100 
  101 struct cgroup_subsys debug_subsys = {
  102         .name = "debug",
  103         .create = debug_create,
  104         .destroy = debug_destroy,
  105         .populate = debug_populate,
  106         .subsys_id = debug_subsys_id,
  107 };

Cache object: e147d22f504f8553d3ba0be4b296631c


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.