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: 124566 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp1469636vqg; Sun, 23 Jul 2023 16:20:06 -0700 (PDT) X-Google-Smtp-Source: APBJJlE7z7f8o/bVnK71xZcB++wVzSeFnnGBQZ036yP9GVpbjCla/996bf+oKyPVBQjXM+jdDtTX X-Received: by 2002:a05:6358:5928:b0:131:b4c:b871 with SMTP id g40-20020a056358592800b001310b4cb871mr4768696rwf.22.1690154406019; Sun, 23 Jul 2023 16:20:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690154405; cv=none; d=google.com; s=arc-20160816; b=lO0sRxTlhwOdqiBa7JiJuy6J/aRPprzz6l04qJkffUFgxKNrkrEXG8bF55m69csak+ mzLkXqiOC2U0C5glDX/ZU2ITkh5vyBq9duQmxHYmo7A9ToZPmdJKevNT4yzNBC8az+z3 OaYWDH5Xe4zMBDzp7qQHwIMuYhtfQXQ8JK2P+ay5KfVJFcTwzvR3JdXnvFKjeRmM9Y26 m1m21jnzz4Wo0T0FgPcETHHjQ9ePNcfxZfqvcMnievUY/R1XWQmk5+yAQReVYq3s41Zj 6WHOtupQ5BCeOm4IKCFw5p2B/CyeWlCP5McJR03hhaxIndLLeGbljYlL7nLwrNBXsmXH 4B8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=xrAdJXY/DYoZ1QqZrxUyGx5Ypm1XnUOGUxRagKc/Az8=; fh=GO5CkOdVNlJPZEarM6OxTuTApqkq+yu4itL8m+Vr0T0=; b=OedKfdAb8sfuBWLwU07hSYJ4nAsu2Qj1R0Ci8QFDmA8S5KPJE07NEpTJVTZNBleO// 9XUHbyx/yod/u1RzdCpxphvNSeR0S1fDZFY0N6Ve8a/e4NdAaYIf+lBV/bjTj1a23fHA lSx2P7uz5SGDJyvcDzRZvVGBXLe2fKy4uJ7DAxXUyUBGKhIu+18k95N50egOW8TM7y9z rXT8m5lHAlm5tyPOwvH3TnneaeofaBascGyorgPsBEyxxcUuBx2smHTifwxr92QL/9n+ aePob3GGVDzvnhqAx/IxbbgimUOZ0+BGYuTwb8Crolc3xeJv+4r/MHbloVwOtWxPrjBB pkyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=iVLb6pAc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h64-20020a638343000000b00563aa631e73si1625863pge.35.2023.07.23.16.19.52; Sun, 23 Jul 2023 16:20:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=iVLb6pAc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229647AbjGWW0U (ORCPT + 99 others); Sun, 23 Jul 2023 18:26:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229470AbjGWW0S (ORCPT ); Sun, 23 Jul 2023 18:26:18 -0400 Received: from mail-yw1-x112e.google.com (mail-yw1-x112e.google.com [IPv6:2607:f8b0:4864:20::112e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5694E5C for ; Sun, 23 Jul 2023 15:26:15 -0700 (PDT) Received: by mail-yw1-x112e.google.com with SMTP id 00721157ae682-5838881e30bso39354787b3.2 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=hgQjhSwgyfzgJzeLbds+XRVHtkdoPebaqdS+a/TBQAvYWU1LTf+nnyH1ZaIEnTz7eo EHqa894zKYRB4MGI87YqtpD9OhAobE5RllRIVwBRppRYZT7UF742sMcO/cbFJq9bXbtl V2yQ7gxNxZSFAGWvv0tNqo5b2ygsjNic8hetf/5ug7YHc6paUUVyBeqqeXrpVUYyyzFO M9UaIyelJGCjmyDNtYG0cYRyOslYhiEFvjKuvZGlhbEsAV7gE2Yg+IRXpH3vhiLs/tfR F7SBZ05EUTnkxfTHyVQhJpciXWIPpPA6AtsmI2Bor3zYVhv4S8a9g9dYiJxW1SKbU6LC X2+Q== X-Gm-Message-State: ABy/qLYpjjdr6qX9SbBF7NAvoJHZWYkeLWOlU900HD2EoFE5i07Djs2x f6tX3ibtbi7UyGq9IW+IsGpyNw== 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-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772255346692741436 X-GMAIL-MSGID: 1772255346692741436 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);