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+iJFtD8iHGPO4e2UyUnGLVL6swszDZAluCeqpLP6shI5exNpq9G8Bur7yhaDmPZV/AfsNKCi576TYQXAXIl1Irq5c5dHlYutacoXMR/zCy1YORwq+oCzRka8YSOjjyRPJqGdAmO64VS8c02iizlLgoKXfKW8/In6t9HKBV78fhXYT6qFQCW2pxXsm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zmnNUDcheZNmKeLQwF9duykWrK0vg80z30noBqB4/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";