From patchwork Fri Jun 4 20:35:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 12301147 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.5 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 400D7C47082 for ; Sat, 5 Jun 2021 05:48:45 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E39536140C for ; Sat, 5 Jun 2021 05:48:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E39536140C 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 74D366B0070; Sat, 5 Jun 2021 01:48:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6FD7C6B0071; Sat, 5 Jun 2021 01:48:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 577106B0072; Sat, 5 Jun 2021 01:48:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0109.hostedemail.com [216.40.44.109]) by kanga.kvack.org (Postfix) with ESMTP id 2418E6B0070 for ; Sat, 5 Jun 2021 01:48:44 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id A999B180AD806 for ; Sat, 5 Jun 2021 05:48:43 +0000 (UTC) X-FDA: 78218590926.02.E8EB8AA Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.175]) by imf25.hostedemail.com (Postfix) with ESMTP id 952E56000163 for ; Sat, 5 Jun 2021 05:48:39 +0000 (UTC) Received: by mail-pg1-f175.google.com with SMTP id q15so9499686pgg.12 for ; Fri, 04 Jun 2021 22:48:38 -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=/LF0w3ZuuV4uKZVE77K5/SgS+KwM0fDxpNt19bsUYJM=; b=T58CnhvoMWwCn0bbPqNWxSRKvP434+uc9yZ6b5QXY2l5JE2w8dRFBZN33lp9oJZUKf yEMIYQAt+W1Kpcx8BDudGkLnVhrTMBT7Tk+KOM98HdMveCvWwpyjORZCXa/nqxrVgrR3 lqyY8j3gctlmBuGkbb7d0iQfnqi/Kww1ZaT9H/jJH969/rdOn/CQ7wTsRAMMPPvq+z65 XuxpBLFTGIZAx+P/ejpwjS1LhGDsGjK+RqYvDSXlRvuf3hHOwJ0ZJ+4WqhALr+4WVOsI FELFflq7pYpnb7M8W+hqBrWzAn0bukTY4Ht4vU2tg5JV1kH5qR4XtHRGqxItaM8ibOiv b+bg== 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=/LF0w3ZuuV4uKZVE77K5/SgS+KwM0fDxpNt19bsUYJM=; b=khJ88+EYgxiXFRWVTKXjALurksIpHAT30DOJYuGr7pUTEYgsViapNiPYDey1viGy3O pbtUMJloHUEFF12lnVGqh78Vl5DUaekst6r9CWShUdWeQaC4g5ZwYcc/1scmESFSSdYo e0k8sosWqiAAy3Sh4Pto19P1Biixrvm3AHRyHLtPlJXS3i78Kq2Dvs3Z8nwj/ncg5nPH Ob6g5uppjaH8UVjRugGQJLliBH//zlc3O7PX2eR6Qtnjtk+FIhzWfOkZRIXMppB0mSgz LWwGNHxbDKBGQNZ2+dbNUQWHwbxGrViIfZGDLrUTD+cXpb4DYfjloFajmuxOfUMZkXxK wEtg== X-Gm-Message-State: AOAM533DxfL1PncC0N8WrUOkLIDbb8nkZCKDzqyqkdBRwM8bo+F84D3m ijpB4AYSxsO8jaAcNc1S0MzBJqwPzYMWUg== X-Google-Smtp-Source: ABdhPJypjvGssCA5hHYSUIGwDK2ejRTX84JJX9jwU6SOoC1y+dS2NZ0w9LXvF/FTi3diMKY3kEu91A== X-Received: by 2002:a17:902:eac1:b029:108:4a7c:ff2d with SMTP id p1-20020a170902eac1b02901084a7cff2dmr6181973pld.62.1622838916660; Fri, 04 Jun 2021 13:35:16 -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 z23sm5262455pjh.44.2021.06.04.13.35.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Jun 2021 13:35:15 -0700 (PDT) From: Yang Shi To: ziy@nvidia.com, nao.horiguchi@gmail.com, mhocko@suse.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: [PATCH] mm: mempolicy: don't have to split pmd for huge zero page Date: Fri, 4 Jun 2021 13:35:13 -0700 Message-Id: <20210604203513.240709-1-shy828301@gmail.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 952E56000163 X-Stat-Signature: q8og4uipq3b9scrnhdkxk5u837uuzmda Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=T58Cnhvo; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf25.hostedemail.com: domain of shy828301@gmail.com designates 209.85.215.175 as permitted sender) smtp.mailfrom=shy828301@gmail.com X-HE-Tag: 1622872119-750676 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 then the page table walk at PTE level just skips zero page. 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. Signed-off-by: Yang Shi Reviewed-by: Zi Yan Acked-by: Michal Hocko --- 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