From patchwork Thu Aug 31 17:18:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Fernandes X-Patchwork-Id: 13371752 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 2A403C83F37 for ; Thu, 31 Aug 2023 17:18:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 88528940007; Thu, 31 Aug 2023 13:18:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 834BE8D0001; Thu, 31 Aug 2023 13:18:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6FD69940007; Thu, 31 Aug 2023 13:18:35 -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 61B998D0001 for ; Thu, 31 Aug 2023 13:18:35 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 28D081C9951 for ; Thu, 31 Aug 2023 17:18:35 +0000 (UTC) X-FDA: 81185058990.04.EA98702 Received: from mail-io1-f52.google.com (mail-io1-f52.google.com [209.85.166.52]) by imf22.hostedemail.com (Postfix) with ESMTP id 3A410C0022 for ; Thu, 31 Aug 2023 17:18:32 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=joelfernandes.org header.s=google header.b=urZejajD; dmarc=none; spf=pass (imf22.hostedemail.com: domain of joel@joelfernandes.org designates 209.85.166.52 as permitted sender) smtp.mailfrom=joel@joelfernandes.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1693502313; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=uNen2wFqGs+WYv0jInGdV6FOrUFFJP4ofxSiG/zeNsQ=; b=oS1ySEdIaI1ngBpFhWfUI1JMqwVAPTNZz164djZlaBEazet15SLsIDXFXfNcCSt/Rco0qV CPA1mRg67rQ2xXilEkRFgRHP+50pQeLWxexYW9mfR82yR+eOXgAvcXspJo6Lgmix7OF4hh atDX56OA228QzUIImPxn0MbnTtClEGQ= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=joelfernandes.org header.s=google header.b=urZejajD; dmarc=none; spf=pass (imf22.hostedemail.com: domain of joel@joelfernandes.org designates 209.85.166.52 as permitted sender) smtp.mailfrom=joel@joelfernandes.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1693502313; a=rsa-sha256; cv=none; b=sw+0xHvxS56p8rP6XLcqUcnEosCOo3AbbTtoWIpYsbhG1l45mRc9ZB7dpywfBiU5fCpEOt ybOd347gdRYjpG+XbmHm3FElmcbJjY9HvX7A/lICMk9DOXJCQVD9clA+bvejhNR/StiYCg fir6jjXJ27RCxfwMiHUSQ/HQ3PZuqNQ= Received: by mail-io1-f52.google.com with SMTP id ca18e2360f4ac-792979d4cb5so39986439f.2 for ; Thu, 31 Aug 2023 10:18:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1693502312; x=1694107112; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=uNen2wFqGs+WYv0jInGdV6FOrUFFJP4ofxSiG/zeNsQ=; b=urZejajDRsG7aLkSf8bulpC2bkitLLvv7j6mrQ45/cTRmr49S9qGRJIZRZeoYYllQr DtmZnphdAkx0BpP9ZC/F2/PtPLzoQwo3H0VyTxWZx6RTyfvbgaq4KV5icO0iLSWZyPXn /rlJVpjNCxXozKQ6R+Iwpb4xh2R+Nshj3DZfg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693502312; x=1694107112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=uNen2wFqGs+WYv0jInGdV6FOrUFFJP4ofxSiG/zeNsQ=; b=K0zxDFFbZ8ZWjcHiwFjTKjeckE/xvhkHOxKgv5immxCfHy0xmCjqUcktvRQJkusJ77 DJ/I85hKE8s/foUgkJmvpNZTBBUUTj7Ug52noAldeULTFFjWRAseM18np21CzVtoO/Ne zvr9dzKMEG7OQw7Ge16qQuno4FSzfOcWZtR1VGKVBtDcPXSHmb07F/P8ur6CSeTcyA8p gOkxltqkgsAGQcjEnd/YaMPXKEIMKJt0YjS598EE+7wVyjJVwpdHwsgCzn3mtr2qPrLd 8tQSNqoytyqiIn8xn14g6NWId7aFmHD5OismDQlC0BXrrH15xC5WSu6/Xq3QEGE3LuYv LxMw== X-Gm-Message-State: AOJu0Yz07V5MAnOS3RYOD6PcgWwJHlNQlvwBkjRHnRNw1hJWXFtqMavL caBXlKTwZQp0DknseH1VXgNv1A== X-Google-Smtp-Source: AGHT+IH9nNzsM/Nlgp8Zi3Oo7b7WP2tj3Njcw0OCUdypAZrLXBRUvBA+50OCgoB1OKAFfZ42JKDmVA== X-Received: by 2002:a5e:c203:0:b0:790:ab53:ed16 with SMTP id v3-20020a5ec203000000b00790ab53ed16mr6691054iop.21.1693502312260; Thu, 31 Aug 2023 10:18:32 -0700 (PDT) Received: from joelboxx5.c.googlers.com.com (156.190.123.34.bc.googleusercontent.com. [34.123.190.156]) by smtp.gmail.com with ESMTPSA id a16-20020a056638019000b0042af069eeefsm489720jaq.50.2023.08.31.10.18.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Aug 2023 10:18:31 -0700 (PDT) From: "Joel Fernandes (Google)" To: linux-kernel@vger.kernel.org, Andrew Morton , Uladzislau Rezki , Christoph Hellwig , Lorenzo Stoakes Cc: "Joel Fernandes (Google)" , Zhen Lei , "Paul E . McKenney" , rcu@vger.kernel.org, Zqiang , Matthew Wilcox , linux-mm@kvack.org Subject: [PATCH v2 1/2] mm/vmalloc: Add a safer version of find_vm_area() for debug Date: Thu, 31 Aug 2023 17:18:25 +0000 Message-ID: <20230831171827.2625016-1-joel@joelfernandes.org> X-Mailer: git-send-email 2.42.0.rc2.253.gd59a3bf2b4-goog MIME-Version: 1.0 X-Rspamd-Queue-Id: 3A410C0022 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 6a6meza9b5ruxfbmcys4i7qitz8ihn6d X-HE-Tag: 1693502312-607761 X-HE-Meta: U2FsdGVkX1/HAsHvxJxBgtSU41qEhUeyklmWcAxngfOhZD38OSNlxHoekGMjGamwoaha744Ouc5HldkwL1Yfur1ejyZuFkRb1dzbzYZAgGt0k3mSiq9u0U8ZmEGIOkQe4fg7g87KcNSj6249LMXcNnu5mkFFv17oT7iAT2jkifGup4t+aaU0sQwuSQu4kFyQaQNFOZpw1J/veSKPfIxuMSlzrqBM8oX2fZgS/NvNICbgFhz8rJkv6MJbgsEq81vlF1uLJGlcX1EzmuDEZ/QthAd9XmE+d6NsK3ZpgKWeBzXvHswBK7nhWiQ8e3VgTTGuE/sES8t7UWJp20HjSuFuiaYraCOtgqimLSCOGqXhl41Gu2SDc8XxPzCfGlW/iMXaJU8ENO7P2syDrFm+WxNs7ADDJRHc1J3D4blFQJd98gqHTnCKrECmVY58pHE9u6LwQBvIANi3k6L5Z9Zx0MTC7K0K1TcgnkvmcfuJC9PqROsbJjzv42hg7i769+k2h8kYzXHBviTooAwzaSV2kZVrLJIfad3MyPZ+JTkBEEXRKD7Ld94zJqhnwihiVpIoWkuc/olTGORcyMSDQBVwQ2sJ+igpnXXEBbd3IQccul5YlM0OxEEwuU1fjA/1BruhBEg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p1g== 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: It is unsafe to dump vmalloc area information when trying to do so from some contexts. Add a safer trylock version of the same function to do a best-effort VMA finding and use it from vmalloc_dump_obj(). [apply test robot feedback on unused function fix.] Reported-by: Zhen Lei Cc: Paul E. McKenney Cc: rcu@vger.kernel.org Cc: Zqiang Reviewed-by: Matthew Wilcox (Oracle) Signed-off-by: Joel Fernandes (Google) Reviewed-by: Uladzislau Rezki (Sony) --- v1->v2: Apply review tags and test robot feedback. mm/vmalloc.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 93cf99aba335..f09e882ae3b8 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -1865,6 +1865,20 @@ struct vmap_area *find_vmap_area(unsigned long addr) return va; } +#ifdef CONFIG_PRINTK +static struct vmap_area *find_vmap_area_trylock(unsigned long addr) +{ + struct vmap_area *va; + + if (!spin_trylock(&vmap_area_lock)) + return NULL; + va = __find_vmap_area(addr, &vmap_area_root); + spin_unlock(&vmap_area_lock); + + return va; +} +#endif + static struct vmap_area *find_unlink_vmap_area(unsigned long addr) { struct vmap_area *va; @@ -2671,6 +2685,29 @@ struct vm_struct *find_vm_area(const void *addr) return va->vm; } +/** + * try_to_find_vm_area - find a continuous kernel virtual area + * @addr: base address + * + * This function is the same as find_vm_area() except that it is + * safe to call if vmap_area_lock is already held and returns NULL + * if it is. See comments in find_vmap_area() for other details. + * + * Return: the area descriptor on success or %NULL on failure. + */ +#ifdef CONFIG_PRINTK +static struct vm_struct *try_to_find_vm_area(const void *addr) +{ + struct vmap_area *va; + + va = find_vmap_area_trylock((unsigned long)addr); + if (!va) + return NULL; + + return va->vm; +} +#endif + /** * remove_vm_area - find and remove a continuous kernel virtual area * @addr: base address @@ -4277,7 +4314,7 @@ bool vmalloc_dump_obj(void *object) struct vm_struct *vm; void *objp = (void *)PAGE_ALIGN((unsigned long)object); - vm = find_vm_area(objp); + vm = try_to_find_vm_area(objp); if (!vm) return false; pr_cont(" %u-page vmalloc region starting at %#lx allocated at %pS\n", From patchwork Thu Aug 31 17:18:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Fernandes X-Patchwork-Id: 13371753 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 E40B2C83F35 for ; Thu, 31 Aug 2023 17:18:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 74D0B8D0001; Thu, 31 Aug 2023 13:18:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6FD0F280002; Thu, 31 Aug 2023 13:18:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5033E8D001D; Thu, 31 Aug 2023 13:18:36 -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 3DD208D0001 for ; Thu, 31 Aug 2023 13:18:36 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 0D323C03FC for ; Thu, 31 Aug 2023 17:18:36 +0000 (UTC) X-FDA: 81185059032.22.31E9162 Received: from mail-io1-f41.google.com (mail-io1-f41.google.com [209.85.166.41]) by imf16.hostedemail.com (Postfix) with ESMTP id 31767180008 for ; Thu, 31 Aug 2023 17:18:34 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=joelfernandes.org header.s=google header.b=p3lksU5a; dmarc=none; spf=pass (imf16.hostedemail.com: domain of joel@joelfernandes.org designates 209.85.166.41 as permitted sender) smtp.mailfrom=joel@joelfernandes.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1693502314; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=j/9/PG9jMlcZB3crQaMzRcArzBV6KYUSerMEBj6hrg8=; b=LrC2kJGo8lVBO3+H5B1fiy7pQRtBoEPiltHvLTdA+NqvzTB0Pgz9d+I0FoSIG+YTAY9uCf kLW5LlaW2dsD2u9pF0Yvk1o7B4XLTa7eUJQVwmAdvz93H5oXWNYUt7RWJcIpwEnp/lFTM4 qppW/mhgDIJdK/X/BQtI3pGKz27gVWQ= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=joelfernandes.org header.s=google header.b=p3lksU5a; dmarc=none; spf=pass (imf16.hostedemail.com: domain of joel@joelfernandes.org designates 209.85.166.41 as permitted sender) smtp.mailfrom=joel@joelfernandes.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1693502314; a=rsa-sha256; cv=none; b=jEMVx7hENbuVadR5QyuKyowcr2Cg/Az6HMwsxr9lWrrNMCOi3k8zioN19/tLXseHXHoGv2 0kcTq0l38BxhEo5vlu5IOuvKNQiUPEaYUip8/fPWhzu7LgdY5gO9Pc4fdf5J4ghUijW64f oqunPk4knk6+TUculkT4bBz/5W+mRMg= Received: by mail-io1-f41.google.com with SMTP id ca18e2360f4ac-7927952ca67so38875039f.2 for ; Thu, 31 Aug 2023 10:18:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1693502313; x=1694107113; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=j/9/PG9jMlcZB3crQaMzRcArzBV6KYUSerMEBj6hrg8=; b=p3lksU5ah9iAUSDpu74O0Ka/+P77QBhTmQxnsSXN5yCYAlrrR9PpYFdGeIOuH8rYU3 qgRTcCm5fUiNFcfjCuMqSoL0cfYYXKuZHIHG29IMXVLeFCVDX+v2xlmVAUF/OQKXujHx 6HA8jimgbG1d3El9IwN7akBbw9hTL6Uria90w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693502313; x=1694107113; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=j/9/PG9jMlcZB3crQaMzRcArzBV6KYUSerMEBj6hrg8=; b=dWZSWbARpioAPHAYtj2GUqYWvX3GUnD0L0r0u62bVl2ZMPT+cHnSjsLjv45vBa0K1n dWZRs+kdgVjJJznf8qWAPY1FYBhAVFBe1QcXiJkE07JAIgSqgyj9eOBU3UelHjwBz8Gs Ss9UobCCja/LhAk5s8o0zWdxHxH58Kd0m2xM+F1RsKuAnhZmy7Y0Y/dGOpq8lK3ZWeAU zp5RAczhzPjdnlOTAi3OCk5iJxNVSV+hy/Gk6ySLfvjIgqAlB4fIKmvG3ow8P2qLmqlN I9SnKr/SDFFK6WkFaAdBsuQg0OA6qGl3d5Pqs7Cyu2iYbVKVfWF4SS6UZnAk4SO+AZ3s r77A== X-Gm-Message-State: AOJu0YxBduJHWH8XbSmWKSVpJF5sAAgwjWecMbTEXQXmgdaFifkXXRuB 6PU1RoErKlOAM/3mtY8xsN6r/Q== X-Google-Smtp-Source: AGHT+IHcox5PcaIvs7MVFvtB0jCP2GW2W8V6QqMbhxRIywTxp3y1gSk6Bn/EIRCUTsCRwW8btiaIxA== X-Received: by 2002:a05:6602:370a:b0:792:4d29:ecc7 with SMTP id bh10-20020a056602370a00b007924d29ecc7mr6959672iob.15.1693502313379; Thu, 31 Aug 2023 10:18:33 -0700 (PDT) Received: from joelboxx5.c.googlers.com.com (156.190.123.34.bc.googleusercontent.com. [34.123.190.156]) by smtp.gmail.com with ESMTPSA id a16-20020a056638019000b0042af069eeefsm489720jaq.50.2023.08.31.10.18.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Aug 2023 10:18:32 -0700 (PDT) From: "Joel Fernandes (Google)" To: linux-kernel@vger.kernel.org, Andrew Morton Cc: Zqiang , Zhen Lei , "Paul E . McKenney" , rcu@vger.kernel.org, Matthew Wilcox , Joel Fernandes , linux-mm@kvack.org Subject: [PATCH v2 2/2] rcu: Dump vmalloc memory info safely Date: Thu, 31 Aug 2023 17:18:26 +0000 Message-ID: <20230831171827.2625016-2-joel@joelfernandes.org> X-Mailer: git-send-email 2.42.0.rc2.253.gd59a3bf2b4-goog In-Reply-To: <20230831171827.2625016-1-joel@joelfernandes.org> References: <20230831171827.2625016-1-joel@joelfernandes.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 31767180008 X-Stat-Signature: mj79kqxohgewkutnpnt4xj7ynjwquutw X-HE-Tag: 1693502314-632617 X-HE-Meta: U2FsdGVkX19ZmxzfOSCaOE+IxajxelId1A/PTh32wC7EXgYE968Wk0ndP+QiQZ4cSU5wUCdInEtdONr6/wm7AXe5pJZmHnikaC+VKdqqLtcicq8XutOnJE7dcTIH5KCSB4qhjCCgKh/zeHnT5o+m/cS8G0JGCXPRBVpDthwerWa+bTGWsYOunUW43YQuDpFzSk5nHlOOJ3XfYfxuocx4aVaCPyvh7dsk6KpcayQBw5JciFIG5Zs2OmS1dbtCgIRCyO7A/2ijvLnXcq8IYGRwiMp9ZSOS52hSDxTIc9HUrr426uGnuEVRa9HNUSeaDgEPbTURt/YBAsjxKO8XXwCPvp7uzhxqscEkJwf3+/X8ugX7Tqon41xKQqKbbV6hNkSWTickXT5+iJFtD8iHGPO4e2UyUnGLVL6swszDZAluCeqpL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c5iJ06/1t/Ih0OPuQoOVjfQO0ynH8Y9ubKEVelz12Y/d/ooVGOsGCjwJaglkUfPB0zUka+pDFP/bhxawBHIHojZGKbBcOKtjHjJczMERxCIOFJdWBa+7qzypPufbxBqkZr5UDqdXoXpCgzmnNUDcheZNmKeLQwF9duykWrK0vg80z30noBqB4/YRaLcj1dLt5f3jvMtLYwG89sbIfw76dL77RW 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: From: Zqiang Currently, for double invoke call_rcu(), will dump rcu_head objects memory info, if the objects is not allocated from the slab allocator, the vmalloc_dump_obj() will be invoke and the vmap_area_lock spinlock need to be held, since the call_rcu() can be invoked in interrupt context, therefore, there is a possibility of spinlock deadlock scenarios. And in Preempt-RT kernel, the rcutorture test also trigger the following lockdep warning: BUG: sleeping function called from invalid context at kernel/locking/spinlock_rt.c:48 in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 1, name: swapper/0 preempt_count: 1, expected: 0 RCU nest depth: 1, expected: 1 3 locks held by swapper/0/1: #0: ffffffffb534ee80 (fullstop_mutex){+.+.}-{4:4}, at: torture_init_begin+0x24/0xa0 #1: ffffffffb5307940 (rcu_read_lock){....}-{1:3}, at: rcu_torture_init+0x1ec7/0x2370 #2: ffffffffb536af40 (vmap_area_lock){+.+.}-{3:3}, at: find_vmap_area+0x1f/0x70 irq event stamp: 565512 hardirqs last enabled at (565511): [] __call_rcu_common+0x218/0x940 hardirqs last disabled at (565512): [] rcu_torture_init+0x20b2/0x2370 softirqs last enabled at (399112): [] __local_bh_enable_ip+0x126/0x170 softirqs last disabled at (399106): [] inet_register_protosw+0x9/0x1d0 Preemption disabled at: [] rcu_torture_init+0x1f13/0x2370 CPU: 0 PID: 1 Comm: swapper/0 Tainted: G W 6.5.0-rc4-rt2-yocto-preempt-rt+ #15 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.16.2-0-gea1b7a073390-prebuilt.qemu.org 04/01/2014 Call Trace: dump_stack_lvl+0x68/0xb0 dump_stack+0x14/0x20 __might_resched+0x1aa/0x280 ? __pfx_rcu_torture_err_cb+0x10/0x10 rt_spin_lock+0x53/0x130 ? find_vmap_area+0x1f/0x70 find_vmap_area+0x1f/0x70 vmalloc_dump_obj+0x20/0x60 mem_dump_obj+0x22/0x90 __call_rcu_common+0x5bf/0x940 ? debug_smp_processor_id+0x1b/0x30 call_rcu_hurry+0x14/0x20 rcu_torture_init+0x1f82/0x2370 ? __pfx_rcu_torture_leak_cb+0x10/0x10 ? __pfx_rcu_torture_leak_cb+0x10/0x10 ? __pfx_rcu_torture_init+0x10/0x10 do_one_initcall+0x6c/0x300 ? debug_smp_processor_id+0x1b/0x30 kernel_init_freeable+0x2b9/0x540 ? __pfx_kernel_init+0x10/0x10 kernel_init+0x1f/0x150 ret_from_fork+0x40/0x50 ? __pfx_kernel_init+0x10/0x10 ret_from_fork_asm+0x1b/0x30 The previous patch fixes this by using the deadlock-safe best-effort version of find_vm_area. However, in case of failure print the fact that the pointer was a vmalloc pointer so that we print at least something. Reported-by: Zhen Lei Cc: Paul E. McKenney Cc: rcu@vger.kernel.org Reviewed-by: Matthew Wilcox (Oracle) Signed-off-by: Zqiang Signed-off-by: Joel Fernandes (Google) --- mm/util.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mm/util.c b/mm/util.c index dd12b9531ac4..406634f26918 100644 --- a/mm/util.c +++ b/mm/util.c @@ -1071,7 +1071,9 @@ void mem_dump_obj(void *object) if (vmalloc_dump_obj(object)) return; - if (virt_addr_valid(object)) + if (is_vmalloc_addr(object)) + type = "vmalloc memory"; + else if (virt_addr_valid(object)) type = "non-slab/vmalloc memory"; else if (object == NULL) type = "NULL pointer";