linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Balbir Singh <balbir@linux.vnet.ibm.com>
To: Alexey Dobriyan <adobriyan@sw.ru>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Nick Piggin <npiggin@suse.de>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Dhaval Giani <dhaval@linux.vnet.ibm.com>,
	YAMAMOTO Takashi <yamamoto@valinux.co.jp>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linux MM Mailing List <linux-mm@kvack.org>,
	Linux Containers <containers@lists.osdl.org>
Subject: Re: [Devel] [-mm PATCH 1/9] Memory controller resource counters (v6)
Date: Mon, 20 Aug 2007 14:31:51 +0530	[thread overview]
Message-ID: <46C9587F.8000402@linux.vnet.ibm.com> (raw)
In-Reply-To: <20070820082054.GA6926@localhost.sw.ru>

Alexey Dobriyan wrote:
> On Fri, Aug 17, 2007 at 02:12:38PM +0530, Balbir Singh wrote:
>> --- /dev/null
>> +++ linux-2.6.23-rc2-mm2-balbir/kernel/res_counter.c
>> +void res_counter_init(struct res_counter *counter)
>> +{
>> +	spin_lock_init(&counter->lock);
>> +	counter->limit = (unsigned long)LONG_MAX;
> 
> why cast?
> 

These patches come from Pavel. They add to readability since
limit is unsigned long.

>> +int res_counter_charge_locked(struct res_counter *counter, unsigned long val)
>> +{
>> +	if (counter->usage > (counter->limit - val)) {
> 
> () aren't needed.
> 

it makes the code more readable

>> +	if (WARN_ON(counter->usage < val))
>> +		val = counter->usage;
> 
> explicit if and WARN_ON(1) is clearer. I should send a patch banning such
> type of usage soon.
> 

We had a WARN_ON(1) before, but we changed it in v2 or v3 based on review
comments from Dave. I think WARN_ON(cond) is more readable than
WARN_ON(1) for the same reason as BUG_ON(cond) vs BUG_ON(1)

>> +	buf = kmalloc(nbytes + 1, GFP_KERNEL);
> 
> please, switch to fixed buffer, allocating memory depending on size
> told by userspace will beat later. Ditto for other proc writing
> functions.
> 

I agree with you in part, but the size of user input is not fixed.
Setting a fixed limit seems artificial, I'll see how this can be improved.


Thanks for the detailed review comments,

-- 
	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:[~2007-08-20  9:05 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-17  8:42 [-mm PATCH 0/9] Memory controller introduction (v6) Balbir Singh
2007-08-17  8:42 ` [-mm PATCH 1/9] Memory controller resource counters (v6) Balbir Singh
2007-08-20  8:20   ` [Devel] " Alexey Dobriyan
2007-08-20  9:01     ` Balbir Singh [this message]
2007-09-11  0:42   ` Paul Menage
2007-09-12 10:05     ` Balbir Singh
2007-08-17  8:42 ` [-mm PATCH 2/9] Memory controller containers setup (v6) Balbir Singh
2007-08-17  8:42 ` [-mm PATCH 3/9] Memory controller accounting " Balbir Singh
2007-08-17  8:43 ` [-mm PATCH 4/9] Memory controller memory accounting (v6) Balbir Singh
2007-08-17  8:43 ` [-mm PATCH 5/9] Memory controller task migration (v6) Balbir Singh
2007-08-17  8:43 ` [-mm PATCH 6/9] Memory controller add per container LRU and reclaim (v6) Balbir Singh
2007-08-17  8:43 ` [-mm PATCH 7/9] Memory controller OOM handling (v6) Balbir Singh
2007-08-17  8:43 ` [-mm PATCH 8/9] Memory controller add switch to control what type of pages to limit (v6) Balbir Singh
2007-08-17  8:44 ` [-mm PATCH 9/9] Memory controller make page_referenced() container aware (v6) Balbir Singh
2007-08-17 15:49 ` [-mm PATCH 0/9] Memory controller introduction (v6) Dhaval Giani

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=46C9587F.8000402@linux.vnet.ibm.com \
    --to=balbir@linux.vnet.ibm.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=adobriyan@sw.ru \
    --cc=akpm@linux-foundation.org \
    --cc=containers@lists.osdl.org \
    --cc=dhaval@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=npiggin@suse.de \
    --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