提交 86ae53e1 编写于 作者: G Glauber Costa 提交者: Linus Torvalds

memcg: change defines to an enum

This is just a cleanup patch for clarity of expression.  In earlier
submissions, people asked it to be in a separate patch, so here it is.
Signed-off-by: NGlauber Costa <glommer@parallels.com>
Acked-by: NKamezawa Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Acked-by: NMichal Hocko <mhocko@suse.cz>
Acked-by: NJohannes Weiner <hannes@cmpxchg.org>
Acked-by: NDavid Rientjes <rientjes@google.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Christoph Lameter <cl@linux.com>
Cc: Frederic Weisbecker <fweisbec@redhat.com>
Cc: Greg Thelen <gthelen@google.com>
Cc: JoonSoo Kim <js1304@gmail.com>
Cc: Mel Gorman <mel@csn.ul.ie>
Cc: Pekka Enberg <penberg@cs.helsinki.fi>
Cc: Rik van Riel <riel@redhat.com>
Cc: Suleiman Souhlal <suleiman@google.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 4c9c5359
...@@ -388,9 +388,12 @@ enum charge_type { ...@@ -388,9 +388,12 @@ enum charge_type {
}; };
/* for encoding cft->private value on file */ /* for encoding cft->private value on file */
#define _MEM (0) enum res_type {
#define _MEMSWAP (1) _MEM,
#define _OOM_TYPE (2) _MEMSWAP,
_OOM_TYPE,
};
#define MEMFILE_PRIVATE(x, val) ((x) << 16 | (val)) #define MEMFILE_PRIVATE(x, val) ((x) << 16 | (val))
#define MEMFILE_TYPE(val) ((val) >> 16 & 0xffff) #define MEMFILE_TYPE(val) ((val) >> 16 & 0xffff)
#define MEMFILE_ATTR(val) ((val) & 0xffff) #define MEMFILE_ATTR(val) ((val) & 0xffff)
...@@ -3952,7 +3955,8 @@ static ssize_t mem_cgroup_read(struct cgroup *cont, struct cftype *cft, ...@@ -3952,7 +3955,8 @@ static ssize_t mem_cgroup_read(struct cgroup *cont, struct cftype *cft,
struct mem_cgroup *memcg = mem_cgroup_from_cont(cont); struct mem_cgroup *memcg = mem_cgroup_from_cont(cont);
char str[64]; char str[64];
u64 val; u64 val;
int type, name, len; int name, len;
enum res_type type;
type = MEMFILE_TYPE(cft->private); type = MEMFILE_TYPE(cft->private);
name = MEMFILE_ATTR(cft->private); name = MEMFILE_ATTR(cft->private);
...@@ -3988,7 +3992,8 @@ static int mem_cgroup_write(struct cgroup *cont, struct cftype *cft, ...@@ -3988,7 +3992,8 @@ static int mem_cgroup_write(struct cgroup *cont, struct cftype *cft,
const char *buffer) const char *buffer)
{ {
struct mem_cgroup *memcg = mem_cgroup_from_cont(cont); struct mem_cgroup *memcg = mem_cgroup_from_cont(cont);
int type, name; enum res_type type;
int name;
unsigned long long val; unsigned long long val;
int ret; int ret;
...@@ -4064,7 +4069,8 @@ static void memcg_get_hierarchical_limit(struct mem_cgroup *memcg, ...@@ -4064,7 +4069,8 @@ static void memcg_get_hierarchical_limit(struct mem_cgroup *memcg,
static int mem_cgroup_reset(struct cgroup *cont, unsigned int event) static int mem_cgroup_reset(struct cgroup *cont, unsigned int event)
{ {
struct mem_cgroup *memcg = mem_cgroup_from_cont(cont); struct mem_cgroup *memcg = mem_cgroup_from_cont(cont);
int type, name; int name;
enum res_type type;
type = MEMFILE_TYPE(event); type = MEMFILE_TYPE(event);
name = MEMFILE_ATTR(event); name = MEMFILE_ATTR(event);
...@@ -4400,7 +4406,7 @@ static int mem_cgroup_usage_register_event(struct cgroup *cgrp, ...@@ -4400,7 +4406,7 @@ static int mem_cgroup_usage_register_event(struct cgroup *cgrp,
struct mem_cgroup *memcg = mem_cgroup_from_cont(cgrp); struct mem_cgroup *memcg = mem_cgroup_from_cont(cgrp);
struct mem_cgroup_thresholds *thresholds; struct mem_cgroup_thresholds *thresholds;
struct mem_cgroup_threshold_ary *new; struct mem_cgroup_threshold_ary *new;
int type = MEMFILE_TYPE(cft->private); enum res_type type = MEMFILE_TYPE(cft->private);
u64 threshold, usage; u64 threshold, usage;
int i, size, ret; int i, size, ret;
...@@ -4483,7 +4489,7 @@ static void mem_cgroup_usage_unregister_event(struct cgroup *cgrp, ...@@ -4483,7 +4489,7 @@ static void mem_cgroup_usage_unregister_event(struct cgroup *cgrp,
struct mem_cgroup *memcg = mem_cgroup_from_cont(cgrp); struct mem_cgroup *memcg = mem_cgroup_from_cont(cgrp);
struct mem_cgroup_thresholds *thresholds; struct mem_cgroup_thresholds *thresholds;
struct mem_cgroup_threshold_ary *new; struct mem_cgroup_threshold_ary *new;
int type = MEMFILE_TYPE(cft->private); enum res_type type = MEMFILE_TYPE(cft->private);
u64 usage; u64 usage;
int i, j, size; int i, j, size;
...@@ -4561,7 +4567,7 @@ static int mem_cgroup_oom_register_event(struct cgroup *cgrp, ...@@ -4561,7 +4567,7 @@ static int mem_cgroup_oom_register_event(struct cgroup *cgrp,
{ {
struct mem_cgroup *memcg = mem_cgroup_from_cont(cgrp); struct mem_cgroup *memcg = mem_cgroup_from_cont(cgrp);
struct mem_cgroup_eventfd_list *event; struct mem_cgroup_eventfd_list *event;
int type = MEMFILE_TYPE(cft->private); enum res_type type = MEMFILE_TYPE(cft->private);
BUG_ON(type != _OOM_TYPE); BUG_ON(type != _OOM_TYPE);
event = kmalloc(sizeof(*event), GFP_KERNEL); event = kmalloc(sizeof(*event), GFP_KERNEL);
...@@ -4586,7 +4592,7 @@ static void mem_cgroup_oom_unregister_event(struct cgroup *cgrp, ...@@ -4586,7 +4592,7 @@ static void mem_cgroup_oom_unregister_event(struct cgroup *cgrp,
{ {
struct mem_cgroup *memcg = mem_cgroup_from_cont(cgrp); struct mem_cgroup *memcg = mem_cgroup_from_cont(cgrp);
struct mem_cgroup_eventfd_list *ev, *tmp; struct mem_cgroup_eventfd_list *ev, *tmp;
int type = MEMFILE_TYPE(cft->private); enum res_type type = MEMFILE_TYPE(cft->private);
BUG_ON(type != _OOM_TYPE); BUG_ON(type != _OOM_TYPE);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册