stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: torvalds@linux-foundation.org, akpm@linux-foundation.org,
	alan@lxorguk.ukuu.org.uk, Dave Jones <davej@redhat.com>,
	Hugh Dickins <hughd@google.com>,
	Andrea Arcangeli <aarcange@redhat.com>,
	David Rientjes <rientjes@google.com>,
	Josh Boyer <jwboyer@redhat.com>
Subject: [ 36/95] mm: thp: fix BUG on mm->nr_ptes
Date: Fri, 09 Mar 2012 11:02:38 -0800	[thread overview]
Message-ID: <20120309190205.238938677@linuxfoundation.org> (raw)
In-Reply-To: <20120309194424.GA2134@kroah.com>

3.2-stable review patch.  If anyone has any objections, please let me know.

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

From: Andrea Arcangeli <aarcange@redhat.com>

commit 1c641e84719429bbfe62a95ed3545ee7fe24408f upstream.

Dave Jones reports a few Fedora users hitting the BUG_ON(mm->nr_ptes...)
in exit_mmap() recently.

Quoting Hugh's discovery and explanation of the SMP race condition:

  "mm->nr_ptes had unusual locking: down_read mmap_sem plus
   page_table_lock when incrementing, down_write mmap_sem (or mm_users
   0) when decrementing; whereas THP is careful to increment and
   decrement it under page_table_lock.

   Now most of those paths in THP also hold mmap_sem for read or write
   (with appropriate checks on mm_users), but two do not: when
   split_huge_page() is called by hwpoison_user_mappings(), and when
   called by add_to_swap().

   It's conceivable that the latter case is responsible for the
   exit_mmap() BUG_ON mm->nr_ptes that has been reported on Fedora."

The simplest way to fix it without having to alter the locking is to make
split_huge_page() a noop in nr_ptes terms, so by counting the preallocated
pagetables that exists for every mapped hugepage.  It was an arbitrary
choice not to count them and either way is not wrong or right, because
they are not used but they're still allocated.

Reported-by: Dave Jones <davej@redhat.com>
Reported-by: Hugh Dickins <hughd@google.com>
Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
Acked-by: Hugh Dickins <hughd@google.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Josh Boyer <jwboyer@redhat.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@linuxfoundation.org>

---
 mm/huge_memory.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -642,6 +642,7 @@ static int __do_huge_pmd_anonymous_page(
 		set_pmd_at(mm, haddr, pmd, entry);
 		prepare_pmd_huge_pte(pgtable, mm);
 		add_mm_counter(mm, MM_ANONPAGES, HPAGE_PMD_NR);
+		mm->nr_ptes++;
 		spin_unlock(&mm->page_table_lock);
 	}
 
