Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp678724pxb; Thu, 14 Jan 2021 16:15:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJwONyFeugkSnsMqm3tWBo4HOYYEnjaMXWVMPxIuVbZhW0CQZV94pECBJZ4+w4n4mE8UlCdM X-Received: by 2002:a50:eb96:: with SMTP id y22mr7658281edr.91.1610669738936; Thu, 14 Jan 2021 16:15:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610669738; cv=none; d=google.com; s=arc-20160816; b=I80YdnYVGFta8gBodXRp9PGFRZ8ogcTtSpdTiL7K7okyGO+qm6FjsAVTToaeHfVyO2 XLTVV2hIb4VvAHNMOELz9mau8DgVpGcZfxjdlE3e1cDyAXGfL7CLC8yZfxCCXyLpUZS5 OPYEVIWnQn4ob+39cf5cxBxHP+ydCMgaW7LzspRql0qxDkNXodEJ8i3CwjK7s+cJZP8m pl5lENf/B8Z1Nbwo1FM2NpimN68f0fFv6GFfOnwbJDtpsxM3o6FXfvRAapeNInHc5QxR HkdABoA13QiJBe/W9OeBjyXdArQVukZJf3gorTEJdcUzxerhN65lAGLhS3qwCfJ3X4sA vbfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=0sL6vMUX5T8yV3WE57C2FZnx/fqs6zyPG8qWqSpnIzU=; b=mBT7ya4mUuNuHOHCPRr7gZIDmyJOMzadGXF4LEBmL6ZMgDrbv2u+thYXFt/AvmIn0c RvkIkkypBwkXusrBJl9Ov3nx1LxAPYHvDVA/e1iQf94fgEmBoGRO4Acw8wrrzNkZh2Xi W/VAUtdtaHjnJelU8V71bZVhFjwuA18K0yL/cDuO0SBn4hvWaiOoRf0OdzHjf7QZZi6U Us6Y+ACxqm55ZOltBV3TVc3kB65btiQ0DfjODxSVmm0WGEjZ2s+8MPf7uWVyTU+jwpF/ rXQ+7Ul0HAUP03cM+vPjOroEHc0ZnH3LFR52iOBUZJJfMMe7YxdBwBGG4EmFwCFLReHm MJoQ== ARC-Authentication-Results: i=1; mx.google.com; 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 j19si742673edw.550.2021.01.14.16.15.15; Thu, 14 Jan 2021 16:15:38 -0800 (PST) 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; 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 S1731185AbhAOAOe (ORCPT + 99 others); Thu, 14 Jan 2021 19:14:34 -0500 Received: from mx2.suse.de ([195.135.220.15]:46042 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729277AbhAOAOd (ORCPT ); Thu, 14 Jan 2021 19:14:33 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id D0993AC24; Fri, 15 Jan 2021 00:13:51 +0000 (UTC) From: Davidlohr Bueso To: jason.wessel@windriver.com Cc: daniel.thompson@linaro.org, kgdb-bugreport@lists.sourceforge.net, linux-kernel@vger.kernel.org, dave@stgolabs.net, Davidlohr Bueso Subject: [PATCH] kgdb: Schedule breakpoints via workqueue Date: Thu, 14 Jan 2021 16:13:44 -0800 Message-Id: <20210115001344.117108-1-dave@stgolabs.net> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The original functionality was added back in: 1cee5e35f15 (kgdb: Add the ability to schedule a breakpoint via a tasklet) However tasklets have long been deprecated as being too heavy on the system by running in irq context - and this is not a performance critical path. If a higher priority process wants to run, it must wait for the tasklet to finish before doing so. Instead, generate the breakpoint exception in process context. Signed-off-by: Davidlohr Bueso --- Compile-tested only. kernel/debug/debug_core.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c index af6e8b4fb359..e1ff974c6b6f 100644 --- a/kernel/debug/debug_core.c +++ b/kernel/debug/debug_core.c @@ -119,7 +119,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock); */ static atomic_t masters_in_kgdb; static atomic_t slaves_in_kgdb; -static atomic_t kgdb_break_tasklet_var; +static atomic_t kgdb_break_work_var; atomic_t kgdb_setting_breakpoint; struct task_struct *kgdb_usethread; @@ -1085,27 +1085,27 @@ static void kgdb_unregister_callbacks(void) } /* - * There are times a tasklet needs to be used vs a compiled in + * There are times a workqueue needs to be used vs a compiled in * break point so as to cause an exception outside a kgdb I/O module, * such as is the case with kgdboe, where calling a breakpoint in the * I/O driver itself would be fatal. */ -static void kgdb_tasklet_bpt(unsigned long ing) +static void kgdb_work_bpt(struct work_struct *unused) { kgdb_breakpoint(); - atomic_set(&kgdb_break_tasklet_var, 0); + atomic_set(&kgdb_break_work_var, 0); } -static DECLARE_TASKLET_OLD(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt); +static DECLARE_WORK(kgdb_async_breakpoint, kgdb_work_bpt); void kgdb_schedule_breakpoint(void) { - if (atomic_read(&kgdb_break_tasklet_var) || + if (atomic_read(&kgdb_break_work_var) || atomic_read(&kgdb_active) != -1 || atomic_read(&kgdb_setting_breakpoint)) return; - atomic_inc(&kgdb_break_tasklet_var); - tasklet_schedule(&kgdb_tasklet_breakpoint); + atomic_inc(&kgdb_break_work_var); + schedule_work(&kgdb_async_breakpoint); } EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint); -- 2.26.2