All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yury Norov <yury.norov@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Brendan Higgins <brendan.higgins@linux.dev>,
	David Gow <davidgow@google.com>,
	Hans de Goede <hdegoede@redhat.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	James Seo <james@equiv.tech>, Jason Baron <jbaron@akamai.com>,
	Kees Cook <keescook@chromium.org>,
	Kefeng Wang <wangkefeng.wang@huawei.com>,
	Marco Elver <elver@google.com>, Mark Brown <broonie@kernel.org>,
	Ming Lei <ming.lei@redhat.com>,
	Petr Tesarik <petr.tesarik.ext@huawei.com>,
	Rae Moar <rmoar@google.com>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH 1/2] lib/bitmap: move bitmap allocators for device to linux/device.h
Date: Sun, 8 Oct 2023 08:39:13 -0700	[thread overview]
Message-ID: <ZSLNIZxCacxioX95@yury-ThinkPad> (raw)
In-Reply-To: <2023100855-railroad-wrecking-25af@gregkh>

On Sun, Oct 08, 2023 at 06:53:49AM +0200, Greg Kroah-Hartman wrote:
> On Sat, Oct 07, 2023 at 04:35:09PM -0700, Yury Norov wrote:
> > The allocators are simple wrappers around bitmap_{alloc,free}().
> > So move them from bitmap to device sources.
> 
> No, they belong in the bitmap.h file, as they are devm_* versions of the
> same functions in this file.  They don't belong in the device.h file.

OK then. I don't thing that the functions are anything wrong, and
don't want to 'get rid of them' in any way.

But could you please elaborate? I'm not too familiar to devm_* things,
and to me devm_alloc/free() look similar to e.g.
vfio_dma_bitmap_alloc_all() or iova_bitmap_alloc(), which allocate
memory for bitmap + do some other initialization things.

And they all reside in corresponding subsystems. Why devm differs? 
 
> > Similarly to other device wrappers, turn them to static inlines
> > and place in header.
> 
> Why do these need to be inline functions?

Because they are small. devm_bitmap_free() and devm_bitmap_zalloc()
are pure one-line wrappers, and devm_bimap_alloc() is a 2 function
calls followed by conditionals, which is similar  to
__devm_add_action_or_reset() or devm_kmalloc_array() in the same file,
and much less than some other inliners in the source tree.

In my plans, I want to move bitmap_{z,}alloc/free() to linux/bitmap.h,
and that way devm_bitmap_alloc() together with other users would be
propagated __kmalloc_array() by compiler without generating pretty
useless call/ret's, and benefit from compile-time optimizations if
__builtin_constant_p() hits.

Maybe it's worth to do in this series.

Thanks,
Yury

  reply	other threads:[~2023-10-08 15:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-07 23:35 [PATCH 0/2] lib: unload lib/bitmap.c Yury Norov
2023-10-07 23:35 ` [PATCH 1/2] lib/bitmap: move bitmap allocators for device to linux/device.h Yury Norov
2023-10-08  4:53   ` Greg Kroah-Hartman
2023-10-08 15:39     ` Yury Norov [this message]
2023-10-08 16:31       ` Greg Kroah-Hartman
2023-10-07 23:35 ` [PATCH 2/2] lib/bitmap: split-out string-related operations to a separate files Yury Norov
2023-10-15  2:32 ` [PATCH 0/2] lib: unload lib/bitmap.c Yury Norov
2023-10-16 18:38   ` Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZSLNIZxCacxioX95@yury-ThinkPad \
    --to=yury.norov@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=brendan.higgins@linux.dev \
    --cc=broonie@kernel.org \
    --cc=davidgow@google.com \
    --cc=elver@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hdegoede@redhat.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=james@equiv.tech \
    --cc=jbaron@akamai.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=ming.lei@redhat.com \
    --cc=petr.tesarik.ext@huawei.com \
    --cc=rafael@kernel.org \
    --cc=rmoar@google.com \
    --cc=tglx@linutronix.de \
    --cc=wangkefeng.wang@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.