Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp3843552img; Mon, 25 Mar 2019 20:14:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqzJCuJwZYcaFUp3z4gupf+6AZ0/QN9c+oNF3xFXhK1sCBZqMNY5KnumxsPPVlMfacQAxolX X-Received: by 2002:a63:c24d:: with SMTP id l13mr27394589pgg.166.1553570054221; Mon, 25 Mar 2019 20:14:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553570054; cv=none; d=google.com; s=arc-20160816; b=YUNWPEaD8AyGXnKfYKXBrrwzsSum+vcQhw9Z+ciUEHe9QL7TJa17BedpfjbqzEbWSL aUYltw/zNjCOwDMiYEdy/FlWk8Fl6nsHTcD8bSpUMDKu9XfUIpsDBp9EaOv+EVSaAPpl ntMjqn0pELrn1ilha4KmXydRCS/DmG62sRhHSXYdIFavcyi7pnDk7YB1jvjBhgv9H0kR CAJ0g34AT7PD0R0gWXR0fu75/nl+ZCSbNPW07EMStWfUxA6mb6EbO4nuYShaG44m3PgI 6fo71VRTx2q7rMedINAyASg1qr8l/DAFRaeF/mT1C+mXCoKIqaf74fH/pOSA+F2iXG9n s2xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=MinFei9y55S8BB3lIJN4Zd2NC15gAsU5rmUgcJ/yuXI=; b=E7JDV5s2bQnftAdFrYwAysfSXfl43rHPUr8q7TdB/0T1ic1EIMsKxXPGZBQCGKG0Qy 7v5PRild1CnQxWP/QQ39VzmNkNxQKKvC/q1N9doaKs48Jh0YAYwfY/Se9prGF7riX1/8 YBP0MTbSr29YolrfcuuxQNOgh0BT0QjvYtOOv2ajeuxAF8vQ/inZhcyNM2b7E9YBSqD6 h7dSio7bQ7dcmNqbCz3dsA+icTI1gDYf/Nal/wnoiVf2mK7ztUyFykY8JOg0UCVtYtWY +zcFG5e5HuMX8hFjcHwKhVlU776cdtbYNdzMLGnZOkETGzLMeaawWUXxPbUBc9Vl9hOv 0suw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=TrjA+eap; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f1si15823331plr.55.2019.03.25.20.13.58; Mon, 25 Mar 2019 20:14:14 -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=@gmail.com header.s=20161025 header.b=TrjA+eap; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730605AbfCZDNY (ORCPT + 99 others); Mon, 25 Mar 2019 23:13:24 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:41306 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727157AbfCZDNX (ORCPT ); Mon, 25 Mar 2019 23:13:23 -0400 Received: by mail-pl1-f193.google.com with SMTP id y5so925866plk.8; Mon, 25 Mar 2019 20:13:23 -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=SfNAcuna+gHRyKWAxq602iDr0QY4SLTfzcUdhj+rZnp/OJg4+9zdErZCqfXcNOrNIk KbyrmBSaz3BrhV4jwlEqIfJQhSMaKLfqr6Ul2jlJSt+z8C82mOr+WoSvCY6l4Cva6MbN Wq/HCuO86lbKmRG67XQ7bod/GJ825s3nK8CmIUmyLt7dgEAcDVZ/UZ5PmgP/HT4R+ya9 Qap8NXrM8cE2UheIMXyqzxqMC75Gg2V2NBEA7K5cJ1wBoAsv28+blKCngZeoT7oJtAwL j7O7EodjNsuSrqVYfeXtIPLvuQzw7Lm6xoj5Xnk4aOmOlxMwK+QZQN1YiDy1ANTqdg7R u96A== X-Gm-Message-State: APjAAAXmqbYmLQXwMzQuDeCpGIaMQWKJQK1/7oJECDe3Q8rY+WOSjVmp zGpwTFUnzZVMOKpq8l39C0M= 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 Cc: linus.walleij@linaro.org, bgolaszewski@baylibre.com, akpm@linux-foundation.org, linux-gpio@vger.kernel.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk, yamada.masahiro@socionext.com, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org, geert@linux-m68k.org, preid@electromag.com.au, Andy Shevchenko , Arnd Bergmann 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-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20190325093854.jzkkwaksxi7zvtrg@wunner.de> User-Agent: Mutt/1.11.4 (2019-03-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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