Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3470306ybg; Fri, 25 Oct 2019 04:44:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqyr3k6FJm9j15T8DJLDmR015Zstr+URBJdOvuaDmhAu/1t2YLCUzdsKLN44XTL4bH4voo1S X-Received: by 2002:a17:906:60c2:: with SMTP id f2mr2974933ejk.21.1572003849278; Fri, 25 Oct 2019 04:44:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572003849; cv=none; d=google.com; s=arc-20160816; b=GqAwHDqgCUymxXUplKfTANgAu34DGQIposgBYPi4ogKN9dT0jWWMXfZNXXablebulk Em7n8SvKaWfAZGBP7vL+DzIloRQwJQHYYflleuJ5DWUvwZligTv1lKUyQJ5qiT3QPIlm Aq8DBYQOhcbqKfYsWwDfPYgW7IKVVH3PBHS4zQGvQB6o6xHt7dGmj1R+62jMQlzfL7bL o6vitlVW7pHu1Rg6++q1RtIJc+Bk9eGz8NaqpcPDomIItmT/81D0GYdylf4fZDKqHLuF IGq7r35Qpm76N0mxmTkjuVTHTTkPW73ebERnZdIm71NJcQThv34QM1crja5L9YlCKuE7 147A== 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 :references:in-reply-to:message-id:subject:cc:to:from:date; bh=jBrLl0/sb/wYFv6HMnhoLyXQmDUdHleJkddBrUTIr5U=; b=R3c5XWzFNYdT/XXEk2N6T500PE3cF4ccrZprGpin0C3rcJrejUgAsmg3+VR7KgOYjJ +iEYeQvIGHAoy5ybQLSG0iW0qoJFZnCGTfkRPPngFn8USlTPH9SY5LtsT3znmhM50puo WlAXxlBReURfHhskfzSDB/zvU0jpWMYdPO6GnPUnPVbeRc8nQ89E1ttrKGBPB9jWoehJ TJ9wSc4KzL+XRwRF66rwNSToing9zE+nZk5zpC4/Q7z8NdI9gJ1gkPYNPOld4xnInESE 4CnqWeFOhRQpEFytS7c7aUXk6rrKq/5Agy8eECgflGYyL6OpTnjyWm+wqZ2HAquzsEDV WRLw== 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 y40si1026227edd.383.2019.10.25.04.43.44; Fri, 25 Oct 2019 04:44:09 -0700 (PDT) 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 S2502242AbfJXNAm (ORCPT + 99 others); Thu, 24 Oct 2019 09:00:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:50548 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726484AbfJXNAl (ORCPT ); Thu, 24 Oct 2019 09:00:41 -0400 Received: from gandalf.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 A16F92166E; Thu, 24 Oct 2019 13:00:39 +0000 (UTC) Date: Thu, 24 Oct 2019 09:00:37 -0400 From: Steven Rostedt To: Divya Indi Cc: linux-kernel@vger.kernel.org, Joe Jin , Srinivas Eeda , Aruna Ramakrishna Subject: Re: [PATCH 4/5] tracing: Handle the trace array ref counter in new functions Message-ID: <20191024090037.78fe9f30@gandalf.local.home> In-Reply-To: <2b08751a-4028-2130-9a70-c2aa2d76a31c@oracle.com> References: <1565805327-579-1-git-send-email-divya.indi@oracle.com> <1565805327-579-5-git-send-email-divya.indi@oracle.com> <20191015190436.65c8c7a3@gandalf.local.home> <4cad186e-ba8b-8e1a-731b-4350a095ba5a@oracle.com> <20191022225253.4086195c@oasis.local.home> <2b08751a-4028-2130-9a70-c2aa2d76a31c@oracle.com> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 23 Oct 2019 15:57:49 -0700 Divya Indi wrote: > Hi Steven, > > A few clarifications on this discussion on reference counter - > > 1) We will still need to export trace_array_put() to be used for every > trace_array_get_by_name() OR trace_array_create() + trace_array_get(). I'm fine with exporting trace_array_put, and even trace_array_get. > > How else will we reduce the reference counter [For eg: When multiple modules > lookup the same trace array (say, reference counter = 4)]? > > 2) tr = trace_array_create("my_tr"); > trace_array_get(tr); > > Both of these functions will iterate through the list of trace arrays to verify > whether the trace array exists (redundant, but more intuitive? Does this seem > acceptable?) > > To avoid iterating twice, we went with increasing ref_ctr in trace_array_create. > This necessitated a trace_array_put() in instance_mkdir (Or as suggested below, > we can do this trace_array_put() in instance_rmdir().) > > > 3) A summary of suggested changes (Let me know if this looks good) - > > tr = trace_array_get_by_name("foo-bar"); // ref_ctr++. > > if (!tr) > { > // instance_mkdir also causes ref_ctr = 1 You'll need locking for anyone who does this, and check the return status below for "foo-bar" existing already (due to another thread jumping in here). -- Steve > tr = trace_array_create("foo-bar"); // ref_ctr = 1 > trace_array_get(tr); // ref_ctr++ > } > > trace_array_printk(.....); > trace_array_set_clr_event(......); > ... > ... > ... > // Done using the trace array. > trace_array_put(tr); // ref_ctr-- > ... > ... > ... > // We can now remove the trace array via trace_array_destroy or instance_rmdir() > trace_array_destroy(tr); // ref_ctr > 1 returns -EBUSY.