OpenCores
URL https://opencores.org/ocsvn/or1k_soc_on_altera_embedded_dev_kit/or1k_soc_on_altera_embedded_dev_kit/trunk

Subversion Repositories or1k_soc_on_altera_embedded_dev_kit

[/] [or1k_soc_on_altera_embedded_dev_kit/] [tags/] [linux-2.6/] [linux-2.6.24_orig/] [kernel/] [cgroup_debug.c] - Diff between revs 3 and 5

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 3 Rev 5
/*
/*
 * kernel/ccontainer_debug.c - Example cgroup subsystem that
 * kernel/ccontainer_debug.c - Example cgroup subsystem that
 * exposes debug info
 * exposes debug info
 *
 *
 * Copyright (C) Google Inc, 2007
 * Copyright (C) Google Inc, 2007
 *
 *
 * Developed by Paul Menage (menage@google.com)
 * Developed by Paul Menage (menage@google.com)
 *
 *
 */
 */
 
 
#include <linux/cgroup.h>
#include <linux/cgroup.h>
#include <linux/fs.h>
#include <linux/fs.h>
#include <linux/slab.h>
#include <linux/slab.h>
#include <linux/rcupdate.h>
#include <linux/rcupdate.h>
 
 
#include <asm/atomic.h>
#include <asm/atomic.h>
 
 
static struct cgroup_subsys_state *debug_create(struct cgroup_subsys *ss,
static struct cgroup_subsys_state *debug_create(struct cgroup_subsys *ss,
                                                   struct cgroup *cont)
                                                   struct cgroup *cont)
{
{
        struct cgroup_subsys_state *css = kzalloc(sizeof(*css), GFP_KERNEL);
        struct cgroup_subsys_state *css = kzalloc(sizeof(*css), GFP_KERNEL);
 
 
        if (!css)
        if (!css)
                return ERR_PTR(-ENOMEM);
                return ERR_PTR(-ENOMEM);
 
 
        return css;
        return css;
}
}
 
 
static void debug_destroy(struct cgroup_subsys *ss, struct cgroup *cont)
static void debug_destroy(struct cgroup_subsys *ss, struct cgroup *cont)
{
{
        kfree(cont->subsys[debug_subsys_id]);
        kfree(cont->subsys[debug_subsys_id]);
}
}
 
 
static u64 cgroup_refcount_read(struct cgroup *cont, struct cftype *cft)
static u64 cgroup_refcount_read(struct cgroup *cont, struct cftype *cft)
{
{
        return atomic_read(&cont->count);
        return atomic_read(&cont->count);
}
}
 
 
static u64 taskcount_read(struct cgroup *cont, struct cftype *cft)
static u64 taskcount_read(struct cgroup *cont, struct cftype *cft)
{
{
        u64 count;
        u64 count;
 
 
        cgroup_lock();
        cgroup_lock();
        count = cgroup_task_count(cont);
        count = cgroup_task_count(cont);
        cgroup_unlock();
        cgroup_unlock();
        return count;
        return count;
}
}
 
 
static u64 current_css_set_read(struct cgroup *cont, struct cftype *cft)
static u64 current_css_set_read(struct cgroup *cont, struct cftype *cft)
{
{
        return (u64)(long)current->cgroups;
        return (u64)(long)current->cgroups;
}
}
 
 
static u64 current_css_set_refcount_read(struct cgroup *cont,
static u64 current_css_set_refcount_read(struct cgroup *cont,
                                           struct cftype *cft)
                                           struct cftype *cft)
{
{
        u64 count;
        u64 count;
 
 
        rcu_read_lock();
        rcu_read_lock();
        count = atomic_read(&current->cgroups->ref.refcount);
        count = atomic_read(&current->cgroups->ref.refcount);
        rcu_read_unlock();
        rcu_read_unlock();
        return count;
        return count;
}
}
 
 
static struct cftype files[] =  {
static struct cftype files[] =  {
        {
        {
                .name = "cgroup_refcount",
                .name = "cgroup_refcount",
                .read_uint = cgroup_refcount_read,
                .read_uint = cgroup_refcount_read,
        },
        },
        {
        {
                .name = "taskcount",
                .name = "taskcount",
                .read_uint = taskcount_read,
                .read_uint = taskcount_read,
        },
        },
 
 
        {
        {
                .name = "current_css_set",
                .name = "current_css_set",
                .read_uint = current_css_set_read,
                .read_uint = current_css_set_read,
        },
        },
 
 
        {
        {
                .name = "current_css_set_refcount",
                .name = "current_css_set_refcount",
                .read_uint = current_css_set_refcount_read,
                .read_uint = current_css_set_refcount_read,
        },
        },
};
};
 
 
static int debug_populate(struct cgroup_subsys *ss, struct cgroup *cont)
static int debug_populate(struct cgroup_subsys *ss, struct cgroup *cont)
{
{
        return cgroup_add_files(cont, ss, files, ARRAY_SIZE(files));
        return cgroup_add_files(cont, ss, files, ARRAY_SIZE(files));
}
}
 
 
struct cgroup_subsys debug_subsys = {
struct cgroup_subsys debug_subsys = {
        .name = "debug",
        .name = "debug",
        .create = debug_create,
        .create = debug_create,
        .destroy = debug_destroy,
        .destroy = debug_destroy,
        .populate = debug_populate,
        .populate = debug_populate,
        .subsys_id = debug_subsys_id,
        .subsys_id = debug_subsys_id,
};
};
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.