Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2158598ybl; Thu, 29 Aug 2019 04:30:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqwE5VL/S7v7NPg82sTDvx45cKc6cHfXkiPAnbjg9iCoYQ+EMtU8VpsXiEVg/5NUTe44gYWO X-Received: by 2002:a17:90a:e2ca:: with SMTP id fr10mr9645785pjb.72.1567078224113; Thu, 29 Aug 2019 04:30:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567078224; cv=none; d=google.com; s=arc-20160816; b=bZ83utS6JEVHUusFxWgZCTpY2UuLECdxfL4J11fPnTikPMry7YsdGKlZ3aaQQ6Z+vd Eg6Sb4CFTfk6teLbF8ZfejN3otH0OpCNOerxx9XBSiqG7Y3n+DADO8NQc7FHwMwAnXCq twDG9Sf1lj+W8VNYhMK6fwYCmcEk0x9FbdoBU+xourw/kpyaL6Au5Y8p1YwaTJSXUDIS 75tA8qiabkVOSrt2yqcqMt2XoNXrnlXp9XIR53hP4bESVXDvc5JsZyqc3GfsjlF2mqFr bMzqhgt1dRJiGO43jmm+PTDsK/awHBjhP1fTP9Ix1ylY7I/ZNp/vXO9R8vbk+Psjuexk 8BGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=5G4fyJI6cXHM40lO9SV59Ocd7ATst9OSyxgH8igoa1k=; b=o73wXUEFxRPue2f/a7x3MAfzW2PUMXd/SA+5QdnRzx+J4PAaMEV5JxlKGN2aSgNsvm Egczp5ML9HRUrdRXAfru4GSXy6GoN6T3HR8+3PS4zjuiYnIB8cH+6HjG3jt67mymZDjx az7/XSYTvfb63vg8bLJgBNtW5J8IiVKLYRt7fY4JDrqUrY3iNOHrEG99baY5Bxc81sgy 6nPteZjv8/kj32rAkj5wfIrfth2k0eHRA2tgNjtWPrrKNDR8bZy4dNCUiuc9NtDAx4t6 mkIOkOjlLc3o3O8Vt1V9L0GPQBncyXUHhtjEY3qIDOCzH2f+uvjc/bKow+q77U9H1Coy /7AA== 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 t21si1649828pga.294.2019.08.29.04.30.08; Thu, 29 Aug 2019 04:30:24 -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 S1727600AbfH2L3C (ORCPT + 99 others); Thu, 29 Aug 2019 07:29:02 -0400 Received: from mx2.suse.de ([195.135.220.15]:37454 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726379AbfH2L3C (ORCPT ); Thu, 29 Aug 2019 07:29:02 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 28598ABE9; Thu, 29 Aug 2019 11:29:00 +0000 (UTC) Date: Thu, 29 Aug 2019 13:28:59 +0200 From: Petr Mladek To: John Ogness Cc: Andrea Parri , Andrea Parri , Sergey Senozhatsky , Sergey Senozhatsky , Steven Rostedt , Brendan Higgins , Peter Zijlstra , Thomas Gleixner , Linus Torvalds , Greg Kroah-Hartman , linux-kernel@vger.kernel.org Subject: Re: numlist API Re: [RFC PATCH v4 1/9] printk-rb: add a new printk ringbuffer implementation Message-ID: <20190829112859.oqhsoudamd3nld7w@pathway.suse.cz> References: <20190807222634.1723-2-john.ogness@linutronix.de> <20190823171802.eo2chwyktibeub7a@pathway.suse.cz> <20190823171802.eo2chwyktibeub7a@pathway.suse.cz> <87sgpnmqdo.fsf@linutronix.de> <20190827130349.6mrnhdlqyqokgsfk@pathway.suse.cz> <20190827130349.6mrnhdlqyqokgsfk@pathway.suse.cz> <87o909lq3g.fsf@linutronix.de> <20190828085845.5k7ewfshbfed7txh@pathway.suse.cz> <20190828085845.5k7ewfshbfed7txh@pathway.suse.cz> <87k1axjsjp.fsf@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87k1axjsjp.fsf@linutronix.de> User-Agent: NeoMutt/20170912 (1.9.0) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 2019-08-28 16:03:38, John Ogness wrote: > On 2019-08-28, Petr Mladek wrote: > > I only think that, especially, numlist API is too generic in v4. > > It is not selfcontained. The consistency depends on external barriers. > > > > I believe that it might become fully self-contained and consistent > > if we reduce possibilities of the generic usage. In particular, > > the numlist should allow only linking of reusable structures > > stored in an array. > > OK. I will make the numlist the master of the ID-to-node mapping. To > implement the getdesc() callback of the dataring, the printk_ringbuffer > can call a numlist mapping function. Also, numlist will need to provide > a function to bump the descriptor version (as your previous idea already > showed). Sounds good. > I plan to change the array to be numlist nodes. The ID would move into > the numlist node structure and a void-pointer private would be added so > that the numlist user can add private data (for printk_ringbuffer that > would just be a pointer to the dataring structure). When the > printk_ringbuffer gets a never-used numlist node, it can set the private > field. I am not sure that I get the full picture. It would help to see some snippet of the code (struct declaration). Anyway, adding void-pointer into struct numlist looks like classic (userspace?) implementation of dynamically linked structures. I do not have strong opinion. But I would prefer to stay with the kernel-style. I mean that the numlist structure is part of the linked structures. And container_of() is eventually used to get pointer to the upper structure. Also passing values via a pointer with generic name (data) slightly complicates the code. I know that numlist is special because id is used to get the pointer of the numlist and also the upper structure. Anyway, the kernel style looks more familiar to me in the kernel context. But I'll leave it up to you. > This has the added benefit of making it easy to detect accidental > never-used descriptor usage when reading dataring garbage. This was > non-trivial and I'm still not sure I solved it correctly. (I've already > spent a week working on a definitive answer to your email[0] asking > about this.) Would a check for NULL data pointer help here? Well, it might be motivation for using the pointer. I wonder if begin_lpos == end_lpos check might be used to detect never used descriptors. It is already used in another situation in dataring_desc_init(). IMHO, the values even do not need to be unaligned. But I might miss something. Best Regards, Petr