Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4430574imm; Mon, 18 Jun 2018 15:02:59 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ6uJQhl7UoG20EvvaoHJN0Lj74pEP0A/61u6xiBe3WxHQo5j/kfkhFMmDknha2VoiDaY+9 X-Received: by 2002:a63:6f89:: with SMTP id k131-v6mr12612642pgc.345.1529359379198; Mon, 18 Jun 2018 15:02:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529359379; cv=none; d=google.com; s=arc-20160816; b=FHR7MmhsucmCEshWHUuo82yOLsuNNoeeFjPS9gXbtvT6G8ZYmPyIwZE1GX93TGTnQT QYrhz62oiaXWdftzX5oNIZ5t0/2CbMAKNJBja/5cg+MFZYnGme0WGljx2jedFDx9k35N SqSTIdQ2Mpi1ps4vTItzE5Xsq1WT4Sujnc5xMowxSGql4MKeB4188hTCAqRVhwep/TGG 4HQsnnISTY9O4ByTg7W92VESh3G2YtlHYkvPxBfwR98mryzRO3YuzwvMnaTInRsnAyqj jfOtXDhnq3fo/IyVSEBDOY2FXqzwDXkpuk2cBY+742DOpgdWFvLFXiWswYw9GKFgDgMJ 5a9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=R/wQt4x5Mq6ZG/doggWKxS7cNxk9mtcKJx80Jx3+tyA=; b=0LAhzxS6anc1B7SbRtSyebVz9cQz7gWrhWVYh2StaxJdbP70TVBrXEnCTLpoM4a8sb NquYGBkmOHPc1I1QDt66RqqvMPyfDDdXVpYXdp0k5RqzIUdvt+E1bShiDLFqvanqhxRc xwMXizkT+vIlbIuMRE900ltkmXY3eBtfNJrcqctv2DRC/YgE5rFNlKVmDv+41TtjQJYF szi+xCpzmkc0c9C2LnDD3Szt1xyeCcFKxPvU7ivAWKVap06b3QRBr+OLWPCoDF+/JpL2 C9Urf3+pc1qh38Osz8SXMl0PI+cQ5e5Sgiy4FTxNeOJPD9ev0BV8O1TY19bUZLIFPiMt 9Fbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=utofY43n; 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 b23-v6si15263378pls.341.2018.06.18.15.02.44; Mon, 18 Jun 2018 15:02:59 -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=utofY43n; 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 S1755456AbeFRWB7 (ORCPT + 99 others); Mon, 18 Jun 2018 18:01:59 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:34187 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754256AbeFRWB5 (ORCPT ); Mon, 18 Jun 2018 18:01:57 -0400 Received: by mail-lf0-f66.google.com with SMTP id v84-v6so3838610lfa.1; Mon, 18 Jun 2018 15:01:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=R/wQt4x5Mq6ZG/doggWKxS7cNxk9mtcKJx80Jx3+tyA=; b=utofY43nC4dbg16Fm0kS9NEb5KjkJmATLTGuGlEeQ15mlEP5b/7o5rH7xundW0/WZa d3uT4s30RmoQ2lP6dLcBCAMGrun+hO+afOQ31378KyD8UrJ01h8RqVLIl7A0sI3giLqS rRJFOCEyW7rjvZcgXeOA78lq56331JE8zD+gcaJHOPXQZ4e50fYYcG5vh8Kmx2irwNDC bdOjZxFZ6f+yHO4Np6kAuOqVNXdDMClQSkAOOHHf8/0XqhCHhJo6F2c1mzku9NGLy5TG aF82CMcVOhNC6wl2jM9NCiTHCp5Fc/14KseC0RPegYewoGvG6GemiOGZHDTbc/zVnKAx HRfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=R/wQt4x5Mq6ZG/doggWKxS7cNxk9mtcKJx80Jx3+tyA=; b=bOgJltUPDxBy+rq/6R+TM750zfTAwhkYv0JrJvF6r+pygzdfpNV0NnC5LVlK5WssIe N9E+Dhnacszxln3nFoRCNcOY/M8IqdE9KGmgFtQlPXpzfL3binsUgS8OSqXj1rfqR6Dx B+6Cfwf8MeNj8m+F99sWdpzjjaZjow9Vi6hmCmY2s6n/c+nAUyc3az1xEF4sOTYxsbn9 zlU8bc8DPQy8AhTiUcfuEQfXwnVUk5aXmgMtPRZPcDJb6RaNfPUhNjpvW+bPM70euF7+ FTy0ji93GrJwwFq7sJz+MOIJ2pGpd+ZxaEev/nd9RImN4gWFTFYfJu4Gr/akN5iLCfzy Z5zA== X-Gm-Message-State: APt69E05NmwJ5ClSdz0undpYe8nuJyYYRzdLfmXRdHzuPoUR4xLMRPZV 8tuIKqtMnspoiezYMEUD+9nG4eiJpwcEcoDLGm4= X-Received: by 2002:a19:5a14:: with SMTP id o20-v6mr4622019lfb.105.1529359315304; Mon, 18 Jun 2018 15:01:55 -0700 (PDT) MIME-Version: 1.0 References: <20180618131003.88110-1-andriy.shevchenko@linux.intel.com> <20180618131003.88110-4-andriy.shevchenko@linux.intel.com> <20180618141404.68124daab97bd0f3a3051544@linux-foundation.org> In-Reply-To: <20180618141404.68124daab97bd0f3a3051544@linux-foundation.org> From: Dmitry Torokhov Date: Mon, 18 Jun 2018 15:01:43 -0700 Message-ID: Subject: Re: [PATCH v3 3/5] bitmap: Add bitmap_alloc(), bitmap_zalloc() and bitmap_free() To: Andrew Morton Cc: Andy Shevchenko , agk@redhat.com, Mike Snitzer , device-mapper development , shli@kernel.org, linux-raid@vger.kernel.org, "linux-input@vger.kernel.org" , ynorov@caviumnetworks.com, lkml , Mika Westerberg , Joe Perches Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 18, 2018 at 2:14 PM Andrew Morton wrote: > > 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. > We can't as we end up including bitmap.h (by the way of cpumask.h) form slab.h, so we gen circular dependency. Maybe if we removed memcg stuff from slab.h so we do not need to include workqueue.h... -- Dmitry