linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Balbir Singh <balbir@linux.vnet.ibm.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: yamamoto@valinux.co.jp, menage@google.com,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	kamezawa.hiroyu@jp.fujitsu.com
Subject: Re: [1/2] memrlimit handle attach_task() failure, add can_attach() callback
Date: Thu, 26 Jun 2008 05:22:18 +0530	[thread overview]
Message-ID: <4862DA32.2070102@linux.vnet.ibm.com> (raw)
In-Reply-To: <20080625163753.6039c46b.akpm@linux-foundation.org>

Andrew Morton wrote:
> On Fri, 20 Jun 2008 20:31:42 +0530
> Balbir Singh <balbir@linux.vnet.ibm.com> wrote:
> 
>> +/*
>> + * Add the value val to the resource counter and check if we are
>> + * still under the limit.
>> + */
>> +static inline bool res_counter_add_check(struct res_counter *cnt,
>> +						unsigned long val)
>> +{
>> +	bool ret = false;
>> +	unsigned long flags;
>> +
>> +	spin_lock_irqsave(&cnt->lock, flags);
>> +	if (cnt->usage + val <= cnt->limit)
>> +		ret = true;
>> +	spin_unlock_irqrestore(&cnt->lock, flags);
>> +	return ret;
>> +}
> 
> The comment and the function name imply that thins function will "Add
> the value val to the resource counter".  But it doesn't do that at all.
> In fact the first arg could be a `const struct res_counter *'.
> 
> Perhaps res_counter_can_add() would be more accurate.

Will fix both problems and send out fixes. I intended to call it
res_counter_check_and_add(), but I don't like "and" in function names.
res_counter_can_add is definitely better.


-- 
	Warm Regards,
	Balbir Singh
	Linux Technology Center
	IBM, ISTL

--
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>

  reply	other threads:[~2008-06-25 23:52 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-20 15:01 [0/2] memrlimit improve error handling Balbir Singh
2008-06-20 15:01 ` [1/2] memrlimit handle attach_task() failure, add can_attach() callback Balbir Singh
2008-06-25 23:37   ` Andrew Morton
2008-06-25 23:52     ` Balbir Singh [this message]
2008-06-20 15:01 ` [2/2] memrlimit fix usage of tmp as a parameter name Balbir Singh
2008-06-25 23:41   ` Andrew Morton
2008-06-25 23:51     ` Balbir Singh
2008-06-24 23:11 ` [0/2] memrlimit improve error handling Hugh Dickins
2008-06-25  1:01   ` Balbir Singh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4862DA32.2070102@linux.vnet.ibm.com \
    --to=balbir@linux.vnet.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=menage@google.com \
    --cc=yamamoto@valinux.co.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox