From patchwork Thu Jun 10 06:50:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 12311969 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=-23.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_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 1DC00C47094 for ; Thu, 10 Jun 2021 06:50:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BD843613CA for ; Thu, 10 Jun 2021 06:50:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BD843613CA 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 4B0436B0036; Thu, 10 Jun 2021 02:50:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4608C6B006E; Thu, 10 Jun 2021 02:50:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2DAAD6B0070; Thu, 10 Jun 2021 02:50:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0110.hostedemail.com [216.40.44.110]) by kanga.kvack.org (Postfix) with ESMTP id EF6836B0036 for ; Thu, 10 Jun 2021 02:50:26 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 7CB99181AEF1F for ; Thu, 10 Jun 2021 06:50:26 +0000 (UTC) X-FDA: 78236890452.05.C4E891A Received: from mail-qv1-f44.google.com (mail-qv1-f44.google.com [209.85.219.44]) by imf18.hostedemail.com (Postfix) with ESMTP id 17475200107C for ; Thu, 10 Jun 2021 06:50:21 +0000 (UTC) Received: by mail-qv1-f44.google.com with SMTP id x6so9273037qvx.4 for ; Wed, 09 Jun 2021 23:50:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :mime-version; bh=MW3P4dEVpzQaKkCia9N+0MaZJYQT+2IAhJVUZg7cfs8=; b=Do8aT0u+DdZZq8kaOVvB6kgFwGS6mToQyGIoS2wWY4uZ3M/EtH9HIcV12t4Dntbu4B GSIWT43fzAd1hVrjp33IgBv/via5r3NIF7MXRDjCH4X2pxhRMwAV7HcouDjLk6kIda0G C77fRSpITnyPd2/XRz/RJyywcVeEZYG/HfryDo45NoUasSyLQPKi1euqRC+PfEg+vddE PwCwcq6Iqa3GiwU4B6VYphKpI242PJS34F4JI0jv5njbSjFOXldXBll/yYyqDWeVRGb4 STufu8xuwTwB7QL2nHvVLIOTQ95uumyfHuejvqKOZ/YfEufUrAtwIpjTPqeUgPnIP4BZ 2yLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:mime-version; bh=MW3P4dEVpzQaKkCia9N+0MaZJYQT+2IAhJVUZg7cfs8=; b=GQ53IYe2QpIA1HEg9YIFeZQl1NpCJSe1y/ggSTjhijcYyiz/um3mgoL9sCgWN7+Ck2 UvpAgWxLldec7+CIhv3qP9Q/ZRub0eYRxj7gZjhN4icfl+9cBcz/VADu0OyO3TbNtVUd DzBMMLTOqF+g8USSl3A/r1OhkGuW8RdHatoMLoBEjJI/Oc01m2l1x5Yxer+LJGRRQ9PN iTwtF8A5bakQUtjFU7Z18e0m+zkJ7fQBgIo1c2k5HqYQRhHp67NfWWjbqfeRSV0qlvH0 QRqPnmEzQz2mL3TL+6FJvPedTCLA1NH9XVZlxK3OVKTcylV8JXKGNVjJeNAOU4n1TGsM Yu/w== X-Gm-Message-State: AOAM532mHT9E4D2EJCjrjGRiZ4Q0xC9hOrMwyBGXJQLENOd3QBSCuFyc MF0MpUVzxSO6l+M/0LHzLo3QGw== X-Google-Smtp-Source: ABdhPJxZswruLW9txlbS5dufC/7Inh5U9BCmjlx6PQDp97tfhKPQgM3yJjJJ09wVZQfRUJlz0FRbqw== X-Received: by 2002:ad4:5fc7:: with SMTP id jq7mr3417734qvb.41.1623307825295; Wed, 09 Jun 2021 23:50:25 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id 85sm1678043qko.14.2021.06.09.23.50.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Jun 2021 23:50:25 -0700 (PDT) Date: Wed, 9 Jun 2021 23:50:23 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.anvils To: Andrew Morton cc: Hugh Dickins , "Kirill A. Shutemov" , Yang Shi , Wang Yugui , Matthew Wilcox , Alistair Popple , Ralph Campbell , Zi Yan , Peter Xu , Will Deacon , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 09/11] mm: page_vma_mapped_walk(): get vma_address_end() earlier In-Reply-To: <589b358c-febc-c88e-d4c2-7834b37fa7bf@google.com> Message-ID: <4542b34d-862f-7cb4-bb22-e0df6ce830a2@google.com> References: <589b358c-febc-c88e-d4c2-7834b37fa7bf@google.com> MIME-Version: 1.0 Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=google.com header.s=20161025 header.b=Do8aT0u+; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf18.hostedemail.com: domain of hughd@google.com designates 209.85.219.44 as permitted sender) smtp.mailfrom=hughd@google.com X-Rspamd-Server: rspam02 X-Stat-Signature: uxom1zex63ep5qna6bmjb5nzb5gt7hm5 X-Rspamd-Queue-Id: 17475200107C X-HE-Tag: 1623307821-933182 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: page_vma_mapped_walk() cleanup: get THP's vma_address_end() at the start, rather than later at next_pte. It's a little unnecessary overhead on the first call, but makes for a simpler loop in the following commit. Signed-off-by: Hugh Dickins Cc: Acked-by: Kirill A. Shutemov --- mm/page_vma_mapped.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/mm/page_vma_mapped.c b/mm/page_vma_mapped.c index 006f4814abbc..f6839f536645 100644 --- a/mm/page_vma_mapped.c +++ b/mm/page_vma_mapped.c @@ -171,6 +171,15 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw) return true; } + /* + * Seek to next pte only makes sense for THP. + * But more important than that optimization, is to filter out + * any PageKsm page: whose page->index misleads vma_address() + * and vma_address_end() to disaster. + */ + end = PageTransCompound(page) ? + vma_address_end(page, pvmw->vma) : + pvmw->address + PAGE_SIZE; if (pvmw->pte) goto next_pte; restart: @@ -239,10 +248,6 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw) if (check_pte(pvmw)) return true; next_pte: - /* Seek to next pte only makes sense for THP */ - if (!PageTransHuge(page)) - return not_found(pvmw); - end = vma_address_end(page, pvmw->vma); do { pvmw->address += PAGE_SIZE; if (pvmw->address >= end)