Received: by 10.213.65.68 with SMTP id h4csp3102726imn; Mon, 2 Apr 2018 21:47:58 -0700 (PDT) X-Google-Smtp-Source: AIpwx49BstD8XEvGnL6BP/M6t2swyC+mxzpgZcUKmqW1w9m89nKVyizAnLdsYwAen5zawEShjU56 X-Received: by 10.99.176.12 with SMTP id h12mr8012398pgf.448.1522730878748; Mon, 02 Apr 2018 21:47:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522730878; cv=none; d=google.com; s=arc-20160816; b=SDf70CH0qq4/R9qcLDZAyXJQm1M9rL6GqjoCGsuYUUnIIvYDQ88iDLVFzzDfsN3TU0 nlcJSbCav08UiOzOb4r2MKBRhvK+m7dhKmvDcr6gxH50WuhYZzXTb9MVG4KhtITyMe5A iDPgOcXePyjMUEjtt0qi5YRBRTpZn7kN0GbLzXnPd4Zv1jRVX4mezWfmNX4WAMcw/RqE TrptbtO9c3HCdI1zxDfM+5JZimuMc3HYsRs3syxhQH6OER0v2lQGVzCFJZWDN8Eqh2pP 7eVJ+OzTgT2AQTbt/3ES/gf8yg79vDtOXRiU+yNW+fjnhlAznuw4iYLjCljrNgzyIBkB stLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=RXjz2qfhPTaCzNkUY4T/gafEA/N1QXKCZ/KVwdD7lTU=; b=XK+yfNmba7CeFisOesY5YRYgf1XOjAO6xNfMjqHv0hFV1hy9wO3DOxCCOYJjo23NUg aI6oUNmFUnkusbhNH+CZLO+RX/ArF0YRJ7V8Zud94JnEzhQjBEiKelkAgBPZBVbZCTpb xn281+BYMR0/B72+xqvYarZ2q+LsGRuVQIfJKnC7UFZb8173Fb9aEOSw56frDqRL7puU 2PWtCrXayXoOqERkI+RUBvbcJnLRHHXVvWFJuPmMDRa+m5ltXDHJ9WCXdmDDkjYmajsZ C7W/kx8oZDhlEDs/8KhNfHj653bo4Jqj8QU+zfHleBt46zUZRtViIG0D3xDTaFTeeMe5 dB4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=mHpgp6NK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m1si1509488pff.43.2018.04.02.21.47.44; Mon, 02 Apr 2018 21:47:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=mHpgp6NK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753285AbeDCEqk (ORCPT + 99 others); Tue, 3 Apr 2018 00:46:40 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:35125 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750929AbeDCEqj (ORCPT ); Tue, 3 Apr 2018 00:46:39 -0400 Received: by mail-pl0-f67.google.com with SMTP id 61-v6so5310506plb.2 for ; Mon, 02 Apr 2018 21:46:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=RXjz2qfhPTaCzNkUY4T/gafEA/N1QXKCZ/KVwdD7lTU=; b=mHpgp6NKErszng9kv2gcoqDn/GaNu4/a/bBwcYV787j9ipuJ5OcCOmy1+4N++73s50 6sp7lc3RDT+3N6jp7E80Kb/RRbGvA+F6GtW73+1MU54wk8BCK8wEuz6cUBJin1yT2syl PRFnRlduzr7ZfWUK1q9lIqc2AWCEF0omDnzFVqf4ZCP2uv/CdARirauFHM8pcSjReAcY fmDwSMgSUj3kBcyrSg86yDibhZgWgPsdIKVzjc57HJal/O6QJVbG1tl1fMXmktBSJyQd bjLNdj8WAyWkLPGh03NymTXTOskxrLhFlyhyGXbGwScHzIzkylw/dQBASdRnTRTXkUHo irrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=RXjz2qfhPTaCzNkUY4T/gafEA/N1QXKCZ/KVwdD7lTU=; b=pgs9+OrFcRX+UucCLHvukP5bZNF6Sl0D0riPgvO+FJp6UgGBgVnj9VNWZ4jvseZra1 DTqnPQfmqoXa1b0CO2JqMV5ADr/CmcsBLWeQQ0LNTKruvaFFPVlrYqJrk/v+QblNa5gk mv3pf23sy5zwvQuPdckZxJIzmCOHjvkRYVECrd5RIBXdnd1k/XJukU9rIt+QOvMl+uJV mzU/U59r3ZM6pOfnffpdU8061I5D8Odb1JOpQI8YCGxDSwPdDVlS41AFMRyS0LwhhPYy NqNitLfxeeQEBbgWfBcrDxrtjILlHdESKA2SgGRB+3ZrzgFq5l54FofqhDecJKOHIi7Q gxyg== X-Gm-Message-State: ALQs6tAPxrLBSeo1GDj/bgv2GLADKfREu808YxN3y4aLcylM0KMO58gW uVdNy9McxiLwlJzZY2at9g== X-Received: by 10.101.101.136 with SMTP id u8mr327387pgv.333.1522730798631; Mon, 02 Apr 2018 21:46:38 -0700 (PDT) Received: from www9186uo.sakura.ne.jp (www9186uo.sakura.ne.jp. [153.121.56.200]) by smtp.gmail.com with ESMTPSA id k24sm3097695pfj.32.2018.04.02.21.46.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Apr 2018 21:46:38 -0700 (PDT) From: Naoya Horiguchi To: linux-mm@kvack.org Cc: Michal Hocko , Andrew Morton , Vlastimil Babka , linux-kernel@vger.kernel.org Subject: [PATCH v1] mm: consider non-anonymous thp as unmovable page Date: Tue, 3 Apr 2018 13:46:28 +0900 Message-Id: <1522730788-24530-1-git-send-email-n-horiguchi@ah.jp.nec.com> X-Mailer: git-send-email 2.7.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org My testing for the latest kernel supporting thp migration found out an infinite loop in offlining the memory block that is filled with shmem thps. We can get out of the loop with a signal, but kernel should return with failure in this case. What happens in the loop is that scan_movable_pages() repeats returning the same pfn without any progress. That's because page migration always fails for shmem thps. In memory offline code, memory blocks containing unmovable pages should be prevented from being offline targets by has_unmovable_pages() inside start_isolate_page_range(). So this patch simply does it for non-anonymous thps. Fixes: commit 72b39cfc4d75 ("mm, memory_hotplug: do not fail offlining too early") Signed-off-by: Naoya Horiguchi Cc: stable@vger.kernel.org # v4.15+ --- Actually I'm not sure which commit we should set to "Fixes" tag. Commit 8135d8926c08 ("mm: memory_hotplug: memory hotremove supports thp migration") failed to introduce the code that this patch is suggesting. But the infinite loop became visible by commit 72b39cfc4d75 ("mm, memory_hotplug: do not fail offlining too early") where retry code was removed. --- mm/page_alloc.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git v4.16-rc7-mmotm-2018-03-28-16-05/mm/page_alloc.c v4.16-rc7-mmotm-2018-03-28-16-05_patched/mm/page_alloc.c index 905db9d..dbbe8fa 100644 --- v4.16-rc7-mmotm-2018-03-28-16-05/mm/page_alloc.c +++ v4.16-rc7-mmotm-2018-03-28-16-05_patched/mm/page_alloc.c @@ -7682,6 +7682,18 @@ bool has_unmovable_pages(struct zone *zone, struct page *page, int count, if (!PageLRU(page)) found++; + + /* + * Thp migration is available only for anonymous thps for now. + * So let's consider non-anonymous thps as unmovable pages. + */ + if (PageTransCompound(page)) { + if (PageAnon(page)) + iter += (1 << page_order(page)) - 1; + else + found++; + } + /* * If there are RECLAIMABLE pages, we need to check * it. But now, memory offline itself doesn't call -- 2.7.0