Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2618711rdh; Wed, 27 Sep 2023 07:55:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH5xgTr8Y63xm47YdT9P5cL6Kxbs+n05ZaFKCGLottokRLjbN+r3vzSrLhZwEsJnzJEZ2WT X-Received: by 2002:a05:6a00:b4f:b0:690:f877:aa1e with SMTP id p15-20020a056a000b4f00b00690f877aa1emr3918925pfo.12.1695826533859; Wed, 27 Sep 2023 07:55:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695826533; cv=none; d=google.com; s=arc-20160816; b=H06htL/7n9GoHCZO3CkOtQFiyN/o4fLXTkOArW87p7427Us9ucI16g6txUDJJJHb2/ ki2QKgngstRlGFpKrBn6WKpMefcedzJHmKQ7B7/oJPpmTxgYqpTRu45LTMZyoUkJTKce pSNFH7FLBbcbqvWGwFXjj6qxM9MfF67Wf2fFeznbY4gTauw0NwhnBeyoAQss3fqXi/6b PpxkthlHsGHLofjzPB5q47RAAjpehnLnX3S3LvYUQqbLKxOa6dkw3AoyK/cr34b0WW7M an0EFAWadM1zAdklq7MlFSNIwYj6BQIndGA8oJ82yeZarZuJGaL1frLYby5KuHlq05mg duXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=3Aw5E5IBdNowjjS4PH7xoOgoqlu9/7i3Bf6Q6v3vpo4=; fh=GhAzZS0VrcP9Wgh2MyACsocSO4ETsMarljI7HvQ0MVM=; b=hOfCENwuE5vrJKmGoox0iwiRnprvNHy+U7+pjCEWG4kw9F2S3XCYlyKOUQi0Evloe2 c4xOq38Z7nLFyHpYG+z/K35r/Fxl2zegzpvsQ5rCMxl4wG+oDqgQuoV8x0uaTtgTAuHz F0ZfKkNINmc+Ns+W59VjSWclvZGu0z75GOxq2dP5olGT7GPlus59sHM1nY7ocarS88Vq /H4C3jmEJWImOia878lmBigUtROTMKO4VU0j9cbQ3U/AV+/nvxbTsDq70Ivk5NfPuk0p 0UioZYX/oc55+K6hepNGPEPdPzdHUxJZpKSWtd3Qyzy6sqozzLArWB44fDvG7RhnheGc vTcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fXeRQRBY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id bv186-20020a632ec3000000b00573f867019fsi14486811pgb.443.2023.09.27.07.55.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 07:55:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fXeRQRBY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 1AD068092DA6; Wed, 27 Sep 2023 06:49:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231987AbjI0Ntq (ORCPT + 99 others); Wed, 27 Sep 2023 09:49:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231966AbjI0Ntp (ORCPT ); Wed, 27 Sep 2023 09:49:45 -0400 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DCA911D; Wed, 27 Sep 2023 06:49:44 -0700 (PDT) Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-690d2441b95so8484704b3a.1; Wed, 27 Sep 2023 06:49:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695822583; x=1696427383; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=3Aw5E5IBdNowjjS4PH7xoOgoqlu9/7i3Bf6Q6v3vpo4=; b=fXeRQRBY+zCNC1Q8Xz9y4tWoBOF8rC3o6FrWWhS8Q3Z9v9MuQyLKqiSAxw9cYm4RVU oqXovOSKCvj3rmlJvcxPpD80j19nuTe7fW7xoIL21epx6UT4VMnHaigE9ABl1o3UzuZA L16rtXmxdhrnJDTP+YJTnsy5TiRjzDSI/ugZrWfpcEJDjQbttglsexfU21VBdRiDBbQ0 T7tYdXiuUzdZRO/0IxELZl9x3NbhrAiP5Xk6X1QcT5TLIGnyZSf4uRdiBukuYVRs2drH i2m4jRTN+NNRzBxGeFt4TnVU+jlNsTWtL0G9qOUzORxhCSg4TiEk+AzIIaW9c7C975SX K0Hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695822583; x=1696427383; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=3Aw5E5IBdNowjjS4PH7xoOgoqlu9/7i3Bf6Q6v3vpo4=; b=kxCH0yUZJV8ZaFRDkBHEDpzEIH2dKnOX9O4dVLin0JGwIe75I0P7KA37TBV3WxTfOD vGgu3R4Y+p68d3FpeYiNFqjWttFNJw5YIXUvObNGPP0mqwCTjgZhXDADWbh3Pe6uwSAy bAOq6+cwUGaSyC5NAyc5IONHkPDFZvo1jQCTyTOTNuhbYU/j0wWo03u0l/w7m4gk85I2 4D57lJj3Y7ZT71yTWEuw1u8YWyGFZg9FyxgAhmnP8bNINgVzMbwPwMTLjHgQng66pxZj Kunqwv0bYQHeYwHl7iBbpcvWAMGzFxLpQH0MnEGLhz+LMooSLQd6H3hyCt+cgTd6AaDg 8Zbw== X-Gm-Message-State: AOJu0YykJYDqKJEKiJZqfAK+fWjVivh6SmdCrIt4ZKJCytkHPa0KnJXZ uBj03jEal8l4xu8b6sfRxuY= X-Received: by 2002:a05:6a20:734e:b0:13e:90aa:8c8b with SMTP id v14-20020a056a20734e00b0013e90aa8c8bmr3270011pzc.4.1695822583550; Wed, 27 Sep 2023 06:49:43 -0700 (PDT) Received: from sol ([118.209.204.34]) by smtp.gmail.com with ESMTPSA id c16-20020aa781d0000000b00686edf28c22sm11779046pfn.87.2023.09.27.06.49.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 06:49:43 -0700 (PDT) Date: Wed, 27 Sep 2023 21:49:35 +0800 From: Kent Gibson To: Andy Shevchenko Cc: Linus Walleij , Bartosz Golaszewski , Yury Norov , linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Shubhrajyoti Datta , Srinivas Neeli , Michal Simek , Bartosz Golaszewski , Rasmus Villemoes , Marek =?iso-8859-1?Q?Beh=FAn?= Subject: Re: [PATCH v1 5/5] gpiolib: cdev: Utilize more bitmap APIs Message-ID: References: <20230926052007.3917389-1-andriy.shevchenko@linux.intel.com> <20230926052007.3917389-6-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 27 Sep 2023 06:49:52 -0700 (PDT) On Wed, Sep 27, 2023 at 03:17:06PM +0300, Andy Shevchenko wrote: > On Wed, Sep 27, 2023 at 09:32:11AM +0800, Kent Gibson wrote: > > On Tue, Sep 26, 2023 at 08:20:07AM +0300, Andy Shevchenko wrote: > > > Currently we have a few bitmap calls that are open coded in the library > > > module. Let's convert them to use generic bitmap APIs instead. > > > > Firstly, I didn't consider using the bitmap module here as, in my mind at > > least, that is intended for bitmaps wider than 64 bits, or with variable > > width. In this case the bitmap is fixed at 64 bits, so bitops seemed more > > appropriate. > > > > And I would argue that they aren't "open coded" - they are parallelized > > to reduce the number of passes over the bitmap. > > This change serialises them, e.g. the get used to require 2 passes over > > the bitmap, it now requires 3 or 4. The set used to require 1 and now > > requires 2. > > And there are additional copies that the original doesn't require. > > So your change looks less efficient to me - unless there is direct > > hardware support for bitmap ops?? > > > > Wrt the argument that the serialized form is clearer and more > > maintainable, optimised code is frequently more cryptic - as noted in > > bitmap.c itself, and this code has remained unchanged since it was merged > > 3 years ago, so the only maintenance it has required is to be more > > maintainable?? Ok then. > > > > Your patch is functionally equivalent and pass my uAPI tests, so > > > > Tested-by: Kent Gibson > > Thanks for testing! > Not a problem - that is what test suites are for. > > but my preference is to leave it as is. > > As Yury mentioned we need to look at bitmap APIs and make them possible to have > a compile-time optimizations. With that in mind, I would prefer bitmap APIs > over open-coded stuff which is hardly to be understood (yes, I still point > out that it takes a few hours to me, maybe because I'm stupid enough, to > get what's the heck is going one there, esp. for the == 1 case). > Really? With all the bits out in the open it seems pretty clear to me. Clearer than scatter/gather in fact. Sure, if there is suitable hardware support then bitmaps COULD be faster than bitops. But without that, and that is the general case, it will be slower. Do you have ANY cases where your implementation is currently faster? Then you would have a stronger case. And if you find the existing implementation unclear then the appropriate solution is to better document it, as bitmaps itself does, not replace it with something simpler and slower. > Yet, it opens a way to scale this in case we might have v3 ABI that let's say > allows to work with 512 GPIOs at a time. With your code it will be much harder > to achieve and see what you wrote about maintenance (in that case). > v3 ABI?? libgpiod v2 is barely out the door! Do you have any cases where 64 lines per request is limiting? If that sort of speculation isn't premature optimisation then I don't know what is. Cheers, Kent.