lib: Uplevel the pmem "region" ida to a global allocator
In preparation for handling platform differentiated memory types beyond persistent memory, uplevel the "region" identifier to a global number space. This enables a device-dax instance to be registered to any memory type with guaranteed unique names. Signed-off-by: Dan Williams <dan.j.williams@intel.com> Acked-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
committed by
Rafael J. Wysocki
parent
199c847176
commit
33dd70752c
18
lib/memregion.c
Normal file
18
lib/memregion.c
Normal file
@@ -0,0 +1,18 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/* identifiers for device / performance-differentiated memory regions */
|
||||
#include <linux/idr.h>
|
||||
#include <linux/types.h>
|
||||
|
||||
static DEFINE_IDA(memregion_ids);
|
||||
|
||||
int memregion_alloc(gfp_t gfp)
|
||||
{
|
||||
return ida_alloc(&memregion_ids, gfp);
|
||||
}
|
||||
EXPORT_SYMBOL(memregion_alloc);
|
||||
|
||||
void memregion_free(int id)
|
||||
{
|
||||
ida_free(&memregion_ids, id);
|
||||
}
|
||||
EXPORT_SYMBOL(memregion_free);
|
||||
Reference in New Issue
Block a user