From patchwork Thu Jun 10 06:40:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 12311945 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 5FE9FC47094 for ; Thu, 10 Jun 2021 06:40:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E10EA613CA for ; Thu, 10 Jun 2021 06:40:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E10EA613CA 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 7A1EB6B0036; Thu, 10 Jun 2021 02:40:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 752A96B006E; Thu, 10 Jun 2021 02:40:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5CB9C6B0070; Thu, 10 Jun 2021 02:40:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0093.hostedemail.com [216.40.44.93]) by kanga.kvack.org (Postfix) with ESMTP id 26DF16B0036 for ; Thu, 10 Jun 2021 02:40:12 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id BF66B813E for ; Thu, 10 Jun 2021 06:40:11 +0000 (UTC) X-FDA: 78236864622.20.7146EA2 Received: from mail-qk1-f175.google.com (mail-qk1-f175.google.com [209.85.222.175]) by imf11.hostedemail.com (Postfix) with ESMTP id 242FA200107C for ; Thu, 10 Jun 2021 06:40:06 +0000 (UTC) Received: by mail-qk1-f175.google.com with SMTP id u30so26285951qke.7 for ; Wed, 09 Jun 2021 23:40:11 -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=kXGE7AZWMRkQI2D2fv4mdt0RT7InHtOBXYXrcKUASZQ=; b=pTtcgnuHkfB+ZWeRrnJcb4kua/2i5mFlvyyK1oUUKP3IwMOaFUBnHVR9givA9IegE8 PsdB/++dX/+OMuBz4wPTjhABOSluN+50HARmKc3x+/6ml6z6v37WHyEnwfWIRWiVfBd8 0W7z2Quygw8xMioTE864MUQdheJ1VMEWk+iiEBOKwF5S1yr+NTTVWzs6+Xr0wzUyvGji OB8b5UecOci6aX3c/2UupL8jk6+KmwDXJUnIXtGnmUv0CNuMawdEbWTKR3+6WCFlYAiq u1zMHesyCTki6CpLiOnqP5+qDgsiBH3IFHJi/8Y1iPixSIKZ4cNbkatGORXJEW0okFlD M4hQ== 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=kXGE7AZWMRkQI2D2fv4mdt0RT7InHtOBXYXrcKUASZQ=; b=n70wx0TGiZs8S9pWET6XNpoIMFlLzhjO6IoTKQ9dkpRvOo3WPNNCtrQ28GAelHzsbO pf3zNQapCMmSGXhTMqCFpNWk0ydiGkLvKOLftgxjFC0CJfbYUx0jw+4NxDgAAfxjj0Fk IZpWpxrBJPlf0Rrb3fXa/nyyjZuXFeW/p28Lb5Ae3s/GxXIZMeLSAs3l5PKx2ayf+esj 41iWImXY5aNMbE4AV5iWuS1mZYwof7pztd0Kw2KebyR9BAJTvbKLMn6ic+0/SKdKIlHd iESD2yO/a/3UXITSgJ9w1xYQdmtnWf6KQN2UnARiyUJMrfwqkGfGC13F1xXBqKUYydy/ ssqQ== X-Gm-Message-State: AOAM531gNFlFwnJOpHCJzLLw+YgHFdR7evNY2RxbVyIuR1cRUK09aLGJ pGDUbGAW9UE+ZfKPFIJ2NjpCAA== X-Google-Smtp-Source: ABdhPJxlHE0YxyFCF53h4uqHehxwG7bqDEAol3I+xWrbbx4f0ummmIi1JMXE/u++r1xFunWK7pFJ7Q== X-Received: by 2002:a05:620a:147a:: with SMTP id j26mr3322349qkl.138.1623307210706; Wed, 09 Jun 2021 23:40:10 -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 a68sm1632172qkd.51.2021.06.09.23.40.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Jun 2021 23:40:10 -0700 (PDT) Date: Wed, 9 Jun 2021 23:40:08 -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 04/11] mm: page_vma_mapped_walk(): use pmde for *pvmw->pmd In-Reply-To: <589b358c-febc-c88e-d4c2-7834b37fa7bf@google.com> Message-ID: <53fbc9d-891e-46b2-cb4b-468c3b19238e@google.com> References: <589b358c-febc-c88e-d4c2-7834b37fa7bf@google.com> MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 242FA200107C X-Stat-Signature: msgbn5qjjp3fun8n8c7s6icofdh4redu Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=google.com header.s=20161025 header.b=pTtcgnuH; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf11.hostedemail.com: domain of hughd@google.com designates 209.85.222.175 as permitted sender) smtp.mailfrom=hughd@google.com X-HE-Tag: 1623307206-738339 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: re-evaluate pmde after taking lock, then use it in subsequent tests, instead of repeatedly dereferencing pointer. Signed-off-by: Hugh Dickins Cc: Acked-by: Kirill A. Shutemov Reviewed-by: Peter Xu --- mm/page_vma_mapped.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/mm/page_vma_mapped.c b/mm/page_vma_mapped.c index 973c3c4e72cc..81000dd0b5da 100644 --- a/mm/page_vma_mapped.c +++ b/mm/page_vma_mapped.c @@ -194,18 +194,19 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw) if (pmd_trans_huge(pmde) || is_pmd_migration_entry(pmde)) { pvmw->ptl = pmd_lock(mm, pvmw->pmd); - if (likely(pmd_trans_huge(*pvmw->pmd))) { + pmde = *pvmw->pmd; + if (likely(pmd_trans_huge(pmde))) { if (pvmw->flags & PVMW_MIGRATION) return not_found(pvmw); - if (pmd_page(*pvmw->pmd) != page) + if (pmd_page(pmde) != page) return not_found(pvmw); return true; - } else if (!pmd_present(*pvmw->pmd)) { + } else if (!pmd_present(pmde)) { if (thp_migration_supported()) { if (!(pvmw->flags & PVMW_MIGRATION)) return not_found(pvmw); - if (is_migration_entry(pmd_to_swp_entry(*pvmw->pmd))) { - swp_entry_t entry = pmd_to_swp_entry(*pvmw->pmd); + if (is_migration_entry(pmd_to_swp_entry(pmde))) { + swp_entry_t entry = pmd_to_swp_entry(pmde); if (migration_entry_to_page(entry) != page) return not_found(pvmw);