From mboxrd@z Thu Jan 1 00:00:00 1970 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=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL 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 77A40C433E0 for ; Sat, 13 Mar 2021 07:58:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0B26664F1D for ; Sat, 13 Mar 2021 07:58:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0B26664F1D Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 7DCDF6B0074; Sat, 13 Mar 2021 02:58:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 78DF26B0075; Sat, 13 Mar 2021 02:58:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 62ED66B0078; Sat, 13 Mar 2021 02:58:07 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0084.hostedemail.com [216.40.44.84]) by kanga.kvack.org (Postfix) with ESMTP id 4198E6B0074 for ; Sat, 13 Mar 2021 02:58:07 -0500 (EST) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id F3B145833 for ; Sat, 13 Mar 2021 07:58:06 +0000 (UTC) X-FDA: 77914097814.14.F7B0AA6 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf23.hostedemail.com (Postfix) with ESMTP id C2353A0049ED for ; Sat, 13 Mar 2021 07:58:05 +0000 (UTC) Received: by mail-yb1-f201.google.com with SMTP id b127so31851052ybc.13 for ; Fri, 12 Mar 2021 23:58:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=sM28HXat3Ro78N+fdELj5tA2TTORYcmSJRB7y0xn668=; b=TkMSfULPVVqqEs8nJoS183e8mdw8yepLBTDn2eNINUqggav0COpVRzISc3zd89NvN9 G1/R3rFQNbXB4Mc0QhWaGTD1Fq53asLndQ1E2i8CSZ95KHVj8MUNkswp9uk2yDDtfErk Sbw+4/WN0WzNqVfegG6JQMHiPP9iXEqGFYVgSZLK8flNYafDsz7FgT4K+/4AxxZLFwj6 mhv5FnKYJxQDSuEX1b3S54OYObhuyWJnGpPGLfPwfJ/quLWGTNO+ZIAeb5KMAmBdnEKV rF1QTgCoPPMsWsShNKe8BsfaSKCMVGiSbi90ZFx8J0HHcn4GpbXrkYUuLSCcm0F4KYI7 fQQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=sM28HXat3Ro78N+fdELj5tA2TTORYcmSJRB7y0xn668=; b=PgsH+LZuquJh6PiITwMqtGOPNVuogsbnzQ+647/z1zP9Bjf3xAy5ihsdcivLeY+i8m mSMlwYZy1Nv9VQ5MR0SdHUvN8HcX9rboP+sMpiaPhdUT5t2wTK58FnrVAWCGGHWMl5kd EdPd77NMq1uUoiMONXzpJCDNUS4l9zkPSPjAyFXEXyWfvAVDdbe1iR2LHDyoQIAgHAoG AX4WsVPt8QGZW0Gi4EVxlSBf9YxxMZ+b01TGviKNJJrveDv1PACl2C05RIcVTXxFP7yu LLyH9gHs1OcB0ZNRWg0O1GEfyj3vmtUn8ojnfOB9qmt7QNpFd+sTTxcjsHJHN8P8WlPY bS3A== X-Gm-Message-State: AOAM531Sd/t0GRhaRqy1i1HKnEJ3jiIXbbi4CXLDSOaGie3uTTZje981 tywBhqDkbuRiUrp2xe3jSt1gQqg5xY31XFBQf7Kkk/l366v1LIheXSfEsWLQXY3NtWspDLMvrcb aoMOACjcU4OGxItT2kSXSj1NGfXeX2bcx9sX8R37k8ySHL9Tg+dvUNyvF X-Google-Smtp-Source: ABdhPJzZYSt4fmXD7VdJ6T+CnbKC2/TjZT+i4G4gEva1Omiq/qzC/4JrVYLGPq2Q22anUOeAEZWsql+skQ8= X-Received: from yuzhao.bld.corp.google.com ([2620:15c:183:200:f931:d3e4:faa0:4f74]) (user=yuzhao job=sendgmr) by 2002:a25:2308:: with SMTP id j8mr24384456ybj.474.1615622285438; Fri, 12 Mar 2021 23:58:05 -0800 (PST) Date: Sat, 13 Mar 2021 00:57:40 -0700 In-Reply-To: <20210313075747.3781593-1-yuzhao@google.com> Message-Id: <20210313075747.3781593-8-yuzhao@google.com> Mime-Version: 1.0 References: <20210313075747.3781593-1-yuzhao@google.com> X-Mailer: git-send-email 2.31.0.rc2.261.g7f71774620-goog Subject: [PATCH v1 07/14] mm/pagewalk.c: add pud_entry_post() for post-order traversals From: Yu Zhao To: linux-mm@kvack.org Cc: Alex Shi , Andrew Morton , Dave Hansen , Hillf Danton , Johannes Weiner , Joonsoo Kim , Matthew Wilcox , Mel Gorman , Michal Hocko , Roman Gushchin , Vlastimil Babka , Wei Yang , Yang Shi , Ying Huang , linux-kernel@vger.kernel.org, page-reclaim@google.com, Yu Zhao Content-Type: text/plain; charset="UTF-8" X-Stat-Signature: pwaoywzcaff7rgpprjghfdto9tozh93z X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: C2353A0049ED Received-SPF: none (flex--yuzhao.bounces.google.com>: No applicable sender policy available) receiver=imf23; identity=mailfrom; envelope-from="<3jXBMYAYKCKggchPIWOWWOTM.KWUTQVcf-UUSdIKS.WZO@flex--yuzhao.bounces.google.com>"; helo=mail-yb1-f201.google.com; client-ip=209.85.219.201 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1615622285-172303 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: Add a new callback pud_entry_post() to struct mm_walk_ops so that page table walkers can visit the non-leaf PMD entries of a PUD entry after they have visited with the leaf PTE entries. This allows page table walkers who clear the accessed bit to take advantage of the last commit, in a similar way walk_pte_range() works for the PTE entries of a PMD entry: they only need to take PTL once to search all the child entries of a parent entry. Signed-off-by: Yu Zhao --- include/linux/pagewalk.h | 4 ++++ mm/pagewalk.c | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/include/linux/pagewalk.h b/include/linux/pagewalk.h index b1cb6b753abb..2b68ae9d27d3 100644 --- a/include/linux/pagewalk.h +++ b/include/linux/pagewalk.h @@ -11,6 +11,8 @@ struct mm_walk; * @pgd_entry: if set, called for each non-empty PGD (top-level) entry * @p4d_entry: if set, called for each non-empty P4D entry * @pud_entry: if set, called for each non-empty PUD entry + * @pud_entry_post: if set, called for each non-empty PUD entry after + * pmd_entry is called, for post-order traversal. * @pmd_entry: if set, called for each non-empty PMD entry * this handler is required to be able to handle * pmd_trans_huge() pmds. They may simply choose to @@ -41,6 +43,8 @@ struct mm_walk_ops { unsigned long next, struct mm_walk *walk); int (*pud_entry)(pud_t *pud, unsigned long addr, unsigned long next, struct mm_walk *walk); + int (*pud_entry_post)(pud_t *pud, unsigned long addr, + unsigned long next, struct mm_walk *walk); int (*pmd_entry)(pmd_t *pmd, unsigned long addr, unsigned long next, struct mm_walk *walk); int (*pte_entry)(pte_t *pte, unsigned long addr, diff --git a/mm/pagewalk.c b/mm/pagewalk.c index e81640d9f177..8ed1533f7eda 100644 --- a/mm/pagewalk.c +++ b/mm/pagewalk.c @@ -160,6 +160,11 @@ static int walk_pud_range(p4d_t *p4d, unsigned long addr, unsigned long end, err = walk_pmd_range(pud, addr, next, walk); if (err) break; + + if (ops->pud_entry_post) + err = ops->pud_entry_post(pud, addr, next, walk); + if (err) + break; } while (pud++, addr = next, addr != end); return err; -- 2.31.0.rc2.261.g7f71774620-goog