linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Joonsoo Kim <iamjoonsoo.kim@lge.com>,
	Aaron Lu <aaron.lu@intel.com>,
	David Rientjes <rientjes@google.com>,
	Mel Gorman <mgorman@suse.de>, Rik van Riel <riel@redhat.com>,
	Vlastimil Babka <vbabka@suse.cz>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: [PATCH 4.4 26/87] mm/compaction: pass only pageblock aligned range to pageblock_pfn_to_page
Date: Mon, 15 Jan 2018 13:34:25 +0100	[thread overview]
Message-ID: <20180115123351.928390763@linuxfoundation.org> (raw)
In-Reply-To: <20180115123349.252309699@linuxfoundation.org>

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

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

From: Joonsoo Kim <iamjoonsoo.kim@lge.com>

commit e1409c325fdc1fef7b3d8025c51892355f065d15 upstream.

pageblock_pfn_to_page() is used to check there is valid pfn and all
pages in the pageblock is in a single zone.  If there is a hole in the
pageblock, passing arbitrary position to pageblock_pfn_to_page() could
cause to skip whole pageblock scanning, instead of just skipping the
hole page.  For deterministic behaviour, it's better to always pass
pageblock aligned range to pageblock_pfn_to_page().  It will also help
further optimization on pageblock_pfn_to_page() in the following patch.

Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Aaron Lu <aaron.lu@intel.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Rik van Riel <riel@redhat.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Mel Gorman <mgorman@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 mm/compaction.c |   41 ++++++++++++++++++++++++++++++-----------
 1 file changed, 30 insertions(+), 11 deletions(-)

