From patchwork Mon Dec 19 18:31:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 13077004 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71EDAC4332F for ; Mon, 19 Dec 2022 18:35:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232465AbiLSSfH (ORCPT ); Mon, 19 Dec 2022 13:35:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232568AbiLSSe3 (ORCPT ); Mon, 19 Dec 2022 13:34:29 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1AF11176; Mon, 19 Dec 2022 10:32:17 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 58697B80F62; Mon, 19 Dec 2022 18:32:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3C30C433D2; Mon, 19 Dec 2022 18:32:14 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.96) (envelope-from ) id 1p7Kvt-0005SZ-2r; Mon, 19 Dec 2022 13:32:13 -0500 Message-ID: <20221219183106.518341498@goodmis.org> User-Agent: quilt/0.66 Date: Mon, 19 Dec 2022 13:31:06 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: Masami Hiramatsu , Andrew Morton , Ross Zwisler , Tom Zanussi , Zheng Yejian Subject: [PATCH 0/2] tracing: Add a way to filter function addresses to function names Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@vger.kernel.org There's been several times where an event records a function address in its field and I needed to filter on that address for a specific function name. It required looking up the function in kallsyms, finding its size, and doing a compare of "field >= function_start && field < function_end". But this would change from boot to boot and is unreliable in scripts. Also, it is useful to have this at boot up, where the addresses will not be known. For example, on the boot command line: trace_trigger="initcall_finish.traceoff if func.function == acpi_init" To implement this, add a ".function" prefix, that will check that the field is of size long, and the only operations allowed (so far) are "==" and "!=". Changes since v1: https://lore.kernel.org/linux-trace-kernel/20221214125209.09d736dd@gandalf.local.home/ - Fix commit log "initcall_finish.function" to "func.function" (Ross Zwisler) - Fixed processing of address (Ross Zwisler) - Added selftest (Masami Hiramatsu) - Just use "trigger" instead of "strsep(&trigger, "")" (Zheng Yejian) Steven Rostedt (Google) (2): tracing: Add a way to filter function addresses to function names tracing/selftests: Add test for event filtering on function name ---- Documentation/trace/events.rst | 12 +++ kernel/trace/trace_events.c | 2 +- kernel/trace/trace_events_filter.c | 93 +++++++++++++++++++++- .../ftrace/test.d/filter/event-filter-function.tc | 58 ++++++++++++++ 4 files changed, 163 insertions(+), 2 deletions(-) create mode 100644 tools/testing/selftests/ftrace/test.d/filter/event-filter-function.tc