Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp875523ybl; Fri, 10 Jan 2020 08:10:28 -0800 (PST) X-Google-Smtp-Source: APXvYqyoF2X3KzapAQ8/QIlU7tN49stoBRI8wVHkNT/8qI76u+0eHG5g3bxflSybGOr26DonCMjt X-Received: by 2002:aca:5745:: with SMTP id l66mr2886356oib.3.1578672628801; Fri, 10 Jan 2020 08:10:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578672628; cv=none; d=google.com; s=arc-20160816; b=QgktnH+n7i27EuszIrjbXfh4BKomu5kmIZIf9mqK0iJJmuvAJ+wlWwWxr/GTXIw23I pbxXuY9gS1w/hINVSuKiiHqvuIKNlSssrTHDtskptth/m9vDTGMnK+djgFtu5cK2W+UF +k8QwzBY6YAmsWLfuMA6o4gan4gwnRYHziTlGtQmIDaeyQTYZ323P8NA9+3aCGvqKA8F sw1mgLozkbAE1P1fsffVB15kK3Z3OiKYAtSOFSp2sWD4GbDloMwK7gfWt6i4Vn+wMWpK bI7l0C3lwF4/VWJiJMoLakijcT6n99DwwK1DxjdWiSBIAVlSOJ3p7I34+hfR9FLUKA7S yffw== 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=J64CcuEDTc2jsmxnsjuuqbiwApygf/wQtVH+gWc6OwI=; b=MW+1Im/MK8W+ozkSdmSL0nSpyCBzmMaOvcx600xwWbHyUSXJAYaCBUTDNrxYLq8WD/ fv/d3/AZ0wlFMKVh1t3ks+/ouXNm91qnWKkLjHmrbd+T4U9CDSZ7iSvYrzllnfFEPHro JuVHjRBg980HDsGE3VmvvTtDkONMTUTD/Ihbn3WV3v4NbTwtxeV4L+bKtrNC5qe3zE6L St2qYrGHKrcHlBJqV1sSfFmYIDkAQnSq97fDeSM+UAjCiP7NOxjJhnvLuWAZVEkTbTrO NCXeuiecPRoyAbA5Zrqq7GX29ye20H8ztfxi5iQ/U3JLtZvGa4cB+B2SWmzYfulaWbTz PVFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sJqG7ThV; 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 d20si1675912oti.311.2020.01.10.08.10.15; Fri, 10 Jan 2020 08:10:28 -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=sJqG7ThV; 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 S1728892AbgAJQHY (ORCPT + 99 others); Fri, 10 Jan 2020 11:07:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:55908 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728599AbgAJQHX (ORCPT ); Fri, 10 Jan 2020 11:07:23 -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 19BE820673; Fri, 10 Jan 2020 16:07:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578672443; bh=SPN0jWwj+cV163gBPS9N5npjdTGqgU2DHIIF56Vp/3M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sJqG7ThVfJOhY9/0xAQhjk1ygLxsT4D2gjmMpIsjqKcyz3C4pesj8X9u2osUtT0yT iHQ1WUfCSAuHDxHpW2nmyVJqcvssYTLdAwy/xYXVOQG8sL0ghdKdfB2uueAFvfr8u8 E8MBf874K8Ig60sbEQ25B404ce5pOpJQVF2+5SbI= 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 20/22] tracing/boot: Add cpu_mask option support Date: Sat, 11 Jan 2020 01:07:16 +0900 Message-Id: <157867243625.17873.13613922641273149372.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 ftrace.cpumask option support to boot-time tracing. This sets cpumask for each instance. - ftrace.[instance.INSTANCE.]cpumask = CPUMASK; Set the trace cpumask. Note that the CPUMASK should be a string which /tracing_cpumask can accepts. Signed-off-by: Masami Hiramatsu --- kernel/trace/trace.c | 42 +++++++++++++++++++++++++++++------------- kernel/trace/trace_boot.c | 14 ++++++++++++++ 2 files changed, 43 insertions(+), 13 deletions(-) diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index c2e1b33aec17..5791e6b5136f 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -4561,20 +4561,13 @@ tracing_cpumask_read(struct file *filp, char __user *ubuf, return count; } -static ssize_t -tracing_cpumask_write(struct file *filp, const char __user *ubuf, - size_t count, loff_t *ppos) +int tracing_set_cpumask(struct trace_array *tr, + cpumask_var_t tracing_cpumask_new) { - struct trace_array *tr = file_inode(filp)->i_private; - cpumask_var_t tracing_cpumask_new; - int err, cpu; - - if (!alloc_cpumask_var(&tracing_cpumask_new, GFP_KERNEL)) - return -ENOMEM; + int cpu; - err = cpumask_parse_user(ubuf, count, tracing_cpumask_new); - if (err) - goto err_unlock; + if (!tr) + return -EINVAL; local_irq_disable(); arch_spin_lock(&tr->max_lock); @@ -4598,11 +4591,34 @@ tracing_cpumask_write(struct file *filp, const char __user *ubuf, local_irq_enable(); cpumask_copy(tr->tracing_cpumask, tracing_cpumask_new); + + return 0; +} + +static ssize_t +tracing_cpumask_write(struct file *filp, const char __user *ubuf, + size_t count, loff_t *ppos) +{ + struct trace_array *tr = file_inode(filp)->i_private; + cpumask_var_t tracing_cpumask_new; + int err; + + if (!alloc_cpumask_var(&tracing_cpumask_new, GFP_KERNEL)) + return -ENOMEM; + + err = cpumask_parse_user(ubuf, count, tracing_cpumask_new); + if (err) + goto err_free; + + err = tracing_set_cpumask(tr, tracing_cpumask_new); + if (err) + goto err_free; + free_cpumask_var(tracing_cpumask_new); return count; -err_unlock: +err_free: free_cpumask_var(tracing_cpumask_new); return err; diff --git a/kernel/trace/trace_boot.c b/kernel/trace/trace_boot.c index f5db30d25b0b..81d923c16a4d 100644 --- a/kernel/trace/trace_boot.c +++ b/kernel/trace/trace_boot.c @@ -18,6 +18,8 @@ extern int trace_set_options(struct trace_array *tr, char *option); extern int tracing_set_tracer(struct trace_array *tr, const char *buf); extern ssize_t tracing_resize_ring_buffer(struct trace_array *tr, unsigned long size, int cpu_id); +extern int tracing_set_cpumask(struct trace_array *tr, + cpumask_var_t tracing_cpumask_new); static void __init trace_boot_set_instance_options(struct trace_array *tr, struct xbc_node *node) @@ -52,6 +54,18 @@ trace_boot_set_instance_options(struct trace_array *tr, struct xbc_node *node) if (tracing_resize_ring_buffer(tr, v, RING_BUFFER_ALL_CPUS) < 0) pr_err("Failed to resize trace buffer to %s\n", p); } + + p = xbc_node_find_value(node, "cpumask", NULL); + if (p && *p != '\0') { + cpumask_var_t new_mask; + + if (alloc_cpumask_var(&new_mask, GFP_KERNEL)) { + if (cpumask_parse(p, new_mask) < 0 || + tracing_set_cpumask(tr, new_mask) < 0) + pr_err("Failed to set new CPU mask %s\n", p); + free_cpumask_var(new_mask); + } + } } #ifdef CONFIG_EVENT_TRACING