From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS, URIBL_BLOCKED,USER_AGENT_MUTT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E46DC43381 for ; Tue, 12 Mar 2019 07:21:51 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3EBB9214AE for ; Tue, 12 Mar 2019 07:21:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Qql3AGmQ"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VnJ9vN5H" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3EBB9214AE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=eyv8pb4vTDLzYkt4Qdp3g+L53ZSgnL2Wrz6Wcj/HVdw=; b=Qql3AGmQ2PCfYn Tr2muWNRqAiaEsemW9aTvgvEyPNb8l1rjUVytKmHQzw7Wu87HP8w67ce3cBbyPSOkpRwQa3bKh4U0 4ONof6mkK1YkaPZRbF9h1ojuKUyOPto49KvXgzHXRRy2MUDpjVItTDIo/D8eC4i7egqZ5wCSVXMiZ Rt4ui5XpWMiD9txtDXE5BIm/WsgLE4UsvkRwVdlRMeOFRlVlMwmh0HexaUFM1/hlkom2K1C/1IPq5 nYBs2bs+1oD7uuELhTQhawYNgzjDOlX/QR2379Za1s2rcevfej0CVD3lVX5ScMd4DM8AMApPw0GqY e/uO/bREK0PzA+ge6/Yw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h3bjO-0000nU-H1; Tue, 12 Mar 2019 07:21:46 +0000 Received: from mail-it1-x144.google.com ([2607:f8b0:4864:20::144]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h3bjL-0000mf-2o for linux-arm-kernel@lists.infradead.org; Tue, 12 Mar 2019 07:21:44 +0000 Received: by mail-it1-x144.google.com with SMTP id w18so2775006itj.4 for ; Tue, 12 Mar 2019 00:21:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=8a8VmXlU8RObQvd/P/gvRLa/m3fDfJy4y8D2hopmt9c=; b=VnJ9vN5HiV6QDiYzX28+tlyE4Wiy/2cQ4T6oanTuk9E5OjlgQWM6O9b6foDZu7XHCy bDm/zW6hin7Uz2WAAzNwTu2bZxfLnxyaMl3Lhwi4IdZ4wxoVXQoEGPY/c4Axs/gxODEU IkwKUJPA8VyJ36K+rClr6ggh1lVBE/QOOXJNXmlOegRVPBfoYRjUjGOPFo8iOy1+Q04E 1ZTyXO/nvZy3lMxU/oX9uj3Mc8gZKSPYxPoIQNbqZ2gHn0V3KqK5aekeYflC1RE3Q9bH xdaKccyugYLhkId37VauEv1o3i1RjUvU9Xuga70HmqsJwtkZ1GUaoXDOk4W22i2kkvVN SwTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=8a8VmXlU8RObQvd/P/gvRLa/m3fDfJy4y8D2hopmt9c=; b=RqvJnVXb37sNy1zI6wdw4rlef4V4WEvQT/i5F1fz6ZDzN6myESy0u+ZY2RMysyFiHJ AA7utAdVE7mfmwQacbvclHDk9daOE6KdQH8ffpxTB7KUJ5rD+m+fJfcyl+HvQvtFfy1f v+9u3d5xwTV4ua6mUpXdoGU5TtqPISYmQbiriOTrZmN8Tz0nIqyuhZH+Xp5yXP0ET7+Y R8mns1bQvmv+n8XH6gsRuFeSmyW/UBXwqTq3pg6IXsRHOBprOcwlgs+1xv9oAsUKQwOB qxQ7mRw3m3SO3KsKavLbvQ7PxxYN686SyLk3YxbNMOGDONIJxApw9xoWSVBGE+plR28W Z1Kg== X-Gm-Message-State: APjAAAWdsbbHFkfNfcLeQ8mpxBKESSQdNWAUVVJTPYXx5PS4m7sgC9BP /gE4mxqwAgjfDtDrMSQy8WI= X-Google-Smtp-Source: APXvYqwojN/L1C7ypKcAJ8FY1ANWqNL/GRVG96CzZVE1iDA3iOJQ6/a5H53T9z2lQfj5aKAKxlCMtg== X-Received: by 2002:a24:8092:: with SMTP id g140mr1239778itd.15.1552375299117; Tue, 12 Mar 2019 00:21:39 -0700 (PDT) Received: from icarus ([2001:268:c0a3:c255:c70:4af9:86e2:2]) by smtp.gmail.com with ESMTPSA id w6sm2892411iom.22.2019.03.12.00.21.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Mar 2019 00:21:38 -0700 (PDT) Date: Tue, 12 Mar 2019 16:22:22 +0900 From: William Breathitt Gray To: Masahiro Yamada Subject: Re: [PATCH v9 1/9] bitops: Introduce the for_each_set_clump8 macro Message-ID: <20190312072222.GA2898@icarus> References: <12b3a364ac7fc32194fa6f55911dd800aca92a56.1551598603.git.vilhelm.gray@gmail.com> <20190308085733.GA3903@icarus> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.3 (2019-02-01) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190312_002143_126913_BFD9BFC6 X-CRM114-Status: GOOD ( 31.57 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch , Arnd Bergmann , Bartosz Golaszewski , Linus Walleij , Rasmus Villemoes , "linux-kernel@vger.kernel.org" , "open list:GPIO SUBSYSTEM" , Andy Shevchenko , Andrew Morton , Andy Shevchenko , Linux ARM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Mar 12, 2019 at 02:36:21PM +0900, Masahiro Yamada wrote: > 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 */ You're right, for_each_set_clump8 wouldn't work in this case since it does not loop in reverse order. I shouldn't have rushed to find a case and ignored the context of the code like that. Since Andy appears to have hardware outside of the GPIO subsystem he's testing, let's wait for that and see how it turns out. William Breathitt Gray > > > 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel