Re: [PATCH 2/2] Make batch size for memory accounting configured according to size of memory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]