Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759135AbcJ1NVx (ORCPT ); Fri, 28 Oct 2016 09:21:53 -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 S1752629AbcJ1NVv (ORCPT ); Fri, 28 Oct 2016 09:21:51 -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: Date: Fri, 28 Oct 2016 15:21:44 +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: 1430 Lines: 43 On 28.10.2016 15:18, Tom Gundersen wrote: > On Fri, Oct 28, 2016 at 2:06 PM, Richard Weinberger > wrote: >> David, Tom, >> >> On Wed, Oct 26, 2016 at 9:18 PM, David Herrmann wrote: >>> +struct bus1_peer *bus1_peer_new(void) >>> +{ >>> + static atomic64_t peer_ids = ATOMIC64_INIT(0); >>> + const struct cred *cred = current_cred(); >>> + struct bus1_peer *peer; >>> + struct bus1_user *user; >>> + >>> + user = bus1_user_ref_by_uid(cred->uid); >>> + if (IS_ERR(user)) >>> + return ERR_CAST(user); >>> + >>> + peer = kmalloc(sizeof(*peer), GFP_KERNEL); >>> + if (!peer) { >>> + bus1_user_unref(user); >>> + return ERR_PTR(-ENOMEM); >>> + } >>> + >>> + /* initialize constant fields */ >>> + peer->id = atomic64_inc_return(&peer_ids); >> >> What is the purpose of this id? Do other components depend on it >> and are they aware of possible overflows? > > The id is used purely to give a name to the peer in debugfs. Okay. >> Since it is an 64bit integer overflowing it is hard but not impossible. > > Hm, what scenario do you have in mind? I cannot see how this could > happen (short of creating peers in a loop for hundreds of years). When it is purely for naming creating peers is slow enough it is no problem at all. That's why I was asking. Thanks, //richard