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: 13249792 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 5FC20C77B75 for ; Mon, 22 May 2023 05:29:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 030946B0074; Mon, 22 May 2023 01:29:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F23426B0078; Mon, 22 May 2023 01:29:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DEC41900002; Mon, 22 May 2023 01:29:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D16096B0074 for ; Mon, 22 May 2023 01:29:13 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 96A2FC0420 for ; Mon, 22 May 2023 05:29:13 +0000 (UTC) X-FDA: 80816762586.28.C9B9424 Received: from mail-yw1-f171.google.com (mail-yw1-f171.google.com [209.85.128.171]) by imf12.hostedemail.com (Postfix) with ESMTP id A9C3340016 for ; Mon, 22 May 2023 05:29:11 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=KUYquKPQ; spf=pass (imf12.hostedemail.com: domain of hughd@google.com designates 209.85.128.171 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=1684733351; 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=++qSmbn7bhjg3RT15iglmwv4R1gESGfbvlyrc9z9nPg=; b=8K7SYK09D+65Qq/GoJDKnaF4IkB3DdN4oEkHJd/PvJoH6hcnhBSOgWkL/hPdFDV5nJiMeL jqHFxp1wxco2GCoqWwNHzMiwJD4kHTPP+YGkLyYB0q0HfgfW1vQhhrH6YBOM66BpMh4Ryu Jsu9ZQwtQANmL4Dd/b1Iyby1ycOstYE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684733351; a=rsa-sha256; cv=none; b=e8fG9fnE8ddHubA6ORYbGImte2cxbSxbmgfJ2YAL3bsFab0Y9TW9loy+OPjudtgi+bio75 W1UTq9TQtoZEVt02W5p9W1Pysmf8HqmjiQe44mzcyFziH7YeJ/vxPc6jwFzgT7pcT+mRNI 6DUkP5NsGJGGxY/bryK9aMMvi66vOLM= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=KUYquKPQ; spf=pass (imf12.hostedemail.com: domain of hughd@google.com designates 209.85.128.171 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-yw1-f171.google.com with SMTP id 00721157ae682-561b7729a12so45910687b3.1 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=Ywx2540gN8AGInE70AqTTJtBj01ejB/3NnO4XAX2iNUMLLRw29VrJqEBHcohc0FtSi 70id3qH/4oesfGfeUKx7tbVKzMQ1/CgkYqXjm3/NWJoK0Y/hubC5fEzC+rAipRfZUYPN CCADpLOXf8cDPcp0zbDVW5LXlf4vrqZFlzGAUXqXej/mAWOdeZNsfs08vqLLcHVtBoTS cnupKFsOct3c/++dwJ+o24gbkMHONqmf1GoJEI2KhZvwSHNMsw+cRUkPzCQvob1mFXHj e+Yxne89BKGQ5xXchD6scjwrP3gJtwLjFrrL1ZEMhLeRF3ARrdHJfFC1x+3kweSlqvCH Jgcw== X-Gm-Message-State: AC+VfDzYhf52z11F5JqJz4STpd/X2XxNasGgW/ORQtlq6lEyhkvBdl0b c6P+aUVnr1bgSwVRPoRRMU+5FQ== X-Google-Smtp-Source: ACHHUZ58DrOuEAqS21o31T6NkFTUrmPfkTQChFezlC+fyR5u9eV8KPIJhLKCfEeaQKdNd4WYmfpBlw== 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-Rspamd-Queue-Id: A9C3340016 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: hnttjr6s1b3ozp4zf4f4zhwrmprw4fwx X-HE-Tag: 1684733351-711623 X-HE-Meta: U2FsdGVkX1/FipF5295d3bBuogxsURVGDKM+LMCcvGeS8Zmi71it0mLOdxF9oOixr9WlCwwvZeQWUR4vAI7igGb37SYTq22jejHJ2Ow7m7Kv5nMM5sFQhYqDQPD2ZIDSQxukx+addmQZZHb/a3+WI4rzhFFop5gcc0TV5NDLgvOP7yEI0W7itROidEuTJcv0gIbT7xcWNaif9wp9cBmT5J4uwHtsu2ygkgNeUuKEtDGzy0l4MLaa5Qztp61gF+tmFz7nGtEBx9RUUzbXG7Vg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xl/eIG+jSxo31GG0z1bSL0pTbUJ6945VAyQas2NGWhOmwiIeF0Aq8oF/My0X1WYT4Wuew== 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: 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);