linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Tim Chen <tim.c.chen@linux.intel.com>
To: Ric Mason <ric.masonn@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Tejun Heo <tj@kernel.org>,
	Christoph Lameter <cl@linux-foundation.org>,
	Al Viro <viro@zeniv.linux.org.uk>,
	Dave Hansen <dave.hansen@intel.com>,
	Andi Kleen <ak@linux.intel.com>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	linux-mm <linux-mm@kvack.org>
Subject: Re: [PATCH 2/2] Make batch size for memory accounting configured according to size of memory
Date: Wed, 01 May 2013 09:07:34 -0700	[thread overview]
Message-ID: <1367424454.27102.204.camel@schen9-DESK> (raw)
In-Reply-To: <5180A37E.8010701@gmail.com>

On Wed, 2013-05-01 at 13:09 +0800, Ric Mason wrote:
> Hi Tim,
> On 04/30/2013 01:12 AM, Tim Chen wrote:
> > Currently the per cpu counter's batch size for memory accounting is
> > configured as twice the number of cpus in the system.  However,
> > for system with very large memory, it is more appropriate to make it
> > proportional to the memory size per cpu in the system.
> >
> > For example, for a x86_64 system with 64 cpus and 128 GB of memory,
> > the batch size is only 2*64 pages (0.5 MB).  So any memory accounting
> > changes of more than 0.5MB will overflow the per cpu counter into
> > the global counter.  Instead, for the new scheme, the batch size
> > is configured to be 0.4% of the memory/cpu = 8MB (128 GB/64 /256),
> 
> If large batch size will lead to global counter more inaccurate?
> 

I've kept the error tolerance fairly small (0.4%), so it should not be
an issue.

If this is a concern, we can switch to percpu_counter_compare that will
use the global counter quick compare and switch to accurate compare if
needed (like the following).

index d1e4124..c78be36 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -187,7 +187,7 @@ int __vm_enough_memory(struct mm_struct *mm, long pages, int cap_sys_admin)
        if (mm)
                allowed -= mm->total_vm / 32;
 
-       if (percpu_counter_read_positive(&vm_committed_as) < allowed)
+       if (percpu_counter_compare(&vm_committed_as, allowed) < 0)
                return 0;
 error:
        vm_unacct_memory(pages);


Tim

--
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:[~2013-05-01 16:07 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-29 17:12 [PATCH 1/2] Make the batch size of the percpu_counter configurable Tim Chen
2013-04-29 17:12 ` [PATCH 2/2] Make batch size for memory accounting configured according to size of memory Tim Chen
2013-05-01  5:09   ` Ric Mason
2013-05-01 16:07     ` Tim Chen [this message]
2013-04-30 13:32 ` [PATCH 1/2] Make the batch size of the percpu_counter configurable Christoph Lameter
2013-04-30 16:23   ` Tim Chen
2013-04-30 17:28     ` Christoph Lameter
2013-04-30 17:48       ` Tim Chen
2013-04-30 17:53         ` Christoph Lameter
2013-04-30 17:55           ` Tim Chen
2013-04-30 18:27             ` Christoph Lameter
2013-04-30 19:00               ` Tim Chen
2013-04-30 19:04                 ` Tejun Heo
2013-04-30 20:50                 ` Christoph Lameter
2013-04-30 17:34     ` Andi Kleen
2013-04-30 18:10     ` Eric Dumazet
2013-04-30 18:28       ` Tim Chen
2013-05-01  4:52 ` Simon Jeons
2013-05-01 15:53   ` Tim Chen

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=1367424454.27102.204.camel@schen9-DESK \
    --to=tim.c.chen@linux.intel.com \
    --cc=ak@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux-foundation.org \
    --cc=dave.hansen@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ric.masonn@gmail.com \
    --cc=tj@kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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