Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760111AbcJ1NzB (ORCPT ); Fri, 28 Oct 2016 09:55:01 -0400 Received: from b.ns.miles-group.at ([95.130.255.144]:44723 "EHLO radon.swed.at" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756119AbcJ1NzA (ORCPT ); Fri, 28 Oct 2016 09:55:00 -0400 Subject: Re: [RFC v1 08/14] bus1: implement peer management context To: Tom Gundersen References: <20161026191810.12275-1-dh.herrmann@gmail.com> <20161026191810.12275-9-dh.herrmann@gmail.com> Cc: David Herrmann , LKML , Andy Lutomirski , Jiri Kosina , Greg KH , Hannes Reinecke , Steven Rostedt , Arnd Bergmann , Josh Triplett , Linus Torvalds , Andrew Morton From: Richard Weinberger Message-ID: <6cfcaabd-9a41-8333-cd4e-fa6f65978151@nod.at> Date: Fri, 28 Oct 2016 15:54:53 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2221 Lines: 57 On 28.10.2016 15:23, Tom Gundersen wrote: > On Fri, Oct 28, 2016 at 3:05 PM, Richard Weinberger > wrote: >> On Wed, Oct 26, 2016 at 9:18 PM, David Herrmann 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