Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4393283imm; Mon, 18 Jun 2018 14:16:31 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLqQXeCFlibu2U66zVzhrAcWocZD+/Ftk+FxPuTFpojdsIoueAX+BeghPJS3eH512UcDnRq X-Received: by 2002:a17:902:6bca:: with SMTP id m10-v6mr15885008plt.6.1529356591172; Mon, 18 Jun 2018 14:16:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529356591; cv=none; d=google.com; s=arc-20160816; b=IAPEf4fmXc4AZrk78v6vSyg85tlzBXdRIvG3xsAch3KXn2xZgNrxwtm1ifgKZEVOgP +31LebSZ8rHVtQOb5E4uWB4ltT9vFY4M1uxS3BNCYzbkjDmZQC3Y5Uo5B65/MCrUNxVy nXYh5L74KJxJpOW4w/mJYs6xuDo9ZYhZUAZn9is9A2vrkJdT4f1gNQcaGTvi95/KzogB pZmEBjBVXfUd4ywSm4cz+5lIsud8FBRHTyso6pR8oh/+w+19SaMpK5kVSCvfzgFbnpwt A/TxpfrlxDTHOXhDWq4ygIKtyDme4MwSX856uuJjm2RBZStFeRd2kE8BMVtUze7Tvtns S8/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=qhz2kFcscZDirNu25F1LDwFRlKvab6bP/6hWGHRlpWk=; b=Z8R1Iis84G8LulRJeybSRyGe7djqZchxr7Z3xV7ML19cX461HG4uy6UnT+EYTw7fv7 r/wG4APMk3opt/a+W5SfYQ4MHfT2IjhPLUE6M9T8o41pUTIjjybqAX4p/DSi3I/37pU4 aAiNXsMXGubILcVF4RSUFiWWLp0UnS/TS4l+6gLcx5AODoqIB77TDbFPaC7HWToWfgIK CBgEEpSOqfEYxlTmSIa7hiMaP6BMo5bGKY3HGuotB7G8uIHhAjS+ilM/4EHVniHiA21V R5dwgl8hyLd48jZ5MGE/LkC463auCKZfzPgEObeheod6isWAhZWnmkRFp7+jmcXsy6VO ge1w== ARC-Authentication-Results: i=1; mx.google.com; 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 m12-v6si15378567pfd.348.2018.06.18.14.16.16; Mon, 18 Jun 2018 14:16:31 -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; 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 S936973AbeFRVOH (ORCPT + 99 others); Mon, 18 Jun 2018 17:14:07 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:48522 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936896AbeFRVOF (ORCPT ); Mon, 18 Jun 2018 17:14:05 -0400 Received: from akpm3.svl.corp.google.com (unknown [104.133.9.92]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 0F7BAD13; Mon, 18 Jun 2018 21:14:05 +0000 (UTC) Date: Mon, 18 Jun 2018 14:14:04 -0700 From: Andrew Morton To: Andy Shevchenko Cc: Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, Shaohua Li , linux-raid@vger.kernel.org, Dmitry Torokhov , linux-input@vger.kernel.org, Yury Norov , linux-kernel@vger.kernel.org, mika.westerberg@linux.intel.com, Joe Perches Subject: Re: [PATCH v3 3/5] bitmap: Add bitmap_alloc(), bitmap_zalloc() and bitmap_free() Message-Id: <20180618141404.68124daab97bd0f3a3051544@linux-foundation.org> In-Reply-To: <20180618131003.88110-4-andriy.shevchenko@linux.intel.com> References: <20180618131003.88110-1-andriy.shevchenko@linux.intel.com> <20180618131003.88110-4-andriy.shevchenko@linux.intel.com> X-Mailer: Sylpheed 3.6.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 18 Jun 2018 16:10:01 +0300 Andy Shevchenko wrote: > A lot of code become ugly because of open coding allocations for bitmaps. > > Introduce three helpers to allow users be more clear of intention > and keep their code neat. > > ... > > +unsigned long *bitmap_alloc(unsigned int nbits, gfp_t flags) > +{ > + return kmalloc_array(BITS_TO_LONGS(nbits), sizeof(unsigned long), flags); > +} > +EXPORT_SYMBOL(bitmap_alloc); > + > +unsigned long *bitmap_zalloc(unsigned int nbits, gfp_t flags) > +{ > + return bitmap_alloc(nbits, flags | __GFP_ZERO); > +} > +EXPORT_SYMBOL(bitmap_zalloc); > + > +void bitmap_free(const unsigned long *bitmap) > +{ > + kfree(bitmap); > +} > +EXPORT_SYMBOL(bitmap_free); > + I suggest these functions are small and simple enough to justify inlining them.