mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org, stable@kernel.org
Cc: Justin Forbes <jmforbes@linuxtx.org>,
	Zwane Mwaikambo <zwane@arm.linux.org.uk>,
	"Theodore Ts'o" <tytso@mit.edu>,
	Randy Dunlap <rdunlap@xenotime.net>,
	Dave Jones <davej@redhat.com>,
	Chuck Wolber <chuckw@quantumlinux.com>,
	Chris Wedgwood <reviews@ml.cw.f00f.org>,
	Michael Krufky <mkrufky@linuxtv.org>,
	Chuck Ebbert <cebbert@redhat.com>,
	Domenico Andreoli <cavokz@gmail.com>, Willy Tarreau <w@1wt.eu>,
	Rodrigo Rubira Branco <rbranco@la.checkpoint.com>,
	Jake Edge <jake@lwn.net>, Eugene Teo <eteo@redhat.com>,
	torvalds@linux-foundation.org, akpm@linux-foundation.org,
	alan@lxorguk.ukuu.org.uk, Mel Gorman <mel@csn.ul.ie>,
	Hugh Dickins <hugh.dickins@tiscali.co.uk>,
	Ingo Molnar <mingo@elte.hu>,
	Lee Schermerhorn <Lee.Schermerhorn@hp.com>,
	KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
	<starlight@binnacle.cx>, Eric B Munson <ebmunson@us.ibm.com>,
	Adam Litke <agl@us.ibm.com>, Andy Whitcroft <apw@canonical.com>,
	Greg Kroah-Hartman <gregkh@suse.de>
Subject: [patch 32/87] mm: account for MAP_SHARED mappings using VM_MAYSHARE and not VM_SHARED in hugetlbfs
Date: Tue, 09 Jun 2009 02:39:20 -0700	[thread overview]
Message-ID: <20090609094059.462757128@blue.kroah.org> (raw)
In-Reply-To: <20090609094451.GA26439@kroah.com>

[-- Attachment #1: mm-account-for-map_shared-mappings-using-vm_mayshare-and-not-vm_shared-in-hugetlbfs.patch --]
[-- Type: text/plain, Size: 6392 bytes --]

2.6.29-stable review patch.  If anyone has any objections, please let us know.

------------------

From: Mel Gorman <mel@csn.ul.ie>

commit f83a275dbc5ca1721143698e844243fcadfabf6a upstream.

Addresses http://bugzilla.kernel.org/show_bug.cgi?id=13302

hugetlbfs reserves huge pages but does not fault them at mmap() time to
ensure that future faults succeed.  The reservation behaviour differs
depending on whether the mapping was mapped MAP_SHARED or MAP_PRIVATE.
For MAP_SHARED mappings, hugepages are reserved when mmap() is first
called and are tracked based on information associated with the inode.
Other processes mapping MAP_SHARED use the same reservation.  MAP_PRIVATE
track the reservations based on the VMA created as part of the mmap()
operation.  Each process mapping MAP_PRIVATE must make its own
reservation.

hugetlbfs currently checks if a VMA is MAP_SHARED with the VM_SHARED flag
and not VM_MAYSHARE.  For file-backed mappings, such as hugetlbfs,
VM_SHARED is set only if the mapping is MAP_SHARED and the file was opened
read-write.  If a shared memory mapping was mapped shared-read-write for
populating of data and mapped shared-read-only by other processes, then
hugetlbfs would account for the mapping as if it was MAP_PRIVATE.  This
causes processes to fail to map the file MAP_SHARED even though it should
succeed as the reservation is there.

This patch alters mm/hugetlb.c and replaces VM_SHARED with VM_MAYSHARE
when the intent of the code was to check whether the VMA was mapped
MAP_SHARED or MAP_PRIVATE.

Signed-off-by: Mel Gorman <mel@csn.ul.ie>
Cc: Hugh Dickins <hugh.dickins@tiscali.co.uk>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: <starlight@binnacle.cx>
Cc: Eric B Munson <ebmunson@us.ibm.com>
Cc: Adam Litke <agl@us.ibm.com>
Cc: Andy Whitcroft <apw@canonical.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
 mm/hugetlb.c |   26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -316,7 +316,7 @@ static void resv_map_release(struct kref
 static struct resv_map *vma_resv_map(struct vm_area_struct *vma)
 {
 	VM_BUG_ON(!is_vm_hugetlb_page(vma));
-	if (!(vma->vm_flags & VM_SHARED))
+	if (!(vma->vm_flags & VM_MAYSHARE))
 		return (struct resv_map *)(get_vma_private_data(vma) &
 							~HPAGE_RESV_MASK);
 	return NULL;
@@ -325,7 +325,7 @@ static struct resv_map *vma_resv_map(str
 static void set_vma_resv_map(struct vm_area_struct *vma, struct resv_map *map)
 {
 	VM_BUG_ON(!is_vm_hugetlb_page(vma));
-	VM_BUG_ON(vma->vm_flags & VM_SHARED);
+	VM_BUG_ON(vma->vm_flags & VM_MAYSHARE);
 
 	set_vma_private_data(vma, (get_vma_private_data(vma) &
 				HPAGE_RESV_MASK) | (unsigned long)map);
@@ -334,7 +334,7 @@ static void set_vma_resv_map(struct vm_a
 static void set_vma_resv_flags(struct vm_area_struct *vma, unsigned long flags)
 {
 	VM_BUG_ON(!is_vm_hugetlb_page(vma));
-	VM_BUG_ON(vma->vm_flags & VM_SHARED);
+	VM_BUG_ON(vma->vm_flags & VM_MAYSHARE);
 
 	set_vma_private_data(vma, get_vma_private_data(vma) | flags);
 }
@@ -353,7 +353,7 @@ static void decrement_hugepage_resv_vma(
 	if (vma->vm_flags & VM_NORESERVE)
 		return;
 
-	if (vma->vm_flags & VM_SHARED) {
+	if (vma->vm_flags & VM_MAYSHARE) {
 		/* Shared mappings always use reserves */
 		h->resv_huge_pages--;
 	} else if (is_vma_resv_set(vma, HPAGE_RESV_OWNER)) {
@@ -369,14 +369,14 @@ static void decrement_hugepage_resv_vma(
 void reset_vma_resv_huge_pages(struct vm_area_struct *vma)
 {
 	VM_BUG_ON(!is_vm_hugetlb_page(vma));
-	if (!(vma->vm_flags & VM_SHARED))
+	if (!(vma->vm_flags & VM_MAYSHARE))
 		vma->vm_private_data = (void *)0;
 }
 
 /* Returns true if the VMA has associated reserve pages */
 static int vma_has_reserves(struct vm_area_struct *vma)
 {
-	if (vma->vm_flags & VM_SHARED)
+	if (vma->vm_flags & VM_MAYSHARE)
 		return 1;
 	if (is_vma_resv_set(vma, HPAGE_RESV_OWNER))
 		return 1;
@@ -924,7 +924,7 @@ static int vma_needs_reservation(struct 
 	struct address_space *mapping = vma->vm_file->f_mapping;
 	struct inode *inode = mapping->host;
 
-	if (vma->vm_flags & VM_SHARED) {
+	if (vma->vm_flags & VM_MAYSHARE) {
 		pgoff_t idx = vma_hugecache_offset(h, vma, addr);
 		return region_chg(&inode->i_mapping->private_list,
 							idx, idx + 1);
@@ -949,7 +949,7 @@ static void vma_commit_reservation(struc
 	struct address_space *mapping = vma->vm_file->f_mapping;
 	struct inode *inode = mapping->host;
 
-	if (vma->vm_flags & VM_SHARED) {
+	if (vma->vm_flags & VM_MAYSHARE) {
 		pgoff_t idx = vma_hugecache_offset(h, vma, addr);
 		region_add(&inode->i_mapping->private_list, idx, idx + 1);
 
@@ -1893,7 +1893,7 @@ retry_avoidcopy:
 	 * at the time of fork() could consume its reserves on COW instead
 	 * of the full address range.
 	 */
-	if (!(vma->vm_flags & VM_SHARED) &&
+	if (!(vma->vm_flags & VM_MAYSHARE) &&
 			is_vma_resv_set(vma, HPAGE_RESV_OWNER) &&
 			old_page != pagecache_page)
 		outside_reserve = 1;
@@ -2000,7 +2000,7 @@ retry:
 		clear_huge_page(page, address, huge_page_size(h));
 		__SetPageUptodate(page);
 
-		if (vma->vm_flags & VM_SHARED) {
+		if (vma->vm_flags & VM_MAYSHARE) {
 			int err;
 			struct inode *inode = mapping->host;
 
@@ -2104,7 +2104,7 @@ int hugetlb_fault(struct mm_struct *mm, 
 			goto out_mutex;
 		}
 
-		if (!(vma->vm_flags & VM_SHARED))
+		if (!(vma->vm_flags & VM_MAYSHARE))
 			pagecache_page = hugetlbfs_pagecache_page(h,
 								vma, address);
 	}
@@ -2289,7 +2289,7 @@ int hugetlb_reserve_pages(struct inode *
 	 * to reserve the full area even if read-only as mprotect() may be
 	 * called to make the mapping read-write. Assume !vma is a shm mapping
 	 */
-	if (!vma || vma->vm_flags & VM_SHARED)
+	if (!vma || vma->vm_flags & VM_MAYSHARE)
 		chg = region_chg(&inode->i_mapping->private_list, from, to);
 	else {
 		struct resv_map *resv_map = resv_map_alloc();
@@ -2330,7 +2330,7 @@ int hugetlb_reserve_pages(struct inode *
 	 * consumed reservations are stored in the map. Hence, nothing
 	 * else has to be done for private mappings here
 	 */
-	if (!vma || vma->vm_flags & VM_SHARED)
+	if (!vma || vma->vm_flags & VM_MAYSHARE)
 		region_add(&inode->i_mapping->private_list, from, to);
 	return 0;
 }



  parent reply	other threads:[~2009-06-09 10:24 UTC|newest]

Thread overview: 92+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20090609093848.204935043@blue.kroah.org>
2009-06-09  9:44 ` [patch 00/87] 2.6.29-stable review Greg KH
2009-06-09  9:38   ` [patch 01/87] xfrm: wrong hash value for temporary SA Greg KH
2009-06-09  9:38   ` [patch 02/87] tcp: fix MSG_PEEK race check Greg KH
2009-06-09  9:38   ` [patch 03/87] [PATCH 03/16] tcp: fix >2 iw selection Greg KH
2009-06-09  9:38   ` [patch 04/87] net: fix skb_seq_read returning wrong offset/length for page frag data Greg KH
2009-06-09  9:38   ` [patch 05/87] sch_teql: should not dereference skb after ndo_start_xmit() Greg KH
2009-06-09  9:38   ` [patch 06/87] net: fix length computation in rt_check_expire() Greg KH
2009-06-09  9:38   ` [patch 07/87] net: fix rtable leak in net/ipv4/route.c Greg KH
2009-06-09  9:38   ` [patch 08/87] Revert "rose: zero length frame filtering in af_rose.c" Greg KH
2009-06-09  9:38   ` [patch 09/87] pktgen: do not access flows[] beyond its length Greg KH
2009-06-09  9:38   ` [patch 10/87] myr10ge: again fix lro_gen_skb() alignment Greg KH
2009-06-09  9:38   ` [patch 11/87] vlan/macvlan: fix NULL pointer dereferences in ethtool handlers Greg KH
2009-06-09  9:39   ` [patch 12/87] mac8390: fix regression caused during net_device_ops conversion Greg KH
2009-06-09  9:39   ` [patch 13/87] bonding: fix alb mode locking regression Greg KH
2009-06-09  9:39   ` [patch 14/87] bonding: Remove debug printk Greg KH
2009-06-09  9:39   ` [patch 15/87] r8169: avoid losing MSI interrupts Greg KH
2009-06-09  9:39   ` [patch 16/87] sparc: Fix bus type probing for ESP and LE devices Greg KH
2009-06-09  9:39   ` [patch 17/87] sparc64: Fix smp_callin() locking Greg KH
2009-06-09  9:39   ` [patch 18/87] mm: SLUB fix reclaim_state Greg KH
2009-06-09  9:39   ` [patch 19/87] Fix oops on close of hot-unplugged FTDI serial converter Greg KH
2009-06-09 11:30     ` David Woodhouse
2009-06-09 13:42       ` Chuck Ebbert
2009-06-09  9:39   ` [patch 20/87] wimax: fix oops if netlink fails to add attribute Greg KH
2009-06-09  9:39   ` [patch 21/87] nfs: Fix NFS v4 client handling of MAY_EXEC in nfs_permission Greg KH
2009-06-09  9:39   ` [patch 22/87] futex: setup writeable mapping for futex ops which modify user space data Greg KH
2009-06-09  9:39   ` [patch 23/87] xen/blkfront: allow xenbus state transition to Closing->Closed when not Connected Greg KH
2009-06-09  9:39   ` [patch 24/87] TPM: get_event_name stack corruption Greg KH
2009-06-09  9:39   ` [patch 25/87] icom: fix rmmod crash Greg KH
2009-06-09  9:39   ` [patch 26/87] KVM: Make paravirt tlb flush also reload the PAE PDPTRs Greg KH
2009-06-09  9:39   ` [patch 27/87] KVM: Fix PDPTR reloading on CR4 writes Greg KH
2009-06-09  9:39   ` [patch 28/87] cfg80211: fix race between core hint and drivers custom apply Greg KH
2009-06-09  9:39   ` [patch 29/87] drm/r128: fix r128 ioremaps to use ioremap_wc Greg KH
2009-06-09  9:39   ` [patch 30/87] drivers/serial/mpc52xx_uart.c: fix array overindexing check Greg KH
2009-06-09  9:39   ` [patch 31/87] x86: ignore VM_LOCKED when determining if hugetlb-backed page tables can be shared or not Greg KH
2009-06-09  9:39   ` Greg KH [this message]
2009-06-09  9:39   ` [patch 33/87] USB: isp1760: urb_dequeue doesnt always find the urbs Greg KH
2009-06-09  9:39   ` [patch 34/87] sound: usb-audio: make the MotU Fastlane work again Greg KH
2009-06-09  9:39   ` [patch 35/87] usb-serial: fix crash when sub-driver updates firmware Greg KH
2009-06-09  9:39   ` [patch 36/87] x86/pci: fix mmconfig detection with 32bit near 4g Greg KH
2009-06-09  9:39   ` [patch 37/87] mtd_dataflash: unbreak erase support Greg KH
2009-06-09  9:39   ` [patch 38/87] hwmon: (lm78) Add missing __devexit_p() Greg KH
2009-06-09  9:39   ` [patch 39/87] cpuidle: make AMC C1E work in processor_idle Greg KH
2009-06-09  9:39   ` [patch 40/87] cpuidle: fix AMD C1E suspend hang Greg KH
2009-06-09  9:39   ` [patch 41/87] ide: fix 40-wire cable detection for TSST SH-S202* ATAPI devices (v2) Greg KH
2009-06-09  9:39   ` [patch 42/87] KVM: Explicity initialize cpus_hardware_enabled Greg KH
2009-06-09  9:39   ` [patch 43/87] ide_pci_generic: add quirk for Netcell ATA RAID Greg KH
2009-06-09  9:39   ` [patch 44/87] ide: fix OOPS during ide-cd error recovery Greg KH
2009-06-09  9:39   ` [patch 45/87] SELinux: BUG in SELinux compat_net code Greg KH
2009-06-09  9:39   ` [patch 46/87] e1000: add missing length check to e1000 receive routine Greg KH
2009-06-09  9:39   ` [patch 47/87] igb: fix LRO warning Greg KH
2009-06-09  9:39   ` [patch 48/87] iwlwifi: update key flags at time key is set Greg KH
2009-06-09  9:39   ` [patch 49/87] mac80211: minstrel, fix memory corruption Greg KH
2009-06-09  9:39   ` [patch 50/87] mac80211: pid, " Greg KH
2009-06-09  9:39   ` [patch 51/87] mac80211: avoid NULL ptr deref when finding max_rates in PID and minstrel Greg KH
2009-06-09  9:39   ` [patch 52/87] bnx2: Fix panic in bnx2_poll_work() Greg KH
2009-06-09  9:39   ` [patch 53/87] random: make get_random_int() more random Greg KH
2009-06-09  9:39   ` [patch 54/87] HID: fix dropped device-specific quirks Greg KH
2009-06-09  9:39   ` [patch 55/87] [SCSI] 3w-xxxx: scsi_dma_unmap fix Greg KH
2009-06-09  9:39   ` [patch 56/87] powerpc: fix for long standing bug noticed by gcc 4.4.0 Greg KH
2009-06-09  9:39   ` [patch 57/87] ide-tape: remove back-to-back REQUEST_SENSE detection Greg KH
2009-06-09  9:39   ` [patch 58/87] ALSA: hda - fix audio on HP TX25xx series notebooks Greg KH
2009-06-09  9:39   ` [patch 59/87] cdc-acm: Fix long standing abuse of tty->low_latency Greg KH
2009-06-09  9:39   ` [patch 60/87] keys: Handle there being no fallback destination keyring for request_key() Greg KH
2009-06-09  9:39   ` [patch 61/87] crypto: padlock - Revert aes-all alias to aes Greg KH
2009-06-09  9:39   ` [patch 62/87] crypto: api - Fix algorithm module auto-loading Greg KH
2009-06-09  9:39   ` [patch 63/87] ptrace: kill __ptrace_detach(), fix ->exit_state check Greg KH
2009-06-09  9:39   ` [patch 64/87] ptrace: simplify ptrace_exit()->ignoring_children() path Greg KH
2009-06-09  9:39   ` [patch 65/87] ptrace: reintroduce __ptrace_detach() as a callee of ptrace_exit() Greg KH
2009-06-09  9:39   ` [patch 66/87] ptrace: fix possible zombie leak on PTRACE_DETACH Greg KH
2009-06-09  9:39   ` [patch 67/87] x86: hpet: provide separate functions to stop and start the counter Greg KH
2009-06-09  9:39   ` [patch 68/87] x86: hpet: stop HPET_COUNTER when programming periodic mode Greg KH
2009-06-09  9:39   ` [patch 69/87] x86: hpet: fix periodic mode programming on AMD 81xx Greg KH
2009-06-09  9:39   ` [patch 70/87] ext4: dont inherit inappropriate inode flags from parent Greg KH
2009-06-09  9:39   ` [patch 71/87] ext4: tighten restrictions on inode flags Greg KH
2009-06-09  9:40   ` [patch 72/87] ext4: return -EIO not -ESTALE on directory traversal through deleted inode Greg KH
2009-06-09  9:40   ` [patch 73/87] ext4: Add fine print for the 32000 subdirectory limit Greg KH
2009-06-09  9:40   ` [patch 74/87] ext4: add EXT4_IOC_ALLOC_DA_BLKS ioctl Greg KH
2009-06-09  9:40   ` [patch 75/87] ext4: Automatically allocate delay allocated blocks on close Greg KH
2009-06-09  9:40   ` [patch 76/87] ext4: Automatically allocate delay allocated blocks on rename Greg KH
2009-06-09  9:40   ` [patch 77/87] ext4: Fix discard of inode prealloc space with delayed allocation Greg KH
2009-06-09  9:40   ` [patch 78/87] ext4: Add auto_da_alloc mount option Greg KH
2009-06-09  9:40   ` [patch 79/87] ext4: Check for an valid i_mode when reading the inode from disk Greg KH
2009-06-09  9:40   ` [patch 80/87] jbd2: Update locking coments Greg KH
2009-06-09  9:40   ` [patch 81/87] ext4: really print the find_group_flex fallback warning only once Greg KH
2009-06-09  9:40   ` [patch 82/87] ext4: Fix softlockup caused by illegal i_file_acl value in on-disk inode Greg KH
2009-06-09  9:40   ` [patch 83/87] ext4: Ignore i_file_acl_high unless EXT4_FEATURE_INCOMPAT_64BIT is present Greg KH
2009-06-09  9:40   ` [patch 84/87] ext4: Fix sub-block zeroing for writes into preallocated extents Greg KH
2009-06-09  9:40   ` [patch 85/87] ext4: Use a fake block number for delayed new buffer_head Greg KH
2009-06-09  9:40   ` [patch 86/87] ext4: Clear the unwritten buffer_head flag after the extent is initialized Greg KH
2009-06-09  9:40   ` [patch 87/87] ext4: Fix race in ext4_inode_info.i_cached_extent Greg KH
2009-06-12 19:11   ` [patch 00/87] 2.6.29-stable review Fabio Comolli
2009-06-12 22:45     ` Greg KH

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=20090609094059.462757128@blue.kroah.org \
    --to=gregkh@suse.de \
    --cc=Lee.Schermerhorn@hp.com \
    --cc=agl@us.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=apw@canonical.com \
    --cc=cavokz@gmail.com \
    --cc=cebbert@redhat.com \
    --cc=chuckw@quantumlinux.com \
    --cc=davej@redhat.com \
    --cc=ebmunson@us.ibm.com \
    --cc=eteo@redhat.com \
    --cc=hugh.dickins@tiscali.co.uk \
    --cc=jake@lwn.net \
    --cc=jmforbes@linuxtx.org \
    --cc=kosaki.motohiro@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mel@csn.ul.ie \
    --cc=mingo@elte.hu \
    --cc=mkrufky@linuxtv.org \
    --cc=rbranco@la.checkpoint.com \
    --cc=rdunlap@xenotime.net \
    --cc=reviews@ml.cw.f00f.org \
    --cc=stable@kernel.org \
    --cc=starlight@binnacle.cx \
    --cc=torvalds@linux-foundation.org \
    --cc=tytso@mit.edu \
    --cc=w@1wt.eu \
    --cc=zwane@arm.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

all inboxes | Powered by JetHome®