From patchwork Thu Jun 10 06:42:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 12311947 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 A4C9FC47094 for ; Thu, 10 Jun 2021 06:42:18 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3173B613CA for ; Thu, 10 Jun 2021 06:42:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3173B613CA 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 B22E76B0036; Thu, 10 Jun 2021 02:42:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AD2186B006E; Thu, 10 Jun 2021 02:42:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 972E36B0070; Thu, 10 Jun 2021 02:42:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0228.hostedemail.com [216.40.44.228]) by kanga.kvack.org (Postfix) with ESMTP id 62DFA6B0036 for ; Thu, 10 Jun 2021 02:42:17 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 04E9C180AD81D for ; Thu, 10 Jun 2021 06:42:17 +0000 (UTC) X-FDA: 78236869914.10.B64561C Received: from mail-qk1-f170.google.com (mail-qk1-f170.google.com [209.85.222.170]) by imf07.hostedemail.com (Postfix) with ESMTP id ABA9FA0001A9 for ; Thu, 10 Jun 2021 06:42:11 +0000 (UTC) Received: by mail-qk1-f170.google.com with SMTP id j184so26306226qkd.6 for ; Wed, 09 Jun 2021 23:42:16 -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=BF7gYv4bUzMzXTGdnVKsNQ49KcCRY8OjCfC9I0iFikc=; b=GK3lO1UZgj0viQsuAlknaSC++U0LASLzlwmP3Ygwbb0R9vdkntk33kVgOb7rxaj4mv yxELPE7Wjnfn5+KYoCameACweq3+yaeqsgFT02R4Enrx84iAhpVMmP9vYxfrkrQl+Kng uxPGPPZQY5yq4sqOdyU8EhRoY8yxvHKoWeg9g0uZxHFxVolQ6WQnJI/bjtzolnTrCdUM 1wVj2lTu50F52DoY7yru/rfi+5TOyctn1dnsEZeLWvRdVpMJknSFUXsKHSmQ1lx/3Yv3 ENPncba//NbOxmU6ZHEO65cr0hMI9dEqQrNvqtd6/uNamY9ozwlilcN9U39yjjxwV6AD PF9g== 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=BF7gYv4bUzMzXTGdnVKsNQ49KcCRY8OjCfC9I0iFikc=; b=mW0br4P44ZiF++w/RJdRLsQUrJqXhmnM28NCnBURaOKbBizuh/4UMGcumGltAuioiT 4Tf1lWihltCXk0hxR5/Wn0TiAGx7RRI6xwIz2qFOKLzaNTBCo8EeQTfRi6IZKfXhgZyR Nn5Y2/p0/6g+SYi8s96rh+/hgQLdV7Et3yvMQj9F12AldNtwH7c7C+PpSvjrklAY/VtZ ZLDXjGGumZjdSgAXlfj8avW6R0y7OYYbqcrz5zn3Y0DLVW1yj2xiKozsCXnGzOyrNyYA siIDE/0rj5p2wmZ4nmxlQglRS1Kp/JYNqrww+ph162/mtHelDFj+pi2iyPvzjvHeLdNO rBwA== X-Gm-Message-State: AOAM531mQoq2Wx7mOWHFV7ecDnxM9+fScHJu+0zfaYHrN8gsx+hpaMLL z23oy76rodcSzi37Wwg3Hw73TA== X-Google-Smtp-Source: ABdhPJyXu+PktDehHYGHVmTT0YocIN/sxyUPwE+UTTh86S5eE20bKBx41KVp+5SfZNFFJyhSi8avtw== X-Received: by 2002:a37:a107:: with SMTP id k7mr3267352qke.362.1623307335910; Wed, 09 Jun 2021 23:42:15 -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 m14sm1671302qti.12.2021.06.09.23.42.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Jun 2021 23:42:15 -0700 (PDT) Date: Wed, 9 Jun 2021 23:42:12 -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 05/11] mm: page_vma_mapped_walk(): prettify PVMW_MIGRATION block In-Reply-To: <589b358c-febc-c88e-d4c2-7834b37fa7bf@google.com> Message-ID: <378c8650-1488-2edf-9647-32a53cf2e21@google.com> References: <589b358c-febc-c88e-d4c2-7834b37fa7bf@google.com> MIME-Version: 1.0 Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=google.com header.s=20161025 header.b=GK3lO1UZ; spf=pass (imf07.hostedemail.com: domain of hughd@google.com designates 209.85.222.170 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com X-Stat-Signature: 9aohw8bq1uwmeganohxnutjh5zq6ygwc X-Rspamd-Queue-Id: ABA9FA0001A9 X-Rspamd-Server: rspam06 X-HE-Tag: 1623307331-717270 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: rearrange the !pmd_present() block to follow the same "return not_found, return not_found, return true" pattern as the block above it (note: returning not_found there is never premature, since existence or prior existence of huge pmd guarantees good alignment). Signed-off-by: Hugh Dickins Cc: Acked-by: Kirill A. Shutemov Reviewed-by: Peter Xu --- mm/page_vma_mapped.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/mm/page_vma_mapped.c b/mm/page_vma_mapped.c index 81000dd0b5da..b96fae568bc2 100644 --- a/mm/page_vma_mapped.c +++ b/mm/page_vma_mapped.c @@ -201,24 +201,22 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw) if (pmd_page(pmde) != page) return not_found(pvmw); return true; - } 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(pmde))) { - swp_entry_t entry = pmd_to_swp_entry(pmde); + } + if (!pmd_present(pmde)) { + swp_entry_t entry; - if (migration_entry_to_page(entry) != page) - return not_found(pvmw); - return true; - } - } - return not_found(pvmw); - } else { - /* THP pmd was split under us: handle on pte level */ - spin_unlock(pvmw->ptl); - pvmw->ptl = NULL; + if (!thp_migration_supported() || + !(pvmw->flags & PVMW_MIGRATION)) + return not_found(pvmw); + entry = pmd_to_swp_entry(pmde); + if (!is_migration_entry(entry) || + migration_entry_to_page(entry) != page) + return not_found(pvmw); + return true; } + /* THP pmd was split under us: handle on pte level */ + spin_unlock(pvmw->ptl); + pvmw->ptl = NULL; } else if (!pmd_present(pmde)) { /* * If PVMW_SYNC, take and drop THP pmd lock so that we