linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Tim Chen <tim.c.chen@linux.intel.com>
Cc: Tejun Heo <tj@kernel.org>,
	Christoph Lameter <cl@linux-foundation.org>,
	Al Viro <viro@zeniv.linux.org.uk>,
	Eric Dumazet <eric.dumazet@gmail.com>,
	Ric Mason <ric.masonn@gmail.com>,
	Simon Jeons <simon.jeons@gmail.com>,
	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 v2 1/2] Make the batch size of the percpu_counter configurable
Date: Wed, 22 May 2013 00:20:20 -0700	[thread overview]
Message-ID: <20130522002020.60c3808f.akpm@linux-foundation.org> (raw)
In-Reply-To: <1369183390.27102.337.camel@schen9-DESK>

On Tue, 21 May 2013 17:43:10 -0700 Tim Chen <tim.c.chen@linux.intel.com> wrote:

> 
> I'll spin off another version of the patch later to add the
> memory-hotplug notifier.  In the mean time, does the following looks
> good to you?
> 
> ...
>
> --- a/include/linux/mman.h
> +++ b/include/linux/mman.h
> @@ -10,12 +10,30 @@
>  extern int sysctl_overcommit_memory;
>  extern int sysctl_overcommit_ratio;
>  extern struct percpu_counter vm_committed_as;
> +#ifdef CONFIG_SMP
> +extern int vm_committed_as_batch;
> +
> +static inline void mm_compute_batch(void)
> +{
> +        int nr = num_present_cpus();
> +        int batch = max(32, nr*2);
> +
> +        /* batch size set to 0.4% of (total memory/#cpus) */
> +        vm_committed_as_batch = max((int) (totalram_pages/nr) / 256, batch);

Use max_t() here.

That expression will overflow when the machine has two exabytes of RAM ;)

> +}
> +#else
> +#define vm_committed_as_batch 0
> +
> +static inline void mm_compute_batch(void)
> +{
> +}
> +#endif

I think it would be better if all the above was not inlined.  There's
no particular reason to inline it, and putting it here requires that
mman.h include a bunch more header files (which the patch forgot to
do).

>  unsigned long vm_memory_committed(void);
>  
>  static inline void vm_acct_memory(long pages)
>  {
> -	percpu_counter_add(&vm_committed_as, pages);
> +	__percpu_counter_add(&vm_committed_as, pages, vm_committed_as_batch);
>  }
>  
>  static inline void vm_unacct_memory(long pages)
> diff --git a/mm/mmap.c b/mm/mmap.c
> index f681e18..55c8773 100644
> --- a/mm/mmap.c
> +++ b/mm/mmap.c
> @@ -3145,11 +3145,15 @@ void mm_drop_all_locks(struct mm_struct *mm)
>  /*
>   * initialise the VMA slab
>   */
> +
> +int vm_committed_as_batch;
> +
>  void __init mmap_init(void)
>  {
>  	int ret;
>  
>  	ret = percpu_counter_init(&vm_committed_as, 0);
> +	mm_compute_batch();
>  	VM_BUG_ON(ret);
>  }
>  
> diff --git a/mm/nommu.c b/mm/nommu.c
> index 298884d..9ad16ba 100644
> --- a/mm/nommu.c
> +++ b/mm/nommu.c
> @@ -527,11 +527,15 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
>  /*
>   * initialise the VMA and region record slabs
>   */
> +
> +int vm_committed_as_batch;

This definition duplicates the one in mmap.c?

>  void __init mmap_init(void)
>  {
>  	int ret;
>  
>  	ret = percpu_counter_init(&vm_committed_as, 0);
> +	mm_compute_batch();
>  	VM_BUG_ON(ret);
>  	vm_region_jar = KMEM_CACHE(vm_region, SLAB_PANIC);
>  }

--
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-22  7:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-03 10:10 [PATCH v2 1/2] Make the batch size of the percpu_counter configurable Tim Chen
2013-05-03 10:10 ` [PATCH v2 2/2] Make batch size for memory accounting configured according to size of memory Tim Chen
2013-05-21 20:41 ` [PATCH v2 1/2] Make the batch size of the percpu_counter configurable Andrew Morton
2013-05-21 23:27   ` Tim Chen
2013-05-21 23:41     ` Andrew Morton
2013-05-22  0:43       ` Tim Chen
2013-05-22  7:20         ` Andrew Morton [this message]
2013-05-22 23:37           ` Tim Chen
2013-05-29 19:26             ` Andrew Morton
2013-05-29 21:20               ` Tim Chen
2013-05-29 21:34                 ` Andrew Morton

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=20130522002020.60c3808f.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=ak@linux.intel.com \
    --cc=cl@linux-foundation.org \
    --cc=dave.hansen@intel.com \
    --cc=eric.dumazet@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ric.masonn@gmail.com \
    --cc=simon.jeons@gmail.com \
    --cc=tim.c.chen@linux.intel.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;
as well as URLs for NNTP newsgroup(s).