Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2495492rwd; Sun, 21 May 2023 22:54:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4xjxuZOEjnyXe2xg0xUvkkvGaQHAy2Ah2ayoIVxs5NxA6JK8Tg5E9+STux5Ck8KRTvjAMv X-Received: by 2002:a17:903:41c9:b0:1ab:28b4:6d5 with SMTP id u9-20020a17090341c900b001ab28b406d5mr13893144ple.5.1684734890678; Sun, 21 May 2023 22:54:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684734890; cv=none; d=google.com; s=arc-20160816; b=mtjWJBZmA7UURFv/97qUA6sA2dOEVC0chh8AxM1jQNnLsg5HJJVhghMci37AI/6hmF +/DEoa7qx8DDqrfSIUlo1G34/Ib5cbjn8YVtlBO/Tt9DV8Raag2SvqHtnB0KBJbsYXto 7YYHRHQN3geTwRx1FD1QewNkfpjHxe+sFUqyGEHG6AiQ4LGByFcYH2EA2yu5Ldz9Y8sf lIUDd+NAIlo+gxJIWlwED/v8Avrf7gL53PR497SQm6KSpIre2Lw3JaXVfx+1lFQI58Q2 WdklkkdIo4sHt7eK4h1ydLvr2vpqBX8ZZ4fyrwCvXK1TAxI1G3h+fZ/EP6bR7XrsvWWV U5fg== 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=++qSmbn7bhjg3RT15iglmwv4R1gESGfbvlyrc9z9nPg=; b=zM7lP8CbXuV7vgr/9B0HjZYVMX7Es/bNrFyK5mWTPdvNHO3C5WG9POygbZMmaiv+ya nsB9uK7/UYg2f0C0G8ZlCT1hzyBBU7ESj/5/IMgpiRqJ49XNzbNQhW4CajPvLGG95VnW tjTanw7AhEZBUwOUiwrYnJjE/38eHeBpQNE/co/W6JKSzWfawlBh1Ox5yfhJfc1Lp6Fi +2dh8JiDaLH1HBnC4jL0X++hoXKsL5RalJIcQVqVKi9QItF2l3wD2l1r180dIlULFa0E 4DvTPfHKFnIfSoiTUiuymmTK2pud3SkNDcI/RqjK7JhtWvfhEiC6qNd4hqxZaV13uBCa EEVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=KUYquKPQ; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id li12-20020a170903294c00b001a0544138b8si3971689plb.395.2023.05.21.22.54.34; Sun, 21 May 2023 22:54:50 -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=KUYquKPQ; 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 S231996AbjEVF3O (ORCPT + 99 others); Mon, 22 May 2023 01:29:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229470AbjEVF3M (ORCPT ); Mon, 22 May 2023 01:29:12 -0400 Received: from mail-yw1-x112d.google.com (mail-yw1-x112d.google.com [IPv6:2607:f8b0:4864:20::112d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1ECAA8 for ; Sun, 21 May 2023 22:29:11 -0700 (PDT) Received: by mail-yw1-x112d.google.com with SMTP id 00721157ae682-55db055b412so46112237b3.0 for ; Sun, 21 May 2023 22:29:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1684733351; x=1687325351; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=++qSmbn7bhjg3RT15iglmwv4R1gESGfbvlyrc9z9nPg=; b=KUYquKPQFLz686sxc05IvSA2pptVmZo25juuDJPh5PU0X8mcUoMX85X6dQWcuCeLiy uZgK8UCVFiR0+JLDfI+BG2fZ4jpaUFacf9y4wexEGbBLRrMU7EGQ2WyCANVks/wifwjW WIWR1uH1YZ2eCpYGacQpMGZqDG1Rast16Vhqw6loQySVQm459lCNaPM2V4pX8ejuYDHJ iWokAPVtiNyJ1VEM+GanV1g70rryZ2Zn0pEeEaFvrZDQKTZaXrD5lh2IK6/6AvLj649e dxMB/Rriy/3qD/arXkivaOaOUE1co2k6CyJ03pNexh99nj5a3n2SbOmvYztGkHfCQKXx DWrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684733351; x=1687325351; 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=++qSmbn7bhjg3RT15iglmwv4R1gESGfbvlyrc9z9nPg=; b=QELWOKdeHEuDJWAOisdqC+w+lPOSfvHFt/6s7MecIq25umeWB3gmwYSCSrl6UeL2WM 8w47JIWszwxeeKrcc9ajh7mpv8/KYf56FxbWGBc5AIHVanxt/a4n2ajTz/JAx+9K3H7q yTmcJoiykV37qKxefOkxQf3opfaLp4G8suwmP+PdWRZc5PONlY0v66nKSrJSkNeAXG77 aaSuUHleZOaAcudZjj2UtqnUI+kbmrL5jUi46dRLtvQYLWaD8iXqOxSPN8XIrKTWYdOn qst6A3E4e5pzRRJtR8vavdLfgUcPPYM6BulqniH1sbJ1gYTo44bGayg8dckJon3hGtXc v5CA== X-Gm-Message-State: AC+VfDymliUZORtXohisVzO4clPzDIrtjSYzRcN4XKo7leDoH7709+Lr DnSInEH8YzUrHIAKQcoaMeRuUA== X-Received: by 2002:a0d:cac7:0:b0:55a:2084:9e05 with SMTP id m190-20020a0dcac7000000b0055a20849e05mr10730696ywd.23.1684733350763; Sun, 21 May 2023 22:29: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 x67-20020a81a046000000b0054fcbf35b94sm1832465ywg.87.2023.05.21.22.29.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 May 2023 22:29:10 -0700 (PDT) Date: Sun, 21 May 2023 22:29:07 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Yang Shi , Mel Gorman , Peter Xu , Peter Zijlstra , Will Deacon , Yu Zhao , Alistair Popple , Ralph Campbell , Ira Weiny , Steven Price , SeongJae Park , Naoya Horiguchi , Christophe Leroy , Zack Rusin , Jason Gunthorpe , Axel Rasmussen , Anshuman Khandual , Pasha Tatashin , Miaohe Lin , Minchan Kim , Christoph Hellwig , Song Liu , Thomas Hellstrom , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 31/31] perf/core: Allow pte_offset_map() to fail In-Reply-To: <68a97fbe-5c1e-7ac6-72c-7b9c6290b370@google.com> Message-ID: References: <68a97fbe-5c1e-7ac6-72c-7b9c6290b370@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII 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=ham 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 In rare transient cases, not yet made possible, pte_offset_map() and pte_offet_map_lock() may not find a page table: handle appropriately. Signed-off-by: Hugh Dickins --- This is a perf patch, not an mm patch, and it will want to go in through the tip tree in due course; but keep it in this series for now, so that it's not missed, and not submitted before mm review. kernel/events/core.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/events/core.c b/kernel/events/core.c index db016e418931..174be710f3b3 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -7490,6 +7490,7 @@ static u64 perf_get_pgtable_size(struct mm_struct *mm, unsigned long addr) return pud_leaf_size(pud); pmdp = pmd_offset_lockless(pudp, pud, addr); +again: pmd = pmdp_get_lockless(pmdp); if (!pmd_present(pmd)) return 0; @@ -7498,6 +7499,9 @@ static u64 perf_get_pgtable_size(struct mm_struct *mm, unsigned long addr) return pmd_leaf_size(pmd); ptep = pte_offset_map(&pmd, addr); + if (!ptep) + goto again; + pte = ptep_get_lockless(ptep); if (pte_present(pte)) size = pte_leaf_size(pte); -- 2.35.3