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=-8.3 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 B7882ECE58C for ; Mon, 7 Oct 2019 20:26:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8B925206C0 for ; Mon, 7 Oct 2019 20:26:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20150623.gappssmtp.com header.i=@toxicpanda-com.20150623.gappssmtp.com header.b="lFU77jbR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728937AbfJGU0Q (ORCPT ); Mon, 7 Oct 2019 16:26:16 -0400 Received: from mail-qt1-f195.google.com ([209.85.160.195]:46792 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728212AbfJGU0Q (ORCPT ); Mon, 7 Oct 2019 16:26:16 -0400 Received: by mail-qt1-f195.google.com with SMTP id u22so21106697qtq.13 for ; Mon, 07 Oct 2019 13:26:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=pWqDYt+vsKqBj4PxqTG0GN9ZKUFhJilJefNqRSNOdXU=; b=lFU77jbRMdB5P5prl/yIcefMvA/BKJN464imlBTzowkoczv7oA5nt9hIMdGypVd8Um 6HloSXwgVR69HQItXvMp3ZRp/hnyOAJS/6zijRoTQT8Mw57u3nJzVgRbbvRrMa/OwYPJ Q30H+CUhpButQmtLFxpp7/RIi/gzfYtDP9AENQ1WBUO7sBMWw+U1yhBsxLHQDuFMmKPJ aSRVzmmptpWkwXiB24juUnkoazpNPVWgfRjDtzRc5Fh5YnWqlTXWGd4SDGU4IIkleR81 /2oa9QHT9gQhPIX/tWRhr33gFVo5iEfNJ3wcOpFk1rK4s69Loa2I4yXR1W6oQ5oj6VzY BU/Q== 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=pWqDYt+vsKqBj4PxqTG0GN9ZKUFhJilJefNqRSNOdXU=; b=gWTVwQrRYexH5nF6+NWCzBap/CpcNAA2HClBNMiRgqzEFUYFT2CH3XvBPVFbJi86XJ KX+khludk6KEeCdFDxQU3rroMbL/X1AP4KATRKA8PDGovSSmmBlh65a9Qt5dT8A7UR4g 3VGjDR/yZnsi6OPBmrcQjc57VRiJjkxw31AynGl+pZLzmB92KXLsmIj+BDHjzTCjMzDb UwEdUq17DjaHEJOjlt7B49/r+n5htJTHLH5FcMbsLxJZ0oh3BANq2jfXwCgRsKZujVu1 ihwIGVrNWC+Zhvt5p7TEpVz1ov8tGhh9qL7Mch45q1vBNpH82pwHMz74TunoTSJRbcDL qKjw== X-Gm-Message-State: APjAAAWlr6zNMUlqO6TLoVKSU1ZgUaLFKcC/xa2nDqjr6iWnp0vlp/YK C50djJ4Bt2+E4tIy0MpNetw45A== X-Google-Smtp-Source: APXvYqy5osbwcIi/xtU81gYnZB9XOGE9n7O25GBvz95v3GZfTQFA99gvOv6I9yyyCWl0zAKCW0ZMyg== X-Received: by 2002:ac8:7b97:: with SMTP id p23mr31790077qtu.292.1570479975301; Mon, 07 Oct 2019 13:26:15 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id q207sm8907940qke.98.2019.10.07.13.26.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Oct 2019 13:26:15 -0700 (PDT) Date: Mon, 7 Oct 2019 16:26:13 -0400 From: Josef Bacik To: Dennis Zhou Cc: David Sterba , Chris Mason , Josef Bacik , Omar Sandoval , kernel-team@fb.com, linux-btrfs@vger.kernel.org Subject: Re: [PATCH 01/19] bitmap: genericize percpu bitmap region iterators Message-ID: <20191007202612.mer74bok5ymyxae6@MacBook-Pro-91.local> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org On Mon, Oct 07, 2019 at 04:17:32PM -0400, Dennis Zhou wrote: > Bitmaps are fairly popular for their space efficiency, but we don't have > generic iterators available. Make percpu's bitmap region iterators > available to everyone. > > Signed-off-by: Dennis Zhou > --- > include/linux/bitmap.h | 35 ++++++++++++++++++++++++ > mm/percpu.c | 61 +++++++++++------------------------------- > 2 files changed, 51 insertions(+), 45 deletions(-) > > diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h > index 90528f12bdfa..9b0664f36808 100644 > --- a/include/linux/bitmap.h > +++ b/include/linux/bitmap.h > @@ -437,6 +437,41 @@ static inline int bitmap_parse(const char *buf, unsigned int buflen, > return __bitmap_parse(buf, buflen, 0, maskp, nmaskbits); > } > > +static inline void bitmap_next_clear_region(unsigned long *bitmap, > + unsigned int *rs, unsigned int *re, > + unsigned int end) > +{ > + *rs = find_next_zero_bit(bitmap, end, *rs); > + *re = find_next_bit(bitmap, end, *rs + 1); > +} > + > +static inline void bitmap_next_set_region(unsigned long *bitmap, > + unsigned int *rs, unsigned int *re, > + unsigned int end) > +{ > + *rs = find_next_bit(bitmap, end, *rs); > + *re = find_next_zero_bit(bitmap, end, *rs + 1); > +} > + > +/* > + * Bitmap region iterators. Iterates over the bitmap between [@start, @end). Gonna be that guy here, should be '[@start, @end]' Reviewed-by: Josef Bacik Thanks, Josef