From nobody Tue Oct 7 11:57:23 2025 Received: from smtpbg151.qq.com (smtpbg151.qq.com [18.169.211.239]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E89AB289833; Thu, 10 Jul 2025 07:33:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=18.169.211.239 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752132820; cv=none; b=Vf8R25vggqkKmPQJh6rAgw01K3trmh4GPJp7b04mBV93drcPRjz8iwIH0Za+pyPaDDBjW6ww3za3+36Y9qDPe8UCt4SBowL203xsgZE2ggC6Q0DU1w3BxEHqAUlRb7hr8GUSjJbmJLkepqEw4jmCHTQ5CQqOnQ1MTihmgh5PyGM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752132820; c=relaxed/simple; bh=Q/Jf3+XVh+iUCR0VCgJfYWeHyXKbJ5iuYDqX1WNlqo4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nN79JdZDsjx9uYbDHQeaqAC1VpqDluF8Jik5RjPu2W8ITX9YEqhARp2HZvBuHhGJYeZdD8cQRoPMDCl/65xqA4ANzstX2LsR234ZUj7YfSN2ztctEJWrvMpXcXFIV/ZziJA4YOOagLlu96WtM/nKGp/6WxoMcsahTHmEdWfUke0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=uniontech.com; spf=pass smtp.mailfrom=uniontech.com; dkim=pass (1024-bit key) header.d=uniontech.com header.i=@uniontech.com header.b=nVdYi1gd; arc=none smtp.client-ip=18.169.211.239 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=uniontech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=uniontech.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=uniontech.com header.i=@uniontech.com header.b="nVdYi1gd" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uniontech.com; s=onoh2408; t=1752132780; bh=eZIfjwyXRyZV9+QTOxx3kw1AO9i/MtOVaN7ILkdVRn8=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=nVdYi1gdWXAmH/5KX2I7pO69faMGJasGBapByyzIv+QQSfu+/B+oFBtn124X1miU8 v85Lg6iM5df4nycepEz/9hCJeG50Jfh/lKSTrvgvH4PCiJ6eCnFGZCEnkT//eWkcRK eX0UWYllkvVJh9PhQCz4HolpTCqUGl8iSDaSP2hc= X-QQ-mid: zesmtpip2t1752132717ta1e33716 X-QQ-Originating-IP: 1m3E08q8ehv1ztCLul4rhiU7h9IeBrnWTDg9XyfvCU8= Received: from avenger-e500 ( [localhost]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 10 Jul 2025 15:31:55 +0800 (CST) X-QQ-SSF: 0002000000000000000000000000000 X-QQ-GoodBg: 1 X-BIZMAIL-ID: 8695579808043688623 EX-QQ-RecipientCnt: 13 From: WangYuli To: wangyuli@uniontech.com Cc: dmitry.torokhov@gmail.com, guanwentao@uniontech.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, mathieu.desnoyers@efficios.com, mhiramat@kernel.org, niecheng1@uniontech.com, rostedt@goodmis.org, wangyuli@deepin.org, zhanjun@uniontech.com, Winston Wen Subject: [PATCH 1/2] input: Add tracepoint support Date: Thu, 10 Jul 2025 15:31:38 +0800 Message-ID: X-Mailer: git-send-email 2.50.0 In-Reply-To: <19571F312EE197A5+20250710072634.3992019-1-wangyuli@uniontech.com> References: <19571F312EE197A5+20250710072634.3992019-1-wangyuli@uniontech.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-QQ-SENDSIZE: 520 Feedback-ID: zesmtpip:uniontech.com:qybglogicsvrgz:qybglogicsvrgz8a-1 X-QQ-XMAILINFO: OKM/rTToQv8JH7MCJl0TB6FWM0fnxhNmAyCKUzMUAVOE/q4Zo9vOwB5h McAchouJ0pwMRm0ggBe2ZuPUba1tkrE+2/5vwoA9Lk7N6SAwHr0ww1TksDcsnZL8cuZTVrC rTCdiDNRVMwhCAD+SKofG+Qappl6GHRcF0kRX6QN3HII5xTAwoTxHXoi91UeNK6JpyFweln q4Y2sc2qPP43Fw+aLF2u43/ihVnc8VVj0xzJM/TLWceJi5jWogQvPq1YDSb9ce6Yv910vDE sgY3QZtXlvSfkKxlwZ02xVqbpnzBpErN6W7SK8abqiWt73LsFz+e3F1JbQ7fH5z2qhPpgBB M8nI6BuJqqxY8ka/kWsfoP1Dqgn5A6u3P480qR5rwYdj3A4eLaZWf8jDSWQoIyLi3Jh0I2p JYgbi2nZWXf/anuilnrOqZ3g4XM6jqFDUd3D7BNOBbcF+mGhnVqD6pQ3SEgN7OGiWlr31pd jEqTGdnx7V0ww2VTBpTEsQyjIfpgLHENQJtaLJ1JElWBm3llDIfXs2/ssD1sK90DU6cVzhA VOvN1xZBqhx0XvbfwRYQ6ySAWcJhhekbXHfySt0I3eyMXsWPsZHNxuXvyZPSI/wz3DvMWit lzpvlMIDBc8mUH08YJsc4BuLwr/aSFRHxWZAy9Xpapg4ObtW8mOlT7YiiqwAKfot2kOOG1z x7b019pbCzZ9XD5TyP02ETOfmZz/m/fy5B+Hi8uyzFpPWz0QuEtLfo1RTzgD8CBJ6pImbup 5f13cf5BYoyQvKBEoNAqeVMbukKG+c1A3Cma03L2ilkFRuN5T/u4MO1JGi28JUbTj4q2Hbf cO+eq7aFBjTqM4gp218Q+FfITfKXuEw7NP2l7j1mp8KC7sFAYRb6whC2pymliFBpVhHoZP9 8g69Yyw6VH78ifVI484FBGAeVcbC+zQLA5DrrBhAN283ZvuUif3BkS4s1AkelmJzaJuN7I/ q5G2TVy1ldG7slDF/LdJpy0otJB5JwZLCD4maHSBP6rOTsJkCaBDK4hqgCLCf53Yl+465jE wuk200w+nP7YIJBw2hghExaeUo9o+RP2SJNa7nmRV+2z6PsICnOVVLT717TXa23uYUqeYDD MMa2Ow4mwjftezpyE8fgDPlsPtenezityVLJcC8tucPZCCNQJ118lvGtagd7y9+2A== X-QQ-XMRINFO: M/715EihBoGSf6IYSX1iLFg= X-QQ-RECHKSPAM: 0 Content-Type: text/plain; charset="utf-8" Introduce a set of tracepoints for the input subsystem to enable better debugging, monitoring, and performance analysis of input device operations. Suggested-by: Winston Wen Signed-off-by: WangYuli --- MAINTAINERS | 1 + drivers/input/input.c | 18 ++- include/trace/events/input.h | 251 +++++++++++++++++++++++++++++++++++ 3 files changed, 269 insertions(+), 1 deletion(-) create mode 100644 include/trace/events/input.h diff --git a/MAINTAINERS b/MAINTAINERS index 00d7dcee88cb..c1b03679a5a1 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -11933,6 +11933,7 @@ F: include/linux/i8042.h F: include/linux/input.h F: include/linux/input/ F: include/linux/libps2.h +F: include/trace/events/input.h F: include/linux/serio.h F: include/uapi/linux/gameport.h F: include/uapi/linux/input-event-codes.h diff --git a/drivers/input/input.c b/drivers/input/input.c index 44887e51e049..925c76a50742 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c @@ -29,6 +29,9 @@ #include "input-core-private.h" #include "input-poller.h" =20 +#define CREATE_TRACE_POINTS +#include + MODULE_AUTHOR("Vojtech Pavlik "); MODULE_DESCRIPTION("Input core"); MODULE_LICENSE("GPL"); @@ -363,6 +366,7 @@ void input_handle_event(struct input_dev *dev, =20 disposition =3D input_get_disposition(dev, type, code, &value); if (disposition !=3D INPUT_IGNORE_EVENT) { + trace_input_event(dev, type, code, value); if (type !=3D EV_SYN) add_input_randomness(type, code, value); =20 @@ -525,6 +529,7 @@ int input_grab_device(struct input_handle *handle) return -EBUSY; =20 rcu_assign_pointer(dev->grab, handle); + trace_input_grab_device(dev, handle); } =20 return 0; @@ -539,6 +544,7 @@ static void __input_release_device(struct input_handle = *handle) grabber =3D rcu_dereference_protected(dev->grab, lockdep_is_held(&dev->mutex)); if (grabber =3D=3D handle) { + trace_input_release_device(dev, handle); rcu_assign_pointer(dev->grab, NULL); /* Make sure input_pass_values() notices that grab is gone */ synchronize_rcu(); @@ -612,6 +618,7 @@ int input_open_device(struct input_handle *handle) =20 if (dev->poller) input_dev_poller_start(dev->poller); + trace_input_open_device(dev); } =20 return 0; @@ -652,6 +659,7 @@ void input_close_device(struct input_handle *handle) input_dev_poller_stop(dev->poller); if (dev->close) dev->close(dev); + trace_input_close_device(dev); } } =20 @@ -991,9 +999,13 @@ static int input_attach_handler(struct input_dev *dev,= struct input_handler *han return -ENODEV; =20 error =3D handler->connect(handler, dev, id); - if (error && error !=3D -ENODEV) + if (error && error !=3D -ENODEV) { pr_err("failed to attach handler %s to device %s, error: %d\n", handler->name, kobject_name(&dev->dev.kobj), error); + } else if (!error) { + /* Connection successful, trace it */ + trace_input_handler_connect(handler, dev, handler->minor); + } =20 return error; } @@ -1791,6 +1803,7 @@ static int input_inhibit_device(struct input_dev *dev) } =20 dev->inhibited =3D true; + trace_input_inhibit_device(dev); =20 return 0; } @@ -1818,6 +1831,7 @@ static int input_uninhibit_device(struct input_dev *d= ev) =20 scoped_guard(spinlock_irq, &dev->event_lock) input_dev_toggle(dev, true); + trace_input_uninhibit_device(dev); =20 return 0; } @@ -2216,6 +2230,7 @@ static void __input_unregister_device(struct input_de= v *dev) { struct input_handle *handle, *next; =20 + trace_input_device_unregister(dev); input_disconnect_device(dev); =20 scoped_guard(mutex, &input_mutex) { @@ -2414,6 +2429,7 @@ int input_register_device(struct input_dev *dev) input_wakeup_procfs_readers(); } =20 + trace_input_device_register(dev); if (dev->devres_managed) { dev_dbg(dev->dev.parent, "%s: registering %s with devres.\n", __func__, dev_name(&dev->dev)); diff --git a/include/trace/events/input.h b/include/trace/events/input.h new file mode 100644 index 000000000000..3c5ffcfb7c8d --- /dev/null +++ b/include/trace/events/input.h @@ -0,0 +1,251 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* input tracepoints + * + * Copyright (C) 2025 WangYuli + */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM input + +#if !defined(_TRACE_INPUT_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_INPUT_H + +#include +#include + +/** + * input_event - called when an input event is processed + * @dev: input device that generated the event + * @type: event type (EV_KEY, EV_REL, EV_ABS, etc.) + * @code: event code within the type + * @value: event value + * + * This tracepoint fires for every input event processed by the input core. + * It can be used to monitor input device activity and debug input issues. + */ +TRACE_EVENT( + input_event, + + TP_PROTO(struct input_dev *dev, unsigned int type, unsigned int code, + int value), + + TP_ARGS(dev, type, code, value), + + TP_STRUCT__entry(__string(name, dev->name ?: "unknown") __field( + unsigned int, type) __field(unsigned int, code) + __field(int, value) __field(u16, bustype) + __field(u16, vendor) + __field(u16, product)), + + TP_fast_assign(__assign_str(name); __entry->type =3D type; + __entry->code =3D code; __entry->value =3D value; + __entry->bustype =3D dev->id.bustype; + __entry->vendor =3D dev->id.vendor; + __entry->product =3D dev->id.product;), + + TP_printk( + "dev=3D%s type=3D%u code=3D%u value=3D%d bus=3D%04x vendor=3D%04x produc= t=3D%04x", + __get_str(name), __entry->type, __entry->code, __entry->value, + __entry->bustype, __entry->vendor, __entry->product)); + +/** + * input_device_register - called when an input device is registered + * @dev: input device being registered + * + * This tracepoint fires when a new input device is registered with the + * input subsystem. Useful for monitoring device hotplug events. + */ +TRACE_EVENT( + input_device_register, + + TP_PROTO(struct input_dev *dev), + + TP_ARGS(dev), + + TP_STRUCT__entry(__string(name, dev->name ?: "unknown") __string( + phys, dev->phys ?: "") __field(u16, bustype) + __field(u16, vendor) __field(u16, product) + __field(u16, version)), + + TP_fast_assign(__assign_str(name); __assign_str(phys); + __entry->bustype =3D dev->id.bustype; + __entry->vendor =3D dev->id.vendor; + __entry->product =3D dev->id.product; + __entry->version =3D dev->id.version;), + + TP_printk( + "dev=3D%s phys=3D%s bus=3D%04x vendor=3D%04x product=3D%04x version=3D%0= 4x", + __get_str(name), __get_str(phys), __entry->bustype, + __entry->vendor, __entry->product, __entry->version)); + +/** + * input_device_unregister - called when an input device is unregistered + * @dev: input device being unregistered + * + * This tracepoint fires when an input device is unregistered from the + * input subsystem. Useful for monitoring device hotplug events. + */ +TRACE_EVENT(input_device_unregister, + + TP_PROTO(struct input_dev *dev), + + TP_ARGS(dev), + + TP_STRUCT__entry(__string(name, dev->name ?: "unknown") __string( + phys, dev->phys ?: "") __field(u16, bustype) + __field(u16, vendor) + __field(u16, product)), + + TP_fast_assign(__assign_str(name); __assign_str(phys); + __entry->bustype =3D dev->id.bustype; + __entry->vendor =3D dev->id.vendor; + __entry->product =3D dev->id.product;), + + TP_printk("dev=3D%s phys=3D%s bus=3D%04x vendor=3D%04x product=3D%04x= ", + __get_str(name), __get_str(phys), __entry->bustype, + __entry->vendor, __entry->product)); + +/** + * input_handler_connect - called when an input handler connects to a devi= ce + * @handler: input handler + * @dev: input device + * @minor: assigned minor number (if applicable) + * + * This tracepoint fires when an input handler (like evdev, mousedev) conn= ects + * to an input device, creating a new input handle. + */ +TRACE_EVENT(input_handler_connect, + + TP_PROTO(struct input_handler *handler, struct input_dev *dev, + int minor), + + TP_ARGS(handler, dev, minor), + + TP_STRUCT__entry(__string(handler_name, handler->name) + __string(dev_name, dev->name ?: "unknown") + __field(int, minor)), + + TP_fast_assign(__assign_str(handler_name); __assign_str(dev_name); + __entry->minor =3D minor;), + + TP_printk("handler=3D%s dev=3D%s minor=3D%d", __get_str(handler_name), + __get_str(dev_name), __entry->minor)); + +/** + * input_grab_device - called when a device is grabbed by a handler + * @dev: input device being grabbed + * @handle: input handle doing the grab + * + * This tracepoint fires when an input device is grabbed exclusively + * by an input handler, typically for security or special processing. + */ +TRACE_EVENT(input_grab_device, + + TP_PROTO(struct input_dev *dev, struct input_handle *handle), + + TP_ARGS(dev, handle), + + TP_STRUCT__entry(__string(dev_name, dev->name ?: "unknown") + __string(handler_name, + handle->handler->name)), + + TP_fast_assign(__assign_str(dev_name); __assign_str(handler_name);), + + TP_printk("dev=3D%s grabbed_by=3D%s", __get_str(dev_name), + __get_str(handler_name))); + +/** + * input_release_device - called when a grabbed device is released + * @dev: input device being released + * @handle: input handle releasing the grab + * + * This tracepoint fires when an input device grab is released. + */ +TRACE_EVENT(input_release_device, + + TP_PROTO(struct input_dev *dev, struct input_handle *handle), + + TP_ARGS(dev, handle), + + TP_STRUCT__entry(__string(dev_name, dev->name ?: "unknown") + __string(handler_name, + handle->handler->name)), + + TP_fast_assign(__assign_str(dev_name); __assign_str(handler_name);), + + TP_printk("dev=3D%s released_by=3D%s", __get_str(dev_name), + __get_str(handler_name))); + +DECLARE_EVENT_CLASS(input_device_state, + + TP_PROTO(struct input_dev *dev), + + TP_ARGS(dev), + + TP_STRUCT__entry(__string(name, dev->name ?: "unknown") + __field(unsigned int, users) + __field(bool, inhibited)), + + TP_fast_assign(__assign_str(name); + __entry->users =3D dev->users; + __entry->inhibited =3D dev->inhibited;), + + TP_printk("dev=3D%s users=3D%u inhibited=3D%s", __get_str(name), + __entry->users, + __entry->inhibited ? "true" : "false")); + +/** + * input_open_device - called when an input device is opened + * @dev: input device being opened + * + * This tracepoint fires when the user count for an input device increases, + * typically when a userspace application opens the device. + */ +DEFINE_EVENT(input_device_state, input_open_device, + + TP_PROTO(struct input_dev *dev), + + TP_ARGS(dev)); + +/** + * input_close_device - called when an input device is closed + * @dev: input device being closed + * + * This tracepoint fires when the user count for an input device decreases, + * typically when a userspace application closes the device. + */ +DEFINE_EVENT(input_device_state, input_close_device, + + TP_PROTO(struct input_dev *dev), + + TP_ARGS(dev)); + +/** + * input_inhibit_device - called when an input device is inhibited + * @dev: input device being inhibited + * + * This tracepoint fires when an input device is inhibited (disabled), + * usually for power management or security reasons. + */ +DEFINE_EVENT(input_device_state, input_inhibit_device, + + TP_PROTO(struct input_dev *dev), + + TP_ARGS(dev)); + +/** + * input_uninhibit_device - called when an input device is uninhibited + * @dev: input device being uninhibited + * + * This tracepoint fires when an input device is uninhibited (re-enabled) + * after being previously inhibited. + */ +DEFINE_EVENT(input_device_state, input_uninhibit_device, + + TP_PROTO(struct input_dev *dev), + + TP_ARGS(dev)); + +#endif /* _TRACE_INPUT_H */ + +/* This part must be outside protection */ +#include --=20 2.50.0 From nobody Tue Oct 7 11:57:23 2025 Received: from smtpbgjp3.qq.com (smtpbgjp3.qq.com [54.92.39.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B2B6E22D7A5; Thu, 10 Jul 2025 07:33:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=54.92.39.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752132813; cv=none; b=U162AD0FNf5eYpXnn3NcYwXubEdJK05ZdF2FTlx12Gad3kMCLdCbbbO5x/rgZcPavKR38G23NOStfSpVlieafKYjLJHUkgHUdc6F6HKCRtP0uVmTgqIJnk5PY4mx9IRXK05JrCjReYsGWHk9A0uUqsqALpnW8qCmBzjz9IElRQk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752132813; c=relaxed/simple; bh=ru6WC3aKTKx+HNUMWn7/ABAYv3F2LVzKQIts/BaQPEA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KZ1REc2OxKXKb9ht7K2It9rdppkmhqaM28vWRpj9wPX3/GSN+bZJY2L0ZeXDPHIvQHuymfDerVvqhkDS/kWuTAal8cpWqXIiWGZ1fnPdmiDSZ1YTcF8VqGTN6qkq5b3D2Wgb73ky12aKpLGhfEIZmR7YXjdJJCOsaUvBxlpiTho= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=uniontech.com; spf=pass smtp.mailfrom=uniontech.com; dkim=pass (1024-bit key) header.d=uniontech.com header.i=@uniontech.com header.b=OREHr7gb; arc=none smtp.client-ip=54.92.39.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=uniontech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=uniontech.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=uniontech.com header.i=@uniontech.com header.b="OREHr7gb" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uniontech.com; s=onoh2408; t=1752132775; bh=wxPDaS9M7eiZgqTbTb/ieaoSzC16Z0UcvtN7Iiihn64=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=OREHr7gbTVsJZ8l6um2x+PgpgksapJ08pSqE/yLcAkoTfseGB50hT7wBOJLdt3m7z CsSiHP4cnqSxB+KpxzH2pTzce//zKmJQj+bF6j2gAafmF80FikO16X5Kch0mWhXPQO /vhfxtHumVH9Q9roQ+UKmf5n9b2OIoMxKzfz0fTk= X-QQ-mid: zesmtpip2t1752132723tf4adab5b X-QQ-Originating-IP: zl7VhSkSdaS7urA94n5L+ibxoa0yuNJuk1pA9GOkrKw= Received: from avenger-e500 ( [localhost]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 10 Jul 2025 15:32:00 +0800 (CST) X-QQ-SSF: 0002000000000000000000000000000 X-QQ-GoodBg: 1 X-BIZMAIL-ID: 15372651956222595813 EX-QQ-RecipientCnt: 12 From: WangYuli To: wangyuli@uniontech.com Cc: dmitry.torokhov@gmail.com, guanwentao@uniontech.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, mathieu.desnoyers@efficios.com, mhiramat@kernel.org, niecheng1@uniontech.com, rostedt@goodmis.org, wangyuli@deepin.org, zhanjun@uniontech.com Subject: [PATCH 2/2] selftests: input: Add tracepoint testing script Date: Thu, 10 Jul 2025 15:31:39 +0800 Message-ID: X-Mailer: git-send-email 2.50.0 In-Reply-To: <19571F312EE197A5+20250710072634.3992019-1-wangyuli@uniontech.com> References: <19571F312EE197A5+20250710072634.3992019-1-wangyuli@uniontech.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-QQ-SENDSIZE: 520 Feedback-ID: zesmtpip:uniontech.com:qybglogicsvrgz:qybglogicsvrgz8a-1 X-QQ-XMAILINFO: MbY7GcL85SkKl0ZaciNxKdxAPkJoX+P7k6UxKNtKO9YG2L0bS4NWDbYN P3Tfl70sJMFcDME/zU65af/h8SB8v5SwlAbiKmH+NQMhH1pKnXUypv5ZpBBYxvPSnBH70lr 7nfHY/QtEC2n1KNyINqZY7njApHB+aImsVr3NuR4zdSBYdBtrXlDPeOFqwk//lpEdECbsby MGjJr7I3yrqSjqDvgbilDAZQkG/EmVXx3lyQ2a0Js3DGo/NxBj3V9kOhmWuuGuMEnLx0Qf1 d4polxQPPOtnlBubJdoKtcJKInm188dtniu3PSmCw06fjMtJ8EwhazAqL/LH1kghjd1Txfx zpseqvOMhTp7+wGp7mxCgZ1LedUtqw2xoPmodYvQ2wNreT7fhXUYWYLwZy8dDXD3zjQ+bEx KB4EeSPjoAyErBxuVdK+ftMDYJ9d912fCIQtri9uewBH9m+b9keB/idbI45wMZ2oQaZgv+e WbbONAGI5X0O9OmonyQhDmjORkZi15OH6FjT6TwIojiYQZuvfvUNtGJiG/AfxRQwMr3lfGi UNR9/MUN97gaHGpggiX77NKb9JxOzuLHiYnhuQje57k+ZUTLrk2H7BHkzXggv9gYwuqZ5VA ceRSEeLFyAq6gNmaFZ/p5yr/pZon2ne8ACysXSs6I7XcSNZHxVTBJ3O7KF3DdsM2tPsYVN6 mNrOZvJZAMFGxi1oX23lSNqCqQpmYjublykOaBGpJ6qrDps4CLvWQwTJPDYfpcdpbNmilsV BcA5gLjSoFYAfAN+m5DECfEaUXuzk9inx+AmjOio/f98M4sESWol/v7qSPXzcQ6Nri5UBaQ PPb6XbycRo+P1KotpusGZcpLHKDfxuObCRzmdEKiyGG4L+78OmbeJxgy1QI3xUDh3Mje91z Z/J66zyCH+em67c2IilToXOwu4GOZlkrt+s9OD17Q5xLIC35QD+biUcBHfaEyPHd2I2lBn/ ix8NoaSS0IqAcDoBoFpfEVXusYXyDj29LjOqB+DhvGo8mglWJUaHmsgvWOBTwBJghtZ0dM0 om60BjfSZwgQvtB47b/FJJOg+bJrGTEKO1AfYQM161e8mzlX/YbxtRnjcWaNaIguiUaioxM IfCC5zWG8V4d1mYZ+X5ESQhOrMwdFNlPQ== X-QQ-XMRINFO: NyFYKkN4Ny6FSmKK/uo/jdU= X-QQ-RECHKSPAM: 0 Add a test script for the input subsystem tracepoints. The script provides: - Automatic detection of available input tracepoints - Privilege and filesystem mount validation - Interactive testing with real-time trace monitoring - Support for both batch and live trace analysis The script enables easy validation and demonstration of the input tracepoint functionality, making it easier for developers to verify the implementation and understand the tracepoint capabilities. Usage: sudo ./tools/testing/selftests/input/test_input_tracepoints.sh Signed-off-by: WangYuli --- MAINTAINERS | 2 + .../selftests/input/test_input_tracepoints.sh | 78 +++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100755 tools/testing/selftests/input/test_input_tracepoints.sh diff --git a/MAINTAINERS b/MAINTAINERS index c1b03679a5a1..8a0920734303 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -11940,6 +11940,7 @@ F: include/uapi/linux/input-event-codes.h F: include/uapi/linux/input.h F: include/uapi/linux/serio.h F: include/uapi/linux/uinput.h +F: tools/testing/selftests/input/ =20 INPUT MULTITOUCH (MT) PROTOCOL M: Henrik Rydberg @@ -25211,6 +25212,7 @@ F: kernel/trace/ F: kernel/tracepoint.c F: scripts/tracing/ F: tools/testing/selftests/ftrace/ +F: tools/testing/selftests/input/test_input_tracepoints.sh =20 TRACING MMIO ACCESSES (MMIOTRACE) M: Steven Rostedt diff --git a/tools/testing/selftests/input/test_input_tracepoints.sh b/tool= s/testing/selftests/input/test_input_tracepoints.sh new file mode 100755 index 000000000000..6ade2619b62d --- /dev/null +++ b/tools/testing/selftests/input/test_input_tracepoints.sh @@ -0,0 +1,78 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later + +##########################################################################= ##### +# +# Input subsystem tracepoint testing script +# +# AUTHOR +# WangYuli +# +##########################################################################= ##### + +DEBUGFS_PATH=3D"/sys/kernel/debug/tracing" +INPUT_EVENTS_PATH=3D"${DEBUGFS_PATH}/events/input" + +# Check if we have sufficient privileges +if [ ! -w "$DEBUGFS_PATH" ]; then + echo "Error: Root privileges required to access tracing system" + echo "Please run: sudo $0" + exit 1 +fi + +# Check if debugfs is mounted +if [ ! -d "$DEBUGFS_PATH" ]; then + echo "Error: debugfs is not mounted" + echo "Please run: mount -t debugfs none /sys/kernel/debug" + exit 1 +fi + +# Check if input tracepoints exist +if [ ! -d "$INPUT_EVENTS_PATH" ]; then + echo "Error: input tracepoints not found, kernel may need to be recomp= iled" + exit 1 +fi + +echo "=3D=3D=3D Input Subsystem Tracepoint Test =3D=3D=3D" +echo + +# Clear existing trace buffer +echo > "${DEBUGFS_PATH}/trace" + +# List available input tracepoints +echo "Available Input Tracepoints:" +for event in "${INPUT_EVENTS_PATH}"/*; do + if [ -d "$event" ]; then + event_name=3D$(basename "$event") + echo " - $event_name" + fi +done +echo + +# Enable all input tracepoints +echo "Enabling all input tracepoints..." +echo 1 > "${INPUT_EVENTS_PATH}/enable" + +if [ $? -eq 0 ]; then + echo "=E2=9C=93 Successfully enabled input tracepoints" +else + echo "=E2=9C=97 Failed to enable input tracepoints" + exit 1 +fi + +echo +echo "Please perform some operations in another terminal (keyboard input, = mouse movement, etc.)" +echo "or plug/unplug USB devices, then come back to view the results..." +echo +echo "Press any key to continue viewing trace output (press Ctrl+C to exit= )..." +read -n 1 + +echo +echo "=3D=3D=3D Trace Output =3D=3D=3D" +echo "(Last 100 lines)" +tail -n 100 "${DEBUGFS_PATH}/trace" + +echo +echo "=3D=3D=3D Real-time Trace Output =3D=3D=3D" +echo "(Press Ctrl+C to stop)" +cat "${DEBUGFS_PATH}/trace_pipe" --=20 2.50.0