public inbox for linux-kernel@vger.kernel.org
 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, Michal Hocko <mhocko@suse.cz>,
	Chris Wilson <chris@chris-wilson.co.uk>,
	Dave Airlie <airlied@gmail.com>, Hugh Dickins <hughd@google.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: [PATCH 3.18 21/39] memcg, shmem: fix shmem migration to use lrucare
Date: Mon,  9 Feb 2015 16:34:04 +0800	[thread overview]
Message-ID: <20150209083329.778822364@linuxfoundation.org> (raw)
In-Reply-To: <20150209083328.753647350@linuxfoundation.org>

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

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

From: Michal Hocko <mhocko@suse.cz>

commit f5e03a4989e80a86f8b514659dca8539132e6e09 upstream.

It has been reported that 965GM might trigger

  VM_BUG_ON_PAGE(!lrucare && PageLRU(oldpage), oldpage)

in mem_cgroup_migrate when shmem wants to replace a swap cache page
because of shmem_should_replace_page (the page is allocated from an
inappropriate zone).  shmem_replace_page expects that the oldpage is not
on LRU list and calls mem_cgroup_migrate without lrucare.  This is
obviously incorrect because swapcache pages might be on the LRU list
(e.g. swapin readahead page).

Fix this by enabling lrucare for the migration in shmem_replace_page.
Also clarify that lrucare should be used even if one of the pages might
be on LRU list.

The BUG_ON will trigger only when CONFIG_DEBUG_VM is enabled but even
without that the migration code might leave the old page on an
inappropriate memcg' LRU which is not that critical because the page
would get removed with its last reference but it is still confusing.

