login
Login
/
Register
Search
Search this site:
Forums
News
Blogs
Features
Site
Home
»
Mailing list archives
»
linux-kernel
»
2008
»
April
»
30
Re: [PATCH 1/2] mm: Fix overcommit overflow
view
thread
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
[view in full thread]
From: Andrew Morton
Subject:
Re: [PATCH 1/2] mm: Fix overcommit overflow
Date: Wednesday, April 30, 2008 - 2:09 pm
On Wed, 30 Apr 2008 21:42:41 +0100 Alan Cox <alan@lxorguk.ukuu.org.uk> wrote:
quoted text
> Sami Farin reported an overflow in the overcommit handling on 64bit boxes. > > We use atomic_t for page counting which is fine on 32bit but on 64bit > overflows. We can use atomic64_t but there is a problem - most heavy > users of zero overcommit are embedded people whose 64bit atomics are > really slow and expensive operations. Thus we use a few defines to flip > 32 or 64bit according to the size of a long > > (Split into two diffs to keep ownership correct) > > Signed-off-by: Alan Cox <alan@redhat.com> > > diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.25-mm1/include/linux/mman.h linux-2.6.25-mm1/include/linux/mman.h > --- linux.vanilla-2.6.25-mm1/include/linux/mman.h 2008-04-28 11:35:21.000000000 +0100 > +++ linux-2.6.25-mm1/include/linux/mman.h 2008-04-30 11:21:10.000000000 +0100 > @@ -15,16 +15,31 @@ > > #include <asm/atomic.h> > > +/* 32bit platforms have a virtual address space in pages we > + can fit into an atomic_t. We want to avoid atomic64_t on > + such boxes as it is often expensive and most strict overcommit > + users turn out to be embedded low power processors */ > + > +#if (BITS_PER_LONG == 32) > +#define vm_atomic_t atomic_t > +#define vm_atomic_read atomic_read > +#define vm_atomic_add atomic_add > +#else > +#define vm_atomic_t atomic64_t > +#define vm_atomic_read atomic64_read > +#define vm_atomic_add atomic64_add > +#endif
ew.
quoted text
> extern int sysctl_overcommit_memory; > extern int sysctl_overcommit_ratio; > -extern atomic_t vm_committed_space; > +extern vm_atomic_t vm_committed_space; > > #ifdef CONFIG_SMP > extern void vm_acct_memory(long pages); > #else > static inline void vm_acct_memory(long pages) > { > - atomic_add(pages, &vm_committed_space); > + vm_atomic_add(pages, &vm_committed_space); > } > #endif > > diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.25-mm1/mm/mmap.c linux-2.6.25-mm1/mm/mmap.c > --- linux.vanilla-2.6.25-mm1/mm/mmap.c 2008-04-28 11:36:52.000000000 +0100 > +++ linux-2.6.25-mm1/mm/mmap.c 2008-04-30 11:17:03.000000000 +0100 > @@ -80,7 +80,7 @@ > int sysctl_overcommit_memory = OVERCOMMIT_GUESS; /* heuristic overcommit */ > int sysctl_overcommit_ratio = 50; /* default is 50% */ > int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT; > -atomic_t vm_committed_space = ATOMIC_INIT(0); > +vm_atomic_t vm_committed_space = ATOMIC_INIT(0);
That'll need to be ATOMIC64_INIT on 64-bit.
quoted text
> > /* > * Check that a process has enough memory to allocate a new virtual > @@ -177,7 +177,7 @@ > * cast `allowed' as a signed long because vm_committed_space > * sometimes has a negative value > */ > - if (atomic_read(&vm_committed_space) < (long)allowed) > + if (vm_atomic_read(&vm_committed_space) < (long)allowed) > return 0; > error: > vm_unacct_memory(pages); > diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.25-mm1/mm/swap.c linux-2.6.25-mm1/mm/swap.c > --- linux.vanilla-2.6.25-mm1/mm/swap.c 2008-04-28 11:36:52.000000000 +0100 > +++ linux-2.6.25-mm1/mm/swap.c 2008-04-30 11:18:05.000000000 +0100 > @@ -503,7 +503,7 @@ > local = &__get_cpu_var(committed_space); > *local += pages; > if (*local > ACCT_THRESHOLD || *local < -ACCT_THRESHOLD) { > - atomic_add(*local, &vm_committed_space); > + vm_atomic_add(*local, &vm_committed_space); > *local = 0; > } > preempt_enable();
But afacit the existing atomic_long_t does exactly what you want? --
unsubscribe notice
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/
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
Messages in current thread:
[PATCH 1/2] mm: Fix overcommit overflow
, Alan Cox
, (Wed Apr 30, 1:42 pm)
Re: [PATCH 1/2] mm: Fix overcommit overflow
, Andrew Morton
, (Wed Apr 30, 2:09 pm)
Re: [PATCH 1/2] mm: Fix overcommit overflow
, Alan Cox
, (Wed Apr 30, 2:14 pm)
Navigation
Create content
Mailing list archives
Recent posts
Popular discussions
linux-kernel
:
Takashi Iwai
Re: [PATCH] usb: usbmixer error path fix
Jakub Narebski
Re: [PATCH] gitweb: Fix shortlog only showing HEAD revision.
Rafael J. Wysocki
[Bug #16136] Linux 2.6.34 causes system lockup on Compaq Presario 2200 Laptop
Trent Waddington
Re: Gaming Interface
Paul E. McKenney
Re: [PATCH, RFC] v4 scalable classic RCU implementation
git
:
Christian Stimming
git-gui: Fix broken revert confirmation.
Stephen R. van den Berg
Re: [RFC] origin link for cherry-pick and revert
Junio C Hamano
Re: git-svnimport
Mark Burton
Re: [PATCH] builtin-branch: highlight current remote branches with an asterisk
Johannes Schindelin
Re: [PATCH] Fix approxidate("never") to always return 0
git-commits-head
:
Linux Kernel Mailing List
ath9k_htc: Allocate URBs properly
Linux Kernel Mailing List
bnx2x: Fan failure mechanism on additional design
Linux Kernel Mailing List
cpumask: make irq_set_affinity() take a const struct cpumask
Linux Kernel Mailing List
ARM: 5670/1: bcmring: add default configuration for bcmring arch
Linux Kernel Mailing List
ahci: Workaround HW bug for SB600/700 SATA controller PMP support
linux-netdev
:
Nick Piggin
Re: Kernel WARNING: at net/core/dev.c:1330 __netif_schedule+0x2c/0x98()
Daniel Lezcano
getsockopt(TCP_DEFER_ACCEPT) value change
David Miller
Re: 2.6.27.18: bnx2/tg3: BUG: "scheduling while atomic" trying to ifenslave a seco...
Amit Kumar Salecha
[PATCH NEXT 10/10] qlcnic: add cksum flag
Patrick McHardy
Re: [PATCH RESEND 1/3] netfilter: xtables: inclusion of xt_condition
openbsd-misc
:
James Hozier
Re: DVD burn error: No space left on device
Christophe Rioux
Implementation example of snmp
Ryan McBride
Re: Packets Per Second Limit?
Nick Holland
Re: booting openbsd on eee without cd-rom
Very Fashion.com
Very-fashion.com -Novo! Brendirana garderoba po najpovoljnijim cenama.Bisou Bisou ...
Colocation donated by:
Syndicate