From patchwork Wed Jun 9 17:21:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 12310791 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B356FC48BCD for ; Wed, 9 Jun 2021 17:21:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 376A7613CA for ; Wed, 9 Jun 2021 17:21:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 376A7613CA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 46C0A6B0036; Wed, 9 Jun 2021 13:21:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3F44B6B006C; Wed, 9 Jun 2021 13:21:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 246C86B0070; Wed, 9 Jun 2021 13:21:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0188.hostedemail.com [216.40.44.188]) by kanga.kvack.org (Postfix) with ESMTP id E35726B006C for ; Wed, 9 Jun 2021 13:21:51 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 8B561BBF2 for ; Wed, 9 Jun 2021 17:21:51 +0000 (UTC) X-FDA: 78234852822.28.EFC0F2C Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) by imf13.hostedemail.com (Postfix) with ESMTP id 54805E00026E for ; Wed, 9 Jun 2021 17:21:47 +0000 (UTC) Received: by mail-pf1-f175.google.com with SMTP id q25so18920299pfh.7 for ; Wed, 09 Jun 2021 10:21:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=E11fKiyQBeEIM/g2HQ/6iNNwM0cPjI01ktT51go/AqI=; b=Dmi8xcS7KbFcgMmCYjw4MiwffWeXDWuN53gaauvpFgGUrJMiq+YH4q6rV7AXkVqPHs 7rVqNhjjPvD9e/3+yQh3Pdbzoo6qtWYLeAFm3FvAoFE97HFgOQoo9hWYLG9ee9zCtykW VIOPZF5gMWWsd2tzpiupRX+CFWITOWzAiXyOR0a4MDCPrmx+pxydldXbCvgzLJbJOVdL Qe+FJ8a5JmceYnfcssdh1Rn9qqSwQD4CPFeqkRUlLp9qiRVeFLLmqb7WB/s1fHp7CzPA aVhHhC0Aqh6JtlmA3BxIjPpH6lqEjVdKoD6oqP2R4Ho2L/TQd3koGuRIoBTXK5IpDuZw /DUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=E11fKiyQBeEIM/g2HQ/6iNNwM0cPjI01ktT51go/AqI=; b=o0BdKENWRiil2NSakUtvi5vWzQreg1TGUNMnlIfq1WMfL/LeHKbJEuDGOI3a0inboc siR4Bc3CPXENmdUwcd4D2LABAsXCm/9jVSNlnjObzYQnePlIRwOkob0WiT9UDw7Xjbil FH6PaeC/LirMhf9+4sju5UuEFSd8LE+eBjhURtDeEyYwIeLmLOqh7gCag4SQuxOnhvWC xoXX7At9puQrDr1vLFlRojr++IA15pEoyk/+M6IWtJ0ZSeRfpA8uNiA+zpiWvqkIpLg7 ViyN72qh4b1Fch0N+KEJ5/uipNJK6a7maGX6DaV45Jak1iR+V8EZOt41Hee8jWYJL5li 2i/Q== X-Gm-Message-State: AOAM533GoUrmeOumeFf2Y2SrnzC+b+YSlgYxmOICpjzxkTxmgLOdVN3x 9jjRZjMdsznRaf+lGs0LieG5auNV2f4ESJ0X X-Google-Smtp-Source: ABdhPJx99zKnbPaq93IhCTkYzCCq70PMOIiKpaq/rgwY6suzy/OxUfxSwQIlIHtrrGkuUcxosQkfKw== X-Received: by 2002:a63:1f1a:: with SMTP id f26mr714106pgf.432.1623259310191; Wed, 09 Jun 2021 10:21:50 -0700 (PDT) Received: from localhost.localdomain (c-73-93-239-127.hsd1.ca.comcast.net. [73.93.239.127]) by smtp.gmail.com with ESMTPSA id oc10sm243756pjb.44.2021.06.09.10.21.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Jun 2021 10:21:48 -0700 (PDT) From: Yang Shi To: mhocko@suse.com, ziy@nvidia.com, nao.horiguchi@gmail.com, kirill.shutemov@linux.intel.com, hughd@google.com, akpm@linux-foundation.org Cc: shy828301@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [v2 PATCH] mm: mempolicy: don't have to split pmd for huge zero page Date: Wed, 9 Jun 2021 10:21:46 -0700 Message-Id: <20210609172146.3594-1-shy828301@gmail.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 54805E00026E Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=Dmi8xcS7; spf=pass (imf13.hostedemail.com: domain of shy828301@gmail.com designates 209.85.210.175 as permitted sender) smtp.mailfrom=shy828301@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Stat-Signature: 6jtnd8nk1ajxw1zgfg9bfp56b8recznq X-HE-Tag: 1623259307-489311 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: When trying to migrate pages to obey mempolicy, the huge zero page is split by inserting base zero pfn to all PTEs, then the page table walk fallback to PTE level and just skips zero page. Skipping zero page for mempolicy has been the behavior of kernel since v2.6.16 due to commit f4598c8b3678 ("[PATCH] migration: make sure there is no attempt to migrate reserved pages."). So it seems pointless to split huge zero page, it could be just skipped like base zero page. Set ACTION_CONTINUE to prevent the walk_page_range() split the pmd for this case. Reviewed-by: Zi Yan Acked-by: Michal Hocko Signed-off-by: Yang Shi --- v2: Rephrased the commit log per Michal Hocko. Collected the review and ack tags. mm/mempolicy.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index b5f4f584009b..205c1a768775 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -436,7 +436,8 @@ static inline bool queue_pages_required(struct page *page, /* * queue_pages_pmd() has four possible return values: - * 0 - pages are placed on the right node or queued successfully. + * 0 - pages are placed on the right node or queued successfully, or + * special page is met, i.e. huge zero page. * 1 - there is unmovable page, and MPOL_MF_MOVE* & MPOL_MF_STRICT were * specified. * 2 - THP was split. @@ -460,8 +461,7 @@ static int queue_pages_pmd(pmd_t *pmd, spinlock_t *ptl, unsigned long addr, page = pmd_page(*pmd); if (is_huge_zero_page(page)) { spin_unlock(ptl); - __split_huge_pmd(walk->vma, pmd, addr, false, NULL); - ret = 2; + walk->action = ACTION_CONTINUE; goto out; } if (!queue_pages_required(page, qp)) @@ -488,7 +488,8 @@ static int queue_pages_pmd(pmd_t *pmd, spinlock_t *ptl, unsigned long addr, * and move them to the pagelist if they do. * * queue_pages_pte_range() has three possible return values: - * 0 - pages are placed on the right node or queued successfully. + * 0 - pages are placed on the right node or queued successfully, or + * special page is met, i.e. zero page. * 1 - there is unmovable page, and MPOL_MF_MOVE* & MPOL_MF_STRICT were * specified. * -EIO - only MPOL_MF_STRICT was specified and an existing page was already