[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6cfcaabd-9a41-8333-cd4e-fa6f65978151@nod.at>
Date: Fri, 28 Oct 2016 15:54:53 +0200
From: Richard Weinberger <richard@....at>
To: Tom Gundersen <teg@...m.no>
Cc: David Herrmann <dh.herrmann@...il.com>,
LKML <linux-kernel@...r.kernel.org>,
Andy Lutomirski <luto@...capital.net>,
Jiri Kosina <jikos@...nel.org>, Greg KH <greg@...ah.com>,
Hannes Reinecke <hare@...e.com>,
Steven Rostedt <rostedt@...dmis.org>,
Arnd Bergmann <arnd@...db.de>,
Josh Triplett <josh@...htriplett.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [RFC v1 08/14] bus1: implement peer management context
On 28.10.2016 15:23, Tom Gundersen wrote:
> On Fri, Oct 28, 2016 at 3:05 PM, Richard Weinberger
> <richard.weinberger@...il.com> wrote:
>> On Wed, Oct 26, 2016 at 9:18 PM, David Herrmann <dh.herrmann@...il.com> wrote:
>>> + /* initialize constant fields */
>>> + peer->id = atomic64_inc_return(&peer_ids);
>>> + peer->flags = 0;
>>> + peer->cred = get_cred(current_cred());
>>> + peer->pid_ns = get_pid_ns(task_active_pid_ns(current));
>>> + peer->user = user;
>>> + peer->debugdir = NULL;
>>> + init_waitqueue_head(&peer->waitq);
>>> + bus1_active_init(&peer->active);
>>> +
>>> + /* initialize data section */
>>> + mutex_init(&peer->data.lock);
>>> +
>>> + /* initialize peer-private section */
>>> + mutex_init(&peer->local.lock);
>>> +
>>> + if (!IS_ERR_OR_NULL(bus1_debugdir)) {
>>
>> How can bus1_debugdir contain an error code? AFACT it is either a
>> valid dentry or NULL.
>
> If debugfs is not enabled it will be ERR_PTR(-ENODEV).
I thought you handle that earlier. But just figured that you check only
for NULL after doing debugfs_create_dir(). This confused me.
>>> + char idstr[22];
>>> +
>>> + snprintf(idstr, sizeof(idstr), "peer-%llx", peer->id);
>>> +
>>> + peer->debugdir = debugfs_create_dir(idstr, bus1_debugdir);
>>> + if (!peer->debugdir) {
>>> + pr_err("cannot create debugfs dir for peer %llx\n",
>>> + peer->id);
>>> + } else if (!IS_ERR_OR_NULL(peer->debugdir)) {
>>> + bus1_debugfs_create_atomic_x("active", S_IRUGO,
>>> + peer->debugdir,
>>> + &peer->active.count);
>>> + }
>>> + }
>>> +
>>> + bus1_active_activate(&peer->active);
>>
>> This is a no-nop since bus1_active_init() set ->count to BUS1_ACTIVE_NEW.
>
> bus1_active_activate() changes count from BUS1_ACTIVE_NEW to 0.
Too many "active" words. ;)
Now it makes sense. BUS1_ACTIVE_NEW is state "NEW"
and the unnamed state "ready to use" is a counter >= 0.
Thanks,
//richard
Powered by blists - more mailing lists