Received: by 10.223.164.202 with SMTP id h10csp1625686wrb; Sat, 18 Nov 2017 02:57:04 -0800 (PST) X-Google-Smtp-Source: AGs4zMb8s8L5tGH41iGo3vhvbSeTjD6vqOrCcvcd0miTvn15RVAnftCg4wS8KwLSF0bfz4dSTYEC X-Received: by 10.159.252.198 with SMTP id o6mr7949673pls.390.1511002624553; Sat, 18 Nov 2017 02:57:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511002624; cv=none; d=google.com; s=arc-20160816; b=Y81Nzs1OQz9D3wAVSili0AlcazHC9nx2QgajjLEmBf5sa1FiXrOxwBnmf0ANqcl4Wv L34SwnQlAH60BVyU9P/gie29EHkYYxAiyAthQOBGDfM92t9FjeDPdeogx3Kd8HxFExev nmw5in6e7NOwerEQ3VMQ4ZYTVB/abiF1fontgORKC1hKmmEKWK6N9oFGbMUW7PfOd6yA tIR55SNXmY5Cy5NsN+0BtXVwbViAtROZZwuhOmZxkXMDswvro/tvXqBsnJXbrbkM/0+g 1Q7DIGACx8oFwFh/zGAeF5T1pe1mEHOD8TVB308V2Xzk1vW19yx0se9bQib+hPD0t4Zy YdMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=dj1XwJcUZLACKf0IavselWQzeZo4CJm8fv7WzYc0isU=; b=AzDtJt66dFbAINe4epZiUb02HTsHdEq176SliQU86qXgI4Bt7KK6FFvuUwQYofw4Rh Z+9GVcmwOD/PpAeTBFGEd32ec6F0qliIBwSL5tDja3MgO59saPn6rtRalwdJP97nqDKk 4k8nuS1mYiIat3H3CNNSJ9kuFo3zL6uzjHRSg+U7VCpKOxXFefkXfIhzIQYr02B4pAIe 4w8Nx20BYiVxWzwhJZ53OwkC9ldtO7EKJKqttwmLQhnreeSTi+hGNvSv3ppY9dcgBn4U JGy5Rj9/PfOBFsABWAngu9Y1m9zbZ8I3QsllZj/oKbvJkmaZG4zlbBL8IB/sNYD8pODX d35A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a14si4478046pln.663.2017.11.18.02.56.50; Sat, 18 Nov 2017 02:57:04 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935977AbdKQUfK (ORCPT + 93 others); Fri, 17 Nov 2017 15:35:10 -0500 Received: from mga01.intel.com ([192.55.52.88]:21780 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934990AbdKQUdv (ORCPT ); Fri, 17 Nov 2017 15:33:51 -0500 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Nov 2017 12:33:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,411,1505804400"; d="scan'208";a="8892639" Received: from mjglynn-mobl.ger.corp.intel.com (HELO localhost) ([10.254.124.112]) by orsmga002.jf.intel.com with ESMTP; 17 Nov 2017 12:33:49 -0800 From: Tom Zanussi To: rostedt@goodmis.org Cc: tglx@linutronix.de, mhiramat@kernel.org, namhyung@kernel.org, vedang.patel@intel.com, bigeasy@linutronix.de, joel.opensrc@gmail.com, joelaf@google.com, mathieu.desnoyers@efficios.com, baohong.liu@intel.com, rajvi.jingar@intel.com, julia@ni.com, fengguang.wu@intel.com, linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org, Tom Zanussi Subject: [PATCH v6 05/37] ring-buffer: Add interface for setting absolute time stamps Date: Fri, 17 Nov 2017 14:32:44 -0600 Message-Id: <451053666066bd179d50c147ff7062c518cea74d.1510948725.git.tom.zanussi@linux.intel.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Define a new function, tracing_set_time_stamp_abs(), which can be used to enable or disable the use of absolute timestamps rather than time deltas for a trace array. Only the interface is added here; a subsequent patch will add the underlying implementation. Signed-off-by: Tom Zanussi Signed-off-by: Baohong Liu --- include/linux/ring_buffer.h | 2 ++ kernel/trace/ring_buffer.c | 11 +++++++++++ kernel/trace/trace.c | 33 ++++++++++++++++++++++++++++++++- kernel/trace/trace.h | 3 +++ 4 files changed, 48 insertions(+), 1 deletion(-) diff --git a/include/linux/ring_buffer.h b/include/linux/ring_buffer.h index ee9b461..28e3472 100644 --- a/include/linux/ring_buffer.h +++ b/include/linux/ring_buffer.h @@ -180,6 +180,8 @@ void ring_buffer_normalize_time_stamp(struct ring_buffer *buffer, int cpu, u64 *ts); void ring_buffer_set_clock(struct ring_buffer *buffer, u64 (*clock)(void)); +void ring_buffer_set_time_stamp_abs(struct ring_buffer *buffer, bool abs); +bool ring_buffer_time_stamp_abs(struct ring_buffer *buffer); size_t ring_buffer_page_len(void *page); diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c index f6ee9b1..1e5b75a 100644 --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c @@ -485,6 +485,7 @@ struct ring_buffer { u64 (*clock)(void); struct rb_irq_work irq_work; + bool time_stamp_abs; }; struct ring_buffer_iter { @@ -1379,6 +1380,16 @@ void ring_buffer_set_clock(struct ring_buffer *buffer, buffer->clock = clock; } +void ring_buffer_set_time_stamp_abs(struct ring_buffer *buffer, bool abs) +{ + buffer->time_stamp_abs = abs; +} + +bool ring_buffer_time_stamp_abs(struct ring_buffer *buffer) +{ + return buffer->time_stamp_abs; +} + static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer); static inline unsigned long rb_page_entries(struct buffer_page *bpage) diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 73e67b6..459924f 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -2269,7 +2269,7 @@ struct ring_buffer_event * *current_rb = trace_file->tr->trace_buffer.buffer; - if ((trace_file->flags & + if (!ring_buffer_time_stamp_abs(*current_rb) && (trace_file->flags & (EVENT_FILE_FL_SOFT_DISABLED | EVENT_FILE_FL_FILTERED)) && (entry = this_cpu_read(trace_buffered_event))) { /* Try to use the per cpu buffer first */ @@ -6298,6 +6298,37 @@ static int tracing_clock_open(struct inode *inode, struct file *file) return ret; } +int tracing_set_time_stamp_abs(struct trace_array *tr, bool abs) +{ + int ret = 0; + + mutex_lock(&trace_types_lock); + + if (abs && tr->time_stamp_abs_ref++) + goto out; + + if (!abs) { + if (WARN_ON_ONCE(!tr->time_stamp_abs_ref)) { + ret = -EINVAL; + goto out; + } + + if (--tr->time_stamp_abs_ref) + goto out; + } + + ring_buffer_set_time_stamp_abs(tr->trace_buffer.buffer, abs); + +#ifdef CONFIG_TRACER_MAX_TRACE + if (tr->max_buffer.buffer) + ring_buffer_set_time_stamp_abs(tr->max_buffer.buffer, abs); +#endif + out: + mutex_unlock(&trace_types_lock); + + return ret; +} + struct ftrace_buffer_info { struct trace_iterator iter; void *spare; diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index f8343eb..4d8bde0 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h @@ -272,6 +272,7 @@ struct trace_array { /* function tracing enabled */ int function_enabled; #endif + int time_stamp_abs_ref; }; enum { @@ -285,6 +286,8 @@ enum { extern int trace_array_get(struct trace_array *tr); extern void trace_array_put(struct trace_array *tr); +extern int tracing_set_time_stamp_abs(struct trace_array *tr, bool abs); + /* * The global tracer (top) should be the first trace array added, * but we check the flag anyway. -- 1.9.3 From 1584398893494242986@xxx Sat Nov 18 10:22:11 +0000 2017 X-GM-THRID: 1584398893494242986 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread