Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp873978ybl; Fri, 10 Jan 2020 08:09:05 -0800 (PST) X-Google-Smtp-Source: APXvYqwWeLIRimfLPJAdbRulgoTQ/LXiyt+nnd2thRPwoYV9EMYmUiPYTL+cEVUG+EsAVOxF1sDJ X-Received: by 2002:a9d:6758:: with SMTP id w24mr3438410otm.155.1578672545440; Fri, 10 Jan 2020 08:09:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578672545; cv=none; d=google.com; s=arc-20160816; b=DLMarS/bGHBvCqKCZw3t9QYOXKF8u1TH2jy2f/HdAcKISJZo5PWPolqKclh/7zyUfD rhxbtZUbq16M7B4pdT860cCZaVlE684aQ9thbHxURHaqfIpZ8LByuuitSgNWKMK0YQgB sLy+GukjkY+DlCLjZ9czW8iw2jPwOk2nJAjKqOBHNRTfIQxZbiep4347fYoagQF14Ghd +D2kJhDaSFH6Utu9ii064NB/k4o1x6C3RZlbUw81C0WPUsFM19Y1WT/LfCBWDMeHl5ot 8Go+IZXPvleQJnfpfVsfPF+z92hWfYLM9UAMcNIYAmoVDaGBqQeuSOQEorpF8CK1MAqu 0N7w== 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=qK0swnzhSQkwdNo+vHLmHHAMNZ0JtKr9I6qZ3X586bM=; b=xczUVLK/VbBQ/bw5UVXlJ6eaWzID+hAVq6tjFOJ4q5I+yRgemHI3I58b32147OQGi3 RqAn6Pasf5kMqzUiFjAB/Y2ErTqv/+ytL3PERnHBhP8VGNjhzWbogi0VbmKSSvRQWNNs FBEbmnteM2dVzfoU0Al4OBLaO4ozEhyNHDk1/OpMZwFzx/zGlQuFt2RS5DRL5n8TJX3N GCLuUDLk8DWQJWcj7S92FkJrYMbpUFj03kEWlFP8WopOXcVvHUBBp217FgSt/73UdtKV u20fO7S/3s3jwK80rG2e7nwPoPZUT1fPgkjsfoz2UOyINB5nparZVOPtW7XOsIHV3EDr pPhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="D3tI58/0"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p71si1333841oic.138.2020.01.10.08.08.52; Fri, 10 Jan 2020 08:09:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="D3tI58/0"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728789AbgAJQHg (ORCPT + 99 others); Fri, 10 Jan 2020 11:07:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:56162 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728568AbgAJQHf (ORCPT ); Fri, 10 Jan 2020 11:07:35 -0500 Received: from localhost.localdomain (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E071A20848; Fri, 10 Jan 2020 16:07:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578672454; bh=mKcScjigF5A1xr+byPY30DfGycrvCOAMZ7zyMac2J1M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D3tI58/0KbG+UWmPIHJi1EbKrXj18Me/KWeawFVEV6wwcxFRSlLWO9hYdbZ8blh1k p/mDOKvIqwklRFuSgQmrfBHoewa+evrDTBEt0uJRJgOmleTYOBsovhTpCChR2WAjAT Qy3TCeCDeDqm4HfgVtIyGZjP6jTsJpzMg5xrKvWo= From: Masami Hiramatsu To: Steven Rostedt Cc: Ingo Molnar , Frank Rowand , Randy Dunlap , Namhyung Kim , Tim Bird , Jiri Olsa , Arnaldo Carvalho de Melo , Tom Zanussi , Rob Herring , Andrew Morton , Thomas Gleixner , Greg Kroah-Hartman , Alexey Dobriyan , Jonathan Corbet , Linus Torvalds , linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 21/22] tracing/boot: Add function tracer filter options Date: Sat, 11 Jan 2020 01:07:28 +0900 Message-Id: <157867244841.17873.10933616628243103561.stgit@devnote2> X-Mailer: git-send-email 2.20.1 In-Reply-To: <157867220019.17873.13377985653744804396.stgit@devnote2> References: <157867220019.17873.13377985653744804396.stgit@devnote2> User-Agent: StGit/0.17.1-dirty 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 Add below function-tracer filter options to boot-time tracing. - ftrace.[instance.INSTANCE.]ftrace.filters This will take an array of tracing function filter rules - ftrace.[instance.INSTANCE.]ftrace.notraces This will take an array of NON-tracing function filter rules Signed-off-by: Masami Hiramatsu --- Changes in v6: - Fix to depend on CONFIG_DYNAMIC_FTRACE instead of CONFIG_FUNCTION_TRACER. --- kernel/trace/trace_boot.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/kernel/trace/trace_boot.c b/kernel/trace/trace_boot.c index 81d923c16a4d..fa9603dc6469 100644 --- a/kernel/trace/trace_boot.c +++ b/kernel/trace/trace_boot.c @@ -244,11 +244,51 @@ trace_boot_init_events(struct trace_array *tr, struct xbc_node *node) #define trace_boot_init_events(tr, node) do {} while (0) #endif +#ifdef CONFIG_DYNAMIC_FTRACE +extern bool ftrace_filter_param __initdata; +extern int ftrace_set_filter(struct ftrace_ops *ops, unsigned char *buf, + int len, int reset); +extern int ftrace_set_notrace(struct ftrace_ops *ops, unsigned char *buf, + int len, int reset); +static void __init +trace_boot_set_ftrace_filter(struct trace_array *tr, struct xbc_node *node) +{ + struct xbc_node *anode; + const char *p; + char *q; + + xbc_node_for_each_array_value(node, "ftrace.filters", anode, p) { + q = kstrdup(p, GFP_KERNEL); + if (!q) + return; + if (ftrace_set_filter(tr->ops, q, strlen(q), 0) < 0) + pr_err("Failed to add %s to ftrace filter\n", p); + else + ftrace_filter_param = true; + kfree(q); + } + xbc_node_for_each_array_value(node, "ftrace.notraces", anode, p) { + q = kstrdup(p, GFP_KERNEL); + if (!q) + return; + if (ftrace_set_notrace(tr->ops, q, strlen(q), 0) < 0) + pr_err("Failed to add %s to ftrace filter\n", p); + else + ftrace_filter_param = true; + kfree(q); + } +} +#else +#define trace_boot_set_ftrace_filter(tr, node) do {} while (0) +#endif + static void __init trace_boot_enable_tracer(struct trace_array *tr, struct xbc_node *node) { const char *p; + trace_boot_set_ftrace_filter(tr, node); + p = xbc_node_find_value(node, "tracer", NULL); if (p && *p != '\0') { if (tracing_set_tracer(tr, p) < 0)