Fixes: 0a31bc97c80c ("mm: memcontrol: rewrite uncharge API")
Signed-off-by: Michal Hocko <mhocko@suse.cz>
Reported-by: Chris Wilson <chris@chris-wilson.co.uk>
Reported-by: Dave Airlie <airlied@gmail.com>
Acked-by: Hugh Dickins <hughd@google.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
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/memcontrol.c |    2 +-
 mm/shmem.c      |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -6589,7 +6589,7 @@ void mem_cgroup_uncharge_list(struct lis
  * mem_cgroup_migrate - migrate a charge to another page
  * @oldpage: currently charged page
  * @newpage: page to transfer the charge to
- * @lrucare: both pages might be on the LRU already
+ * @lrucare: either or both pages might be on the LRU already
  *
  * Migrate the charge from @oldpage to @newpage.
  *
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -1013,7 +1013,7 @@ static int shmem_replace_page(struct pag
 		 */
 		oldpage = newpage;
 	} else {
-		mem_cgroup_migrate(oldpage, newpage, false);
+		mem_cgroup_migrate(oldpage, newpage, true);
 		lru_cache_add_anon(newpage);
 		*pagep = newpage;
 	}



  parent reply	other threads:[~2015-02-09  8:38 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-09  8:33 [PATCH 3.18 00/39] 3.18.7-stable review Greg Kroah-Hartman
2015-02-09  8:33 ` [PATCH 3.18 01/39] gpio: sysfs: fix memory leak in gpiod_export_link Greg Kroah-Hartman
2015-02-09  8:33 ` [PATCH 3.18 02/39] gpio: sysfs: fix memory leak in gpiod_sysfs_set_active_low Greg Kroah-Hartman
2015-02-09  8:33 ` [PATCH 3.18 03/39] gpio: mcp23s08: handle default gpio base Greg Kroah-Hartman
2015-02-09  8:33 ` [PATCH 3.18 04/39] PCI: designware: Reject MSI-X IRQs Greg Kroah-Hartman
2015-02-09  8:33 ` [PATCH 3.18 05/39] PCI: Add NEC variants to Stratus ftServer PCIe DMI check Greg Kroah-Hartman
2015-02-09  8:33 ` [PATCH 3.18 06/39] PCI: Handle read-only BARs on AMD CS553x devices Greg Kroah-Hartman
2015-02-09  8:33 ` [PATCH 3.18 07/39] spi: spi-fsl-dspi: Remove usage of devm_kzalloc Greg Kroah-Hartman
2015-02-09  8:33 ` [PATCH 3.18 08/39] spi: imx: use pio mode for i.mx6dl Greg Kroah-Hartman
2015-02-09  8:33 ` [PATCH 3.18 09/39] sd: Fix max transfer length for 4k disks Greg Kroah-Hartman
2015-02-09  8:33 ` [PATCH 3.18 10/39] MIPS: Fix C0_Pagegrain[IEC] support Greg Kroah-Hartman
2015-02-09  8:33 ` [PATCH 3.18 11/39] MIPS: IRQ: Fix disable_irq on CPU IRQs Greg Kroah-Hartman
2015-02-09  8:33 ` [PATCH 3.18 12/39] MIPS: OCTEON: fix kernel crash when offlining a CPU Greg Kroah-Hartman
2015-02-09  8:33 ` [PATCH 3.18 13/39] MIPS: Fix kernel lockup or crash after CPU offline/online Greg Kroah-Hartman
2015-02-09  8:33 ` [PATCH 3.18 14/39] MIPS: mipsregs.h: Add write_32bit_cp1_register() Greg Kroah-Hartman
2015-02-09  8:33 ` [PATCH 3.18 15/39] MIPS: traps: Fix inline asm ctc1 missing .set hardfloat Greg Kroah-Hartman
2015-02-09  8:33 ` [PATCH 3.18 16/39] ARM: 8299/1: mm: ensure local active ASID is marked as allocated on rollover Greg Kroah-Hartman
2015-02-09  8:34 ` [PATCH 3.18 17/39] Complete oplock break jobs before closing file handle Greg Kroah-Hartman
2015-02-09  8:34 ` [PATCH 3.18 18/39] md/raid5: fix another livelock caused by non-aligned writes Greg Kroah-Hartman
2015-02-09  8:34 ` [PATCH 3.18 19/39] mm: pagewalk: call pte_hole() for VM_PFNMAP during walk_page_range Greg Kroah-Hartman
2015-02-09  8:34 ` [PATCH 3.18 20/39] lib/checksum.c: fix carry in csum_tcpudp_nofold Greg Kroah-Hartman
2015-02-09  8:34 ` Greg Kroah-Hartman [this message]
2015-02-09  8:34 ` [PATCH 3.18 22/39] nilfs2: fix deadlock of segment constructor over I_SYNC flag Greg Kroah-Hartman
2015-02-09  8:34 ` [PATCH 3.18 23/39] drm/radeon: dont init gpuvm if accel is disabled (v3) Greg Kroah-Hartman
2015-02-09  8:34 ` [PATCH 3.18 27/39] drm/radeon: properly set vm fragment size for TN/RL Greg Kroah-Hartman
2015-02-09  8:34 ` [PATCH 3.18 29/39] arm64: Fix up /proc/cpuinfo Greg Kroah-Hartman
2015-02-09  8:34 ` [PATCH 3.18 30/39] lib/checksum.c: fix build for generic csum_tcpudp_nofold Greg Kroah-Hartman
2015-02-09  8:34 ` [PATCH 3.18 31/39] ASoC: atmel_ssc_dai: fix start event for I2S mode Greg Kroah-Hartman
2015-02-09  8:34 ` [PATCH 3.18 32/39] ASoC: sgtl5000: add delay before first I2C access Greg Kroah-Hartman
2015-02-09  8:34 ` [PATCH 3.18 33/39] ALSA: ak411x: Fix stall in work callback Greg Kroah-Hartman
2015-02-09  8:34 ` [PATCH 3.18 34/39] ARM: dts: Fix I2S1, I2S2 compatible for exynos4 SoCs Greg Kroah-Hartman
2015-02-09  8:34 ` [PATCH 3.18 35/39] x86, microcode: Return error from driver init code when loader is disabled Greg Kroah-Hartman
2015-02-09  8:34 ` [PATCH 3.18 36/39] smpboot: Add missing get_online_cpus() in smpboot_register_percpu_thread() Greg Kroah-Hartman
2015-02-09  8:34 ` [PATCH 3.18 37/39] hrtimer: Fix incorrect tai offset calculation for non high-res timer systems Greg Kroah-Hartman
2015-02-09  8:34 ` [PATCH 3.18 38/39] tracing: Add condition check to RCU lockdep checks Greg Kroah-Hartman
2015-02-09  8:34 ` [PATCH 3.18 39/39] x86/tlb/trace: Do not trace on CPU that is offline Greg Kroah-Hartman
2015-02-09 16:40 ` [PATCH 3.18 00/39] 3.18.7-stable review Guenter Roeck
2015-02-09 18:27 ` Shuah Khan
2015-02-09 21:37   ` Greg Kroah-Hartman
2015-02-09 22:03     ` Guenter Roeck
2015-02-09 22:24       ` Winkler, Tomas
2015-02-09 23:19         ` 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=20150209083329.778822364@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=airlied@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=chris@chris-wilson.co.uk \
    --cc=hannes@cmpxchg.org \
    --cc=hughd@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhocko@suse.cz \
    --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