--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -553,13 +553,17 @@ unsigned long
 isolate_freepages_range(struct compact_control *cc,
 			unsigned long start_pfn, unsigned long end_pfn)
 {
-	unsigned long isolated, pfn, block_end_pfn;
+	unsigned long isolated, pfn, block_start_pfn, block_end_pfn;
 	LIST_HEAD(freelist);
 
 	pfn = start_pfn;
+	block_start_pfn = pfn & ~(pageblock_nr_pages - 1);
+	if (block_start_pfn < cc->zone->zone_start_pfn)
+		block_start_pfn = cc->zone->zone_start_pfn;
 	block_end_pfn = ALIGN(pfn + 1, pageblock_nr_pages);
 
 	for (; pfn < end_pfn; pfn += isolated,
+				block_start_pfn = block_end_pfn,
 				block_end_pfn += pageblock_nr_pages) {
 		/* Protect pfn from changing by isolate_freepages_block */
 		unsigned long isolate_start_pfn = pfn;
@@ -572,11 +576,13 @@ isolate_freepages_range(struct compact_c
 		 * scanning range to right one.
 		 */
 		if (pfn >= block_end_pfn) {
+			block_start_pfn = pfn & ~(pageblock_nr_pages - 1);
 			block_end_pfn = ALIGN(pfn + 1, pageblock_nr_pages);
 			block_end_pfn = min(block_end_pfn, end_pfn);
 		}
 
-		if (!pageblock_pfn_to_page(pfn, block_end_pfn, cc->zone))
+		if (!pageblock_pfn_to_page(block_start_pfn,
+					block_end_pfn, cc->zone))
 			break;
 
 		isolated = isolate_freepages_block(cc, &isolate_start_pfn,
@@ -862,18 +868,23 @@ unsigned long
 isolate_migratepages_range(struct compact_control *cc, unsigned long start_pfn,
 							unsigned long end_pfn)
 {
-	unsigned long pfn, block_end_pfn;
+	unsigned long pfn, block_start_pfn, block_end_pfn;
 
 	/* Scan block by block. First and last block may be incomplete */
 	pfn = start_pfn;
+	block_start_pfn = pfn & ~(pageblock_nr_pages - 1);
+	if (block_start_pfn < cc->zone->zone_start_pfn)
+		block_start_pfn = cc->zone->zone_start_pfn;
 	block_end_pfn = ALIGN(pfn + 1, pageblock_nr_pages);
 
 	for (; pfn < end_pfn; pfn = block_end_pfn,
+				block_start_pfn = block_end_pfn,
 				block_end_pfn += pageblock_nr_pages) {
 
 		block_end_pfn = min(block_end_pfn, end_pfn);
 
-		if (!pageblock_pfn_to_page(pfn, block_end_pfn, cc->zone))
+		if (!pageblock_pfn_to_page(block_start_pfn,
+					block_end_pfn, cc->zone))
 			continue;
 
 		pfn = isolate_migratepages_block(cc, pfn, block_end_pfn,
@@ -1091,7 +1102,9 @@ int sysctl_compact_unevictable_allowed _
 static isolate_migrate_t isolate_migratepages(struct zone *zone,
 					struct compact_control *cc)
 {
-	unsigned long low_pfn, end_pfn;
+	unsigned long block_start_pfn;
+	unsigned long block_end_pfn;
+	unsigned long low_pfn;
 	unsigned long isolate_start_pfn;
 	struct page *page;
 	const isolate_mode_t isolate_mode =
@@ -1103,16 +1116,21 @@ static isolate_migrate_t isolate_migrate
 	 * initialized by compact_zone()
 	 */
 	low_pfn = cc->migrate_pfn;
+	block_start_pfn = cc->migrate_pfn & ~(pageblock_nr_pages - 1);
+	if (block_start_pfn < zone->zone_start_pfn)
+		block_start_pfn = zone->zone_start_pfn;
 
 	/* Only scan within a pageblock boundary */
-	end_pfn = ALIGN(low_pfn + 1, pageblock_nr_pages);
+	block_end_pfn = ALIGN(low_pfn + 1, pageblock_nr_pages);
 
 	/*
 	 * Iterate over whole pageblocks until we find the first suitable.
 	 * Do not cross the free scanner.
 	 */
-	for (; end_pfn <= cc->free_pfn;
-			low_pfn = end_pfn, end_pfn += pageblock_nr_pages) {
+	for (; block_end_pfn <= cc->free_pfn;
+			low_pfn = block_end_pfn,
+			block_start_pfn = block_end_pfn,
+			block_end_pfn += pageblock_nr_pages) {
 
 		/*
 		 * This can potentially iterate a massively long zone with
@@ -1123,7 +1141,8 @@ static isolate_migrate_t isolate_migrate
 						&& compact_should_abort(cc))
 			break;
 
-		page = pageblock_pfn_to_page(low_pfn, end_pfn, zone);
+		page = pageblock_pfn_to_page(block_start_pfn, block_end_pfn,
+									zone);
 		if (!page)
 			continue;
 
@@ -1142,8 +1161,8 @@ static isolate_migrate_t isolate_migrate
 
 		/* Perform the isolation */
 		isolate_start_pfn = low_pfn;
-		low_pfn = isolate_migratepages_block(cc, low_pfn, end_pfn,
-								isolate_mode);
+		low_pfn = isolate_migratepages_block(cc, low_pfn,
+						block_end_pfn, isolate_mode);
 
 		if (!low_pfn || cc->contended) {
 			acct_isolated(zone, cc);

  parent reply	other threads:[~2018-01-15 12:39 UTC|newest]

Thread overview: 103+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-15 12:33 [PATCH 4.4 00/87] 4.4.112-stable review Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 01/87] dm bufio: fix shrinker scans when (nr_to_scan < retain_target) Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 02/87] KVM: Fix stack-out-of-bounds read in write_mmio Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 03/87] can: gs_usb: fix return value of the "set_bittiming" callback Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 04/87] IB/srpt: Disable RDMA access by the initiator Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 05/87] MIPS: Validate PR_SET_FP_MODE prctl(2) requests against the ABI of the task Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 06/87] MIPS: Factor out NT_PRFPREG regset access helpers Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 07/87] MIPS: Guard against any partial write attempt with PTRACE_SETREGSET Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 08/87] MIPS: Consistently handle buffer counter " Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 09/87] MIPS: Fix an FCSR access API regression with NT_PRFPREG and MSA Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 10/87] MIPS: Also verify sizeof `elf_fpreg_t with PTRACE_SETREGSET Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 11/87] MIPS: Disallow outsized PTRACE_SETREGSET NT_PRFPREG regset accesses Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 12/87] net/mac80211/debugfs.c: prevent build failure with CONFIG_UBSAN=y Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 13/87] kvm: vmx: Scrub hardware GPRs at VM-exit Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 14/87] x86/vsdo: Fix build on PARAVIRT_CLOCK=y, KVM_GUEST=n Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 15/87] x86/acpi: Handle SCI interrupts above legacy space gracefully Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 16/87] iommu/arm-smmu-v3: Dont free page table ops twice Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 17/87] ALSA: pcm: Remove incorrect snd_BUG_ON() usages Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 18/87] ALSA: pcm: Add missing error checks in OSS emulation plugin builder Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 19/87] ALSA: pcm: Abort properly at pending signal in OSS read/write loops Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 20/87] ALSA: pcm: Allow aborting mutex lock at " Greg Kroah-Hartman
2018-01-23 23:35   ` Ben Hutchings
2018-02-12  8:34     ` Takashi Iwai
2018-02-14 16:20       ` Ben Hutchings
2018-02-14 16:43         ` Takashi Iwai
2018-01-15 12:34 ` [PATCH 4.4 21/87] ALSA: aloop: Release cable upon open error path Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 22/87] ALSA: aloop: Fix inconsistent format due to incomplete rule Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 23/87] ALSA: aloop: Fix racy hw constraints adjustment Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 24/87] x86/acpi: Reduce code duplication in mp_override_legacy_irq() Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 25/87] mm/compaction: fix invalid free_pfn and compact_cached_free_pfn Greg Kroah-Hartman
2018-01-15 12:34 ` Greg Kroah-Hartman [this message]
2018-01-15 12:34 ` [PATCH 4.4 27/87] mm/page-writeback: fix dirty_ratelimit calculation Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 28/87] mm/zswap: use workqueue to destroy pool Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 29/87] zswap: dont param_set_charp while holding spinlock Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 30/87] locks: dont check for race with close when setting OFD lock Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 31/87] futex: Replace barrier() in unqueue_me() with READ_ONCE() Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 32/87] locking/mutex: Allow next waiter lockless wakeup Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 33/87] [media] usbvision fix overflow of interfaces array Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 34/87] usb: musb: ux500: Fix NULL pointer dereference at system PM Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 35/87] r8152: fix the wake event Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 36/87] r8152: use test_and_clear_bit Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 37/87] r8152: adjust ALDPS function Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 38/87] lan78xx: use skb_cow_head() to deal with cloned skbs Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 39/87] sr9700: " Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 40/87] smsc75xx: " Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 41/87] cx82310_eth: " Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 42/87] x86/mm/pat, /dev/mem: Remove superfluous error message Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 43/87] hwrng: core - sleep interruptible in read Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 44/87] sysrq: Fix warning in sysrq generated crash Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 45/87] xhci: Fix ring leak in failure path of xhci_alloc_virt_device() Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 46/87] Revert "userfaultfd: selftest: vm: allow to build in vm/ directory" Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 47/87] x86/pti/efi: broken conversion from efi to kernel page table Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 48/87] 8021q: fix a memory leak for VLAN 0 device Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 49/87] ip6_tunnel: disable dst caching if tunnel is dual-stack Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 50/87] net: core: fix module type in sock_diag_bind Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 51/87] RDS: Heap OOB write in rds_message_alloc_sgs() Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 52/87] RDS: null pointer dereference in rds_atomic_free_op Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 53/87] sh_eth: fix TSU resource handling Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 54/87] sh_eth: fix SH7757 GEther initialization Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 55/87] net: stmmac: enable EEE in MII, GMII or RGMII only Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 56/87] ipv6: fix possible mem leaks in ipv6_make_skb() Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 57/87] crypto: algapi - fix NULL dereference in crypto_remove_spawns() Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 58/87] rbd: set max_segments to USHRT_MAX Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 59/87] x86/microcode/intel: Extend BDW late-loading with a revision check Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 60/87] KVM: x86: Add memory barrier on vmcs field lookup Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 61/87] drm/vmwgfx: Potential off by one in vmw_view_add() Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 62/87] kaiser: Set _PAGE_NX only if supported Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 63/87] bpf: add bpf_patch_insn_single helper Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 64/87] bpf: dont (ab)use instructions to store state Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 65/87] bpf: move fixup_bpf_calls() function Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 66/87] bpf: refactor fixup_bpf_calls() Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 67/87] bpf: adjust insn_aux_data when patching insns Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 68/87] bpf: prevent out-of-bounds speculation Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 69/87] bpf, array: fix overflow in max_entries and undefined behavior in index_mask Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 70/87] iscsi-target: Make TASK_REASSIGN use proper se_cmd->cmd_kref Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 71/87] target: Avoid early CMD_T_PRE_EXECUTE failures during ABORT_TASK Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 72/87] USB: serial: cp210x: add IDs for LifeScan OneTouch Verio IQ Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 73/87] USB: serial: cp210x: add new device ID ELV ALC 8xxx Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 74/87] usb: misc: usb3503: make sure reset is low for at least 100us Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 75/87] USB: fix usbmon BUG trigger Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 76/87] usbip: remove kernel addresses from usb device and urb debug msgs Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 77/87] staging: android: ashmem: fix a race condition in ASHMEM_SET_SIZE ioctl Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 78/87] Bluetooth: Prevent stack info leak from the EFS element Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 79/87] uas: ignore UAS for Norelsys NS1068(X) chips Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 80/87] e1000e: Fix e1000_check_for_copper_link_ich8lan return value Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 81/87] x86/Documentation: Add PTI description Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 82/87] sysfs/cpu: Add vulnerability folder Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 83/87] x86/cpu: Implement CPU vulnerabilites sysfs functions Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 84/87] sysfs/cpu: Fix typos in vulnerability documentation Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 85/87] x86/alternatives: Fix optimize_nops() checking Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 86/87] x86/alternatives: Add missing \n at end of ALTERNATIVE inline asm Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 87/87] selftests/x86: Add test_vsyscall Greg Kroah-Hartman
2018-01-15 13:01 ` [PATCH 4.4 00/87] 4.4.112-stable review Greg Kroah-Hartman
2018-01-15 13:47 ` Greg Kroah-Hartman
2018-01-15 16:28 ` kernelci.org bot
2018-01-15 16:39 ` Nathan Chancellor
2018-01-15 18:02   ` Greg Kroah-Hartman
2018-01-15 21:59 ` Dan Rue
2018-01-16  5:53   ` Greg Kroah-Hartman
2018-01-16 11:22     ` Naresh Kamboju
2018-01-16 12:15       ` Greg Kroah-Hartman
2018-01-16 14:29 ` Guenter Roeck
2018-01-16 20:24 ` Shuah Khan

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=20180115123351.928390763@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=aaron.lu@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=riel@redhat.com \
    --cc=rientjes@google.com \
    --cc=stable@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=vbabka@suse.cz \
    /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).