Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4470798imm; Mon, 18 Jun 2018 15:53:07 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLD0797jPe+qKdbHoY5g+EvVgOhc+kieziqRqF0t1vNb8erIjqqhQ/LLYG6xWqGNsbxsL6q X-Received: by 2002:a17:902:9a8a:: with SMTP id w10-v6mr16033321plp.333.1529362387915; Mon, 18 Jun 2018 15:53:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529362387; cv=none; d=google.com; s=arc-20160816; b=IN1DRLsUzKGZMfTn1/ri4gDChht0k0ef9yzuJ+pDSpcCh1iYomVkot9ajqdgbl/tcu WKb0ilNCJXjbM+wW9acebTdMlnBqz19aTJV9s38LyciRs/2ygnFd/PPiN7jY4yQUJb4N i0Jxq25UaV+AR4dXf4W2zdKVz++mnLo8EgIqlGA5jih0ocHk9RZiwLgD/fIVZytAwt8Q GT+ieNBInagh2Q7ES++HiL2ryOX6+493OuFGTkj6Z/Sxbf2hrvhueYZO6dGZESrTI/uf adJ1vdrQehV7PdHQL4zNFljvgHOwVg3YbRw4hqk9hMyBEqRkx7w9FtWv4IbCc2Wmaxxq DeTA== 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 :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=DUh/BdUCoOISWT8eUOYXHilFbNBpolZpltroZB1lHPA=; b=lknppFsrx1bFthlcD1gg47H7VwWq9DUReCExMrWGakhyNBs1PKmhwrEsSlfqrwa0sg O/l2wmBzFjreyuatkiJZJPDh0eAhTO6WC5bbDCK0+xd+iZnBfbKOXnylMwgffhcmnWmw lPh4QxG8iNVJZTpeFdyiEx6QFvZk9WGE4wBXrLtBbmfA1PCYD0ulMZsWqYf0BLzlO1NV OxI2QoHPug2NOXUXHyDth0HS8PlM6J28EBtvQgO2cHbvogFKGzJYkFZqL6RWea50A/io lymhzoZEyM12ZsfUAUQ/1YhyI0D0si4DNK+JYir1nMI0zBSf7+CPe0OaW3F7yOaFfOwL dG7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=EOnYYSgj; 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 v12-v6si15669582plo.264.2018.06.18.15.52.53; Mon, 18 Jun 2018 15:53:07 -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=EOnYYSgj; 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 S1755418AbeFRWwR (ORCPT + 99 others); Mon, 18 Jun 2018 18:52:17 -0400 Received: from mail-vk0-f68.google.com ([209.85.213.68]:39077 "EHLO mail-vk0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755329AbeFRWwP (ORCPT ); Mon, 18 Jun 2018 18:52:15 -0400 Received: by mail-vk0-f68.google.com with SMTP id r83-v6so10570223vkf.6; Mon, 18 Jun 2018 15:52:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=DUh/BdUCoOISWT8eUOYXHilFbNBpolZpltroZB1lHPA=; b=EOnYYSgjOmYfxpIlbr/UpILzEobhKDRO2X6WRU26DmZoTj5hYwgP66yu1eW2GyW9W/ Uu5BuEPQZ0L/4LzgTtf7ib+cWeBlC+Lp+upqRf2YjKxcwSpuxC/pNdoZuun4IPJjlCF1 iCPn/uwQeM0KVIWr3NEorIkStTXKIWbmkV5w0XnWpiDTuNAz5vNBo6d3FdlOqR52q37w C7hOkhEs5tHB7DJionOHzsNgjKJDysaZj+Azaq8cmE9wxMBRMsMueTk/zggSgAZkDQ++ rR8QLXYFGZykiu/BnS8Qroo52VvrhdNfDshgvA8H2KTehBerZ3VfDMe3z4Dq3kOWpCGe igZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=DUh/BdUCoOISWT8eUOYXHilFbNBpolZpltroZB1lHPA=; b=In8kQb17s8yKu+N3ZkUfG91mpIl6JwKV2csKPvV7+aR2ZnM/DODEIonXzRvrrZGhTC xU92V+++GVtFigGi+7GQdTmntblMGYIpdSorMfPBnttzr5ibii6y58nkgO0XHCVqBKQ/ rd8iuEfnRdVkPdGgUg8XfnmWDiggO/vzSmhWxzHUtwHbt/7Uaf3OWgT3NAHxWL+7Q8yL MKGT/23sv8nhlxrVSYu0C7gHH5CLU9tvZm5E0kSm+Y0QEhYOn48luE6ZwqJ6W9X3Qwit /n2DS4YS3XU8GsioJ/4atJrCOFPATE+Kr2msZgwOllShD1l5L9bDh3gKJ62KCU/wzvxO DY1A== X-Gm-Message-State: APt69E1ow/oiMGOMCB9HisIot4IpcRHt2V2/8BuA8xC2MdbXrvfm5H2S UkYrStGaX5tmJDLy5fh8lowf7RTivEJs80rp/5U= X-Received: by 2002:a1f:d1c5:: with SMTP id i188-v6mr8413950vkg.131.1529362334309; Mon, 18 Jun 2018 15:52:14 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a67:8b02:0:0:0:0:0 with HTTP; Mon, 18 Jun 2018 15:52:13 -0700 (PDT) In-Reply-To: References: <20180618131003.88110-1-andriy.shevchenko@linux.intel.com> <20180618131003.88110-4-andriy.shevchenko@linux.intel.com> <20180618141404.68124daab97bd0f3a3051544@linux-foundation.org> From: Andy Shevchenko Date: Tue, 19 Jun 2018 01:52:13 +0300 Message-ID: Subject: Re: [PATCH v3 3/5] bitmap: Add bitmap_alloc(), bitmap_zalloc() and bitmap_free() To: Dmitry Torokhov Cc: Andrew Morton , Andy Shevchenko , agk@redhat.com, Mike Snitzer , device-mapper development , shli@kernel.org, linux-raid@vger.kernel.org, "linux-input@vger.kernel.org" , Yury Norov , 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 Tue, Jun 19, 2018 at 1:01 AM, Dmitry Torokhov wrote: > 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... I will look at it. It might be doable. Though I dunno what MM people would say about this. Anyone's name comes to your mind to ask? -- With Best Regards, Andy Shevchenko