Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp1734100imc; Mon, 11 Mar 2019 22:38:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqxFlcscyjgsTcg9igoQ66YAubc0TyUyh+9qeqY9m8bF4pOohEeAUTqa/g2xNuWC6le9F9ll X-Received: by 2002:a65:6149:: with SMTP id o9mr33356086pgv.315.1552369098654; Mon, 11 Mar 2019 22:38:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552369098; cv=none; d=google.com; s=arc-20160816; b=dTIdYmBg7sHC1yqxigbnshS/1TJjfPKZTX71HAb4VDimyjuZfdfIJ8VK8NgbECg5sV 8w3FNnaFbbSqr3kJEK+oW6US89Nnrxzds4ww+SdTzOPSAFh+9EKgc5jXR6qtODkccRhw oKGYk8GE3+4df0g5cQ5Bsg3Y4wxWsBYuy6lxGre5hwz2Vm2tehUa8/lxNuC+Qn82mNw0 FAZRFjiHndny5pc4qI9Ip3GqrLuEfJt0stf7y9nn1fp8L9Nq7zForQ9QXwiISYtNT8Zf LAGjICNXL/mRLmjI7UfADIDhzNNN5l3ZTlc0Nvp6EBbWAPZacpdj1r5OwYiRrFdgBtRM Ba3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature:dkim-filter; bh=lhKJrFRsXpVQ3gIrx8behZH6ffnT+QME0xZWR+k1SZQ=; b=SM3kGOVey9AaT7noIEaVbrDh6XJrqR7IzSNKhDcq9CT489/br8WEkKlHo1OxASXt82 taO8UHK6E7nNxeji2zu99LT2NjxdAhjfLw+KlsBf393E1q9TiakR9llcId+KGJmWyNpE b5dJVz2zAOjFlfthfqjAon0QzVAg2WRn2u7fVkALCViabVTyBsNVmJVqS4DCwUZw8tV3 Z8Ka0/hnhSEW9s65GyDXHNDMP0SOcC1ol9El3P7FUSf3V0c8l/89iIG4AJj6WDTfK1O3 XjN1v+RnWvMhgQ/ZnTjqXroX9/QNIj+WLUFvjbCz3s+RoCNcG98cDHe/a0umzGQGKGVi 5/kQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=kRhF3ypD; 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 w21si6948610pga.0.2019.03.11.22.38.02; Mon, 11 Mar 2019 22:38:18 -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; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=kRhF3ypD; 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 S1727136AbfCLFhF (ORCPT + 99 others); Tue, 12 Mar 2019 01:37:05 -0400 Received: from conssluserg-02.nifty.com ([210.131.2.81]:28562 "EHLO conssluserg-02.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725855AbfCLFhE (ORCPT ); Tue, 12 Mar 2019 01:37:04 -0400 Received: from mail-vs1-f52.google.com (mail-vs1-f52.google.com [209.85.217.52]) (authenticated) by conssluserg-02.nifty.com with ESMTP id x2C5avSU001330; Tue, 12 Mar 2019 14:36:58 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-02.nifty.com x2C5avSU001330 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1552369018; bh=lhKJrFRsXpVQ3gIrx8behZH6ffnT+QME0xZWR+k1SZQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=kRhF3ypDLRvYFrsqaBxKXcy2GTP4CrUI98KUqoXLgE5YcDc7222ItNz1/J6OCDt9T xCP4O9KrEp76QNvz1i4eH/eJFOoDIbEZaOd4cAToE0bm9EntvtKq0R3BPofV4AyYfQ RVumlecIYdebxQiDH820zaORBBkPWp60oMu5qXQKrsKW2lcp90cVgIAFkcMknF5tTe gBHZYsp57dD/gVKRcaEcPVz8rCc/noIZAgYCJhHLG6Ogy8+0HFdQymigXeS28EFV+L gJlr/Dk4aRh+j5O+lEmYP9MrN+NRvdHKwHV+NvEieZ5+kLsW/XfNqEKyGhnSQ2rwJr gpRA+VT3C+l8g== X-Nifty-SrcIP: [209.85.217.52] Received: by mail-vs1-f52.google.com with SMTP id w14so855012vso.6; Mon, 11 Mar 2019 22:36:58 -0700 (PDT) X-Gm-Message-State: APjAAAUC3K0wXSxGZ4uASore7QPmHITLJy+Tkwr/4q8Pnyf3hK2lOthO 5gb2ilIQ+9kzCOktPdufdIS0UrQnOASKQrnfrOU= X-Received: by 2002:a67:f90e:: with SMTP id t14mr19094259vsq.181.1552369017355; Mon, 11 Mar 2019 22:36:57 -0700 (PDT) MIME-Version: 1.0 References: <12b3a364ac7fc32194fa6f55911dd800aca92a56.1551598603.git.vilhelm.gray@gmail.com> <20190308085733.GA3903@icarus> In-Reply-To: <20190308085733.GA3903@icarus> From: Masahiro Yamada Date: Tue, 12 Mar 2019 14:36:21 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v9 1/9] bitops: Introduce the for_each_set_clump8 macro To: William Breathitt Gray Cc: Linus Walleij , Andrew Morton , "open list:GPIO SUBSYSTEM" , linux-arch , "linux-kernel@vger.kernel.org" , Andy Shevchenko , Rasmus Villemoes , Bartosz Golaszewski , Linux ARM , Andy Shevchenko , Arnd Bergmann Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 8, 2019 at 5:57 PM William Breathitt Gray wrote: > > On Fri, Mar 08, 2019 at 09:31:00AM +0100, Linus Walleij wrote: > > On Sun, Mar 3, 2019 at 8:47 AM William Breathitt Gray > > wrote: > > > > > This macro iterates for each 8-bit group of bits (clump) with set bits, > > > within a bitmap memory region. For each iteration, "start" is set to the > > > bit offset of the found clump, while the respective clump value is > > > stored to the location pointed by "clump". Additionally, the > > > bitmap_get_value8 and bitmap_set_value8 functions are introduced to > > > respectively get and set an 8-bit value in a bitmap memory region. > > > > > > Suggested-by: Andy Shevchenko > > > Suggested-by: Rasmus Villemoes > > > Cc: Arnd Bergmann > > > Cc: Andrew Morton > > > Reviewed-by: Andy Shevchenko > > > Reviewed-by: Linus Walleij > > > Signed-off-by: William Breathitt Gray > > > > Andrew: would you be OK with this being merged in v5.1? > > > > If we need to move the code to drivers/gpio that's OK (though > > I think it's generally useful) but I need to know to proceed with > > the William's nice optimization of these drivers. > > > > Yours, > > Linus Walleij > > I was waiting on Andy to suggest some examples out of the GPIO realm, > but he may be under a heavy workload right so I decided to do a quick > search for one. > > In drivers/of/unittest.c, there is loop across a bitmap in the > of_unittest_destroy_tracked_overlays function: > > for (id = MAX_UNITTEST_OVERLAYS - 1; id >= 0; id--) { > if (!(overlay_id_bits[BIT_WORD(id)] & BIT_MASK(id))) > continue; > > This section of code is checking each bit individually, and skipping if > that bit is not set. This looping can be optimized by using the > for_each_set_clump8 macro Probably no. I see this comment before the loop. /* remove in reverse order */ Also, the unittest code handles per-bit whereas your helper does per-byte. > to skip clumps of nonset bits (not to mention > make the logic of the code much simpler and easier to follow by reducing > the code to a single line): > > for_each_set_clump8(id, clump, overlay_id_bits, MAX_UNITTEST_OVERLAYS-1) > > The for_each_set_clump8 macro is not specific to the GPIO subsystem; I > just happen to use it in these GPIO drivers simply because I am most > familar with this section of the kernel (it's where most of my > contributions occur afterall). > > Consider this, if I am able to find a use for this macro outside of the > GPIO subsystem within a matter minutes, then there must be some benefit > in allowing the rest of the kernel to use the for_each_set_clump8 macro. > So let's put it in bitops.h rather than restrict it to just the GPIO > subsystem. If we do not find useful cases in other subsystem, this patch set looks over-engineering to me. > William Breathitt Gray -- Best Regards Masahiro Yamada