From patchwork Fri Jun 9 01:27:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13273080 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 ADE2CC7EE25 for ; Fri, 9 Jun 2023 01:28:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 461A08E0002; Thu, 8 Jun 2023 21:28:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3EB1D8E0001; Thu, 8 Jun 2023 21:28:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 263CB8E0002; Thu, 8 Jun 2023 21:28:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 146108E0001 for ; Thu, 8 Jun 2023 21:28:00 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id DF4CA1C7695 for ; Fri, 9 Jun 2023 01:27:59 +0000 (UTC) X-FDA: 80881473078.16.BB0171B Received: from mail-yw1-f173.google.com (mail-yw1-f173.google.com [209.85.128.173]) by imf18.hostedemail.com (Postfix) with ESMTP id 1779D1C000D for ; Fri, 9 Jun 2023 01:27:57 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=OyAJimk3; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf18.hostedemail.com: domain of hughd@google.com designates 209.85.128.173 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686274078; 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=MyPFy0gUSdpV3ibLKHHJg/J/UWoL9nTKOb5gbs61iKQ=; b=QiFUGkoICGkHCkwjR6US07s0ePIE17pxrN6DkILlzFRoNC9mM2zYPkxSnikyBrAbCO7t/L yNlp2UCm4y71sH4FbnH8y/l7zTkE2e5dPxGlrI0aYP304Tu1d+z40EvBTPhjUqOkgtgmMn hFixl3EShPjjLy8vebZ0vazzJAOvxNw= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=OyAJimk3; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf18.hostedemail.com: domain of hughd@google.com designates 209.85.128.173 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686274078; a=rsa-sha256; cv=none; b=m/8twCNaQhK7SQhWiRP2ucqvvVnRHiXNqA4ncKFSjCJ0Q6cIdFH/rqirFhfoCeHUz2aEIN M0R9kmos3VhrppNiw/Y6SUIrbRaoi7Oswsq+vNJtETV1ct1B73IC5Opl00vZEDz5Ys5uRu 2+KbrQzN5IhxSxnpn2dQr2WiQzvqnU0= Received: by mail-yw1-f173.google.com with SMTP id 00721157ae682-565c3aa9e82so12131027b3.2 for ; Thu, 08 Jun 2023 18:27:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686274077; x=1688866077; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=MyPFy0gUSdpV3ibLKHHJg/J/UWoL9nTKOb5gbs61iKQ=; b=OyAJimk3fc+/Li5me7PIcu882/+lDPwqec67fOflTDld8VWvm0ZySNcdoJgLTrD9rx WoOLU/XWyP4MN+Eoi7KJZTv1R6ExtbK2SMofkB2PIt1uKNhRHeS+xx4hN9Wks9SB/Hkk 4gzmFYarU9qov9Uzj7o9h1zLdkAzYRq/b/kKfVItrvxfhKgU8iMFFvE5pQZ3kgV2up+L hNFZoE2nbmMWdsnJ1XbGUBg6gK5gwmUXxa01pub4RN5ECsXTRQyDMvk6goIXaQohEPKU wCMnLqlIXUxUsnIlKrzfLeDs5rhQwhiPDht5XmK01inAm6KH0sUkni/+00j7bluhyFK7 RwQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686274077; x=1688866077; 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=MyPFy0gUSdpV3ibLKHHJg/J/UWoL9nTKOb5gbs61iKQ=; b=QdIXhHuCE9+na7R0j2E2DyVsgSk2udFW4q5LPlRUcaf+9hoOEm6hQs/RgWWrnV4FMI CpzdywX/ilXs6vB+E4V0P3Eotk3yVzoz5/i0Vg2gTMBmM7Kttcrf/AAUWvxm7BkSOxxU A8HAGhoBgp3LwlWhRB0TGMTwG9uHHrdgE7+5axQwdyiE7t3LVinrNehnv4oZdl/qsqIu tgJAIRHNp8uVg1flr/mWC68c9yM6AR0rpxFV3oJ2lIH5HOEHXZXIQi5z9onvM2QCQvgG 2YStXfrWQZ2IvzqLTjKTLN902F0HYQ6AyRp/YCgYusHfveTHkvtJrWqrZ0Dun47pyQCV AyDQ== X-Gm-Message-State: AC+VfDyg9a0jr9+DO8EnJypiQx14GhFPpAKa/oviSi5t2ORIdpDofdtS A0JEdhHIfzQ6a9HV/z59MLHKAQ== X-Google-Smtp-Source: ACHHUZ5jGBBEQ5gswQSXjac3sdwb/7+VqiRoKupCeGhVPyqG0jNqvRoD86vqt+pEd3PQOO1HZrsBzg== X-Received: by 2002:a81:8005:0:b0:569:74f3:ed2e with SMTP id q5-20020a818005000000b0056974f3ed2emr1337210ywf.22.1686274077005; Thu, 08 Jun 2023 18:27:57 -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 c205-20020a814ed6000000b005688ca40c4bsm291663ywb.61.2023.06.08.18.27.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 18:27:56 -0700 (PDT) Date: Thu, 8 Jun 2023 18:27:52 -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 , Lorenzo Stoakes , Huang Ying , Naoya Horiguchi , Christophe Leroy , Zack Rusin , Jason Gunthorpe , Axel Rasmussen , Anshuman Khandual , Pasha Tatashin , Miaohe Lin , Minchan Kim , Christoph Hellwig , Song Liu , Thomas Hellstrom , Ryan Roberts , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 16/32] mm/debug_vm_pgtable,page_table_check: warn pte map fails In-Reply-To: Message-ID: <3ea9e4f-e5cf-d7d9-4c2-291b3c5a3636@google.com> References: MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: kxqdhchtwmzpmqeeyibdbf8qm3tckzfy X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 1779D1C000D X-HE-Tag: 1686274077-362586 X-HE-Meta: U2FsdGVkX1+zPKzQgDwAdWRh5cyHN5Vp3QyNbSx7pHm6nA7aOsYh2NqmLGnXdJOzrklY5/EfMC0XQ/VyOS49Blvj0kRo+k/IvJcYOLuA7tluZhrYCnjRTfGtPFLG/3wSGYSWtx4HR+C9j+lbef3XfbIGUzpXt4iosMmdTJlG/l1eBlyW1VfZk09DEZF3tnWokDsxfzvEEcHchZ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yZO7e5PzYnypgNuYXDms7AJ2oB7M2xbVtbKTi450QQGetXYGXTzanCc5iShutidu5U34qe6WMtflac2X40Uu820qjIb9/WCWHZsJeodKSawUBqAVlFY7ufwsp1Ffj9UYf9jtAbboI3rO2ihyQLg== 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: Failures here would be surprising: pte_advanced_tests() and pte_clear_tests() and __page_table_check_pte_clear_range() each issue a warning if pte_offset_map() or pte_offset_map_lock() fails. Signed-off-by: Hugh Dickins --- mm/debug_vm_pgtable.c | 9 ++++++++- mm/page_table_check.c | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/mm/debug_vm_pgtable.c b/mm/debug_vm_pgtable.c index c54177aabebd..ee119e33fef1 100644 --- a/mm/debug_vm_pgtable.c +++ b/mm/debug_vm_pgtable.c @@ -138,6 +138,9 @@ static void __init pte_advanced_tests(struct pgtable_debug_args *args) return; pr_debug("Validating PTE advanced\n"); + if (WARN_ON(!args->ptep)) + return; + pte = pfn_pte(args->pte_pfn, args->page_prot); set_pte_at(args->mm, args->vaddr, args->ptep, pte); flush_dcache_page(page); @@ -619,6 +622,9 @@ static void __init pte_clear_tests(struct pgtable_debug_args *args) * the unexpected overhead of cache flushing is acceptable. */ pr_debug("Validating PTE clear\n"); + if (WARN_ON(!args->ptep)) + return; + #ifndef CONFIG_RISCV pte = __pte(pte_val(pte) | RANDOM_ORVALUE); #endif @@ -1377,7 +1383,8 @@ static int __init debug_vm_pgtable(void) args.ptep = pte_offset_map_lock(args.mm, args.pmdp, args.vaddr, &ptl); pte_clear_tests(&args); pte_advanced_tests(&args); - pte_unmap_unlock(args.ptep, ptl); + if (args.ptep) + pte_unmap_unlock(args.ptep, ptl); ptl = pmd_lock(args.mm, args.pmdp); pmd_clear_tests(&args); diff --git a/mm/page_table_check.c b/mm/page_table_check.c index f2baf97d5f38..b743a2f6bce0 100644 --- a/mm/page_table_check.c +++ b/mm/page_table_check.c @@ -246,6 +246,8 @@ void __page_table_check_pte_clear_range(struct mm_struct *mm, pte_t *ptep = pte_offset_map(&pmd, addr); unsigned long i; + if (WARN_ON(!ptep)) + return; for (i = 0; i < PTRS_PER_PTE; i++) { __page_table_check_pte_clear(mm, addr, *ptep); addr += PAGE_SIZE;