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,
Herbert van den Bergh <herbert.van.den.bergh@oracle.com>,
Mel Gorman <mgorman@suse.de>,
Michal Nazarewicz <mina86@mina86.com>
Subject: [patch 28/86] mm: compaction: check pfn_valid when entering a new MAX_ORDER_NR_PAGES block during isolation for migration
Date: Fri, 10 Feb 2012 14:29:47 -0800 [thread overview]
Message-ID: <20120210222947.549237435@clark.kroah.org> (raw)
In-Reply-To: <20120210223514.GA24190@kroah.com>
3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mel Gorman <mgorman@suse.de>
commit 0bf380bc70ecba68cb4d74dc656cc2fa8c4d801a upstream.
When isolating for migration, migration starts at the start of a zone
which is not necessarily pageblock aligned. Further, it stops isolating
when COMPACT_CLUSTER_MAX pages are isolated so migrate_pfn is generally
not aligned. This allows isolate_migratepages() to call pfn_to_page() on
an invalid PFN which can result in a crash. This was originally reported
against a 3.0-based kernel with the following trace in a crash dump.
PID: 9902 TASK: d47aecd0 CPU: 0 COMMAND: "memcg_process_s"
#0 [d72d3ad0] crash_kexec at c028cfdb
#1 [d72d3b24] oops_end at c05c5322
#2 [d72d3b38] __bad_area_nosemaphore at c0227e60
#3 [d72d3bec] bad_area at c0227fb6
#4 [d72d3c00] do_page_fault at c05c72ec
#5 [d72d3c80] error_code (via page_fault) at c05c47a4
EAX: 00000000 EBX: 000c0000 ECX: 00000001 EDX: 00000807 EBP: 000c0000
DS: 007b ESI: 00000001 ES: 007b EDI: f3000a80 GS: 6f50
CS: 0060 EIP: c030b15a ERR: ffffffff EFLAGS: 00010002
#6 [d72d3cb4] isolate_migratepages at c030b15a
#7 [d72d3d14] zone_watermark_ok at c02d26cb
#8 [d72d3d2c] compact_zone at c030b8de
#9 [d72d3d68] compact_zone_order at c030bba1
#10 [d72d3db4] try_to_compact_pages at c030bc84
#11 [d72d3ddc] __alloc_pages_direct_compact at c02d61e7
#12 [d72d3e08] __alloc_pages_slowpath at c02d66c7
#13 [d72d3e78] __alloc_pages_nodemask at c02d6a97
#14 [d72d3eb8] alloc_pages_vma at c030a845
#15 [d72d3ed4] do_huge_pmd_anonymous_page at c03178eb
#16 [d72d3f00] handle_mm_fault at c02f36c6
#17 [d72d3f30] do_page_fault at c05c70ed
#18 [d72d3fb0] error_code (via page_fault) at c05c47a4
EAX: b71ff000 EBX: 00000001 ECX: 00001600 EDX: 00000431
DS: 007b ESI: 08048950 ES: 007b EDI: bfaa3788
SS: 007b ESP: bfaa36e0 EBP: bfaa3828 GS: 6f50
CS: 0073 EIP: 080487c8 ERR: ffffffff EFLAGS: 00010202
It was also reported by Herbert van den Bergh against 3.1-based kernel
with the following snippet from the console log.
BUG: unable to handle kernel paging request at 01c00008
IP: [<c0522399>] isolate_migratepages+0x119/0x390
*pdpt = 000000002f7ce001 *pde = 0000000000000000
It is expected that it also affects 3.2.x and current mainline.
The problem is that pfn_valid is only called on the first PFN being
checked and that PFN is not necessarily aligned. Lets say we have a case
like this
H = MAX_ORDER_NR_PAGES boundary
| = pageblock boundary
m = cc->migrate_pfn
f = cc->free_pfn
o = memory hole
H------|------H------|----m-Hoooooo|ooooooH-f----|------H
The migrate_pfn is just below a memory hole and the free scanner is beyond
the hole. When isolate_migratepages started, it scans from migrate_pfn to
migrate_pfn+pageblock_nr_pages which is now in a memory hole. It checks
pfn_valid() on the first PFN but then scans into the hole where there are
not necessarily valid struct pages.
This patch ensures that isolate_migratepages calls pfn_valid when
necessary.
Reported-by: Herbert van den Bergh <herbert.van.den.bergh@oracle.com>
Tested-by: Herbert van den Bergh <herbert.van.den.bergh@oracle.com>
Signed-off-by: Mel Gorman <mgorman@suse.de>
Acked-by: Michal Nazarewicz <mina86@mina86.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/compaction.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -313,6 +313,19 @@ static isolate_migrate_t isolate_migrate
} else if (!locked)
spin_lock_irq(&zone->lru_lock);
+ /*
+ * migrate_pfn does not necessarily start aligned to a
+ * pageblock. Ensure that pfn_valid is called when moving
+ * into a new MAX_ORDER_NR_PAGES range in case of large
+ * memory holes within the zone
+ */
+ if ((low_pfn & (MAX_ORDER_NR_PAGES - 1)) == 0) {
+ if (!pfn_valid(low_pfn)) {
+ low_pfn += MAX_ORDER_NR_PAGES - 1;
+ continue;
+ }
+ }
+
if (!pfn_valid_within(low_pfn))
continue;
nr_scanned++;
next prev parent reply other threads:[~2012-02-10 23:19 UTC|newest]
Thread overview: 87+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-10 22:35 [patch 00/86] 3.2.6-stable review Greg KH
2012-02-10 22:29 ` [patch 01/86] readahead: fix pipeline break caused by block plug Greg KH
2012-02-10 22:29 ` [patch 02/86] ALSA: hda - Fix the logic to detect VIA analog low-current mode Greg KH
2012-02-10 22:29 ` [patch 03/86] ALSA: HDA: Remove quirk for Asus N53Jq Greg KH
2012-02-10 22:29 ` [patch 04/86] ALSA: hda - Apply 0x0f-VREF fix to all ASUS laptops with ALC861/660 Greg KH
2012-02-10 22:29 ` [patch 05/86] ALSA: hda - Fix calling cs_automic twice for Cirrus codecs Greg KH
2012-02-10 22:29 ` [patch 06/86] ALSA: hda - Allow analog low-current mode when dynamic power-control is on Greg KH
2012-02-10 22:29 ` [patch 07/86] ALSA: HDA: Fix duplicated output to more than one codec Greg KH
2012-02-10 22:29 ` [patch 08/86] ALSA: hda - Disable dynamic-power control for VIA as default Greg KH
2012-02-10 22:29 ` [patch 09/86] ASoC: wm_hubs: Enable line out VMID buffer for single ended line outputs Greg KH
2012-02-10 22:29 ` [patch 10/86] ASoC: wm_hubs: fix wrong bits for LINEOUT2 N/P mixer Greg KH
2012-02-10 22:29 ` [patch 11/86] ARM: 7306/1: vfp: flush thread hwstate before restoring context from sigframe Greg KH
2012-02-10 22:29 ` [patch 12/86] ARM: 7307/1: vfp: fix ptrace regset modification race Greg KH
2012-02-10 22:29 ` [patch 13/86] ARM: 7308/1: vfp: flush thread hwstate before copying ptrace registers Greg KH
2012-02-10 22:29 ` [patch 14/86] ARM: OMAP2+: GPMC: fix device size setup Greg KH
2012-02-10 22:29 ` [patch 15/86] drivers/tty/vt/vt_ioctl.c: fix KDFONTOP 32bit compatibility layer Greg KH
2012-02-10 22:29 ` [patch 16/86] proc: mem_release() should check mm != NULL Greg KH
2012-02-10 22:29 ` [patch 17/86] proc: unify mem_read() and mem_write() Greg KH
2012-02-10 22:29 ` [patch 18/86] proc: make sure mem_open() doesnt pin the targets memory Greg KH
2012-02-10 22:29 ` [patch 19/86] firewire: ohci: add reset packet quirk for SB Audigy Greg KH
2012-02-10 22:29 ` [patch 20/86] firewire: ohci: disable MSI on Ricoh controllers Greg KH
2012-02-10 22:29 ` [patch 21/86] IB/mlx4: pass SMP vendor-specific attribute MADs to firmware Greg KH
2012-02-10 22:29 ` [patch 22/86] RDMA/core: Fix kernel panic by always initializing qp->usecnt Greg KH
2012-02-10 22:29 ` [patch 23/86] kprobes: fix a memory leak in function pre_handler_kretprobe() Greg KH
2012-02-10 22:29 ` [patch 24/86] mtd: gpmi-nand bugfix: reset the BCH module when it is not MX23 Greg KH
2012-02-10 22:29 ` [patch 25/86] Revert "mtd: atmel_nand: optimize read/write buffer functions" Greg KH
2012-02-10 22:29 ` [patch 26/86] at_hdmac: bugfix for enabling channel irq Greg KH
2012-02-10 22:29 ` [patch 27/86] mm/filemap_xip.c: fix race condition in xip_file_fault() Greg KH
2012-02-10 22:29 ` Greg KH [this message]
2012-02-10 22:29 ` [patch 29/86] PM / Hibernate: Fix s2disk regression related to freezing workqueues Greg KH
2012-02-10 22:29 ` [patch 30/86] PM / QoS: CPU C-state breakage with PM Qos change Greg KH
2012-02-10 22:29 ` [patch 31/86] drm/radeon: Set DESKTOP_HEIGHT register to the framebuffer (not mode) height Greg KH
2012-02-10 22:29 ` [patch 32/86] drm/nouveau/gem: fix fence_sync race / oops Greg KH
2012-02-10 22:29 ` [patch 33/86] drm/radeon/kms: disable output polling when suspended Greg KH
2012-02-10 22:29 ` [patch 34/86] drm/radeon/kms: fix TRAVIS panel setup Greg KH
2012-02-10 22:29 ` [patch 35/86] sched/rt: Fix task stack corruption under __ARCH_WANT_INTERRUPTS_ON_CTXSW Greg KH
2012-02-10 22:29 ` [patch 36/86] PM / Hibernate: Thaw processes in SNAPSHOT_CREATE_IMAGE ioctl test path Greg KH
2012-02-10 22:29 ` [patch 37/86] PM / Hibernate: Thaw kernel threads in SNAPSHOT_CREATE_IMAGE ioctl path Greg KH
2012-02-10 22:29 ` [patch 38/86] 8139cp: fix missing napi_gro_flush Greg KH
2012-02-10 22:29 ` [patch 39/86] udf: Mark LVID buffer as uptodate before marking it dirty Greg KH
2012-02-10 22:29 ` [patch 40/86] drm/i915: HDMI hot remove notification to audio driver Greg KH
2012-02-10 22:30 ` [patch 41/86] drm/i915: DisplayPort " Greg KH
2012-02-10 22:30 ` [patch 42/86] drm/i915: check ACTHD of all rings Greg KH
2012-02-10 22:30 ` [patch 43/86] drm/i915: Fix TV Out refresh rate Greg KH
2012-02-10 22:30 ` [patch 44/86] drm/i915: handle 3rd pipe Greg KH
2012-02-10 22:30 ` [patch 45/86] drm/i915: convert force_wake_get to func pointer in the gpu reset code Greg KH
2012-02-10 22:30 ` [patch 46/86] drm/i915: protect force_wake_(get|put) with the gt_lock Greg KH
2012-02-10 22:30 ` [patch 47/86] eCryptfs: Infinite loop due to overflow in ecryptfs_write() Greg KH
2012-02-10 22:30 ` [patch 48/86] hwmon: (w83627ehf) Fix number of fans for NCT6776F Greg KH
2012-02-10 22:30 ` [patch 49/86] cifs: Fix oops in session setup code for null user mounts Greg KH
2012-02-10 22:30 ` [patch 50/86] atmel_lcdfb: fix usage of CONTRAST_CTR in suspend/resume Greg KH
2012-02-10 22:30 ` [patch 51/86] lockdep, bug: Exclude TAINT_FIRMWARE_WORKAROUND from disabling lockdep Greg KH
2012-02-10 22:30 ` [patch 52/86] lockdep, bug: Exclude TAINT_OOT_MODULE from disabling lock debugging Greg KH
2012-02-10 22:30 ` [patch 53/86] iscsi-target: Fix reject release handling in iscsit_free_cmd() Greg KH
2012-02-10 22:30 ` [patch 54/86] iscsi-target: Fix double list_add with iscsit_alloc_buffs reject Greg KH
2012-02-10 22:30 ` [patch 55/86] iscsi-target: Fix discovery with INADDR_ANY and IN6ADDR_ANY_INIT Greg KH
2012-02-10 22:30 ` [patch 56/86] ASoC: wm_hubs: Fix routing of input PGAs to line output mixer Greg KH
2012-02-10 22:30 ` [patch 57/86] ASoC: wm_hubs: Correct line input to line output 2 paths Greg KH
2012-02-10 22:30 ` [patch 58/86] ASoC: wm8962: Fix word length configuration Greg KH
2012-02-10 22:30 ` [patch 59/86] ASoC: wm8994: Enabling VMID should take a runtime PM reference Greg KH
2012-02-10 22:30 ` [patch 60/86] ASoC: wm8994: Fix typo in VMID ramp setting Greg KH
2012-02-10 22:30 ` [patch 61/86] pcmcia: fix socket refcount decrementing on each resume Greg KH
2012-02-10 22:30 ` [patch 62/86] ALSA: oxygen, virtuoso: fix exchanged L/R volumes of aux and CD inputs Greg KH
2012-02-10 22:30 ` [patch 63/86] iommu/amd: Work around broken IVRS tables Greg KH
2012-02-10 22:30 ` [patch 64/86] iommu/msm: Fix error handling in msm_iommu_unmap() Greg KH
2012-02-10 22:30 ` [patch 65/86] mm: compaction: check for overlapping nodes during isolation for migration Greg KH
2012-02-10 22:30 ` [patch 66/86] mm: fix UP THP spin_is_locked BUGs Greg KH
2012-02-10 22:30 ` [patch 67/86] target: Use correct preempted registration sense code Greg KH
2012-02-10 22:30 ` [patch 68/86] target: Allow PERSISTENT RESERVE IN for non-reservation holder Greg KH
2012-02-10 22:30 ` [patch 69/86] target: Correct sense key for INVALID FIELD IN {PARAMETER LIST,CDB} Greg KH
2012-02-10 22:30 ` [patch 70/86] target: Add workaround for zero-length control CDB handling Greg KH
2012-02-10 22:30 ` [patch 71/86] target: Return correct ASC for unimplemented VPD pages Greg KH
2012-02-10 22:30 ` [patch 72/86] target: Fail INQUIRY commands with EVPD==0 but PAGE CODE!=0 Greg KH
2012-02-10 22:30 ` [patch 73/86] Staging: asus_oled: fix image processing Greg KH
2012-02-10 22:30 ` [patch 74/86] Staging: asus_oled: fix NULL-ptr crash on unloading Greg KH
2012-02-10 22:30 ` [patch 75/86] staging: r8712u: Add new Sitecom UsB ID Greg KH
2012-02-10 22:30 ` [patch 76/86] staging: r8712u: Use asynchronous firmware loading Greg KH
2012-02-10 22:30 ` [patch 77/86] usb: ch9.h: usb_endpoint_maxp() uses __le16_to_cpu() Greg KH
2012-02-10 22:30 ` [patch 78/86] usb: gadget: zero: fix bug in loopback autoresume handling Greg KH
2012-02-10 22:30 ` [patch 79/86] usb: Skip PCI USB quirk handling for Netlogic XLP Greg KH
2012-02-10 22:30 ` [patch 80/86] USB: usbserial: add new PID number (0xa951) to the ftdi driver Greg KH
2012-02-10 22:30 ` [patch 81/86] USB: add new zte 3g-dongles pid to option.c Greg KH
2012-02-10 22:30 ` [patch 82/86] zcache: Set SWIZ_BITS to 8 to reduce tmem bucket lock contention Greg KH
2012-02-10 22:30 ` [patch 83/86] zcache: fix deadlock condition Greg KH
2012-02-10 22:30 ` [patch 84/86] mmc: cb710 core: Add missing spin_lock_init for irq_lock of struct cb710_chip Greg KH
2012-02-10 22:30 ` [patch 85/86] [CPUFREQ] powernow-k8: Avoid Pstate MSR accesses on systems supporting CPB Greg KH
2012-02-10 22:30 ` [patch 86/86] [CPUFREQ] powernow-k8: Fix indexing issue 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=20120210222947.549237435@clark.kroah.org \
--to=gregkh@linuxfoundation.org \
--cc=akpm@linux-foundation.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=herbert.van.den.bergh@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mina86@mina86.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