From patchwork Thu Jun 10 06:44:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 12311949 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 2B43AC47094 for ; Thu, 10 Jun 2021 06:44:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id ADE42613E2 for ; Thu, 10 Jun 2021 06:44:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ADE42613E2 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 41AAB6B0036; Thu, 10 Jun 2021 02:44:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3CAD26B006E; Thu, 10 Jun 2021 02:44:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 26BD76B0070; Thu, 10 Jun 2021 02:44:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0239.hostedemail.com [216.40.44.239]) by kanga.kvack.org (Postfix) with ESMTP id EB52D6B0036 for ; Thu, 10 Jun 2021 02:44:14 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 8243E40E1 for ; Thu, 10 Jun 2021 06:44:14 +0000 (UTC) X-FDA: 78236874828.30.E44A189 Received: from mail-qv1-f42.google.com (mail-qv1-f42.google.com [209.85.219.42]) by imf22.hostedemail.com (Postfix) with ESMTP id 2C21AC005A20 for ; Thu, 10 Jun 2021 06:44:08 +0000 (UTC) Received: by mail-qv1-f42.google.com with SMTP id e18so14162481qvm.10 for ; Wed, 09 Jun 2021 23:44:13 -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=akymlcTjak2aiLxju3nvGrvixCmoGtWlsFfmG/UDbtE=; b=MkEt15JmyYSAQ+RVuy42Ljti0kzjYxMG1NcV1cwy50nRl6vRoncOkzghyDe4se7H+c GK3oAdp+cr0pMytWAFXnCaZIP4PXXPmxt/GGtorivsAlQ9wr1WPTY9pb3okv4y0hwjWF f0ig6Dbf2GWBXHvC60iY2h+R1mWvaMi7U/s/zfiDez2w0O2cFGJPFrLauq2XgwlaEa1Z JmvhibYkqss7F/ZFx9im9UzrewbbehaLv92KMQFhWZ9noj0+mgW2LhK3ahjypVq7E/v6 Drh9gSNvhsUL9EHI8CUMP13xFZiYfJNRf6yVODI6iBHsjEKBeRao0mE/LGsEJqoPyc9U 9UYg== 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=akymlcTjak2aiLxju3nvGrvixCmoGtWlsFfmG/UDbtE=; b=KHqaO0TCukj+ylEBsB2/+/hL0MmFOoINMYpajQJeOSQI6DStCeJU2WrPVN+sVJo1T6 1zlDijrTGEnYsLJB9hTGH/AGlmv6Ga96hOqAP1KHprwzo+YGdYJitJZN4CMeWusFyd9W FvAKhmOkgPGTDl0tjflohvAP+TJJLKbwh2Zid5WpVG/TxS0zjT2o+XIbg5gDlhnEWtoN t1IwH7jSqBZilIdT6QRbcChNX6T3e3a10At1SnydDqXk16glPF+wZ6ZIazBjaeaVg3/E lzoib35gP1iBq/f6MKyI1wIAqQhHzuEbRiPzFuc4HDxF2K4wPjsEwPEpQ0pw7XaDNIDX ONKg== X-Gm-Message-State: AOAM532MACSGos2l1N0bFlGR1BZ98vSkJ3rJsF/OY7GCUCQNbeUGtvQs GfSA9j+ekgmGacwSYL0djKBRuQ== X-Google-Smtp-Source: ABdhPJw+h+5g4qsaqPq9hBVqb+DYjhTLlr01z83/WwZH9CfNzJzW4AMFaeYoGQbJMjmA43tYbaijbg== X-Received: by 2002:a05:6214:260b:: with SMTP id gu11mr3840211qvb.12.1623307453261; Wed, 09 Jun 2021 23:44:13 -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 p8sm1598335qkm.119.2021.06.09.23.44.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Jun 2021 23:44:12 -0700 (PDT) Date: Wed, 9 Jun 2021 23:44:10 -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 06/11] mm: page_vma_mapped_walk(): crossing page table boundary In-Reply-To: <589b358c-febc-c88e-d4c2-7834b37fa7bf@google.com> Message-ID: <799b3f9c-2a9e-dfef-5d89-26e9f76fd97@google.com> References: <589b358c-febc-c88e-d4c2-7834b37fa7bf@google.com> MIME-Version: 1.0 Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20161025 header.b=MkEt15Jm; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf22.hostedemail.com: domain of hughd@google.com designates 209.85.219.42 as permitted sender) smtp.mailfrom=hughd@google.com X-Stat-Signature: owpgkbsyqci1ib7qw1xt59y4z4bqeo4f X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 2C21AC005A20 X-HE-Tag: 1623307448-946894 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: adjust the test for crossing page table boundary - I believe pvmw->address is always page-aligned, but nothing else here assumed that; and remember to reset pvmw->pte to NULL after unmapping the page table, though I never saw any bug from that. Signed-off-by: Hugh Dickins Cc: --- mm/page_vma_mapped.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mm/page_vma_mapped.c b/mm/page_vma_mapped.c index b96fae568bc2..0fe6e558d336 100644 --- a/mm/page_vma_mapped.c +++ b/mm/page_vma_mapped.c @@ -247,16 +247,16 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw) if (pvmw->address >= end) return not_found(pvmw); /* Did we cross page table boundary? */ - if (pvmw->address % PMD_SIZE == 0) { - pte_unmap(pvmw->pte); + if ((pvmw->address & (PMD_SIZE - PAGE_SIZE)) == 0) { if (pvmw->ptl) { spin_unlock(pvmw->ptl); pvmw->ptl = NULL; } + pte_unmap(pvmw->pte); + pvmw->pte = NULL; goto restart; - } else { - pvmw->pte++; } + pvmw->pte++; } while (pte_none(*pvmw->pte)); if (!pvmw->ptl) {