Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1039801pxb; Tue, 26 Oct 2021 01:32:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzoA0cerVmQhwJ5JinnGN9kk09YDFwUn8D8xPLhey+EU3TJDRiS0hXOHzUM0duiWj8RLMmH X-Received: by 2002:a17:902:e543:b0:13f:dffb:8e6 with SMTP id n3-20020a170902e54300b0013fdffb08e6mr20686258plf.27.1635237159431; Tue, 26 Oct 2021 01:32:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635237159; cv=none; d=google.com; s=arc-20160816; b=jZx0Vcl6ov6Ft3qoZsqiFQKLvQXsc95DZr4g0c4mErtE1FT2zhJ7SVBgV0nwUNjKpO AJxlh0HEfAF8ge6oBtNQGC+JV5+Su2r7CbaUz9Le7KxMGm/GJed71Pk15js108/GYlR3 N2kMZAb6cjKh32Amp61z3vhE3jGUpIE6vcM8GtZpzGdPPI8fOlQb1hT5n52HZQq50IP3 4RonT1tVKPdOL/ebgeacWwjfolCG4qARJ3lUaHkb4NC4fTXohvWCZQCNAJpxdFr33KK0 cEl2TDv9j4NliSAT3aPYE5H6/CRaH++gAxIq9jbLoblmTUO2HZBC3QTh3T3USBCsKW47 kvag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=DcemLr8KJdmVpqOSO3EK6MN07CW4aGrHs4VrgTHH2Aw=; b=RsPZxvhM08Th6HR6DCbBUQtMAUpJhjGrImvJTHJgdr1Mkoq05swv97NB9obpkjh6rf mVxWZqrPqx8tRM1xoWmvFgF6Bvp4m7SGfl1IPc/Eyoa5Ccx1fug3/FRJGu56xpDsj9D3 Sscy2AQ2yGYJz4Fiita97IBJF4wY4yHAkXW7S1ULDL97hlm2hq1tScruqciRFXsp/T1O qXCVu+B1NFdDj+tgaDOP7anviIyJqRTYIto8MNmdJ732zERZPRC+DZb19r4n/SrYd6kq EX1zHl8VdN6mh+yH6xPwRbRtHjYy56INw9T/cCil5XKAfiN7ffi55TdG/ThC/lo9RyGC dpvw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 17si23161360pgc.481.2021.10.26.01.32.26; Tue, 26 Oct 2021 01:32:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232805AbhJZCLW (ORCPT + 99 others); Mon, 25 Oct 2021 22:11:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:43356 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230216AbhJZCLW (ORCPT ); Mon, 25 Oct 2021 22:11:22 -0400 Received: from rorschach.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0272560C49; Tue, 26 Oct 2021 02:08:57 +0000 (UTC) Date: Mon, 25 Oct 2021 22:08:56 -0400 From: Steven Rostedt To: Daniel Bristot de Oliveira Cc: Ingo Molnar , Tom Zanussi , Masami Hiramatsu , Juri Lelli , Clark Williams , John Kacur , Peter Zijlstra , Thomas Gleixner , Sebastian Andrzej Siewior , linux-rt-users@vger.kernel.org, linux-trace-devel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH V5 06/20] trace/osnoise: Allow multiple instances of the same tracer Message-ID: <20211025220856.7fef7581@rorschach.local.home> In-Reply-To: <69cbbd98cce2515c84127c8827d733dc87b04823.1635181938.git.bristot@kernel.org> References: <69cbbd98cce2515c84127c8827d733dc87b04823.1635181938.git.bristot@kernel.org> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 25 Oct 2021 19:40:31 +0200 Daniel Bristot de Oliveira wrote: > kernel/trace/trace_osnoise.c | 101 +++++++++++++++++++++++++++-------- > 1 file changed, 78 insertions(+), 23 deletions(-) > > diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c > index 3db506f49a90..8681ffc3817b 100644 > --- a/kernel/trace/trace_osnoise.c > +++ b/kernel/trace/trace_osnoise.c > @@ -64,6 +64,24 @@ static bool osnoise_has_registered_instances(void) > list); > } > > +/* > + * osnoise_instance_registered - check if a tr is already registered > + */ > +static int osnoise_instance_registered(struct trace_array *tr) > +{ > + struct osnoise_instance *inst; > + int found = 0; > + > + rcu_read_lock(); > + list_for_each_entry_rcu(inst, &osnoise_instances, list) { > + if (inst->tr == tr) > + found = 1; > + } > + rcu_read_unlock(); > + > + return found; > +} > + > /* > * osnoise_register_instance - register a new trace instance > * > @@ -2048,6 +2066,16 @@ static int osnoise_workload_start(void) > { > int retval; > > + /* > + * Instances need to be registered after calling workload > + * start. Hence, if there is already an instance, the > + * workload was already registered. Otherwise, this > + * code is on the way to register the first instance, > + * and the workload will start. > + */ > + if (osnoise_has_registered_instances()) > + return 0; Looking at how this is checked before being called, it really should return -1, as it is an error if this is called with instances active. -- Steve > + > osn_var_reset_all(); > > retval = osnoise_hook_events(); > @@ -2075,6 +2103,13 @@ static int osnoise_workload_start(void) > */ > static void osnoise_workload_stop(void) > { > + /* > + * Instances need to be unregistered before calling > + * stop. Hence, if there is a registered instance, more > + * than one instance is running, and the workload will not > + * yet stop. Otherwise, this code is on the way to disable > + * the last instance, and the workload can stop. > + */ > if (osnoise_has_registered_instances()) > return; > > @@ -2096,7 +2131,11 @@ static void osnoise_tracer_start(struct trace_array *tr) > { > int retval; > > - if (osnoise_has_registered_instances()) > + /* > + * If the instance is already registered, there is no need to > + * register it again. > + */ > + if (osnoise_instance_registered(tr)) > return; > > retval = osnoise_workload_start();