@@ -760,6 +761,7 @@ int copy_huge_pmd(struct mm_struct *dst_
 	pmd = pmd_mkold(pmd_wrprotect(pmd));
 	set_pmd_at(dst_mm, addr, dst_pmd, pmd);
 	prepare_pmd_huge_pte(pgtable, dst_mm);
+	dst_mm->nr_ptes++;
 
 	ret = 0;
 out_unlock:
@@ -858,7 +860,6 @@ static int do_huge_pmd_wp_page_fallback(
 	}
 	kfree(pages);
 
-	mm->nr_ptes++;
 	smp_wmb(); /* make pte visible before pmd */
 	pmd_populate(mm, pmd, pgtable);
 	page_remove_rmap(page);
@@ -1017,6 +1018,7 @@ int zap_huge_pmd(struct mmu_gather *tlb,
 			VM_BUG_ON(page_mapcount(page) < 0);
 			add_mm_counter(tlb->mm, MM_ANONPAGES, -HPAGE_PMD_NR);
 			VM_BUG_ON(!PageHead(page));
+			tlb->mm->nr_ptes--;
 			spin_unlock(&tlb->mm->page_table_lock);
 			tlb_remove_page(tlb, page);
 			pte_free(tlb->mm, pgtable);
@@ -1356,7 +1358,6 @@ static int __split_huge_page_map(struct
 			pte_unmap(pte);
 		}
 
-		mm->nr_ptes++;
 		smp_wmb(); /* make pte visible before pmd */
 		/*
 		 * Up to this point the pmd is present and huge and
@@ -1969,7 +1970,6 @@ static void collapse_huge_page(struct mm
 	set_pmd_at(mm, address, pmd, _pmd);
 	update_mmu_cache(vma, address, _pmd);
 	prepare_pmd_huge_pte(pgtable, mm);
-	mm->nr_ptes--;
 	spin_unlock(&mm->page_table_lock);
 
 #ifndef CONFIG_NUMA



  parent reply	other threads:[~2012-03-09 19:02 UTC|newest]

Thread overview: 98+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-09 19:44 [ 00/95] 3.2.10-stable review Greg KH
2012-03-09 19:02 ` [ 01/95] ARM: OMAP: make iommu subsys_initcall to fix builtin omap3isp Greg KH
2012-03-10 12:47   ` Ohad Ben-Cohen
2012-03-11 17:10     ` Greg KH
2012-03-09 19:02 ` [ 02/95] autofs: work around unhappy compat problem on x86-64 Greg KH
2012-03-09 19:02 ` [ 03/95] Fix autofs compile without CONFIG_COMPAT Greg KH
2012-03-09 19:02 ` [ 04/95] compat: fix compile breakage on s390 Greg KH
2012-03-09 19:02 ` [ 05/95] drm/i915: Prevent a machine hang by checking crtc->active before loading lut Greg KH
2012-03-09 19:02 ` [ 06/95] ARM: LPC32xx: serial.c: HW bug workaround Greg KH
2012-03-09 19:02 ` [ 07/95] ARM: LPC32xx: serial.c: Fixed loop limit Greg KH
2012-03-09 19:02 ` [ 08/95] ARM: LPC32xx: irq.c: Clear latched event Greg KH
2012-03-09 19:02 ` [ 09/95] ARM: LPC32xx: Fix interrupt controller init Greg KH
2012-03-09 19:02 ` [ 10/95] ARM: LPC32xx: Fix irq on GPI_28 Greg KH
2012-03-09 19:02 ` [ 11/95] watchdog: hpwdt: clean up set_memory_x call for 32 bit Greg KH
2012-03-09 19:02 ` [ 12/95] i2c: mxs: only flag completion when queue is completely done Greg KH
2012-03-09 19:02 ` [ 13/95] regulator: fix the ldo configure according to 88pm860x spec Greg KH
2012-03-09 19:02 ` [ 14/95] S390: KEYS: Enable the compat keyctl wrapper on s390x Greg KH
2012-03-09 19:02 ` [ 15/95] perf/x86/kvm: Fix Host-Only/Guest-Only counting with SVM disabled Greg KH
2012-03-09 19:02 ` [ 16/95] ALSA: hda/realtek - Fix resume of multiple input sources Greg KH
2012-03-09 19:02 ` [ 17/95] ALSA: hda - Add a fake mute feature Greg KH
2012-03-09 19:02 ` [ 18/95] ALSA: hda - Always set HP pin in unsol handler for STAC/IDT codecs Greg KH
2012-03-09 19:02 ` [ 19/95] regset: Prevent null pointer reference on readonly regsets Greg KH
2012-03-09 19:02 ` [ 20/95] regset: Return -EFAULT, not -EIO, on host-side memory fault Greg KH
2012-03-09 19:02 ` [ 21/95] mfd: Fix ACPI conflict check Greg KH
2012-03-09 19:02 ` [ 22/95] mfd: Test for jack detection when deciding if wm8994 should suspend Greg KH
2012-03-09 19:02 ` [ 23/95] genirq: Clear action->thread_mask if IRQ_ONESHOT is not set Greg KH
2012-03-09 19:02 ` [ 24/95] ARM: S3C24XX: DMA resume regression fix Greg KH
2012-03-09 19:02 ` [ 25/95] Move Logitech Harmony 900 from cdc_ether to zaurus Greg KH
2012-03-09 19:02 ` [ 26/95] alpha: fix 32/64-bit bug in futex support Greg KH
2012-03-09 19:02 ` [ 27/95] mmc: atmel-mci: dont use dma features when using DMA with no chan available Greg KH
2012-03-09 19:02 ` [ 28/95] mmc: sdhci-esdhc-imx: fix for mmc cards on i.MX5 Greg KH
2012-03-09 19:02 ` [ 29/95] aio: wake up waiters when freeing unused kiocbs Greg KH
2012-03-09 19:02 ` [ 30/95] mm: memcg: Correct unregistring of events attached to the same eventfd Greg KH
2012-03-09 19:02 ` [ 31/95] NOMMU: Dont need to clear vm_mm when deleting a VMA Greg KH
2012-03-09 19:02 ` [ 32/95] cifs: fix dentry refcount leak when opening a FIFO on lookup Greg KH
2012-03-09 19:02 ` [ 33/95] mac80211: zero initialize count field in ieee80211_tx_rate Greg KH
2012-03-09 19:02 ` [ 34/95] ath9k_hw: prevent writes to const data on AR9160 Greg KH
2012-03-09 19:02 ` [ 35/95] kprobes: return proper error code from register_kprobe() Greg KH
2012-03-09 19:02 ` Greg KH [this message]
2012-03-09 19:02 ` [ 37/95] iwlwifi: fix key removal Greg KH
2012-03-09 19:02 ` [ 38/95] tty/powerpc: early udbg consoles cant be modules Greg KH
2012-03-09 19:02 ` [ 39/95] S390: qdio: fix handler function arguments for zfcp data router Greg KH
2012-03-09 19:02 ` [ 40/95] rapidio/tsi721: fix queue wrapping bug in inbound doorbell handler Greg KH
2012-03-09 19:02 ` [ 41/95] HID: usbhid: Add NOGET quirk for the AIREN Slim+ keyboard Greg KH
2012-03-09 19:02 ` [ 42/95] crypto: mv_cesa - fix final callback not ignoring input data Greg KH
2012-03-09 19:02 ` [ 43/95] [SCSI] osd_uld: Bump MAX_OSD_DEVICES from 64 to 1,048,576 Greg KH
2012-03-09 19:02 ` [ 44/95] viafb: select HW scaling on VX900 for IGA2 Greg KH
2012-03-09 19:02 ` [ 45/95] viafb: fix IGA1 modesetting on VX900 Greg KH
2012-03-09 19:02 ` [ 46/95] ASoC: dapm: Check for bias level when powering down Greg KH
2012-03-09 19:02 ` [ 47/95] ASoC: i.MX SSI: Fix DSP_A format Greg KH
2012-03-09 19:02 ` [ 48/95] bsg: fix sysfs link remove warning Greg KH
2012-03-09 19:02 ` [ 49/95] avr32: select generic atomic64_t support Greg KH
2012-03-09 19:02 ` [ 50/95] ACPI / PM: Do not save/restore NVS on Asus K54C/K54HR Greg KH
2012-03-09 19:02 ` [ 51/95] rtl8192cu: Add new device IDs Greg KH
2012-03-09 19:02 ` [ 52/95] drm/i915: gen7: implement rczunit workaround Greg KH
2012-03-09 19:02 ` [ 53/95] drm/i915: gen7: Implement an L3 caching workaround Greg KH
2012-03-09 19:02 ` [ 54/95] drm/i915: gen7: work around a system hang on IVB Greg KH
2012-03-09 19:02 ` [ 55/95] drm/i915: gen7: Disable the RHWO optimization as it can cause GPU hangs Greg KH
2012-03-09 19:02 ` [ 56/95] drm/i915: fix ELD writing for SandyBridge Greg KH
2012-03-09 19:02 ` [ 57/95] ARM: orion: Fix USB phy for orion5x Greg KH
2012-03-09 19:03 ` [ 58/95] ARM: orion: Fix Orion5x GPIO regression from MPP cleanup Greg KH
2012-03-09 19:03 ` [ 59/95] OMAP: 4430SDP/Panda: use gpio_free_array to free HDMI gpios Greg KH
2012-03-09 19:03 ` [ 60/95] OMAP: 4430SDP/Panda: rename HPD GPIO to CT_CP_HPD Greg KH
2012-03-09 19:03 ` [ 61/95] OMAPDSS: remove wrong HDMI HPD muxing Greg KH
2012-03-09 19:03 ` [ 62/95] OMAP: 4430SDP/Panda: setup HDMI GPIO muxes Greg KH
2012-03-09 19:03 ` [ 63/95] OMAP: 4430SDP/Panda: add HDMI HPD gpio Greg KH
2012-03-09 19:03 ` [ 64/95] OMAPDSS: HDMI: PHY burnout fix Greg KH
2012-03-09 19:03 ` [ 65/95] OMAPDSS: HDMI: hot plug detect fix Greg KH
2012-03-09 19:03 ` [ 66/95] ARM: 7345/1: errata: update workaround for A9 erratum #743622 Greg KH
2012-03-09 19:03 ` [ 67/95] ARM: 7354/1: perf: limit sample_period to half max_period in non-sampling mode Greg KH
2012-03-09 19:03 ` [ 68/95] ARM: 7355/1: perf: clear overflow flag when disabling counter on ARMv7 PMU Greg KH
2012-03-09 19:03 ` [ 69/95] ARM: 7356/1: perf: check that we have an event in the PMU IRQ handlers Greg KH
2012-03-09 19:03 ` [ 70/95] ARM: 7357/1: perf: fix overflow handling for xscale2 PMUs Greg KH
2012-03-09 19:03 ` [ 71/95] media: staging: lirc_serial: Fix init/exit order Greg KH
2012-03-09 19:03 ` [ 72/95] media: staging: lirc_serial: Free resources on failure paths of lirc_serial_probe() Greg KH
2012-03-09 19:03 ` [ 73/95] media: staging: lirc_serial: Fix deadlock on resume failure Greg KH
2012-03-09 19:03 ` [ 74/95] media: staging: lirc_serial: Do not assume error codes returned by request_irq() Greg KH
2012-03-09 19:03 ` [ 75/95] Input: ALPS - fix touchpad detection when buttons are pressed Greg KH
2012-03-09 19:03 ` [ 76/95] hwmon: (pmbus_core) Fix maximum number of POUT alarm attributes Greg KH
2012-03-09 19:03 ` [ 77/95] hwmon: (jc42) Add support for ST Microelectronics STTS2002 and STTS3000 Greg KH
2012-03-09 19:03 ` [ 78/95] hwmon: (jc42) Add support for AT30TS00, TS3000GB2, TSE2002GB2, and MCP9804 Greg KH
2012-03-09 19:03 ` [ 79/95] hwmon: (zl6100) Maintain delay parameter in driver instance data Greg KH
2012-03-09 19:03 ` [ 80/95] carl9170: Fix memory accounting when sta is in power-save mode Greg KH
2012-03-09 19:03 ` [ 81/95] carl9170: fix frame delivery if sta is in powersave mode Greg KH
2012-03-09 19:03 ` [ 82/95] drm/radeon/kms: set SX_MISC in the r6xx blit code (v2) Greg KH
2012-03-09 19:03 ` [ 83/95] net/usbnet: avoid recursive locking in usbnet_stop() Greg KH
2012-03-09 19:03 ` [ 84/95] x86/amd: iommu_set_device_table() must not be __init Greg KH
2012-03-09 19:03 ` [ 85/95] dm ioctl: do not leak argv if target message only contains whitespace Greg KH
2012-03-09 19:03 ` [ 86/95] dm io: fix discard support Greg KH
2012-03-09 19:03 ` [ 87/95] dm flakey: fix crash on read when corrupt_bio_byte not set Greg KH
2012-03-09 19:03 ` [ 88/95] dm thin metadata: remove incorrect close_device on creation error paths Greg KH
2012-03-09 19:03 ` [ 89/95] dm thin metadata: unlock superblock in init_pmd error path Greg KH
2012-03-09 19:03 ` [ 90/95] dm thin metadata: decrement counter after removing mapped block Greg KH
2012-03-09 19:03 ` [ 91/95] dm raid: set MD_CHANGE_DEVS when rebuilding Greg KH
2012-03-09 19:03 ` [ 92/95] dm raid: fix flush support Greg KH
2012-03-09 19:03 ` [ 93/95] cs5535-mfgpt: dont call __init function from __devinit Greg KH
2012-03-09 19:03 ` [ 94/95] mfd: Fix cs5535 section mismatch Greg KH
2012-03-09 19:03 ` [ 95/95] spi-topcliff-pch: rename pch_spi_pcidev to pch_spi_pcidev_driver 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=20120309190205.238938677@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=davej@redhat.com \
    --cc=hughd@google.com \
    --cc=jwboyer@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rientjes@google.com \
    --cc=stable@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /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).