[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <74a1af20-5f99-bb64-1e0f-c8405bd68014@oracle.com>
Date: Thu, 24 Oct 2019 14:31:51 -0700
From: Divya Indi <divya.indi@...cle.com>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: linux-kernel@...r.kernel.org, Joe Jin <joe.jin@...cle.com>,
Srinivas Eeda <srinivas.eeda@...cle.com>,
Aruna Ramakrishna <aruna.ramakrishna@...cle.com>
Subject: Re: [PATCH 4/5] tracing: Handle the trace array ref counter in new
functions
Hi Steven,
On 10/24/19 6:00 AM, Steven Rostedt wrote:
> On Wed, 23 Oct 2019 15:57:49 -0700
> Divya Indi <divya.indi@...cle.com> 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).
Right, Noted! Thanks for the pointer.
>
> -- 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.
Powered by blists - more mailing lists