Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3798038pxk; Tue, 22 Sep 2020 02:54:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy22bXpbN7+ES6z44McgeOpqa0/fZEKzRjAt6eeEua7uslFi2JQMYEteI4gwcYusqx1mNM9 X-Received: by 2002:a17:906:ae50:: with SMTP id lf16mr3834252ejb.343.1600768473793; Tue, 22 Sep 2020 02:54:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600768473; cv=none; d=google.com; s=arc-20160816; b=KL76eCQg2BzXmqqZl+NVmN3gIxUohGizhaIX5CWjCwQn7gtl/KCMLi9llHDIypMOFo ptaQryQevWvexeZ5eWKV4KR0CbQtnRmt3jOTTJ3uEV2pdP5rPVif6vXHMW4GtvBXCjTx +RUdMXbBOzEFbYPKM7Q/SDAFFLOJPTNGNI2DW1onS7dQmKW4IIx171U5brPsr3Qf2GbM 8ecLB+rp92zWi3/W8R5//OItSyi3OP2j+XhugQKf3gjzNQ12ge16t2q9uM0XEfDYfWcH z7vR8B8AxBiEpGGq3i0UfB5W7mzbiiUcwd3T3aue5HpEruokFoKlyd7xCRKYW/t5VjS+ Lf3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=bQvtQGp/KLFnOLWRiqixFEpZAYTNPr5oScyrlQ2lzEE=; b=kTgSoSfni4cn7dvSGWomZM+S9lGMkoduvNXg5yyoFWT4K6qCEn1uqRKpd7OAinIEZJ Yr0skhrHVPHXjnsMkFVV+lKyUSl1JL4U+qp9fOGwCR+RlWeTWYQVhm00uzuqJMk0LLNz 78t1BYQos482104xJvfcxPxBHLFX9weEtRk1hGuFwGKaRWOm/UsLkzn4f2buit/YQ0Gw /8eKsHaN/mo/w3TeE56Il5Y/MqCj+89rbty8eTxdLUkVRPkQYWwoNkh+iiTMT6eDBnnf 9QdxIDWpSmpOm97Lf+xtOXKqC5R4puFK9PO1cqYWN7YwUJocw3CWMnF5eHeAyadGY/8w a9yA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=gITCHOxw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u7si9614539edo.567.2020.09.22.02.54.10; Tue, 22 Sep 2020 02:54:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=gITCHOxw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726533AbgIVJvE (ORCPT + 99 others); Tue, 22 Sep 2020 05:51:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726461AbgIVJvD (ORCPT ); Tue, 22 Sep 2020 05:51:03 -0400 Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A065C061755 for ; Tue, 22 Sep 2020 02:51:03 -0700 (PDT) Received: by mail-ej1-x644.google.com with SMTP id i26so21883925ejb.12 for ; Tue, 22 Sep 2020 02:51:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=bQvtQGp/KLFnOLWRiqixFEpZAYTNPr5oScyrlQ2lzEE=; b=gITCHOxwcSAAjU4PnfdGZe3rwfIVDR1qijRZJNtrZIA1InVYlvJYzUqxNBSnK1X6hQ M/RwWjL2dyy4WUKoNQKxAmkluClAPweuDuIAz5RGRNpyOqShf009zsMqwXn8Rgdj/Rux q41yQdLuEoSTVTqFdHLboC9HgOuHw7zoGGQYGEtjwizZHBygu60Ta0k5GLK+iH5Sbhmz ZHs1kdtRPBOKWnOAw+2GgEwfDPlgCtMD+1Fr/V2+PBlGX/br98FPwMp4zZHn1PvpOYFl iQSqyIq+wpbC7mgsH8ZTGW/ClWv7OUKv5P2pMQYlAgqd/PuCPLzwfGr1zJDi1yYdj+Jc 6ZyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=bQvtQGp/KLFnOLWRiqixFEpZAYTNPr5oScyrlQ2lzEE=; b=Z9AOuTC/reus/0mZVRMdHw5yZs6HaAFvOQJIO+0S6ref6XvvC1nJs4LJp02fX8bW+7 90vberAOy/Q5WgQdbT/vgSo6Qm+v7aNoTriiP9TaMUFqAQNxPSTKvPoPo0qx3Bshg59Z IWNRRndsLKAFoRqtPpdmlFeVoji+Zf67kdsN49I1gK6ZgHvKV0HL+4xL9L+4CVllNSmT XwtNZfubkOT2E2P1TUnEmsAyIn3TILjEpvjtb1PJmc8PT65ZdrXdDhrSRcDxKaXBCaXy FE3UNWSTI5nScEZaduwncUhq/uywOSGZH7y38joAa0LpCs+0Fdj9fK7Es1fJNqcMtUjK sX2g== X-Gm-Message-State: AOAM530mTuuuwty7AY78VCihLzTUhyN4pqo8rRiRUSuiY3o7Xxljtq6T 0twg/btJlapNHUu6x7Rx7XTqHjrZ7u3GQPAmz0VE4A== X-Received: by 2002:a17:906:11d2:: with SMTP id o18mr3838714eja.420.1600768262126; Tue, 22 Sep 2020 02:51:02 -0700 (PDT) MIME-Version: 1.0 References: <20200922023151.387447-1-warthog618@gmail.com> <20200922023151.387447-5-warthog618@gmail.com> In-Reply-To: From: Bartosz Golaszewski Date: Tue, 22 Sep 2020 11:50:51 +0200 Message-ID: Subject: Re: [PATCH v9 04/20] gpio: uapi: define uAPI v2 To: Arnd Bergmann Cc: Kent Gibson , "linux-kernel@vger.kernel.org" , "open list:GPIO SUBSYSTEM" , Linus Walleij , Andy Shevchenko Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 22, 2020 at 9:41 AM Arnd Bergmann wrote: > > On Tue, Sep 22, 2020 at 4:34 AM Kent Gibson wrote: > > +/** > > + * struct gpio_v2_line_attribute - a configurable attribute of a line > > + * @id: attribute identifier with value from &enum gpio_v2_line_attr_id > > + * @padding: reserved for future use and must be zero filled > > + * @flags: if id is GPIO_V2_LINE_ATTR_ID_FLAGS, the flags for the GPIO > > + * line, with values from enum gpio_v2_line_flag, such as > > + * GPIO_V2_LINE_FLAG_ACTIVE_LOW, GPIO_V2_LINE_FLAG_OUTPUT etc, OR:ed > > + * together. This overrides the default flags contained in the &struct > > + * gpio_v2_line_config for the associated line. > > + * @values: if id is GPIO_V2_LINE_ATTR_ID_OUTPUT_VALUES, a bitmap > > + * containing the values to which the lines will be set, with each bit > > + * number corresponding to the index into &struct > > + * gpio_v2_line_request.offsets. > > + * @debounce_period_us: if id is GPIO_V2_LINE_ATTR_ID_DEBOUNCE, the desired > > + * debounce period, in microseconds > > + */ > > +struct gpio_v2_line_attribute { > > + __u32 id; > > + __u32 padding; > > + union { > > + __aligned_u64 flags; > > + __aligned_u64 values; > > + __u32 debounce_period_us; > > + }; > > +}; > > Having different-sized members in the union makes it hard for > something like strace to print the contents. How about just making > them all __aligned_u64 even when 32 bits are sufficient? > Ah yes, adding support for GPIO ioctl()'s to strace has been on my TODO list for 3 years now. :( > > +struct gpio_v2_line_request { > > + __u32 offsets[GPIO_V2_LINES_MAX]; > > + char consumer[GPIO_MAX_NAME_SIZE]; > > + struct gpio_v2_line_config config; > > + __u32 num_lines; > > + __u32 event_buffer_size; > > + /* Pad to fill implicit padding and reserve space for future use. */ > > + __u32 padding[5]; > > + __s32 fd; > > +}; > > > +struct gpio_v2_line_info { > > + char name[GPIO_MAX_NAME_SIZE]; > > + char consumer[GPIO_MAX_NAME_SIZE]; > > + __u32 offset; > > + __u32 num_attrs; > > + __aligned_u64 flags; > > + struct gpio_v2_line_attribute attrs[GPIO_V2_LINE_NUM_ATTRS_MAX]; > > + /* Space reserved for future use. */ > > + __u32 padding[4]; > > +}; > > These are both several hundred bytes long, requiring a lot of data > to be copied to the stack and take up space there. I see this is not > actually much different for the v1 API, but I wonder if there has been > any analysis of whether this has a noticeable effect on application > runtime. > The main difference between this and V1 is that we can now pass arguments for flags as defined in struct gpio_v2_line_attribute. I haven't measured the impact but first: this is not a hot path (retrieving line info is not done a lot like reading line events or setting/getting values), and second: this structure is 280 bytes long which is still less than a page so we should not face more context switches than with a smaller structure, right? Bartosz