@@ -11,8 +11,13 @@
#include <stdbool.h>
#include <asm/memory_areas.h>
-#define AREA_ANY -1
-#define AREA_ANY_NUMBER 0xff
+#define AREA_ANY_NUMBER 0xff
+
+#define AREA_ANY 0x00000
+#define AREA_MASK 0x0ffff
+
+#define FLAG_ZERO 0x10000
+#define FLAG_FRESH 0x20000
/* Returns true if the page allocator has been initialized */
bool page_alloc_initialized(void);
@@ -34,22 +39,22 @@ void page_alloc_ops_enable(void);
* areas is a bitmap of allowed areas
* alignment must be a power of 2
*/
-void *memalign_pages_area(unsigned int areas, size_t alignment, size_t size);
+void *memalign_pages_flags(size_t alignment, size_t size, unsigned int flags);
/*
* Allocate aligned memory from any area.
- * Equivalent to memalign_pages_area(AREA_ANY, alignment, size).
+ * Equivalent to memalign_pages_flags(alignment, size, AREA_ANY).
*/
static inline void *memalign_pages(size_t alignment, size_t size)
{
- return memalign_pages_area(AREA_ANY, alignment, size);
+ return memalign_pages_flags(alignment, size, AREA_ANY);
}
/*
* Allocate naturally aligned memory from the specified areas.
- * Equivalent to memalign_pages_area(areas, 1ull << order, 1ull << order).
+ * Equivalent to memalign_pages_flags(1ull << order, 1ull << order, flags).
*/
-void *alloc_pages_area(unsigned int areas, unsigned int order);
+void *alloc_pages_flags(unsigned int order, unsigned int flags);
/*
* Allocate naturally aligned memory from any area.
@@ -57,7 +62,7 @@ void *alloc_pages_area(unsigned int areas, unsigned int order);
*/
static inline void *alloc_pages(unsigned int order)
{
- return alloc_pages_area(AREA_ANY, order);
+ return alloc_pages_flags(order, AREA_ANY);
}
/*
@@ -361,13 +361,13 @@ void free_pages_special(phys_addr_t addr, size_t n)
spin_unlock(&lock);
}
-static void *page_memalign_order_area(unsigned area, u8 ord, u8 al)
+static void *page_memalign_order_flags(u8 ord, u8 al, u32 flags)
{
void *res = NULL;
- int i;
+ int i, area;
spin_lock(&lock);
- area &= areas_mask;
+ area = (flags & AREA_MASK) ? flags & areas_mask : areas_mask;
for (i = 0; !res && (i < MAX_AREAS); i++)
if (area & BIT(i))
res = page_memalign_order(areas + i, ord, al);
@@ -379,23 +379,23 @@ static void *page_memalign_order_area(unsigned area, u8 ord, u8 al)
* Allocates (1 << order) physically contiguous and naturally aligned pages.
* Returns NULL if the allocation was not possible.
*/
-void *alloc_pages_area(unsigned int area, unsigned int order)
+void *alloc_pages_flags(unsigned int order, unsigned int flags)
{
- return page_memalign_order_area(area, order, order);
+ return page_memalign_order_flags(order, order, flags);
}
/*
* Allocates (1 << order) physically contiguous aligned pages.
* Returns NULL if the allocation was not possible.
*/
-void *memalign_pages_area(unsigned int area, size_t alignment, size_t size)
+void *memalign_pages_flags(size_t alignment, size_t size, unsigned int flags)
{
assert(is_power_of_2(alignment));
alignment = get_order(PAGE_ALIGN(alignment) >> PAGE_SHIFT);
size = get_order(PAGE_ALIGN(size) >> PAGE_SHIFT);
assert(alignment < NLISTS);
assert(size < NLISTS);
- return page_memalign_order_area(area, size, alignment);
+ return page_memalign_order_flags(size, alignment, flags);
}
@@ -190,7 +190,7 @@ int smp_cpu_setup(uint16_t addr, struct psw psw)
sigp_retry(cpu->addr, SIGP_INITIAL_CPU_RESET, 0, NULL);
- lc = alloc_pages_area(AREA_DMA31, 1);
+ lc = alloc_pages_flags(1, AREA_DMA31);
cpu->lowcore = lc;
memset(lc, 0, PAGE_SIZE * 2);
sigp_retry(cpu->addr, SIGP_SET_PREFIX, (unsigned long )lc, NULL);
Replace the areas parameter with a more generic flags parameter. This allows for up to 16 allocation areas and 16 allocation flags. This patch introduces the flags and changes the names of the funcions, subsequent patches will actually wire up the flags to do something. The first two flags introduced are: FLAG_ZERO to ask the allocated memory to be zeroed FLAG_FRESH to indicate that the allocated memory should have not been touched (READ or written to) in any way since boot. Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com> --- lib/alloc_page.h | 21 +++++++++++++-------- lib/alloc_page.c | 14 +++++++------- lib/s390x/smp.c | 2 +- 3 files changed, 21 insertions(+), 16 deletions(-)