LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 1/3] res_counter: introduce res_counter_write_u64()
@ 2008-03-11 10:08 Li Zefan
  2008-03-11 10:21 ` KAMEZAWA Hiroyuki
  0 siblings, 1 reply; 3+ messages in thread
From: Li Zefan @ 2008-03-11 10:08 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Balbir Singh, KAMEZAWA Hiroyuki, Pavel Emelianov, Paul Menage,
	LKML, linux-mm, Linux Containers

This function can be used to assign the value of a resource counter member.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
 include/linux/res_counter.h |    9 ++++++---
 kernel/res_counter.c        |    9 +++++++++
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/include/linux/res_counter.h b/include/linux/res_counter.h
index 8cb1ecd..8c23f7f 100644
--- a/include/linux/res_counter.h
+++ b/include/linux/res_counter.h
@@ -41,9 +41,10 @@ struct res_counter {
 
 /**
  * Helpers to interact with userspace
- * res_counter_read_u64() - returns the value of the specified member.
- * res_counter_read/_write - put/get the specified fields from the
- * res_counter struct to/from the user
+ * res_counter_read_64/_write_u64 - returns/assigns the value of the
+ *	specified member
+ * res_counter_read/_write - puts/gets the specified fields from the
+ *	res_counter struct to/from the user
  *
  * @counter:     the counter in question
  * @member:  the field to work with (see RES_xxx below)
@@ -53,6 +54,8 @@ struct res_counter {
  */
 
 u64 res_counter_read_u64(struct res_counter *counter, int member);
+void res_counter_write_u64(struct res_counter *counter, int member,
+			   unsigned long long val);
 
 ssize_t res_counter_read(struct res_counter *counter, int member,
 		const char __user *buf, size_t nbytes, loff_t *pos,
diff --git a/kernel/res_counter.c b/kernel/res_counter.c
index 791ff2b..a16b727 100644
--- a/kernel/res_counter.c
+++ b/kernel/res_counter.c
@@ -97,6 +97,15 @@ u64 res_counter_read_u64(struct res_counter *counter, int member)
 	return *res_counter_member(counter, member);
 }
 
+void res_counter_write_u64(struct res_counter *counter, int member,
+			   unsigned long long val)
+{
+	unsigned long long *tmp;
+
+	tmp = res_counter_member(counter, member);
+	*tmp = val;
+}
+
 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))
-- 
1.5.4.rc3


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/3] res_counter: introduce res_counter_write_u64()
  2008-03-11 10:08 [PATCH 1/3] res_counter: introduce res_counter_write_u64() Li Zefan
@ 2008-03-11 10:21 ` KAMEZAWA Hiroyuki
  2008-03-13 23:34   ` Li Zefan
  0 siblings, 1 reply; 3+ messages in thread
From: KAMEZAWA Hiroyuki @ 2008-03-11 10:21 UTC (permalink / raw)
  To: Li Zefan
  Cc: Andrew Morton, Balbir Singh, Pavel Emelianov, Paul Menage, LKML,
	linux-mm, Linux Containers

On Tue, 11 Mar 2008 19:08:39 +0900
Li Zefan <lizf@cn.fujitsu.com> wrote:

> This function can be used to assign the value of a resource counter member.
> 
Why don't you make this function to do the same work as res_counter_write() ?

Thanks,
-Kame


> Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
> ---
>  include/linux/res_counter.h |    9 ++++++---
>  kernel/res_counter.c        |    9 +++++++++
>  2 files changed, 15 insertions(+), 3 deletions(-)
> 
> diff --git a/include/linux/res_counter.h b/include/linux/res_counter.h
> index 8cb1ecd..8c23f7f 100644
> --- a/include/linux/res_counter.h
> +++ b/include/linux/res_counter.h
> @@ -41,9 +41,10 @@ struct res_counter {
>  
>  /**
>   * Helpers to interact with userspace
> - * res_counter_read_u64() - returns the value of the specified member.
> - * res_counter_read/_write - put/get the specified fields from the
> - * res_counter struct to/from the user
> + * res_counter_read_64/_write_u64 - returns/assigns the value of the
> + *	specified member
> + * res_counter_read/_write - puts/gets the specified fields from the
> + *	res_counter struct to/from the user
>   *
>   * @counter:     the counter in question
>   * @member:  the field to work with (see RES_xxx below)
> @@ -53,6 +54,8 @@ struct res_counter {
>   */
>  
>  u64 res_counter_read_u64(struct res_counter *counter, int member);
> +void res_counter_write_u64(struct res_counter *counter, int member,
> +			   unsigned long long val);
>  
>  ssize_t res_counter_read(struct res_counter *counter, int member,
>  		const char __user *buf, size_t nbytes, loff_t *pos,
> diff --git a/kernel/res_counter.c b/kernel/res_counter.c
> index 791ff2b..a16b727 100644
> --- a/kernel/res_counter.c
> +++ b/kernel/res_counter.c
> @@ -97,6 +97,15 @@ u64 res_counter_read_u64(struct res_counter *counter, int member)
>  	return *res_counter_member(counter, member);
>  }
>  
> +void res_counter_write_u64(struct res_counter *counter, int member,
> +			   unsigned long long val)
> +{
> +	unsigned long long *tmp;
> +
> +	tmp = res_counter_member(counter, member);
> +	*tmp = val;
> +}
> +
>  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))
> -- 
> 1.5.4.rc3
> 
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@kvack.org.  For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/3] res_counter: introduce res_counter_write_u64()
  2008-03-11 10:21 ` KAMEZAWA Hiroyuki
@ 2008-03-13 23:34   ` Li Zefan
  0 siblings, 0 replies; 3+ messages in thread
From: Li Zefan @ 2008-03-13 23:34 UTC (permalink / raw)
  To: KAMEZAWA Hiroyuki
  Cc: Andrew Morton, Balbir Singh, Pavel Emelianov, Paul Menage, LKML,
	linux-mm, Linux Containers

KAMEZAWA Hiroyuki wrote:
> On Tue, 11 Mar 2008 19:08:39 +0900
> Li Zefan <lizf@cn.fujitsu.com> wrote:
> 
>> This function can be used to assign the value of a resource counter member.
>>
> Why don't you make this function to do the same work as res_counter_write() ?
> 

You mean to deal with write strategy? We don't need that complexity. If it does
the same work as res_counter_write(), it's just a redundant function. ;)

But I forgot to take res_counter->lock ...

> Thanks,
> -Kame
> 
> 
>> Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
>> ---
>>  include/linux/res_counter.h |    9 ++++++---
>>  kernel/res_counter.c        |    9 +++++++++
>>  2 files changed, 15 insertions(+), 3 deletions(-)
>>
>> diff --git a/include/linux/res_counter.h b/include/linux/res_counter.h
>> index 8cb1ecd..8c23f7f 100644
>> --- a/include/linux/res_counter.h
>> +++ b/include/linux/res_counter.h
>> @@ -41,9 +41,10 @@ struct res_counter {
>>  
>>  /**
>>   * Helpers to interact with userspace
>> - * res_counter_read_u64() - returns the value of the specified member.
>> - * res_counter_read/_write - put/get the specified fields from the
>> - * res_counter struct to/from the user
>> + * res_counter_read_64/_write_u64 - returns/assigns the value of the
>> + *	specified member
>> + * res_counter_read/_write - puts/gets the specified fields from the
>> + *	res_counter struct to/from the user
>>   *
>>   * @counter:     the counter in question
>>   * @member:  the field to work with (see RES_xxx below)
>> @@ -53,6 +54,8 @@ struct res_counter {
>>   */
>>  
>>  u64 res_counter_read_u64(struct res_counter *counter, int member);
>> +void res_counter_write_u64(struct res_counter *counter, int member,
>> +			   unsigned long long val);
>>  
>>  ssize_t res_counter_read(struct res_counter *counter, int member,
>>  		const char __user *buf, size_t nbytes, loff_t *pos,
>> diff --git a/kernel/res_counter.c b/kernel/res_counter.c
>> index 791ff2b..a16b727 100644
>> --- a/kernel/res_counter.c
>> +++ b/kernel/res_counter.c
>> @@ -97,6 +97,15 @@ u64 res_counter_read_u64(struct res_counter *counter, int member)
>>  	return *res_counter_member(counter, member);
>>  }
>>  
>> +void res_counter_write_u64(struct res_counter *counter, int member,
>> +			   unsigned long long val)
>> +{
>> +	unsigned long long *tmp;
>> +
>> +	tmp = res_counter_member(counter, member);
>> +	*tmp = val;
>> +}
>> +
>>  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))
>> -- 
>> 1.5.4.rc3
>>
>> --
>> To unsubscribe, send a message with 'unsubscribe linux-mm' in
>> the body to majordomo@kvack.org.  For more info on Linux MM,
>> see: http://www.linux-mm.org/ .
>> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
>>
> 
> 
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-03-13 23:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-11 10:08 [PATCH 1/3] res_counter: introduce res_counter_write_u64() Li Zefan
2008-03-11 10:21 ` KAMEZAWA Hiroyuki
2008-03-13 23:34   ` Li Zefan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).