Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751630AbdFZTNB (ORCPT ); Mon, 26 Jun 2017 15:13:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:48108 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751419AbdFZTMz (ORCPT ); Mon, 26 Jun 2017 15:12:55 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 74A4322B5B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=goodmis.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=rostedt@goodmis.org Date: Mon, 26 Jun 2017 15:12:52 -0400 From: Steven Rostedt To: Joel Fernandes Cc: LKML , Michael Sartain , kernel-team@android.com, Ingo Molnar Subject: Re: [PATCH v4 1/3] tracing: Add support for recording tgid of tasks Message-ID: <20170626151252.30e5f2bd@gandalf.local.home> In-Reply-To: References: <20170626053844.5746-1-joelaf@google.com> <20170626053844.5746-2-joelaf@google.com> <20170626125226.05c9a80e@gandalf.local.home> X-Mailer: Claws Mail 3.14.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1854 Lines: 50 On Mon, 26 Jun 2017 12:02:12 -0700 Joel Fernandes wrote: > >> diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c > >> index e7973e10398c..240c6df95ea6 100644 > >> --- a/kernel/trace/trace_events.c > >> +++ b/kernel/trace/trace_events.c > >> @@ -343,6 +343,28 @@ void trace_event_enable_cmd_record(bool enable) > >> mutex_unlock(&event_mutex); > >> } > >> > >> +void trace_event_enable_tgid_record(bool enable) > > > > This should return a value. > > > >> +{ > >> + struct trace_event_file *file; > >> + struct trace_array *tr; > >> + > >> + mutex_lock(&event_mutex); > >> + do_for_each_event_file(tr, file) { > >> + if (!(file->flags & EVENT_FILE_FL_ENABLED)) > >> + continue; > >> + > >> + if (enable) { > >> + tracing_start_tgid_record(); > > > > If we fail to start, the bit should not be set, and we should return > > failure. Note, it can only fail on the first try, as once it is > > allocated, you don't need to worry about it failing. Thus, if it fails, > > break out of the loop now and return failure. > > > > That seems Ok with me to do, I think a valid point. > > I think that I should do it in the second call to > tracing_start_tgid_record too then (__ftrace_event_enable_disable) to > error out if the allocation fails. > > While going this code I again, I noticed another potential issue in > __ftrace_event_enable_disable Thinking about this more. Just allocate the array as soon as the option is enabled, regardless if an trace event is set. That will make it a lot simpler. If it fails to allocate, you can simply bail out with -ENOMEM, and the setting of the option will return that. Then we can even remove the WARN_ONCE() at allocation failure, as the user will know what happened. -- Steve