Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1138107ybt; Tue, 7 Jul 2020 08:35:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJys5Aj4wYivU7saab5XilDPUY/uOz8/NaKajcPS6yecyA3anXyXqZfYCddyRbMelIuNzYm+ X-Received: by 2002:a05:6402:1c8f:: with SMTP id cy15mr62403464edb.308.1594136110610; Tue, 07 Jul 2020 08:35:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594136110; cv=none; d=google.com; s=arc-20160816; b=ZtxzrAosg2lpXBtIDapG9cScXposx8MxWsbLPVGKm5VhSRGb25WtIFDNuUEjLMGlX9 wIuEGqbYp9bAGy3UTwmsCxv7sjdO6CeOD5AQDD7rkC7A+9Jq91CjonfPiL+3vo8g9wMa yXSmNhH9e70WgmdnCuMBk69J/1LBoR6Z0orixQ+zdvlL48NMsk+dz75XPvoooUvaGLsM OeD28NcPCJLeIe8H4EigesbJLQrXo8ubuUSpsXamLGW+D/M+zRVgBEvlcwcvNEjrprcx FvkAon1SPa7zB16ZUyK7wa4Uhn5cCxmXdwTUKxVIFr0EANi3mNq/LpWb4bdPBqOhSB7H xAOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=FZkxFjru4LWUgW54uA4gblirn4tbh1uG10NEU93rlAA=; b=pBQZhhbz7TdMkfbqKr7mKegAXA5OPRa8W1ngcHEUNP10ThludG1K3GVhhI+5B3Scki xDUw+D9BBpQhRTcTQVH/hmJ3HINp10Yob302zCwsRSI3Mvk90g6k+tKPDgTHZXTrZg4R h1+Kzel5l6ZZ+wrS8JHd5tASssJboVfF4ArBQ54Ir2K6TcHW4r9aqui4vBhH5R658+IQ Nd6zRZ/uTqXb4a7kqvH7EWewAfuPR25rpaaaAqvl4rVIAB76N94O61+ELp4AcV5HVDFJ D5JjA1jVLHTW4W+/hkzKSo/HL/VXGUEPwpqSblKb3oXTXyHcUMHFCfF+sFDxNSplBqO1 XU2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hv5ClVg4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dp8si20397338ejc.281.2020.07.07.08.34.46; Tue, 07 Jul 2020 08:35:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hv5ClVg4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728834AbgGGPS1 (ORCPT + 99 others); Tue, 7 Jul 2020 11:18:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:57658 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728029AbgGGPSX (ORCPT ); Tue, 7 Jul 2020 11:18:23 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3B99520738; Tue, 7 Jul 2020 15:18:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594135102; bh=9OmlKNqJ+4/nPvflKJ4ptgswRxfkQ/UEjIiDkbTSzw4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hv5ClVg4EGbPSvXvoftKjTzocf2+8WOH1tubpsyMTCpZ7T55sx3/Da7frh/Ejg4fP Lb5Jq/1EtMcvq9lgh8TdezQcMfLOkMxCGwPxbrgQZ7+KEY2jlqYwshxme+eSkFxC9n csYtOTLDbTiNxbatO2/kpC9fSS5wEJFPDAwOQRuA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Douglas Anderson , Daniel Thompson , Sasha Levin Subject: [PATCH 4.19 12/36] kgdb: Avoid suspicious RCU usage warning Date: Tue, 7 Jul 2020 17:17:04 +0200 Message-Id: <20200707145749.725908319@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200707145749.130272978@linuxfoundation.org> References: <20200707145749.130272978@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Douglas Anderson [ Upstream commit 440ab9e10e2e6e5fd677473ee6f9e3af0f6904d6 ] At times when I'm using kgdb I see a splat on my console about suspicious RCU usage. I managed to come up with a case that could reproduce this that looked like this: WARNING: suspicious RCU usage 5.7.0-rc4+ #609 Not tainted ----------------------------- kernel/pid.c:395 find_task_by_pid_ns() needs rcu_read_lock() protection! other info that might help us debug this: rcu_scheduler_active = 2, debug_locks = 1 3 locks held by swapper/0/1: #0: ffffff81b6b8e988 (&dev->mutex){....}-{3:3}, at: __device_attach+0x40/0x13c #1: ffffffd01109e9e8 (dbg_master_lock){....}-{2:2}, at: kgdb_cpu_enter+0x20c/0x7ac #2: ffffffd01109ea90 (dbg_slave_lock){....}-{2:2}, at: kgdb_cpu_enter+0x3ec/0x7ac stack backtrace: CPU: 7 PID: 1 Comm: swapper/0 Not tainted 5.7.0-rc4+ #609 Hardware name: Google Cheza (rev3+) (DT) Call trace: dump_backtrace+0x0/0x1b8 show_stack+0x1c/0x24 dump_stack+0xd4/0x134 lockdep_rcu_suspicious+0xf0/0x100 find_task_by_pid_ns+0x5c/0x80 getthread+0x8c/0xb0 gdb_serial_stub+0x9d4/0xd04 kgdb_cpu_enter+0x284/0x7ac kgdb_handle_exception+0x174/0x20c kgdb_brk_fn+0x24/0x30 call_break_hook+0x6c/0x7c brk_handler+0x20/0x5c do_debug_exception+0x1c8/0x22c el1_sync_handler+0x3c/0xe4 el1_sync+0x7c/0x100 rpmh_rsc_probe+0x38/0x420 platform_drv_probe+0x94/0xb4 really_probe+0x134/0x300 driver_probe_device+0x68/0x100 __device_attach_driver+0x90/0xa8 bus_for_each_drv+0x84/0xcc __device_attach+0xb4/0x13c device_initial_probe+0x18/0x20 bus_probe_device+0x38/0x98 device_add+0x38c/0x420 If I understand properly we should just be able to blanket kgdb under one big RCU read lock and the problem should go away. We'll add it to the beast-of-a-function known as kgdb_cpu_enter(). With this I no longer get any splats and things seem to work fine. Signed-off-by: Douglas Anderson Link: https://lore.kernel.org/r/20200602154729.v2.1.I70e0d4fd46d5ed2aaf0c98a355e8e1b7a5bb7e4e@changeid Signed-off-by: Daniel Thompson Signed-off-by: Sasha Levin --- kernel/debug/debug_core.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c index 6a1dc2613bb92..fbb1bfdd2fa53 100644 --- a/kernel/debug/debug_core.c +++ b/kernel/debug/debug_core.c @@ -489,6 +489,7 @@ static int kgdb_cpu_enter(struct kgdb_state *ks, struct pt_regs *regs, arch_kgdb_ops.disable_hw_break(regs); acquirelock: + rcu_read_lock(); /* * Interrupts will be restored by the 'trap return' code, except when * single stepping. @@ -545,6 +546,7 @@ return_normal: atomic_dec(&slaves_in_kgdb); dbg_touch_watchdogs(); local_irq_restore(flags); + rcu_read_unlock(); return 0; } cpu_relax(); @@ -563,6 +565,7 @@ return_normal: raw_spin_unlock(&dbg_master_lock); dbg_touch_watchdogs(); local_irq_restore(flags); + rcu_read_unlock(); goto acquirelock; } @@ -686,6 +689,7 @@ kgdb_restore: raw_spin_unlock(&dbg_master_lock); dbg_touch_watchdogs(); local_irq_restore(flags); + rcu_read_unlock(); return kgdb_info[cpu].ret_state; } -- 2.25.1