Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932692Ab3EAQHk (ORCPT ); Wed, 1 May 2013 12:07:40 -0400 Received: from mga09.intel.com ([134.134.136.24]:42849 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754011Ab3EAQHf (ORCPT ); Wed, 1 May 2013 12:07:35 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.87,589,1363158000"; d="scan'208";a="306266938" Subject: Re: [PATCH 2/2] Make batch size for memory accounting configured according to size of memory From: Tim Chen To: Ric Mason Cc: Andrew Morton , Tejun Heo , Christoph Lameter , Al Viro , Dave Hansen , Andi Kleen , linux-kernel , linux-mm In-Reply-To: <5180A37E.8010701@gmail.com> References: <8c9bc7d4646d48154604820a3ec5952ba8949de4.1367254913.git.tim.c.chen@linux.intel.com> <5180A37E.8010701@gmail.com> Content-Type: text/plain; charset="UTF-8" Date: Wed, 01 May 2013 09:07:34 -0700 Message-ID: <1367424454.27102.204.camel@schen9-DESK> Mime-Version: 1.0 X-Mailer: Evolution 2.32.3 (2.32.3-1.fc14) Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1743 Lines: 45 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 from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/