From patchwork Sun Jul 23 22:26:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13323368 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C8F7C001DE for ; Sun, 23 Jul 2023 22:26:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8A1256B0071; Sun, 23 Jul 2023 18:26:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 82A398D0001; Sun, 23 Jul 2023 18:26:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 67C686B0075; Sun, 23 Jul 2023 18:26:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 4F5A46B0071 for ; Sun, 23 Jul 2023 18:26:18 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 83C78160853 for ; Sun, 23 Jul 2023 22:26:17 +0000 (UTC) X-FDA: 81044311194.16.4FE1E27 Received: from mail-yw1-f180.google.com (mail-yw1-f180.google.com [209.85.128.180]) by imf12.hostedemail.com (Postfix) with ESMTP id AE0B94000C for ; Sun, 23 Jul 2023 22:26:15 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=iVLb6pAc; spf=pass (imf12.hostedemail.com: domain of hughd@google.com designates 209.85.128.180 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690151175; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=xrAdJXY/DYoZ1QqZrxUyGx5Ypm1XnUOGUxRagKc/Az8=; b=3NEmFwalF7++THgF5qWpg7zROAVCF7413tZ+pkC1yu1X3oqckK1DJ+gjRqzUaSZAq2fMNp R6C/TPlwrwVzlBP52srycWLqePr59Mrv6JoFUT1NYk+e4sd00sT62rZyrwWRbDkYDtqVk4 /NlVPgwuL0Vm+E9wvwG3gI2DrcMjH+E= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690151175; a=rsa-sha256; cv=none; b=J77awy1kfJWd/nFkD+m1kofW+baVwNPsm3ivSAqvYwzuQlXwIRulHRnoub4scLmdKp1tF1 XxicEa6RURnAUECrqmF8Fc0gvrq9dQFk6IqyrRnUBYLd671pO15xlpnUzBNMD9x7/kW0q1 BFB3FGv4rrItEON/xw9TnZYTOcR8mFQ= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=iVLb6pAc; spf=pass (imf12.hostedemail.com: domain of hughd@google.com designates 209.85.128.180 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-yw1-f180.google.com with SMTP id 00721157ae682-583d63ca1e9so10859457b3.1 for ; Sun, 23 Jul 2023 15:26:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690151175; x=1690755975; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=xrAdJXY/DYoZ1QqZrxUyGx5Ypm1XnUOGUxRagKc/Az8=; b=iVLb6pAcMPMbH+sKIFDKrp13WE2BH14wgf0sfLLhG3EUD8G/hlzddsk9BjOLwwBDek i4tMCHQWviMOQirYDf83bTCcJPZWFHJR7xkFk3VHd5hC7xG8MCrz4NcetF3qgqDqKUnu xAsV+Rie6eGsL074ig7H7XBphUKKdrVVeh2TIH148CpPb1+P0n1+X7jZdveWNOjVJ6Ba Kp6B7SozJs02j+R5YidTAfbP/CCuxGe3VqDtLCHCvJZKMpIS4f/D4qj/sIim49FJ+8/T kdqRCusHGpxIPd559J2JIVCjJWnkF/KB5ylzgPVROKPwcB7Y5HxAlrSuCa01u6hWj0LC 1Twg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690151175; x=1690755975; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=xrAdJXY/DYoZ1QqZrxUyGx5Ypm1XnUOGUxRagKc/Az8=; b=AiY+jbjKmStrAF6x1n8eBjDYI1lVluATSa3JaeW5UMx7lGkLTvxaHE36dJU2CY7en/ Dlh8VsST2jJMuNMLmo5UjPIrXY/eprrOQJYC6rtnT08VeMePYCdpT0VjjHM61jvADVTm tlvnDg2AshEJ46tuGZtZsHrD0sSUcnz5bLGc92PIczYf3GoG5Win0KpJJ8LZtNll13Pg WS0h4C/24Yp4AWI6o6DoZ0Uip884ONaVdhTXDvBaXbA8ErLMtPvnl93Laz31n7eyR0PI reA/LzF8VxnsPdbpovUcROm7dwBsxlv/H3sxjM2Aw0InLXFMIhtMvOdOVw74/kCdL0kG mY7g== X-Gm-Message-State: ABy/qLbkht9bg67TPZvztv7vSNailPAs0IFZlJX7ticXzul2wGfz+hr9 fg6ZMZsv8i3EY05ZRZgo+/QbLA== X-Google-Smtp-Source: APBJJlG9iREnJulltCfWnEIqWXVGbxKFPc9M2vviU+KVFolzwpucWCLcuiZJ3CMHwTth2+2e2Ovuug== X-Received: by 2002:a81:7d88:0:b0:583:9018:6fbb with SMTP id y130-20020a817d88000000b0058390186fbbmr5157782ywc.37.1690151174666; Sun, 23 Jul 2023 15:26:14 -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 n124-20020a817282000000b00573898fb12bsm78328ywc.82.2023.07.23.15.26.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jul 2023 15:26:13 -0700 (PDT) Date: Sun, 23 Jul 2023 15:26:02 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Jay Patel , Aneesh Kumar K V , Hugh Dickins , Miaohe Lin , David Hildenbrand , Peter Zijlstra , Yang Shi , Peter Xu , linux-kernel@vger.kernel.org, Song Liu , sparclinux@vger.kernel.org, Alexander Gordeev , Claudio Imbrenda , Will Deacon , linux-s390@vger.kernel.org, Yu Zhao , Ira Weiny , Alistair Popple , Russell King , Matthew Wilcox , Steven Price , Christoph Hellwig , Jason Gunthorpe , linux-arm-kernel@lists.infradead.org, Zi Yan , Huang Ying , Axel Rasmussen , Gerald Schaefer , Christian Borntraeger , Thomas Hellstrom , Ralph Camp bell , Pasha Tatashin , Vasily Gorbik , Anshuman Khandual , Heiko Carstens , Qi Zheng , Suren Baghdasaryan , Vlastimil Babka , SeongJae Park , Lorenzo Stoakes , Jann Horn , linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, Naoya Horiguchi , Zack Rusin , Vishal Moola , Minchan Kim , "Kirill A. Shutemov" , Mel Gorman , "David S. Miller" , Mike Rapoport , Mike Kravetz Subject: [PATCH v3 04/13 fix] powerpc: assert_pte_locked() use pte_offset_map_nolock(): fix In-Reply-To: <20230721131341.w5abuxcbohofpzwa@patel> Message-ID: References: <7cd843a9-aa80-14f-5eb2-33427363c20@google.com> <87msztbiy8.fsf@linux.ibm.com> <392f311f-83ac-a5a2-d16e-2c7736d1b577@google.com> <6762c880-6d2b-233f-6786-7ad5b0472dc7@linux.ibm.com> <20230721131341.w5abuxcbohofpzwa@patel> MIME-Version: 1.0 X-Rspamd-Queue-Id: AE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aLKeGuSwPSZ A1ua5ufa s5vsxJ/qcqTYYCz4YtU04sOn0J+/zCe+1H6nZuiHTDp5+CZfYfzl7qYiwjCHYUNcqkj74jbOeTsVfcXiTVEz3p0sRcNLmDXYPjpI6z8AL6rd44VL3mM8GeFagJEuZtsl2EXFmsb+ATwWqtVPR7fErPhrC3JuiHaCnibrCZrd/Dt5Gz8u2syvO/5Qe0hcsSURJ801+sBYgkHMkes1LX2FS/BFhDviODj1poaLUbTPB2Wqr2zG5aBF93PTxFBciyujx2992TYzv4kAbhIuNogCou6vJ3mI6zhmI8FEhd+nshzcDoTAIBSZKfUxkAEmuvF/E9f5mCrc2XMlzShu0UDS6ildA1ragS9S8wyAiflU2vgzOiME+8yWfARoWlFbNA5bm0lvtUdLr3lGU9fJKzb3ZITmyvYBwY43erXiSYHAlQKxhB6PGzBsKQz2dTGIuALTwpJAYkzzVH+A37+C/59kj9jl/jXyNfjRKNemeYf7duHk2LYkDranWsKXZpg== 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: Aneesh points out that assert_pte_locked() still needs the pmd_none() check, to stop crashing in khugepaged: restore that comment and check. Andrew, when merging with original commit, please edit its 1st para to: Instead of pte_lockptr(), use the recently added pte_offset_map_nolock() in assert_pte_locked(). BUG if pte_offset_map_nolock() fails. Signed-off-by: Hugh Dickins --- arch/powerpc/mm/pgtable.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/powerpc/mm/pgtable.c b/arch/powerpc/mm/pgtable.c index 16b061af86d7..a3dcdb2d5b4b 100644 --- a/arch/powerpc/mm/pgtable.c +++ b/arch/powerpc/mm/pgtable.c @@ -323,6 +323,14 @@ void assert_pte_locked(struct mm_struct *mm, unsigned long addr) pud = pud_offset(p4d, addr); BUG_ON(pud_none(*pud)); pmd = pmd_offset(pud, addr); + /* + * khugepaged to collapse normal pages to hugepage, first set + * pmd to none to force page fault/gup to take mmap_lock. After + * pmd is set to none, we do a pte_clear which does this assertion + * so if we find pmd none, return. + */ + if (pmd_none(*pmd)) + return; pte = pte_offset_map_nolock(mm, pmd, addr, &ptl); BUG_ON(!pte); assert_spin_locked(ptl);