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=-2.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,SPF_PASS,URIBL_BLOCKED, USER_AGENT_MUTT autolearn=ham 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 37962C43381 for ; Tue, 26 Mar 2019 03:13:37 +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 0625B20828 for ; Tue, 26 Mar 2019 03:13:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="jFWhnKqs"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TrjA+eap" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0625B20828 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=MdtEK75kh5aYDc/m+Gcn+0CNedpN+r2hCp+0m+szKeg=; b=jFWhnKqsqypAxK bsCvs2QWY9fC56GGIqQHKGn/yZauzVXrdC5hoClXAG0fOc2Dd/fBo6ZAddzzZyrNOOldrpv9DDjYK sUXCEiiBfD1Yl3uJKa6Zo/SorvEQO/Xmyw30W5k0eXXatLnYdbQPwZJZhmqyx1os0rbIft7TbybU+ UtfP5Q6V8pIe7B1S952GldMtrJUVzQI/sCf0kwdfEAbsKNz14sH2W0eJaiWwPbQDW+CmAvWEP1gUX eekwWdydl8ZoL9PBGG6dznNWwo2GdTSoRpFbC9SzW/38+lNq+wfQzv1mVTYbLWV5AFFlVgQa50uGr hMBGbSJwqtteAwzUjUkg==; 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 1h8cWo-0000XH-3H; Tue, 26 Mar 2019 03:13:30 +0000 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h8cWi-0000WR-7x for linux-arm-kernel@lists.infradead.org; Tue, 26 Mar 2019 03:13:27 +0000 Received: by mail-pl1-x644.google.com with SMTP id b65so928356plb.6 for ; Mon, 25 Mar 2019 20:13:24 -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=MinFei9y55S8BB3lIJN4Zd2NC15gAsU5rmUgcJ/yuXI=; b=TrjA+eapEbjBMS8P7sEKmLpBp0YEw+GcQcONqsGvTaqETKh+x+NLKocqs9zPHNR13F m+BYYqLlu1cf4zDi4dz3L8CxrMGJ+OvKBdP/pcRa7aZgbh/JBWKr7J772+2Z8LWhXQd2 VsNJIDMK1iVKhT8Bd5HQ0xiI+h80584mliCEwN+dUlG1IW6xVaFK5+a25wmj+QfMT04F koJVn4ovW5BxgaNP9v3aZlES5gpEBnkpQoJRVhqsRhBbLszkve9is/TYdolnPABlMhAy oZYB/PEIcI9syoGbEhKQ3LVdAZ4LkC+B8G7KU8LUxRHUK4gStnKBjDeY1bm4PSMBzV7v PWXQ== 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=MinFei9y55S8BB3lIJN4Zd2NC15gAsU5rmUgcJ/yuXI=; b=P1Jyh2aP3pyjI4dJofBkvVFIyfORQnxFtfTYUG32+xr3M5rathp+dJchcl7F6QdKbn RCVjKwmPekOBpx754OJuCfWawDdiZM1SweB9nzAw2Hj9inm9ElmbtlJ6JhcAHtXztK+N GASvTEM1W4yDapyrIUfnteC8/ky26ahfrkLuZ+rrSZ9uS2IhmrzQrq1g/xmOXCQPHBKB pqX3krP5N2GjWtSW6jT/W609kH28tpJVaABQ8UTqMwLpIs0qIBgZGyl0pRbW1VRimbAh 2y/g/G6HeVleC30Brt3HvZjENLxSmZ17TLtjzZus+iKzMdTcRiqPyB5t/D48kTsYklXM EiYw== X-Gm-Message-State: APjAAAWwABeznlTOs8QgPVTtKxKkSMma17Jjanr0rI17SkA5Xfsq3LGU pAYgwX8GRe35PygdRhOvB94edlrfu6Y= X-Google-Smtp-Source: APXvYqwSFiRdDaTC0unzOdl6OozUx1Di7vdpvlhIFLAoPI/PoJwnq/bdkwslNzOq2Jz4dD1X0QaKqA== X-Received: by 2002:a17:902:9a98:: with SMTP id w24mr28467310plp.247.1553570002759; Mon, 25 Mar 2019 20:13:22 -0700 (PDT) Received: from icarus ([2001:268:c0a3:6e7a:c70:4af9:86e2:2]) by smtp.gmail.com with ESMTPSA id b133sm23029909pfb.62.2019.03.25.20.13.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Mar 2019 20:13:22 -0700 (PDT) Date: Tue, 26 Mar 2019 12:14:22 +0900 From: William Breathitt Gray To: Lukas Wunner Subject: Re: [PATCH v12 01/11] bitops: Introduce the for_each_set_clump8 macro Message-ID: <20190326031422.GB3356@icarus> References: <9afc30a574ce3e6a86b51dd522146a1d2156dedd.1553494625.git.vilhelm.gray@gmail.com> <20190325093854.jzkkwaksxi7zvtrg@wunner.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190325093854.jzkkwaksxi7zvtrg@wunner.de> User-Agent: Mutt/1.11.4 (2019-03-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190325_201324_340982_1DFC6D96 X-CRM114-Status: GOOD ( 15.88 ) 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@vger.kernel.org, preid@electromag.com.au, Arnd Bergmann , linux-gpio@vger.kernel.org, yamada.masahiro@socionext.com, linus.walleij@linaro.org, linux-pm@vger.kernel.org, linux@rasmusvillemoes.dk, linux-kernel@vger.kernel.org, bgolaszewski@baylibre.com, Andy Shevchenko , geert@linux-m68k.org, akpm@linux-foundation.org, andriy.shevchenko@linux.intel.com, linux-arm-kernel@lists.infradead.org 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 Mon, Mar 25, 2019 at 10:38:54AM +0100, Lukas Wunner wrote: > On Mon, Mar 25, 2019 at 03:22:23PM +0900, William Breathitt Gray wrote: > > +/** > > + * find_next_clump8 - find next 8-bit clump with set bits in a memory region > > + * @clump: location to store copy of found clump > > + * @addr: address to base the search on > > + * @offset: bit offset at which to start searching > > + * @size: bitmap size in number of bits > > + * > > + * Returns the bit offset for the next set clump; the found clump value is > > + * copied to the location pointed by @clump. If no bits are set, returns @size. > > + */ > > +unsigned int find_next_clump8(unsigned long *const clump, > > + const unsigned long *const addr, > > + unsigned int offset, const unsigned int size) > > +{ > > + for (; offset < size; offset += 8) { > > + *clump = bitmap_get_value8(addr, size, offset); > > + if (!*clump) > > + continue; > > + > > + return offset; > > + } > > + > > + return size; > > +} > > +EXPORT_SYMBOL(find_next_clump8); > > Just use find_first_bit() / find_next_bit() to use optimized arch-specific > bitops instead of open-coding the iteration over the bitmap. > > See max3191x_get_multiple() for an example. > > Thanks, > > Lukas Is this the sort of implementation you had in mind: offset = find_next_bit(addr, size, offset); if (offset == size) return size; offset -= offset % 8; *clump = bitmap_get_value8(addr, size, offset); return offset; Yes, this does seem more efficient to leverage the existing find_next_bit function. Should the offset and size parameters be redefined as unsigned long to match the find_first_bit/find_next_bit function parameters? William Breathitt Gray _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel