From: Dan Williams <dan.j.williams@intel.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Keith Busch <keith.busch@intel.com>,
Vishal L Verma <vishal.l.verma@intel.com>,
X86 ML <x86@kernel.org>, Linux MM <linux-mm@kvack.org>,
linux-nvdimm <linux-nvdimm@lists.01.org>
Subject: Re: [RFC PATCH 2/5] lib/memregion: Uplevel the pmem "region" ida to a global allocator
Date: Thu, 4 Apr 2019 14:02:30 -0700 [thread overview]
Message-ID: <CAPcyv4hruLHWpEq_fT=_uFeO8X6KLjLsR2=s577iXey+NUFz4Q@mail.gmail.com> (raw)
In-Reply-To: <20190404193211.GK22763@bombadil.infradead.org>
On Thu, Apr 4, 2019 at 12:32 PM Matthew Wilcox <willy@infradead.org> wrote:
>
> On Thu, Apr 04, 2019 at 12:08:38PM -0700, Dan Williams wrote:
> > +++ b/lib/Kconfig
> > @@ -318,6 +318,12 @@ config DECOMPRESS_LZ4
> > config GENERIC_ALLOCATOR
> > bool
> >
> > +#
> > +# Generic IDA for memory regions
> > +#
>
> Leaky abstraction -- nobody needs know that it's implemented as an IDA.
> Suggest:
>
> # Memory region ID allocation
>
Looks good to me.
> ...
>
> > +++ b/lib/memregion.c
> > @@ -0,0 +1,22 @@
> > +#include <linux/idr.h>
> > +#include <linux/module.h>
> > +
> > +static DEFINE_IDA(region_ida);
> > +
> > +int memregion_alloc(void)
> > +{
> > + return ida_simple_get(®ion_ida, 0, 0, GFP_KERNEL);
> > +}
> > +EXPORT_SYMBOL(memregion_alloc);
> > +
> > +void memregion_free(int id)
> > +{
> > + ida_simple_remove(®ion_ida, id);
> > +}
> > +EXPORT_SYMBOL(memregion_free);
> > +
> > +static void __exit memregion_exit(void)
> > +{
> > + ida_destroy(®ion_ida);
> > +}
> > +module_exit(memregion_exit);
>
> - Should these be EXPORT_SYMBOL_GPL?
I don't see the need. These are simple wrappers around existing
EXPORT_SYMBOL() exports, and there's little concern that these
interfaces might disappear in the future causing us pain with out of
tree modules as these don't touch anything in the core.
> - Can we use the new interface, ida_alloc() and ida_free()?
Sure.
> - Do we really want memregion_exit() to happen while there are still IDs
> allocated in the IDA? I think this might well be better as:
>
> BUG_ON(!ida_empty(®ion_ida));
True, or just delete the module_exit because this functionality can't
be built as a module, so the exit path is already dead code.
> Also, do we really want to call the structure the region_ida? Why not
> region_ids?
Sure, sounds good.
next prev parent reply other threads:[~2019-04-04 21:02 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-04 19:08 [RFC PATCH 0/5] EFI Special Purpose Memory Support Dan Williams
2019-04-04 19:08 ` [RFC PATCH 1/5] efi: Detect UEFI 2.8 Special Purpose Memory Dan Williams
2019-04-06 4:21 ` Ard Biesheuvel
2019-04-09 16:43 ` Dan Williams
2019-04-09 17:21 ` Ard Biesheuvel
2019-04-10 2:10 ` Dan Williams
2019-04-12 20:43 ` Ard Biesheuvel
2019-04-12 21:18 ` Dan Williams
2019-04-15 11:43 ` Enrico Weigelt, metux IT consult
2019-04-04 19:08 ` [RFC PATCH 2/5] lib/memregion: Uplevel the pmem "region" ida to a global allocator Dan Williams
2019-04-04 19:32 ` Matthew Wilcox
2019-04-04 21:02 ` Dan Williams [this message]
2019-04-04 19:08 ` [RFC PATCH 3/5] acpi/hmat: Track target address ranges Dan Williams
2019-04-04 20:58 ` Keith Busch
2019-04-04 20:58 ` Dan Williams
2019-04-04 19:08 ` [RFC PATCH 4/5] acpi/hmat: Register special purpose memory as a device Dan Williams
2019-04-05 11:18 ` Jonathan Cameron
2019-04-05 15:43 ` Dan Williams
2019-04-05 16:23 ` Jonathan Cameron
2019-04-05 16:56 ` Dan Williams
2019-04-05 17:39 ` Jonathan Cameron
2019-04-09 12:13 ` Christoph Hellwig
2019-04-09 14:49 ` Dan Williams
2019-04-04 19:08 ` [RFC PATCH 5/5] device-dax: Add a driver for "hmem" devices Dan Williams
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='CAPcyv4hruLHWpEq_fT=_uFeO8X6KLjLsR2=s577iXey+NUFz4Q@mail.gmail.com' \
--to=dan.j.williams@intel.com \
--cc=keith.busch@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-nvdimm@lists.01.org \
--cc=vishal.l.verma@intel.com \
--cc=willy@infradead.org \
--cc=x86@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).