From patchwork Mon May 22 05:29:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 97039 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1226367vqo; Sun, 21 May 2023 22:47:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5KUXXJWX/lQ2tv6kShlhFFguM4TN2soHPl564kEub4NemvLKoU2GN+H6rImEvh1QUJRBUu X-Received: by 2002:a05:6a20:1606:b0:104:1016:dd0e with SMTP id l6-20020a056a20160600b001041016dd0emr11385755pzj.3.1684734419937; Sun, 21 May 2023 22:46:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684734419; cv=none; d=google.com; s=arc-20160816; b=cyofMHQzkH2dF29q15sRfbKsPA+GfjD4tqpTrEF7or/+uUsjmAhEUAXIOCE6ILzd7D ZujlxvrKXp/RO1b5J/Jmthh0DTzxm5I8uYRC6nmEfzP2uaeXs8qxs3kudG64s04x9pDu tGFs2j7aTJmywUVhA0E5V89YMUQbV+stH7VQ9HWhH9/nsGxhHc4Fjq1vhQceckLraE1W NSAL9V+XEvybSU/C1qt4keJ7mN6oKQl1+z2txcPAz1TE4HDaPLLA6mYoY4wvqhhjFysT IywVQLy70EizjaTBJIC16wGO0XPrE3ZTGo7T1jOeCmRigxL0E8Q4NeTCKVf+3MpjHu9D woeg== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 24-20020a631258000000b005323e566996si2555614pgs.58.2023.05.21.22.46.45; Sun, 21 May 2023 22:46:59 -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 S231997AbjEVF3O (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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766572078717387526?= X-GMAIL-MSGID: =?utf-8?q?1766572078717387526?= 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);