CGroup API: More structured API for CGroups control files
Subsystems (4)
cover CGroup API: More structured API for CGroups control files
This set of patches makes the Control Groups API more structured and self-describing.
1) Allows control files to be associated with data types such as "u64", "string", "map", etc. These types show up in a new cgroup.api file in each cgroup directory, along with a user-readable string. Files that use cgroup-provided data accessors have these file types inferred automatically.
2) Moves various files in cpusets and the memory controller from using custom-written file handlers to cgroup-defined handlers
3) Adds the "cgroup." prefix for existing cgroup-provided control files (tasks, release_agent, releasable, notify_on_release). Given than we've already had 2.6.24 go out without this prefix, I guess this could be a little contentious - but it seems like a good move to prevent name clashes in the future. (Note that this doesn't affect mounting the legacy cpuset filesystem, since the compatibility layer disables all prefixes when mounted with filesystem type "cpuset"). If people object too strongly, we could just make this the case for *new* cgroup API files, but I think this is a case where consistency would be better than compatibility - I'd be surprised if anyone has written major legacy apps yet that rely on 2.6.24 cgroup control file names.
There are various motivations for this:
1) We said at Kernel Summit '07 that the cgroup API wouldn't be allowed to spiral into an arbitrary mess of ad-hoc APIs. Having simple ways to represent common data types makes this easier. (E.g. one standard way to report a map of string,u64 pairs to userspace.)
2) People were divided on the issue of binary APIs versus ASCII APIs for control groups. Compatibility with the existing cpusets system, and ease of experimentation, were two important reasons for going with the current. ASCII API. But by having structured control files, we can open the path towards having more efficient binary APIs for simpler and more efficient programmatic access too, without any additional modifications required from the subsystems themselves.
My plans for this potential binary API are a little hazy at this point, but they might go something like opening a cgroup.bin file in a cgroup directory, and writing the names of the control files that you were interested in; then a read on that file handle would return the contents of the given control files in a single read in a simple binary format. (Better suggestions are welcome). Regardless, getting a good typing/structure on the control files is an important first step if we want to go in that direction.
3) The memory controller currently has files with the "_in_bytes" suffix, on the grounds that otherwise it's not obvious to a new user what they represent. By moving the description to a auto-generated API file, we can remove this (IMO) inelegant suffix.
--
RFC PATCH 1/7 CGroup API: Add cgroup.api control file
Add a cgroup.api control file in every cgroup directory. This reports for each control file the type of data represented by that control file, and a user-friendly description of the contents.
A secondary effect of this patch is to add the "cgroup." prefix in front of all cgroup-provided control files. This will reduce the chance of future control files clashing with user-provided names.
--- include/linux/cgroup.h | 21 +++++++ kernel/cgroup.c | 133 ++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 148 insertions(+), 6 deletions(-)
include/linux/cgroup.h +21 -0
@@ -179,12 +179,33 @@ struct css_set {* - the 'cftype' of the file is file->f_dentry->d_fsdata */ +/* +* The various types of control file that are reported in the +* cgroup.api file. "String" is a catch-all default, but should only +* be used for special cases. If you use the appropriate accessors +* (such as "read_uint") in your control file, then you can leave this +* as 0 (CGROUP_FILE_UNKNOWN) and let cgroup figure out the right type. +*/ +enum cgroup_file_type { +CGROUP_FILE_UNKNOWN =0 , +CGROUP_FILE_VOID , +CGROUP_FILE_U64 , +CGROUP_FILE_STRING , +}; +#define MAX_CFTYPE_NAME 64struct cftype {/* By convention, the name should begin with the name of the * subsystem, followed by a period */ char name[MAX_CFTYPE_NAME ];int private; + +/* The type of a file - reported in the cgroup.api file */ +enum cgroup_file_type type; + +/* Human-readable description of the file */ +const char *desc; +int (*open) (struct inode *inode,struct file *file); ssize_t (*read) (struct cgroup *cont, struct cftype *cft, struct file *file,
kernel/cgroup.c +127 -6
181 lines not on this page · raw message
--
A message that is not in the archive (sent off-list or not yet received): 20080215204820.734926000-B63HFAS8fGlSzHKm+aFRNNkmqwFzkYv6@public.gmane.org
Re: [RFC][PATCH 1/7] CGroup API: Add cgroup.api control file
Paul Menage wrote:
Hi, Paul,
Do we need to use a cgroup.api file? Why not keep up to date documentation and get users to use that. I fear that, cgroup.api will not be kept up-to-date, leading to confusion.
Why should the kernel carry so much of documentation in the image as strings?
Signature · 4 lines
Warm Regards, Balbir Singh Linux Technology Center IBM, ISTL
Re: [RFC][PATCH 1/7] CGroup API: Add cgroup.api control file
In reply to Paul MenagePaul Menage wrote:
Hi, Paul,
Do we need to use a cgroup.api file? Why not keep up to date documentation and get users to use that. I fear that, cgroup.api will not be kept up-to-date, leading to confusion.
Why should the kernel carry so much of documentation in the image as strings?
Signature · 4 lines
Warm Regards, Balbir Singh Linux Technology Center IBM, ISTL
A message that is not in the archive (sent off-list or not yet received): 47B6B5CA.7040201-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org
Re: [RFC][PATCH 1/7] CGroup API: Add cgroup.api control file
Quoted 7 lines · Balbir Singh
Paul Menage wrote:
Hi, Paul,
Do we need to use a cgroup.api file? Why not keep up to date documentation and get users to use that. I fear that, cgroup.api will not be kept up-to-date, leading to confusion.
The cgroup.api file isn't meant to give complete documentation for a control file, simply a brief indication of its usage.
The aim is that most bits of the information reported in cgroup.api are auto-generated, so there shouldn't be problems with it getting out-of-date.
Is it just the space used by the documentation string that you're objecting to? The other function of the file is to declare a type for each variable.
Paul
Re: [RFC][PATCH 1/7] CGroup API: Add cgroup.api control file
In reply to Balbir SinghQuoted 7 lines · Balbir Singh
Paul Menage wrote:
Hi, Paul,
Do we need to use a cgroup.api file? Why not keep up to date documentation and get users to use that. I fear that, cgroup.api will not be kept up-to-date, leading to confusion.
The cgroup.api file isn't meant to give complete documentation for a control file, simply a brief indication of its usage.
The aim is that most bits of the information reported in cgroup.api are auto-generated, so there shouldn't be problems with it getting out-of-date.
Is it just the space used by the documentation string that you're objecting to? The other function of the file is to declare a type for each variable.
Paul
A message that is not in the archive (sent off-list or not yet received): 6599ad830802160944v6d529570k1ade6df273ca3d0d-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [RFC][PATCH 1/7] CGroup API: Add cgroup.api control file
Quoted 12 lines · Paul Menage
Quoted 7 lines · Balbir Singh
Paul Menage wrote:
Hi, Paul,
Do we need to use a cgroup.api file? Why not keep up to date documentation and get users to use that. I fear that, cgroup.api will not be kept up-to-date, leading to confusion.
The cgroup.api file isn't meant to give complete documentation for a control file, simply a brief indication of its usage.
But we don't have /proc/proc.api or /sys/sysfs.api ...
Quoted 8 lines
The aim is that most bits of the information reported in cgroup.api are auto-generated, so there shouldn't be problems with it getting out-of-date.
Is it just the space used by the documentation string that you're objecting to? The other function of the file is to declare a type for each variable.
[root@localhost mnt]# cat cgroup.api
debug.current_css_set_refcount u64
debug.current_css_set u64
debug.taskcount u64
debug.cgroup_refcount u64
cgroup.release_agent string Path to release agent binary
cgroup.api unknown Control file descriptions
cgroup.releasable u64 Is this cgroup able to be freed when empty
cgroup.notify_on_release u64 Should the release agent trigger when this cgroup is empty
cgroup.tasks string Thread ids of threads in this cgroup
It seems to me this is a little messy.
And is it better to describe the debug subsystem too?
Re: [RFC][PATCH 1/7] CGroup API: Add cgroup.api control file
In reply to Paul MenageQuoted 12 lines · Paul Menage
Quoted 7 lines · Balbir Singh
Paul Menage wrote:
Hi, Paul,
Do we need to use a cgroup.api file? Why not keep up to date documentation and get users to use that. I fear that, cgroup.api will not be kept up-to-date, leading to confusion.
The cgroup.api file isn't meant to give complete documentation for a control file, simply a brief indication of its usage.
But we don't have /proc/proc.api or /sys/sysfs.api ...
Quoted 8 lines
The aim is that most bits of the information reported in cgroup.api are auto-generated, so there shouldn't be problems with it getting out-of-date.
Is it just the space used by the documentation string that you're objecting to? The other function of the file is to declare a type for each variable.
[root@localhost mnt]# cat cgroup.api
debug.current_css_set_refcount u64
debug.current_css_set u64
debug.taskcount u64
debug.cgroup_refcount u64
cgroup.release_agent string Path to release agent binary
cgroup.api unknown Control file descriptions
cgroup.releasable u64 Is this cgroup able to be freed when empty
cgroup.notify_on_release u64 Should the release agent trigger when this cgroup is empty
cgroup.tasks string Thread ids of threads in this cgroup
It seems to me this is a little messy.
And is it better to describe the debug subsystem too?
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [RFC][PATCH 1/7] CGroup API: Add cgroup.api control file
Quoted 6 lines · Li Zefan
Quoted 5 lines · Paul Menage
Quoted 4 lines · Balbir Singh
Paul Menage wrote:
Hi, Paul,
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
Do we need to use a cgroup.api file? Why not keep up to date documentation and get users to use that. I fear that, cgroup.api will not be kept up-to-date, leading to confusion.
The cgroup.api file isn't meant to give complete documentation for a control file, simply a brief indication of its usage.
But we don't have
/proc/proc.apior/sys/sysfs.api...
Yes, doing that would make the size of the kernel go out of control.
Quoted 8 lines
Quoted 8 lines
The aim is that most bits of the information reported in cgroup.api are auto-generated, so there shouldn't be problems with it getting out-of-date.
Is it just the space used by the documentation string that you're objecting to? The other function of the file is to declare a type for each variable.
I like the documentation aspect, it is the space that I object to.
Signature · 4 lines
Warm Regards, Balbir Singh Linux Technology Center IBM, ISTL
Re: [RFC][PATCH 1/7] CGroup API: Add cgroup.api control file
In reply to a message not in the archiveQuoted 1 line · Li Zefan
It seems to me this is a little messy.
Agreed. It looks too finicky to base real software on; that is, I doubt that any robust application or user level software is going to depend on it for serious automated self-configuration.
I haven't seen a serious problem with cpuset documentation, which is the earlier API of this flavor (though, granted, I'd be the last person on the planet to see such ;). It seems to me that this style of API is easy enough for a variety of people to figure out that this won't help that much. And certainly the more interesting details that need documentation are far too verbose for this presentation.
So ... little or no programmatic use, little or no human use.
It also reminds me a bit, in a very loose way, of efforts in sysfs that have taken us a while, and too many changes, to get right. One needs to be -selective- in what one exposes, in order to minimize maintenance costs and maximize the signal-to-noise ratio, over time. This feels like it exposes too much.
Finally, it goes against the one thingie per file (at most, one scalar vector) that has worked well for us when tried.
As to the motivations Paul M gives:
1) Avoid "an arbitrary mess of ad-hoc APIs":
We can still do that, whether or not we "self-document" these API's in this manner.
2) binary APIs versus ASCII APIs:
Well, I have an ASCII API bias, not surprising. But I'd suggest not doing things "in anticipation" of some future fuzzy binary API support. Wait until that day actually arrives.
3) The memory controller currently has files with the "_in_bytes":
The traditional way to handle this is Documentation and man pages; good enough for my granddad, good enough for me ;).
Signature · 3 lines
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <pj-sJ/[email protected]> 1.940.382.4214Re: [RFC][PATCH 1/7] CGroup API: Add cgroup.api control file
In reply to a message not in the archiveQuoted 3 lines · Li Zefan
Quoted 1 line
But we don't have
/proc/proc.apior/sys/sysfs.api...
True. And /proc is a bit of a mess. Having a similar API file for sysfs sounds like a good idea to me.
Quoted 3 lines
And is it better to describe the debug subsystem too?
Yes, probably, but that would be a separate patch to the debug subsystem itself, not the main cgroups code.
Paul
Re: [RFC][PATCH 1/7] CGroup API: Add cgroup.api control file
In reply to Li ZefanQuoted 6 lines · Li Zefan
Quoted 5 lines · Paul Menage
Quoted 4 lines · Balbir Singh
Paul Menage wrote:
Hi, Paul,
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
Do we need to use a cgroup.api file? Why not keep up to date documentation and get users to use that. I fear that, cgroup.api will not be kept up-to-date, leading to confusion.
The cgroup.api file isn't meant to give complete documentation for a control file, simply a brief indication of its usage.
But we don't have
/proc/proc.apior/sys/sysfs.api...
Yes, doing that would make the size of the kernel go out of control.
Quoted 8 lines
Quoted 8 lines
The aim is that most bits of the information reported in cgroup.api are auto-generated, so there shouldn't be problems with it getting out-of-date.
Is it just the space used by the documentation string that you're objecting to? The other function of the file is to declare a type for each variable.
I like the documentation aspect, it is the space that I object to.
Signature · 4 lines
Warm Regards, Balbir Singh Linux Technology Center IBM, ISTL
Re: [RFC][PATCH 1/7] CGroup API: Add cgroup.api control file
In reply to Li ZefanQuoted 1 line · Li Zefan
It seems to me this is a little messy.
Agreed. It looks too finicky to base real software on; that is, I doubt that any robust application or user level software is going to depend on it for serious automated self-configuration.
I haven't seen a serious problem with cpuset documentation, which is the earlier API of this flavor (though, granted, I'd be the last person on the planet to see such ;). It seems to me that this style of API is easy enough for a variety of people to figure out that this won't help that much. And certainly the more interesting details that need documentation are far too verbose for this presentation.
So ... little or no programmatic use, little or no human use.
It also reminds me a bit, in a very loose way, of efforts in sysfs that have taken us a while, and too many changes, to get right. One needs to be -selective- in what one exposes, in order to minimize maintenance costs and maximize the signal-to-noise ratio, over time. This feels like it exposes too much.
Finally, it goes against the one thingie per file (at most, one scalar vector) that has worked well for us when tried.
As to the motivations Paul M gives:
1) Avoid "an arbitrary mess of ad-hoc APIs":
We can still do that, whether or not we "self-document" these API's in this manner.
2) binary APIs versus ASCII APIs:
Well, I have an ASCII API bias, not surprising. But I'd suggest not doing things "in anticipation" of some future fuzzy binary API support. Wait until that day actually arrives.
3) The memory controller currently has files with the "_in_bytes":
The traditional way to handle this is Documentation and man pages; good enough for my granddad, good enough for me ;).
Signature · 3 lines
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <[email protected]> 1.940.382.4214A message that is not in the archive (sent off-list or not yet received): 20080219155742.0298f25f.pj-sJ/[email protected]
Re: [RFC][PATCH 1/7] CGroup API: Add cgroup.api control file
Quoted 3 lines · Paul Jackson
Finally, it goes against the one thingie per file (at most, one scalar vector) that has worked well for us when tried.
Right, I like the idea of keeping things simple. But if you're going to accept that a vector is useful, then it seems reasonable that some other *simple* structured datatypes can be useful. An N-element key/value map (a la /proc/meminfo) is, I think, nicer than having to read values from N separate files.
Quoted 5 lines
As to the motivations Paul M gives:
1) Avoid "an arbitrary mess of ad-hoc APIs":
We can still do that, whether or not we "self-document" these API's in this manner.
We can, but this file makes it more clear what control files have a well-defined API and which are just returning some ad-hoc string.
I guess it's not essential, I just figured that if we had that information, it made sense to make it available to userspace. I guess I'm happy with dropping the actual exposed cgroup.api file for now as long as we can work towards reducing the number of control files that just return strings, and make use of the structured output such as read_uint() miore.
Quoted 4 lines
2) binary APIs versus ASCII APIs:
Well, I have an ASCII API bias, not surprising. But I'd suggest not doing things "in anticipation" of some future fuzzy binary API support. Wait until that day actually arrives.
I have a reasonably clear idea of how we can do the binary API.
That's mostly for a separate RFC. But for example, reading a map via the binary API would be able to just return a list values since the keys could be parsed once from the ascii map (provided that the subsystem guaranteed that the map keys and their order wouldn't change between reboots).
Quoted 3 lines
3) The memory controller currently has files with the "
_in_bytes":
The traditional way to handle this is Documentation and man pages; good enough for my granddad, good enough for me ;).
I've tried submitting patches to remove the in_bytes suffix and just rely on the documentation, and people didn't seem to like it ...
Paul
Re: [RFC][PATCH 1/7] CGroup API: Add cgroup.api control file
In reply to Paul JacksonQuoted 3 lines · Paul Jackson
Finally, it goes against the one thingie per file (at most, one scalar vector) that has worked well for us when tried.
Right, I like the idea of keeping things simple. But if you're going to accept that a vector is useful, then it seems reasonable that some other *simple* structured datatypes can be useful. An N-element key/value map (a la /proc/meminfo) is, I think, nicer than having to read values from N separate files.
Quoted 5 lines
As to the motivations Paul M gives:
1) Avoid "an arbitrary mess of ad-hoc APIs":
We can still do that, whether or not we "self-document" these API's in this manner.
We can, but this file makes it more clear what control files have a well-defined API and which are just returning some ad-hoc string.
I guess it's not essential, I just figured that if we had that information, it made sense to make it available to userspace. I guess I'm happy with dropping the actual exposed cgroup.api file for now as long as we can work towards reducing the number of control files that just return strings, and make use of the structured output such as read_uint() miore.
Quoted 4 lines
2) binary APIs versus ASCII APIs:
Well, I have an ASCII API bias, not surprising. But I'd suggest not doing things "in anticipation" of some future fuzzy binary API support. Wait until that day actually arrives.
I have a reasonably clear idea of how we can do the binary API.
That's mostly for a separate RFC. But for example, reading a map via the binary API would be able to just return a list values since the keys could be parsed once from the ascii map (provided that the subsystem guaranteed that the map keys and their order wouldn't change between reboots).
Quoted 3 lines
3) The memory controller currently has files with the "
_in_bytes":
The traditional way to handle this is Documentation and man pages; good enough for my granddad, good enough for me ;).
I've tried submitting patches to remove the in_bytes suffix and just rely on the documentation, and people didn't seem to like it ...
Paul
A message that is not in the archive (sent off-list or not yet received): 6599ad830802191851l66281e67rb49c766c2b1427c9-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [RFC][PATCH 1/7] CGroup API: Add cgroup.api control file
Quoted 6 lines · Paul M
I guess it's not essential, I just figured that if we had that information, it made sense to make it available to userspace. I guess I'm happy with dropping the actual exposed cgroup.api file for now as long as we can work towards reducing the number of control files that just return strings, and make use of the structured output such as
read_uint()miore.
I could certainly go along with that ... reducing the proportion of control files returning untyped strings.
My sense of kernel-user API's is that usually the less said the better. Identify the essential information that one side requires from the other via a runtime API, and pass only that. API's represent a lifetime commitment, so the less promised the better.
Perhaps my primary concern with these *.api files was that I did not understand who or what the critical use or user was; who found this essential, not just nice to have.
Signature · 3 lines
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <pj-sJ/[email protected]> 1.940.382.4214Re: [RFC][PATCH 1/7] CGroup API: Add cgroup.api control file
In reply to Paul MenageQuoted 6 lines · Paul M
I guess it's not essential, I just figured that if we had that information, it made sense to make it available to userspace. I guess I'm happy with dropping the actual exposed cgroup.api file for now as long as we can work towards reducing the number of control files that just return strings, and make use of the structured output such as
read_uint()miore.
I could certainly go along with that ... reducing the proportion of control files returning untyped strings.
My sense of kernel-user API's is that usually the less said the better. Identify the essential information that one side requires from the other via a runtime API, and pass only that. API's represent a lifetime commitment, so the less promised the better.
Perhaps my primary concern with these *.api files was that I did not understand who or what the critical use or user was; who found this essential, not just nice to have.
Signature · 3 lines
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <[email protected]> 1.940.382.4214A message that is not in the archive (sent off-list or not yet received): 20080219231726.4bd97520.pj-sJ/[email protected]
Re: [RFC][PATCH 1/7] CGroup API: Add cgroup.api control file
Quoted 5 lines · Paul Jackson
Perhaps my primary concern with these *.api files was that I did not understand who or what the critical use or user was; who found this essential, not just nice to have.
Right now, no-one would find it essential. If/when a binary API is added, I guess I'll ressurrect this part of the patchset.
Paul
Re: [RFC][PATCH 1/7] CGroup API: Add cgroup.api control file
In reply to Paul JacksonQuoted 5 lines · Paul Jackson
Perhaps my primary concern with these *.api files was that I did not understand who or what the critical use or user was; who found this essential, not just nice to have.
Right now, no-one would find it essential. If/when a binary API is added, I guess I'll ressurrect this part of the patchset.
Paul
Re: [RFC][PATCH 1/7] CGroup API: Add cgroup.api control file
In reply to Li ZefanQuoted 3 lines · Li Zefan
Quoted 1 line
But we don't have
/proc/proc.apior/sys/sysfs.api...
True. And /proc is a bit of a mess. Having a similar API file for sysfs sounds like a good idea to me.
Quoted 3 lines
And is it better to describe the debug subsystem too?
Yes, probably, but that would be a separate patch to the debug subsystem itself, not the main cgroups code.
Paul
RFC PATCH 2/7 CGroup API: Add cgroup map data type
In reply to Paul MenageAdds a new type of supported control file representation, a map from strings to u64 values.
--- include/linux/cgroup.h | 19 +++++++++++++++ kernel/cgroup.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 79 insertions(+), 1 deletion(-)
include/linux/cgroup.h +19 -0
@@ -191,6 +191,17 @@ enum cgroup_file_type {CGROUP_FILE_VOID ,CGROUP_FILE_U64 ,CGROUP_FILE_STRING , + CGROUP_FILE_MAP, +}; + +/* +* cgroup_map_cb is an abstract callback API for reporting map-valued +* control files +*/ + +struct cgroup_map_cb { +int (*fill)(struct cgroup_map_cb *cb,const char *key,u64 value); +void *state; };#define MAX_CFTYPE_NAME 64
@@ -215,6 +226,14 @@ struct cftype {* single integer. Use it in place of read() */ u64 (*read_uint) (struct cgroup *cont,struct cftype *cft); +/* +* read_map() is used for defining a map of key/value +* pairs. It should call cb->fill(cb, key, value) for each +* entry. +*/ +int (*read_map) (struct cgroup *cont,struct cftype *cft, +struct cgroup_map_cb *cb); +ssize_t (*write) (struct cgroup *cont,struct cftype *cft,struct file *file,const char __user *buf,size_t nbytes,loff_t *ppos);
kernel/cgroup.c +60 -1
85 lines not on this page · raw message
--
RFC PATCH 3/7 CGroup API: Use cgroup map for memcontrol stats file
In reply to Paul MenageRemove the seq_file boilerplate used to construct the memcontrol stats map, and instead use the new map representation for cgroup control files
--- mm/memcontrol.c | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-)
mm/memcontrol.c +6 -24
@@ -974,9 +974,9 @@ static const struct mem_cgroup_stat_desc [MEM_CGROUP_STAT_RSS] = { "rss", PAGE_SIZE, }, }; -static int mem_control_stat_show (struct seq_file *m,void *arg) +static int mem_control_stat_show (struct cgroup *cont,struct cftype *cft, +struct cgroup_map_cb *cb) { -struct cgroup *cont = m->private;struct mem_cgroup *mem_cont =mem_cgroup_from_cont (cont);struct mem_cgroup_stat *stat = &mem_cont->stat;int i;
@@ -986,8 +986,7 @@ static int mem_control_stat_show(struct val =mem_cgroup_read_stat (stat, i); val *= mem_cgroup_stat_desc[i].unit; -seq_printf (m,"%s %lld\n" , mem_cgroup_stat_desc[i].msg, - (long long )val); + cb->fill (cb, mem_cgroup_stat_desc[i].msg, val); }/* showing # of active pages */ {
@@ -997,29 +996,12 @@ static int mem_control_stat_show(struct MEM_CGROUP_ZSTAT_INACTIVE); active =mem_cgroup_get_all_zonestat (mem_cont,MEM_CGROUP_ZSTAT_ACTIVE ); -seq_printf (m,"active %ld\n" , (active) *PAGE_SIZE ); -seq_printf (m,"inactive %ld\n" , (inactive) *PAGE_SIZE ); + cb->fill (cb,"active" , (active) *PAGE_SIZE ); + cb->fill (cb,"inactive" , (inactive) *PAGE_SIZE ); }return 0 ; } -static const struct file_operations mem_control_stat_file_operations = { - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static int mem_control_stat_open (struct inode *unused,struct file *file) -{ -/* XXX __d_cont */ -struct cgroup *cont = file->f_dentry->d_parent->d_fsdata; - - file->f_op = &mem_control_stat_file_operations; -return single_open (file, mem_control_stat_show, cont); -} - - -static struct cftype mem_cgroup_files[] = { { .name ="usage_in_bytes" ,
@@ -1044,7 +1026,7 @@ static struct cftype mem_cgroup_files[] }, { .name = "stat", - .open = mem_control_stat_open, + .read_map = mem_control_stat_show, }, };
--
RFC PATCH 4/7 CGroup API: Add res_counter_read_uint()
In reply to Paul MenageAdds a function for returning the value of a resource counter member, in a form suitable for use in a cgroup read_uint control file method.
--- include/linux/res_counter.h | 1 + kernel/res_counter.c | 5 +++++ 2 files changed, 6 insertions(+)
include/linux/res_counter.h +1 -0
@@ -54,6 +54,7 @@ struct res_counter {ssize_t res_counter_read (struct res_counter *counter,int member,const char __user *buf,size_t nbytes,loff_t *pos,int (*read_strategy)(unsigned long long val,char *s)); +u64 res_counter_read_uint (struct res_counter *counter,int member);ssize_t res_counter_write (struct res_counter *counter,int member,const char __user *buf,size_t nbytes,loff_t *pos,int (*write_strategy)(char *buf,unsigned long long *val));
kernel/res_counter.c +5 -0
@@ -92,6 +92,11 @@ ssize_t res_counter_read(struct res_coun pos, buf, s - buf); } +u64 res_counter_read_uint (struct res_counter *counter,int member) +{ +return *res_counter_member (counter, member); +} +ssize_t res_counter_write (struct res_counter *counter,int member,const char __user *userbuf,size_t nbytes,loff_t *pos,int (*write_strategy)(char *st_buf,unsigned long long *val))
--
RFC PATCH 5/7 CGroup API: Use read_uint in memory controller
In reply to Paul MenageUpdate the memory controller to use read_uint for its limit/usage/failcnt control files, calling the new res_counter_read_uint() function. This allows the files to show up as u64 rather than string in the cgroup.api file.
--- mm/memcontrol.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
mm/memcontrol.c +6 -9
@@ -922,13 +922,10 @@ int mem_cgroup_write_strategy(char *buf,return 0 ; } -static ssize_t mem_cgroup_read (struct cgroup *cont, -struct cftype *cft,struct file *file, -char __user *userbuf,size_t nbytes,loff_t *ppos) +static u64 mem_cgroup_read (struct cgroup *cont,struct cftype *cft) { -return res_counter_read (&mem_cgroup_from_cont (cont)->res, - cft->private, userbuf, nbytes, ppos, -NULL ); +return res_counter_read_uint (&mem_cgroup_from_cont (cont)->res, + cft->private); } static ssize_t mem_cgroup_write(struct cgroup *cont, struct cftype *cft,
@@ -1006,18 +1003,18 @@ static struct cftype mem_cgroup_files[] { .name = "usage_in_bytes", .private = RES_USAGE, - .read = mem_cgroup_read, + .read_uint = mem_cgroup_read, }, { .name = "limit_in_bytes", .private = RES_LIMIT, .write = mem_cgroup_write, - .read = mem_cgroup_read, + .read_uint = mem_cgroup_read, }, { .name = "failcnt", .private = RES_FAILCNT, - .read = mem_cgroup_read, + .read_uint = mem_cgroup_read, }, { .name = "force_empty",
--
RFC PATCH 6/7 CGroup API: Use descriptions for memory controller API files
In reply to Paul MenageThis patch adds descriptions to the memory controller API files to indicate that the usage/limit are in bytes; the names of the control files can then be simplified to usage/limit.
Also removes the unnecessary mem_force_empty_read() function
--- mm/memcontrol.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-)
mm/memcontrol.c +5 -16
@@ -950,19 +950,6 @@ static ssize_t mem_force_empty_write(strreturn ret; } -/* -* Note: This should be removed if cgroup supports write-only file. -*/ - -static ssize_t mem_force_empty_read (struct cgroup *cont, -struct cftype *cft, -struct file *file,char __user *userbuf, -size_t nbytes,loff_t *ppos) -{ -return -EINVAL ; -} - - static const struct mem_cgroup_stat_desc { const char *msg; u64 unit;
@@ -1001,15 +988,17 @@ static int mem_control_stat_show(structstatic struct cftype mem_cgroup_files[] = { { - .name ="usage_in_bytes" , + .name ="usage" , .private =RES_USAGE , .read_uint = mem_cgroup_read, + .desc ="Memory usage in bytes" , }, { - .name ="limit_in_bytes" , + .name ="limit" , .private =RES_LIMIT , .write = mem_cgroup_write, .read_uint = mem_cgroup_read, + .desc ="Memory limit in bytes" , }, { .name ="failcnt" ,
@@ -1019,7 +1008,7 @@ static struct cftype mem_cgroup_files[] { .name = "force_empty", .write = mem_force_empty_write, - .read = mem_force_empty_read, + .desc ="Write to this file to forget all memory charges" }, { .name = "stat",
--
RFC PATCH 7/7 CGroup API: Update cpusets to use cgroup structured file API
In reply to Paul MenageMany of the cpusets control files are simple integer values, which don't require the overhead of memory allocations for reads and writes.
Move the handlers for these control files into cpuset_read_uint() and cpuset_write_uint(). This also has the advantage that the control files show up as "u64" rather than "string" in the cgroup.api file.
--- kernel/cpuset.c | 158 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 83 insertions(+), 75 deletions(-)
kernel/cpuset.c +83 -75
@@ -999,19 +999,6 @@ int current_cpuset_is_being_rebound(void }/* -* Call with cgroup_mutex held. -*/ - -static int update_memory_pressure_enabled (struct cpuset *cs,char *buf) -{ -if (simple_strtoul (buf,NULL ,10 ) !=0 ) - cpuset_memory_pressure_enabled =1 ; -else - cpuset_memory_pressure_enabled =0 ; -return 0 ; -} - -/* * update_flag - read a 0 or a 1 in a file and update associated flag * bit: the bit to update (CS_CPU_EXCLUSIVE, CS_MEM_EXCLUSIVE, * CS_SCHED_LOAD_BALANCE,
@@ -1023,15 +1010,13 @@ static int update_memory_pressure_enable* Call with cgroup_mutex held. */ -static int update_flag (cpuset_flagbits_t bit,struct cpuset *cs,char *buf) +static int update_flag (cpuset_flagbits_t bit,struct cpuset *cs, +int turning_on) { -int turning_on;struct cpuset trialcs;int err;int cpus_nonempty, balance_flag_changed; - turning_on = (simple_strtoul (buf,NULL ,10 ) !=0 ); - trialcs = *cs;if (turning_on)set_bit (bit, &trialcs.flags);
@@ -1247,44 +1232,66 @@ static ssize_t cpuset_common_file_write(case FILE_MEMLIST : retval =update_nodemask (cs, buffer);break ; +default : + retval = -EINVAL ; + goto out2; + } + +if (retval ==0 ) + retval = nbytes; +out2: +cgroup_unlock (); +out1: +kfree (buffer); +return retval; +} + +static int cpuset_write_uint (struct cgroup *cgrp,struct cftype *cft,u64 val) +{ +int retval =0 ; +struct cpuset *cs =cgroup_cs (cgrp); +cpuset_filetype_t type = cft->private; + +cgroup_lock (); + +if (cgroup_is_removed (cgrp)) { +cgroup_unlock (); +return -ENODEV ; + } + +switch (type) {case FILE_CPU_EXCLUSIVE : - retval =update_flag (CS_CPU_EXCLUSIVE , cs, buffer); + retval =update_flag (CS_CPU_EXCLUSIVE , cs, val);break ;case FILE_MEM_EXCLUSIVE : - retval =update_flag (CS_MEM_EXCLUSIVE , cs, buffer); + retval =update_flag (CS_MEM_EXCLUSIVE , cs, val);break ;case FILE_SCHED_LOAD_BALANCE : - retval =update_flag (CS_SCHED_LOAD_BALANCE , cs, buffer); + retval =update_flag (CS_SCHED_LOAD_BALANCE , cs, val);break ;case FILE_MEMORY_MIGRATE : - retval =update_flag (CS_MEMORY_MIGRATE , cs, buffer); + retval =update_flag (CS_MEMORY_MIGRATE , cs, val);break ;case FILE_MEMORY_PRESSURE_ENABLED : - retval =update_memory_pressure_enabled (cs, buffer); + cpuset_memory_pressure_enabled = val;break ;case FILE_MEMORY_PRESSURE : retval = -EACCES ;break ;case FILE_SPREAD_PAGE : - retval =update_flag (CS_SPREAD_PAGE , cs, buffer); + retval =update_flag (CS_SPREAD_PAGE , cs, val); cs->mems_generation = cpuset_mems_generation++;break ;case FILE_SPREAD_SLAB : - retval =update_flag (CS_SPREAD_SLAB , cs, buffer); + retval =update_flag (CS_SPREAD_SLAB , cs, val); cs->mems_generation = cpuset_mems_generation++;break ;default : retval = -EINVAL ; - goto out2; +break ; } - -if (retval ==0 ) - retval = nbytes; -out2:cgroup_unlock (); -out1: -kfree (buffer); -return retval; +return -EINVAL ; }/*
@@ -1345,30 +1352,6 @@ static ssize_t cpuset_common_file_read(scase FILE_MEMLIST : s +=cpuset_sprintf_memlist (s, cs);break ; -case FILE_CPU_EXCLUSIVE : - *s++ =is_cpu_exclusive (cs) ?'1' :'0' ; -break ; -case FILE_MEM_EXCLUSIVE : - *s++ =is_mem_exclusive (cs) ?'1' :'0' ; -break ; -case FILE_SCHED_LOAD_BALANCE : - *s++ =is_sched_load_balance (cs) ?'1' :'0' ; -break ; -case FILE_MEMORY_MIGRATE : - *s++ =is_memory_migrate (cs) ?'1' :'0' ; -break ; -case FILE_MEMORY_PRESSURE_ENABLED : - *s++ = cpuset_memory_pressure_enabled ?'1' :'0' ; -break ; -case FILE_MEMORY_PRESSURE : - s +=sprintf (s,"%d" ,fmeter_getrate (&cs->fmeter)); -break ; -case FILE_SPREAD_PAGE : - *s++ =is_spread_page (cs) ?'1' :'0' ; -break ; -case FILE_SPREAD_SLAB : - *s++ =is_spread_slab (cs) ?'1' :'0' ; -break ;default : retval = -EINVAL ; goto out;
@@ -1381,8 +1364,32 @@ out:return retval; } - - +static u64 cpuset_read_uint (struct cgroup *cont,struct cftype *cft) +{ +struct cpuset *cs =cgroup_cs (cont); +cpuset_filetype_t type = cft->private; +switch (type) { +case FILE_CPU_EXCLUSIVE : +return is_cpu_exclusive (cs); +case FILE_MEM_EXCLUSIVE : +return is_mem_exclusive (cs); +case FILE_SCHED_LOAD_BALANCE : +return is_sched_load_balance (cs); +case FILE_MEMORY_MIGRATE : +return is_memory_migrate (cs); +case FILE_MEMORY_PRESSURE_ENABLED : +return cpuset_memory_pressure_enabled; +case FILE_MEMORY_PRESSURE : +return fmeter_getrate (&cs->fmeter); +break ; +case FILE_SPREAD_PAGE : +return is_spread_page (cs); +case FILE_SPREAD_SLAB : +return is_spread_slab (cs); +default : +BUG (); + } +}/*
@@ -1405,57 +1412,58 @@ static struct cftype cft_mems = {static struct cftype cft_cpu_exclusive = { .name ="cpu_exclusive" , - .read = cpuset_common_file_read, - .write = cpuset_common_file_write, + .read_uint = cpuset_read_uint, + .write_uint = cpuset_write_uint, .private =FILE_CPU_EXCLUSIVE , };static struct cftype cft_mem_exclusive = { .name ="mem_exclusive" , - .read = cpuset_common_file_read, - .write = cpuset_common_file_write, + .read_uint = cpuset_read_uint, + .write_uint = cpuset_write_uint, .private =FILE_MEM_EXCLUSIVE , };static struct cftype cft_sched_load_balance = { .name ="sched_load_balance" , - .read = cpuset_common_file_read, - .write = cpuset_common_file_write, + .read_uint = cpuset_read_uint, + .write_uint = cpuset_write_uint, .private =FILE_SCHED_LOAD_BALANCE , };static struct cftype cft_memory_migrate = { .name ="memory_migrate" , - .read = cpuset_common_file_read, - .write = cpuset_common_file_write, + .read_uint = cpuset_read_uint, + .read_uint = cpuset_read_uint, + .write_uint = cpuset_write_uint, .private =FILE_MEMORY_MIGRATE , };static struct cftype cft_memory_pressure_enabled = { .name ="memory_pressure_enabled" , - .read = cpuset_common_file_read, - .write = cpuset_common_file_write, + .read_uint = cpuset_read_uint, + .write_uint = cpuset_write_uint, .private =FILE_MEMORY_PRESSURE_ENABLED , };static struct cftype cft_memory_pressure = { .name ="memory_pressure" , - .read = cpuset_common_file_read, - .write = cpuset_common_file_write, + .read_uint = cpuset_read_uint, + .write_uint = cpuset_write_uint, .private =FILE_MEMORY_PRESSURE , };static struct cftype cft_spread_page = { .name ="memory_spread_page" , - .read = cpuset_common_file_read, - .write = cpuset_common_file_write, + .read_uint = cpuset_read_uint, + .write_uint = cpuset_write_uint, .private =FILE_SPREAD_PAGE , };static struct cftype cft_spread_slab = { .name ="memory_spread_slab" , - .read = cpuset_common_file_read, - .write = cpuset_common_file_write, + .read_uint = cpuset_read_uint, + .write_uint = cpuset_write_uint, .private =FILE_SPREAD_SLAB , };
@@ -1584,7 +1592,7 @@ static void cpuset_destroy(struct cgroupcpuset_update_task_memory_state ();if (is_sched_load_balance (cs)) -update_flag (CS_SCHED_LOAD_BALANCE , cs,"0" ); +update_flag (CS_SCHED_LOAD_BALANCE , cs,0 ); number_of_cpusets--;kfree (cs);
--
RFC PATCH 3/7 CGroup API: Use cgroup map for memcontrol stats file
In reply to Paul MenageRemove the seq_file boilerplate used to construct the memcontrol stats map, and instead use the new map representation for cgroup control files
--- mm/memcontrol.c | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-)
mm/memcontrol.c +6 -24
@@ -974,9 +974,9 @@ static const struct mem_cgroup_stat_desc [MEM_CGROUP_STAT_RSS] = { "rss", PAGE_SIZE, }, }; -static int mem_control_stat_show (struct seq_file *m,void *arg) +static int mem_control_stat_show (struct cgroup *cont,struct cftype *cft, +struct cgroup_map_cb *cb) { -struct cgroup *cont = m->private;struct mem_cgroup *mem_cont =mem_cgroup_from_cont (cont);struct mem_cgroup_stat *stat = &mem_cont->stat;int i;
@@ -986,8 +986,7 @@ static int mem_control_stat_show(struct val =mem_cgroup_read_stat (stat, i); val *= mem_cgroup_stat_desc[i].unit; -seq_printf (m,"%s %lld\n" , mem_cgroup_stat_desc[i].msg, - (long long )val); + cb->fill (cb, mem_cgroup_stat_desc[i].msg, val); }/* showing # of active pages */ {
@@ -997,29 +996,12 @@ static int mem_control_stat_show(struct MEM_CGROUP_ZSTAT_INACTIVE); active =mem_cgroup_get_all_zonestat (mem_cont,MEM_CGROUP_ZSTAT_ACTIVE ); -seq_printf (m,"active %ld\n" , (active) *PAGE_SIZE ); -seq_printf (m,"inactive %ld\n" , (inactive) *PAGE_SIZE ); + cb->fill (cb,"active" , (active) *PAGE_SIZE ); + cb->fill (cb,"inactive" , (inactive) *PAGE_SIZE ); }return 0 ; } -static const struct file_operations mem_control_stat_file_operations = { - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static int mem_control_stat_open (struct inode *unused,struct file *file) -{ -/* XXX __d_cont */ -struct cgroup *cont = file->f_dentry->d_parent->d_fsdata; - - file->f_op = &mem_control_stat_file_operations; -return single_open (file, mem_control_stat_show, cont); -} - - -static struct cftype mem_cgroup_files[] = { { .name ="usage_in_bytes" ,
@@ -1044,7 +1026,7 @@ static struct cftype mem_cgroup_files[] }, { .name = "stat", - .open = mem_control_stat_open, + .read_map = mem_control_stat_show, }, };
--
RFC PATCH 4/7 CGroup API: Add res_counter_read_uint()
In reply to Paul MenageAdds a function for returning the value of a resource counter member, in a form suitable for use in a cgroup read_uint control file method.
--- include/linux/res_counter.h | 1 + kernel/res_counter.c | 5 +++++ 2 files changed, 6 insertions(+)
include/linux/res_counter.h +1 -0
@@ -54,6 +54,7 @@ struct res_counter {ssize_t res_counter_read (struct res_counter *counter,int member,const char __user *buf,size_t nbytes,loff_t *pos,int (*read_strategy)(unsigned long long val,char *s)); +u64 res_counter_read_uint (struct res_counter *counter,int member);ssize_t res_counter_write (struct res_counter *counter,int member,const char __user *buf,size_t nbytes,loff_t *pos,int (*write_strategy)(char *buf,unsigned long long *val));
kernel/res_counter.c +5 -0
@@ -92,6 +92,11 @@ ssize_t res_counter_read(struct res_coun pos, buf, s - buf); } +u64 res_counter_read_uint (struct res_counter *counter,int member) +{ +return *res_counter_member (counter, member); +} +ssize_t res_counter_write (struct res_counter *counter,int member,const char __user *userbuf,size_t nbytes,loff_t *pos,int (*write_strategy)(char *st_buf,unsigned long long *val))
--
RFC PATCH 5/7 CGroup API: Use read_uint in memory controller
In reply to Paul MenageUpdate the memory controller to use read_uint for its limit/usage/failcnt control files, calling the new res_counter_read_uint() function. This allows the files to show up as u64 rather than string in the cgroup.api file.
--- mm/memcontrol.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
mm/memcontrol.c +6 -9
@@ -922,13 +922,10 @@ int mem_cgroup_write_strategy(char *buf,return 0 ; } -static ssize_t mem_cgroup_read (struct cgroup *cont, -struct cftype *cft,struct file *file, -char __user *userbuf,size_t nbytes,loff_t *ppos) +static u64 mem_cgroup_read (struct cgroup *cont,struct cftype *cft) { -return res_counter_read (&mem_cgroup_from_cont (cont)->res, - cft->private, userbuf, nbytes, ppos, -NULL ); +return res_counter_read_uint (&mem_cgroup_from_cont (cont)->res, + cft->private); } static ssize_t mem_cgroup_write(struct cgroup *cont, struct cftype *cft,
@@ -1006,18 +1003,18 @@ static struct cftype mem_cgroup_files[] { .name = "usage_in_bytes", .private = RES_USAGE, - .read = mem_cgroup_read, + .read_uint = mem_cgroup_read, }, { .name = "limit_in_bytes", .private = RES_LIMIT, .write = mem_cgroup_write, - .read = mem_cgroup_read, + .read_uint = mem_cgroup_read, }, { .name = "failcnt", .private = RES_FAILCNT, - .read = mem_cgroup_read, + .read_uint = mem_cgroup_read, }, { .name = "force_empty",
--
RFC PATCH 6/7 CGroup API: Use descriptions for memory controller API files
In reply to Paul MenageThis patch adds descriptions to the memory controller API files to indicate that the usage/limit are in bytes; the names of the control files can then be simplified to usage/limit.
Also removes the unnecessary mem_force_empty_read() function
--- mm/memcontrol.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-)
mm/memcontrol.c +5 -16
@@ -950,19 +950,6 @@ static ssize_t mem_force_empty_write(strreturn ret; } -/* -* Note: This should be removed if cgroup supports write-only file. -*/ - -static ssize_t mem_force_empty_read (struct cgroup *cont, -struct cftype *cft, -struct file *file,char __user *userbuf, -size_t nbytes,loff_t *ppos) -{ -return -EINVAL ; -} - - static const struct mem_cgroup_stat_desc { const char *msg; u64 unit;
@@ -1001,15 +988,17 @@ static int mem_control_stat_show(structstatic struct cftype mem_cgroup_files[] = { { - .name ="usage_in_bytes" , + .name ="usage" , .private =RES_USAGE , .read_uint = mem_cgroup_read, + .desc ="Memory usage in bytes" , }, { - .name ="limit_in_bytes" , + .name ="limit" , .private =RES_LIMIT , .write = mem_cgroup_write, .read_uint = mem_cgroup_read, + .desc ="Memory limit in bytes" , }, { .name ="failcnt" ,
@@ -1019,7 +1008,7 @@ static struct cftype mem_cgroup_files[] { .name = "force_empty", .write = mem_force_empty_write, - .read = mem_force_empty_read, + .desc ="Write to this file to forget all memory charges" }, { .name = "stat",
--
RFC PATCH 7/7 CGroup API: Update cpusets to use cgroup structured file API
In reply to Paul MenageMany of the cpusets control files are simple integer values, which don't require the overhead of memory allocations for reads and writes.
Move the handlers for these control files into cpuset_read_uint() and cpuset_write_uint(). This also has the advantage that the control files show up as "u64" rather than "string" in the cgroup.api file.
--- kernel/cpuset.c | 158 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 83 insertions(+), 75 deletions(-)
kernel/cpuset.c +83 -75
@@ -999,19 +999,6 @@ int current_cpuset_is_being_rebound(void }/* -* Call with cgroup_mutex held. -*/ - -static int update_memory_pressure_enabled (struct cpuset *cs,char *buf) -{ -if (simple_strtoul (buf,NULL ,10 ) !=0 ) - cpuset_memory_pressure_enabled =1 ; -else - cpuset_memory_pressure_enabled =0 ; -return 0 ; -} - -/* * update_flag - read a 0 or a 1 in a file and update associated flag * bit: the bit to update (CS_CPU_EXCLUSIVE, CS_MEM_EXCLUSIVE, * CS_SCHED_LOAD_BALANCE,
@@ -1023,15 +1010,13 @@ static int update_memory_pressure_enable* Call with cgroup_mutex held. */ -static int update_flag (cpuset_flagbits_t bit,struct cpuset *cs,char *buf) +static int update_flag (cpuset_flagbits_t bit,struct cpuset *cs, +int turning_on) { -int turning_on;struct cpuset trialcs;int err;int cpus_nonempty, balance_flag_changed; - turning_on = (simple_strtoul (buf,NULL ,10 ) !=0 ); - trialcs = *cs;if (turning_on)set_bit (bit, &trialcs.flags);
@@ -1247,44 +1232,66 @@ static ssize_t cpuset_common_file_write(case FILE_MEMLIST : retval =update_nodemask (cs, buffer);break ; +default : + retval = -EINVAL ; + goto out2; + } + +if (retval ==0 ) + retval = nbytes; +out2: +cgroup_unlock (); +out1: +kfree (buffer); +return retval; +} + +static int cpuset_write_uint (struct cgroup *cgrp,struct cftype *cft,u64 val) +{ +int retval =0 ; +struct cpuset *cs =cgroup_cs (cgrp); +cpuset_filetype_t type = cft->private; + +cgroup_lock (); + +if (cgroup_is_removed (cgrp)) { +cgroup_unlock (); +return -ENODEV ; + } + +switch (type) {case FILE_CPU_EXCLUSIVE : - retval =update_flag (CS_CPU_EXCLUSIVE , cs, buffer); + retval =update_flag (CS_CPU_EXCLUSIVE , cs, val);break ;case FILE_MEM_EXCLUSIVE : - retval =update_flag (CS_MEM_EXCLUSIVE , cs, buffer); + retval =update_flag (CS_MEM_EXCLUSIVE , cs, val);break ;case FILE_SCHED_LOAD_BALANCE : - retval =update_flag (CS_SCHED_LOAD_BALANCE , cs, buffer); + retval =update_flag (CS_SCHED_LOAD_BALANCE , cs, val);break ;case FILE_MEMORY_MIGRATE : - retval =update_flag (CS_MEMORY_MIGRATE , cs, buffer); + retval =update_flag (CS_MEMORY_MIGRATE , cs, val);break ;case FILE_MEMORY_PRESSURE_ENABLED : - retval =update_memory_pressure_enabled (cs, buffer); + cpuset_memory_pressure_enabled = val;break ;case FILE_MEMORY_PRESSURE : retval = -EACCES ;break ;case FILE_SPREAD_PAGE : - retval =update_flag (CS_SPREAD_PAGE , cs, buffer); + retval =update_flag (CS_SPREAD_PAGE , cs, val); cs->mems_generation = cpuset_mems_generation++;break ;case FILE_SPREAD_SLAB : - retval =update_flag (CS_SPREAD_SLAB , cs, buffer); + retval =update_flag (CS_SPREAD_SLAB , cs, val); cs->mems_generation = cpuset_mems_generation++;break ;default : retval = -EINVAL ; - goto out2; +break ; } - -if (retval ==0 ) - retval = nbytes; -out2:cgroup_unlock (); -out1: -kfree (buffer); -return retval; +return -EINVAL ; }/*
@@ -1345,30 +1352,6 @@ static ssize_t cpuset_common_file_read(scase FILE_MEMLIST : s +=cpuset_sprintf_memlist (s, cs);break ; -case FILE_CPU_EXCLUSIVE : - *s++ =is_cpu_exclusive (cs) ?'1' :'0' ; -break ; -case FILE_MEM_EXCLUSIVE : - *s++ =is_mem_exclusive (cs) ?'1' :'0' ; -break ; -case FILE_SCHED_LOAD_BALANCE : - *s++ =is_sched_load_balance (cs) ?'1' :'0' ; -break ; -case FILE_MEMORY_MIGRATE : - *s++ =is_memory_migrate (cs) ?'1' :'0' ; -break ; -case FILE_MEMORY_PRESSURE_ENABLED : - *s++ = cpuset_memory_pressure_enabled ?'1' :'0' ; -break ; -case FILE_MEMORY_PRESSURE : - s +=sprintf (s,"%d" ,fmeter_getrate (&cs->fmeter)); -break ; -case FILE_SPREAD_PAGE : - *s++ =is_spread_page (cs) ?'1' :'0' ; -break ; -case FILE_SPREAD_SLAB : - *s++ =is_spread_slab (cs) ?'1' :'0' ; -break ;default : retval = -EINVAL ; goto out;
@@ -1381,8 +1364,32 @@ out:return retval; } - - +static u64 cpuset_read_uint (struct cgroup *cont,struct cftype *cft) +{ +struct cpuset *cs =cgroup_cs (cont); +cpuset_filetype_t type = cft->private; +switch (type) { +case FILE_CPU_EXCLUSIVE : +return is_cpu_exclusive (cs); +case FILE_MEM_EXCLUSIVE : +return is_mem_exclusive (cs); +case FILE_SCHED_LOAD_BALANCE : +return is_sched_load_balance (cs); +case FILE_MEMORY_MIGRATE : +return is_memory_migrate (cs); +case FILE_MEMORY_PRESSURE_ENABLED : +return cpuset_memory_pressure_enabled; +case FILE_MEMORY_PRESSURE : +return fmeter_getrate (&cs->fmeter); +break ; +case FILE_SPREAD_PAGE : +return is_spread_page (cs); +case FILE_SPREAD_SLAB : +return is_spread_slab (cs); +default : +BUG (); + } +}/*
@@ -1405,57 +1412,58 @@ static struct cftype cft_mems = {static struct cftype cft_cpu_exclusive = { .name ="cpu_exclusive" , - .read = cpuset_common_file_read, - .write = cpuset_common_file_write, + .read_uint = cpuset_read_uint, + .write_uint = cpuset_write_uint, .private =FILE_CPU_EXCLUSIVE , };static struct cftype cft_mem_exclusive = { .name ="mem_exclusive" , - .read = cpuset_common_file_read, - .write = cpuset_common_file_write, + .read_uint = cpuset_read_uint, + .write_uint = cpuset_write_uint, .private =FILE_MEM_EXCLUSIVE , };static struct cftype cft_sched_load_balance = { .name ="sched_load_balance" , - .read = cpuset_common_file_read, - .write = cpuset_common_file_write, + .read_uint = cpuset_read_uint, + .write_uint = cpuset_write_uint, .private =FILE_SCHED_LOAD_BALANCE , };static struct cftype cft_memory_migrate = { .name ="memory_migrate" , - .read = cpuset_common_file_read, - .write = cpuset_common_file_write, + .read_uint = cpuset_read_uint, + .read_uint = cpuset_read_uint, + .write_uint = cpuset_write_uint, .private =FILE_MEMORY_MIGRATE , };static struct cftype cft_memory_pressure_enabled = { .name ="memory_pressure_enabled" , - .read = cpuset_common_file_read, - .write = cpuset_common_file_write, + .read_uint = cpuset_read_uint, + .write_uint = cpuset_write_uint, .private =FILE_MEMORY_PRESSURE_ENABLED , };static struct cftype cft_memory_pressure = { .name ="memory_pressure" , - .read = cpuset_common_file_read, - .write = cpuset_common_file_write, + .read_uint = cpuset_read_uint, + .write_uint = cpuset_write_uint, .private =FILE_MEMORY_PRESSURE , };static struct cftype cft_spread_page = { .name ="memory_spread_page" , - .read = cpuset_common_file_read, - .write = cpuset_common_file_write, + .read_uint = cpuset_read_uint, + .write_uint = cpuset_write_uint, .private =FILE_SPREAD_PAGE , };static struct cftype cft_spread_slab = { .name ="memory_spread_slab" , - .read = cpuset_common_file_read, - .write = cpuset_common_file_write, + .read_uint = cpuset_read_uint, + .write_uint = cpuset_write_uint, .private =FILE_SPREAD_SLAB , };
@@ -1584,7 +1592,7 @@ static void cpuset_destroy(struct cgroupcpuset_update_task_memory_state ();if (is_sched_load_balance (cs)) -update_flag (CS_SCHED_LOAD_BALANCE , cs,"0" ); +update_flag (CS_SCHED_LOAD_BALANCE , cs,0 ); number_of_cpusets--;kfree (cs);
--
A message that is not in the archive (sent off-list or not yet received): 20080215204821.778088000-B63HFAS8fGlSzHKm+aFRNNkmqwFzkYv6@public.gmane.org
Re: [RFC][PATCH 7/7] CGroup API: Update cpusets to use cgroup structured file API
Ok ... this would (I suspect, just from code reading, no bytes were harmed in actual testing of this) have a minor change to how white space is handled writing integer flags to cpuset files, and a minor inconstency.
1) Existing cpuset code lets you set a flag (e.g. cpu_exclusive) by doing:
echo '1 rumplestiltskin' > cpu_exclusive # same as: echo 1 > cpu_exclusive
With this patch, that probably fails, EINVAL.
2) With this patch, one can write "1" or "1\n" to cpuset integer files, but one cannot successfully write "1\r\n" or "1 " or "1 \n". However, for the cpuset control files that take strings, not single integers, one -can- have any mix of trailing white space.
So far as I know, I have no requirement to write rumplestiltskin to cpuset files ;). So I'm content to let the minor change in (1) pass without further comment.
I'd like to recommend consideration of the following patch, to address the minor inconsistency of (2), and to save a few bytes of kernel text space.
=======
From: Paul Jackson <pj-sJ/[email protected]>
Strip all trailing whitespace (such as carriage returns) when parsing integer writes to cgroup files, not just one trailing newline if present.
--- kernel/cgroup.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
kernel/cgroup.c +1 -4
@@ -1321,10 +1321,7 @@ static ssize_t cgroup_write_uint(structreturn -EFAULT ; buffer[nbytes] =0 ;/* nul-terminate */ - -/* strip newline if necessary */ -if (nbytes && (buffer[nbytes-1 ] =='\n' )) - buffer[nbytes-1 ] =0 ; +strstrip (buffer);/* strip -just- trailing whitespace */ val =simple_strtoull (buffer, &end,0 );if (*end)return -EINVAL ;
Signature · 3 lines
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <pj-sJ/[email protected]> 1.940.382.4214Re: [RFC][PATCH 7/7] CGroup API: Update cpusets to use cgroup structured file API
In reply to Paul MenageOk ... this would (I suspect, just from code reading, no bytes were harmed in actual testing of this) have a minor change to how white space is handled writing integer flags to cpuset files, and a minor inconstency.
1) Existing cpuset code lets you set a flag (e.g. cpu_exclusive) by doing:
echo '1 rumplestiltskin' > cpu_exclusive # same as: echo 1 > cpu_exclusive
With this patch, that probably fails, EINVAL.
2) With this patch, one can write "1" or "1\n" to cpuset integer files, but one cannot successfully write "1\r\n" or "1 " or "1 \n". However, for the cpuset control files that take strings, not single integers, one -can- have any mix of trailing white space.
So far as I know, I have no requirement to write rumplestiltskin to cpuset files ;). So I'm content to let the minor change in (1) pass without further comment.
I'd like to recommend consideration of the following patch, to address the minor inconsistency of (2), and to save a few bytes of kernel text space.
=======
From: Paul Jackson <[email protected]>
Strip all trailing whitespace (such as carriage returns) when parsing integer writes to cgroup files, not just one trailing newline if present.
--- kernel/cgroup.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
kernel/cgroup.c +1 -4
@@ -1321,10 +1321,7 @@ static ssize_t cgroup_write_uint(structreturn -EFAULT ; buffer[nbytes] =0 ;/* nul-terminate */ - -/* strip newline if necessary */ -if (nbytes && (buffer[nbytes-1 ] =='\n' )) - buffer[nbytes-1 ] =0 ; +strstrip (buffer);/* strip -just- trailing whitespace */ val =simple_strtoull (buffer, &end,0 );if (*end)return -EINVAL ;
Signature · 3 lines
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <[email protected]> 1.940.382.4214A message that is not in the archive (sent off-list or not yet received): 20080216212901.70fe35ce.pj-sJ/[email protected]
Paul Menage
Acked-byRe: [RFC][PATCH 7/7] CGroup API: Update cpusets to use cgroup structured file API
Quoted 6 lines · Paul Jackson
From: Paul Jackson <pj-sJ/[email protected]>
Strip all trailing whitespace (such as carriage returns) when parsing integer writes to cgroup files, not just one trailing newline if present.
Sounds like a good idea to me. Thanks for this.
Quoted 3 lines
Signed-off-by Paul Jackson <pj-sJ/[email protected]>Cc Paul Menage <[email protected]>
Quoted 26 lines
--- kernel/cgroup.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)kernel/cgroup.c 2008-02-16 19:00:41.207478218 -0800 renamed from kernel/cgroup.c 2008-02-16 04:20:33.000000000 -0800 +1
-5@@ -1321,10 +1321,7 @@ static ssize_t cgroup_write_uint(struct return -EFAULT; buffer[nbytes] = 0; /* nul-terminate */ - - /* strip newline if necessary */ - if (nbytes && (buffer[nbytes-1] == '\n')) - buffer[nbytes-1] = 0; + strstrip(buffer); /* strip -just- trailing whitespace */ val = simple_strtoull(buffer, &end, 0); if (*end) return -EINVAL; -- I won't rest till it's the best ... Programmer, Linux Scalability Paul Jackson <pj-sJ/[email protected]> 1.940.382.4214
Re: [RFC][PATCH 7/7] CGroup API: Update cpusets to use cgroup structured file API
In reply to a message not in the archiveQuoted 14 lines · Paul Jackson
Ok ... this would (I suspect, just from code reading, no bytes were harmed in actual testing of this) have a minor change to how white space is handled writing integer flags to cpuset files, and a minor inconstency.
1) Existing cpuset code lets you set a flag (e.g.
cpu_exclusive) by doing:
echo '1 rumplestiltskin' >cpu_exclusive# same as: echo 1 >cpu_exclusive
With this patch, that probably fails, EINVAL.2) With this patch, one can write "1" or "1\n" to cpuset integer files, but one cannot successfully write "1\r\n" or "1 " or "1 \n". However, for the cpuset control files that take strings, not single integers, one -can- have any mix of trailing white space.
Quoted 6 lines
So far as I know, I have no requirement to write rumplestiltskin to cpuset files ;). So I'm content to let the minor change in (1) pass without further comment.
I'd like to recommend consideration of the following patch, to address the minor inconsistency of (2), and to save a few bytes of kernel text space.
For memory controller, we have to do this:
echo -n 4m > memory.limit_in_bytes
'-n' is necessary. This is another inconsistency..
Paul Menage
Acked-byRe: [RFC][PATCH 7/7] CGroup API: Update cpusets to use cgroup structured file API
In reply to Paul JacksonQuoted 6 lines · Paul Jackson
From: Paul Jackson <[email protected]>
Strip all trailing whitespace (such as carriage returns) when parsing integer writes to cgroup files, not just one trailing newline if present.
Sounds like a good idea to me. Thanks for this.
Quoted 3 lines
Signed-off-by Paul Jackson <[email protected]>Cc Paul Menage <[email protected]>
Quoted 26 lines
--- kernel/cgroup.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)kernel/cgroup.c 2008-02-16 19:00:41.207478218 -0800 renamed from kernel/cgroup.c 2008-02-16 04:20:33.000000000 -0800 +1
-5@@ -1321,10 +1321,7 @@ static ssize_t cgroup_write_uint(struct return -EFAULT; buffer[nbytes] = 0; /* nul-terminate */ - - /* strip newline if necessary */ - if (nbytes && (buffer[nbytes-1] == '\n')) - buffer[nbytes-1] = 0; + strstrip(buffer); /* strip -just- trailing whitespace */ val = simple_strtoull(buffer, &end, 0); if (*end) return -EINVAL; -- I won't rest till it's the best ... Programmer, Linux Scalability Paul Jackson <[email protected]> 1.940.382.4214
A message that is not in the archive (sent off-list or not yet received): 6599ad830802170918q4c748f7fs32e5b8ea63e49f15-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [RFC][PATCH 7/7] CGroup API: Update cpusets to use cgroup structured file API
Quoted 5 lines
Quoted 3 lines
Strip all trailing whitespace (such as carriage returns) when parsing integer writes to cgroup files, not just one trailing newline if present.
Sounds like a good idea to me. Thanks for this.
I'm figuring it would be easiest if you just threw this little change into your hopper for the bigger changes you're making ... no need to preserve my name as author of this.
But if you'd rather you or I send this separately to Andrew Morton, that works too.
Signature · 3 lines
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <pj-sJ/[email protected]> 1.940.382.4214Re: [RFC][PATCH 7/7] CGroup API: Update cpusets to use cgroup structured file API
In reply to Paul MenageQuoted 5 lines
Quoted 3 lines
Strip all trailing whitespace (such as carriage returns) when parsing integer writes to cgroup files, not just one trailing newline if present.
Sounds like a good idea to me. Thanks for this.
I'm figuring it would be easiest if you just threw this little change into your hopper for the bigger changes you're making ... no need to preserve my name as author of this.
But if you'd rather you or I send this separately to Andrew Morton, that works too.
Signature · 3 lines
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <[email protected]> 1.940.382.4214A message that is not in the archive (sent off-list or not yet received): 20080217112843.5496412d.pj-sJ/[email protected]
Re: [RFC][PATCH 7/7] CGroup API: Update cpusets to use cgroup structured file API
Quoted 4 lines · Paul Jackson
I'm figuring it would be easiest if you just threw this little change into your hopper for the bigger changes you're making
OK, will do.
Paul
Re: [RFC][PATCH 7/7] CGroup API: Update cpusets to use cgroup structured file API
In reply to Paul JacksonQuoted 4 lines · Paul Jackson
I'm figuring it would be easiest if you just threw this little change into your hopper for the bigger changes you're making
OK, will do.
Paul
Re: [RFC][PATCH 7/7] CGroup API: Update cpusets to use cgroup structured file API
In reply to Paul JacksonQuoted 14 lines · Paul Jackson
Ok ... this would (I suspect, just from code reading, no bytes were harmed in actual testing of this) have a minor change to how white space is handled writing integer flags to cpuset files, and a minor inconstency.
1) Existing cpuset code lets you set a flag (e.g.
cpu_exclusive) by doing:
echo '1 rumplestiltskin' >cpu_exclusive# same as: echo 1 >cpu_exclusive
With this patch, that probably fails, EINVAL.2) With this patch, one can write "1" or "1\n" to cpuset integer files, but one cannot successfully write "1\r\n" or "1 " or "1 \n". However, for the cpuset control files that take strings, not single integers, one -can- have any mix of trailing white space.
Quoted 6 lines
So far as I know, I have no requirement to write rumplestiltskin to cpuset files ;). So I'm content to let the minor change in (1) pass without further comment.
I'd like to recommend consideration of the following patch, to address the minor inconsistency of (2), and to save a few bytes of kernel text space.
For memory controller, we have to do this:
echo -n 4m > memory.limit_in_bytes
'-n' is necessary. This is another inconsistency..
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): 47B96805.7070002-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org
Re: [RFC][PATCH 7/7] CGroup API: Update cpusets to use cgroup structured file API
Quoted 19 lines · Balbir Singh
Quoted 18 lines · Li Zefan
Quoted 17 lines · Paul Jackson
Ok ... this would (I suspect, just from code reading, no bytes were harmed in actual testing of this) have a minor change to how white space is handled writing integer flags to cpuset files, and a minor inconstency.
1) Existing cpuset code lets you set a flag (e.g.
cpu_exclusive) by doing:
echo '1 rumplestiltskin' >cpu_exclusive# same as: echo 1 >cpu_exclusive
With this patch, that probably fails, EINVAL.2) With this patch, one can write "1" or "1\n" to cpuset integer files, but one cannot successfully write "1\r\n" or "1 " or "1 \n". However, for the cpuset control files that take strings, not single integers, one -can- have any mix of trailing white space.
So far as I know, I have no requirement to write rumplestiltskin to cpuset files ;). So I'm content to let the minor change in (1) pass without further comment.
Quoted 8 lines
Quoted 7 lines
Quoted 3 lines
I'd like to recommend consideration of the following patch, to address the minor inconsistency of (2), and to save a few bytes of kernel text space.
For memory controller, we have to do this:
echo -n 4m > memory.limit_in_bytes
'-n' is necessary. This is another inconsistency..
Hi. Li,
I have a similar patch that fixes the inconsistency.
It's attached below. Andrew, could we please consider this patch for -mm
The memory controller has a requirement that while writing values, we need to use echo -n. This patch fixes the problem and makes the UI more consistent.
---
Documentation/controllers/memory.txt | 8 ++++---- kernel/res_counter.c | 1 + 2 files changed, 5 insertions(+), 4 deletions(-)
diff -puN mm/memcontrol.c~memory-controller-fix-crlf-echo-issue mm/memcontrol.c
kernel/res_counter.c renamed from kernel/res_counter.c~memory-controller-fix-crlf-echo-issue +1 -0
@@ -113,6 +113,7 @@ ssize_t res_counter_write(struct res_cou ret = -EINVAL ; +strstrip (buf);if (write_strategy) {if (write_strategy (buf, &tmp)) { goto out_free;
Documentation/controllers/memory.txt renamed from Documentation/controllers/memory.txt~memory-controller-fix-crlf-echo-issue +4 -4
@@ -164,7 +164,7 @@ c. Enable CONFIG_CGROUP_MEM_CONT Since now we're in the 0 cgroup, We can alter the memory limit: -# echo -n 4M > /cgroups/0/memory.limit_in_bytes +# echo 4M > /cgroups/0/memory.limit_in_bytes NOTE: We can use a suffix (k, K, m, M, g or G) to indicate values in kilo, mega or gigabytes.
@@ -185,7 +185,7 @@ number of factors, such as rounding up t availability of memory on the system. The user is required to re-read this file after a write to guarantee the value committed by the kernel. -# echo -n 1 > memory.limit_in_bytes +# echo 1 > memory.limit_in_bytes # cat memory.limit_in_bytes 4096 Bytes
@@ -197,7 +197,7 @@ caches, RSS and Active pages/Inactive pa The memory.force_empty gives an interface to drop *all* charges by force. -# echo -n 1 > memory.force_empty +# echo 1 > memory.force_empty will drop all charges in cgroup. Currently, this is maintained for test.
@@ -238,7 +238,7 @@ rmdir() if there are no tasks. The type of memory accounted by the cgroup can be limited to just mapped pages by writing "1" to memory.control_type field -echo -n 1 > memory.control_type +echo > memory.control_type 5. TODO
_
Signature · 4 lines
Warm Regards, Balbir Singh Linux Technology Center IBM, ISTL
Re: [RFC][PATCH 7/7] CGroup API: Update cpusets to use cgroup structured file API
In reply to a message not in the archiveQuoted 19 lines · Balbir Singh
Quoted 18 lines · Li Zefan
Quoted 17 lines · Paul Jackson
Ok ... this would (I suspect, just from code reading, no bytes were harmed in actual testing of this) have a minor change to how white space is handled writing integer flags to cpuset files, and a minor inconstency.
1) Existing cpuset code lets you set a flag (e.g.
cpu_exclusive) by doing:
echo '1 rumplestiltskin' >cpu_exclusive# same as: echo 1 >cpu_exclusive
With this patch, that probably fails, EINVAL.2) With this patch, one can write "1" or "1\n" to cpuset integer files, but one cannot successfully write "1\r\n" or "1 " or "1 \n". However, for the cpuset control files that take strings, not single integers, one -can- have any mix of trailing white space.
So far as I know, I have no requirement to write rumplestiltskin to cpuset files ;). So I'm content to let the minor change in (1) pass without further comment.
Quoted 8 lines
Quoted 7 lines
Quoted 3 lines
I'd like to recommend consideration of the following patch, to address the minor inconsistency of (2), and to save a few bytes of kernel text space.
For memory controller, we have to do this:
echo -n 4m > memory.limit_in_bytes
'-n' is necessary. This is another inconsistency..
Hi. Li,
I have a similar patch that fixes the inconsistency.
It's attached below. Andrew, could we please consider this patch for -mm
The memory controller has a requirement that while writing values, we need to use echo -n. This patch fixes the problem and makes the UI more consistent.
---
Documentation/controllers/memory.txt | 8 ++++---- kernel/res_counter.c | 1 + 2 files changed, 5 insertions(+), 4 deletions(-)
diff -puN mm/memcontrol.c~memory-controller-fix-crlf-echo-issue mm/memcontrol.c
kernel/res_counter.c renamed from kernel/res_counter.c~memory-controller-fix-crlf-echo-issue +1 -0
@@ -113,6 +113,7 @@ ssize_t res_counter_write(struct res_cou ret = -EINVAL ; +strstrip (buf);if (write_strategy) {if (write_strategy (buf, &tmp)) { goto out_free;
Documentation/controllers/memory.txt renamed from Documentation/controllers/memory.txt~memory-controller-fix-crlf-echo-issue +4 -4
@@ -164,7 +164,7 @@ c. Enable CONFIG_CGROUP_MEM_CONT Since now we're in the 0 cgroup, We can alter the memory limit: -# echo -n 4M > /cgroups/0/memory.limit_in_bytes +# echo 4M > /cgroups/0/memory.limit_in_bytes NOTE: We can use a suffix (k, K, m, M, g or G) to indicate values in kilo, mega or gigabytes.
@@ -185,7 +185,7 @@ number of factors, such as rounding up t availability of memory on the system. The user is required to re-read this file after a write to guarantee the value committed by the kernel. -# echo -n 1 > memory.limit_in_bytes +# echo 1 > memory.limit_in_bytes # cat memory.limit_in_bytes 4096 Bytes
@@ -197,7 +197,7 @@ caches, RSS and Active pages/Inactive pa The memory.force_empty gives an interface to drop *all* charges by force. -# echo -n 1 > memory.force_empty +# echo 1 > memory.force_empty will drop all charges in cgroup. Currently, this is maintained for test.
@@ -238,7 +238,7 @@ rmdir() if there are no tasks. The type of memory accounted by the cgroup can be limited to just mapped pages by writing "1" to memory.control_type field -echo -n 1 > memory.control_type +echo > memory.control_type 5. TODO
_
Signature · 4 lines
Warm Regards, Balbir Singh Linux Technology Center IBM, ISTL
A message that is not in the archive (sent off-list or not yet received): 20080218111333.GA6333-SINUvgVNF2CyUtPGxGje5AC/[email protected]
Re: [RFC][PATCH 7/7] CGroup API: Update cpusets to use cgroup structured file API
Documentation/controllers/memory.txt rmdir() if there are no tasks. · line 241
Quoted 6 lines · Balbir Singh
Documentation/controllers/memory.txt renamed from Documentation/controllers/memory.txt~memory-controller-fix-crlf-echo-issue +1
-1@@ -238,7 +238,7 @@ rmdir() if there are no tasks. The type of memory accounted by the cgroup can be limited to just mapped pages by writing "1" to memory.control_type field -echo -n 1 > memory.control_type +echo > memory.control_type
Looks like you stripped too much here.
Andreas.
Signature · 4 lines
Andreas Schwab, SuSE Labs, [email protected] SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
Re: [RFC][PATCH 7/7] CGroup API: Update cpusets to use cgroup structured file API
In reply to Balbir SinghDocumentation/controllers/memory.txt rmdir() if there are no tasks. · line 241
Quoted 6 lines · Balbir Singh
Documentation/controllers/memory.txt renamed from Documentation/controllers/memory.txt~memory-controller-fix-crlf-echo-issue +1
-1@@ -238,7 +238,7 @@ rmdir() if there are no tasks. The type of memory accounted by the cgroup can be limited to just mapped pages by writing "1" to memory.control_type field -echo -n 1 > memory.control_type +echo > memory.control_type
Looks like you stripped too much here.
Andreas.
Signature · 4 lines
Andreas Schwab, SuSE Labs, [email protected] SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): 47B971C6.4080807-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org
Re: [RFC][PATCH 7/7] CGroup API: Update cpusets to use cgroup structured file API
Quoted 7 lines · Balbir Singh
Quoted 6 lines · Andreas Schwab
Quoted 4 lines · Balbir Singh
(quoted diff) +0
-0@@ -238,7 +238,7 @@ rmdir() if there are no tasks. The type of memory accounted by the cgroup can be limited to just mapped pages by writing "1" to memory.control_type field
Quoted 8 lines
Quoted 7 lines
Review rmdir() if there are no tasks. · line 241
Quoted 2 lines
(quoted diff) +1
-1-echo -n 1 > memory.control_type +echo > memory.control_typeLooks like you stripped too much here.
Andreas.
Yikes,
The control type feature documentation needs to go away and Li has a patch for it, so I'll not touch that part. Here's the updated patch. Thanks for catching this Andreas.
The memory controller has a requirement that while writing values, we need to use echo -n. This patch fixes the problem and makes the UI more consistent.
---
Documentation/controllers/memory.txt | 6 +++--- kernel/res_counter.c | 1 + 2 files changed, 4 insertions(+), 3 deletions(-)
diff -puN mm/memcontrol.c~memory-controller-fix-crlf-echo-issue mm/memcontrol.c
kernel/res_counter.c renamed from kernel/res_counter.c~memory-controller-fix-crlf-echo-issue +1 -0
@@ -113,6 +113,7 @@ ssize_t res_counter_write(struct res_cou ret = -EINVAL ; +strstrip (buf);if (write_strategy) {if (write_strategy (buf, &tmp)) { goto out_free;
Documentation/controllers/memory.txt renamed from Documentation/controllers/memory.txt~memory-controller-fix-crlf-echo-issue +3 -3
@@ -164,7 +164,7 @@ c. Enable CONFIG_CGROUP_MEM_CONT Since now we're in the 0 cgroup, We can alter the memory limit: -# echo -n 4M > /cgroups/0/memory.limit_in_bytes +# echo 4M > /cgroups/0/memory.limit_in_bytes NOTE: We can use a suffix (k, K, m, M, g or G) to indicate values in kilo, mega or gigabytes.
@@ -185,7 +185,7 @@ number of factors, such as rounding up t availability of memory on the system. The user is required to re-read this file after a write to guarantee the value committed by the kernel. -# echo -n 1 > memory.limit_in_bytes +# echo 1 > memory.limit_in_bytes # cat memory.limit_in_bytes 4096 Bytes
@@ -197,7 +197,7 @@ caches, RSS and Active pages/Inactive pa The memory.force_empty gives an interface to drop *all* charges by force. -# echo -n 1 > memory.force_empty +# echo 1 > memory.force_empty will drop all charges in cgroup. Currently, this is maintained for test.
_
Signature · 4 lines
Warm Regards, Balbir Singh Linux Technology Center IBM, ISTL
Re: [RFC][PATCH 7/7] CGroup API: Update cpusets to use cgroup structured file API
In reply to a message not in the archiveQuoted 7 lines · Balbir Singh
Quoted 6 lines · Andreas Schwab
Quoted 4 lines · Balbir Singh
(quoted diff) +0
-0@@ -238,7 +238,7 @@ rmdir() if there are no tasks. The type of memory accounted by the cgroup can be limited to just mapped pages by writing "1" to memory.control_type field
Quoted 8 lines
Quoted 7 lines
Review rmdir() if there are no tasks. · line 241
Quoted 2 lines
(quoted diff) +1
-1-echo -n 1 > memory.control_type +echo > memory.control_typeLooks like you stripped too much here.
Andreas.
Yikes,
The control type feature documentation needs to go away and Li has a patch for it, so I'll not touch that part. Here's the updated patch. Thanks for catching this Andreas.
The memory controller has a requirement that while writing values, we need to use echo -n. This patch fixes the problem and makes the UI more consistent.
---
Documentation/controllers/memory.txt | 6 +++--- kernel/res_counter.c | 1 + 2 files changed, 4 insertions(+), 3 deletions(-)
diff -puN mm/memcontrol.c~memory-controller-fix-crlf-echo-issue mm/memcontrol.c
kernel/res_counter.c renamed from kernel/res_counter.c~memory-controller-fix-crlf-echo-issue +1 -0
@@ -113,6 +113,7 @@ ssize_t res_counter_write(struct res_cou ret = -EINVAL ; +strstrip (buf);if (write_strategy) {if (write_strategy (buf, &tmp)) { goto out_free;
Documentation/controllers/memory.txt renamed from Documentation/controllers/memory.txt~memory-controller-fix-crlf-echo-issue +3 -3
@@ -164,7 +164,7 @@ c. Enable CONFIG_CGROUP_MEM_CONT Since now we're in the 0 cgroup, We can alter the memory limit: -# echo -n 4M > /cgroups/0/memory.limit_in_bytes +# echo 4M > /cgroups/0/memory.limit_in_bytes NOTE: We can use a suffix (k, K, m, M, g or G) to indicate values in kilo, mega or gigabytes.
@@ -185,7 +185,7 @@ number of factors, such as rounding up t availability of memory on the system. The user is required to re-read this file after a write to guarantee the value committed by the kernel. -# echo -n 1 > memory.limit_in_bytes +# echo 1 > memory.limit_in_bytes # cat memory.limit_in_bytes 4096 Bytes
@@ -197,7 +197,7 @@ caches, RSS and Active pages/Inactive pa The memory.force_empty gives an interface to drop *all* charges by force. -# echo -n 1 > memory.force_empty +# echo 1 > memory.force_empty will drop all charges in cgroup. Currently, this is maintained for test.
_
Signature · 4 lines
Warm Regards, Balbir Singh Linux Technology Center IBM, ISTL
Quoted 13 lines · On Fri, 15 Feb 2008 12:44:18 -0800 Paul Menage <[email protected]> wrote:
This set of patches makes the Control Groups API more structured and self-describing.
1) Allows control files to be associated with data types such as "u64", "string", "map", etc. These types show up in a new cgroup.api file in each cgroup directory, along with a user-readable string. Files that use cgroup-provided data accessors have these file types inferred automatically.
2) Moves various files in cpusets and the memory controller from using custom-written file handlers to cgroup-defined handlers
Quoted 12 lines
3) Adds the "cgroup." prefix for existing cgroup-provided control files (tasks,
release_agent, releasable,notify_on_release). Given than we've already had 2.6.24 go out without this prefix, I guess this could be a little contentious - but it seems like a good move to prevent name clashes in the future. (Note that this doesn't affect mounting the legacy cpuset filesystem, since the compatibility layer disables all prefixes when mounted with filesystem type "cpuset"). If people object too strongly, we could just make this the case for *new* cgroup API files, but I think this is a case where consistency would be better than compatibility - I'd be surprised if anyone has written major legacy apps yet that rely on 2.6.24 cgroup control file names.
Hi, I like this direction very much. thank you for your work. Self-describing cgroup.api file is a good idea!
One request from me is add "mode" bit to cftype for allowing write-only/read-only files.
Thanks,
-Kame
A message that is not in the archive (sent off-list or not yet received): 20080216132118.877e769b.kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org
Quoted 29 lines · KAMEZAWA Hiroyuki
Quoted 12 lines · On Fri, 15 Feb 2008 12:44:18 -0800 Paul Menage…
This set of patches makes the Control Groups API more structured and self-describing.
1) Allows control files to be associated with data types such as "u64", "string", "map", etc. These types show up in a new cgroup.api file in each cgroup directory, along with a user-readable string. Files that use cgroup-provided data accessors have these file types inferred automatically.
2) Moves various files in cpusets and the memory controller from using custom-written file handlers to cgroup-defined handlers
Quoted 12 lines
3) Adds the "cgroup." prefix for existing cgroup-provided control files (tasks,
release_agent, releasable,notify_on_release). Given than we've already had 2.6.24 go out without this prefix, I guess this could be a little contentious - but it seems like a good move to prevent name clashes in the future. (Note that this doesn't affect mounting the legacy cpuset filesystem, since the compatibility layer disables all prefixes when mounted with filesystem type "cpuset"). If people object too strongly, we could just make this the case for *new* cgroup API files, but I think this is a case where consistency would be better than compatibility - I'd be surprised if anyone has written major legacy apps yet that rely on 2.6.24 cgroup control file names.
Quoted 9 lines
Hi, I like this direction very much. thank you for your work. Self-describing cgroup.api file is a good idea!
One request from me is add "mode" bit to cftype for allowing write-only/read-only files.
Thanks,
-Kame
I don't quite catch what you mean. Cgoup does support write-only/read-only files. For a write-only file, just set .write and .write_uint to be NULL, similar for a read-only file.
Do I miss something?
Quoted 29 lines · KAMEZAWA Hiroyuki
Quoted 12 lines · On Fri, 15 Feb 2008 12:44:18 -0800 Paul Menage <[email protected]> wrote:
This set of patches makes the Control Groups API more structured and self-describing.
1) Allows control files to be associated with data types such as "u64", "string", "map", etc. These types show up in a new cgroup.api file in each cgroup directory, along with a user-readable string. Files that use cgroup-provided data accessors have these file types inferred automatically.
2) Moves various files in cpusets and the memory controller from using custom-written file handlers to cgroup-defined handlers
Quoted 12 lines
3) Adds the "cgroup." prefix for existing cgroup-provided control files (tasks,
release_agent, releasable,notify_on_release). Given than we've already had 2.6.24 go out without this prefix, I guess this could be a little contentious - but it seems like a good move to prevent name clashes in the future. (Note that this doesn't affect mounting the legacy cpuset filesystem, since the compatibility layer disables all prefixes when mounted with filesystem type "cpuset"). If people object too strongly, we could just make this the case for *new* cgroup API files, but I think this is a case where consistency would be better than compatibility - I'd be surprised if anyone has written major legacy apps yet that rely on 2.6.24 cgroup control file names.
Quoted 9 lines
Hi, I like this direction very much. thank you for your work. Self-describing cgroup.api file is a good idea!
One request from me is add "mode" bit to cftype for allowing write-only/read-only files.
Thanks,
-Kame
I don't quite catch what you mean. Cgoup does support write-only/read-only files. For a write-only file, just set .write and .write_uint to be NULL, similar for a read-only file.
Do I miss something?
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 7 lines · Li Zefan
I don't quite catch what you mean. Cgoup does support write-only/read-only files. For a write-only file, just set .write and .write_uint to be NULL, similar for a read-only file.
Do I miss something?
I suppose we could infer from the lack of any write handlers that we should give the file in the filesystem a mode of 444 rather 644.
Paul
Quoted 7 lines · Li Zefan
I don't quite catch what you mean. Cgoup does support write-only/read-only files. For a write-only file, just set .write and .write_uint to be NULL, similar for a read-only file.
Do I miss something?
I suppose we could infer from the lack of any write handlers that we should give the file in the filesystem a mode of 444 rather 644.
Paul
A message that is not in the archive (sent off-list or not yet received): 20080215204418.535025000-B63HFAS8fGlSzHKm+aFRNNkmqwFzkYv6@public.gmane.org
Quoted 13 lines · On Fri, 15 Feb 2008 12:44:18 -0800 Paul Menage…
This set of patches makes the Control Groups API more structured and self-describing.
1) Allows control files to be associated with data types such as "u64", "string", "map", etc. These types show up in a new cgroup.api file in each cgroup directory, along with a user-readable string. Files that use cgroup-provided data accessors have these file types inferred automatically.
2) Moves various files in cpusets and the memory controller from using custom-written file handlers to cgroup-defined handlers
Quoted 12 lines
3) Adds the "cgroup." prefix for existing cgroup-provided control files (tasks,
release_agent, releasable,notify_on_release). Given than we've already had 2.6.24 go out without this prefix, I guess this could be a little contentious - but it seems like a good move to prevent name clashes in the future. (Note that this doesn't affect mounting the legacy cpuset filesystem, since the compatibility layer disables all prefixes when mounted with filesystem type "cpuset"). If people object too strongly, we could just make this the case for *new* cgroup API files, but I think this is a case where consistency would be better than compatibility - I'd be surprised if anyone has written major legacy apps yet that rely on 2.6.24 cgroup control file names.
Hi, I like this direction very much. thank you for your work. Self-describing cgroup.api file is a good idea!
One request from me is add "mode" bit to cftype for allowing write-only/read-only files.
Thanks,
-Kame