ihk_mc_ap_flag: rewrite flag type, intro for denoting user level allocations
This commit is contained in:
@ -179,7 +179,7 @@ static void init_normal_area(struct page_table *pt)
|
||||
}
|
||||
}
|
||||
|
||||
static struct page_table *__alloc_new_pt(enum ihk_mc_ap_flag ap_flag)
|
||||
static struct page_table *__alloc_new_pt(ihk_mc_ap_flag ap_flag)
|
||||
{
|
||||
struct page_table *newpt = ihk_mc_alloc_pages(1, ap_flag);
|
||||
|
||||
@ -278,7 +278,7 @@ void set_pte(pte_t *ppte, unsigned long phys, enum ihk_mc_pt_attribute attr)
|
||||
* and returns a pointer to the PTE corresponding to the
|
||||
* virtual address.
|
||||
*/
|
||||
pte_t *get_pte(struct page_table *pt, void *virt, enum ihk_mc_pt_attribute attr, enum ihk_mc_ap_flag ap_flag)
|
||||
pte_t *get_pte(struct page_table *pt, void *virt, enum ihk_mc_pt_attribute attr, ihk_mc_ap_flag ap_flag)
|
||||
{
|
||||
int l4idx, l3idx, l2idx, l1idx;
|
||||
unsigned long v = (unsigned long)virt;
|
||||
@ -339,7 +339,7 @@ static int __set_pt_page(struct page_table *pt, void *virt, unsigned long phys,
|
||||
int l4idx, l3idx, l2idx, l1idx;
|
||||
unsigned long v = (unsigned long)virt;
|
||||
struct page_table *newpt;
|
||||
enum ihk_mc_ap_flag ap_flag;
|
||||
ihk_mc_ap_flag ap_flag;
|
||||
int in_kernel =
|
||||
(((unsigned long long)virt) >= 0xffff000000000000ULL);
|
||||
unsigned long init_pt_lock_flags;
|
||||
@ -664,7 +664,7 @@ int ihk_mc_pt_prepare_map(page_table_t p, void *virt, unsigned long size,
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct page_table *ihk_mc_pt_create(enum ihk_mc_ap_flag ap_flag)
|
||||
struct page_table *ihk_mc_pt_create(ihk_mc_ap_flag ap_flag)
|
||||
{
|
||||
struct page_table *pt = ihk_mc_alloc_pages(1, ap_flag);
|
||||
|
||||
|
||||
@ -28,9 +28,9 @@ r;\
|
||||
})
|
||||
#define kfree(ptr) _kfree(ptr, __FILE__, __LINE__)
|
||||
#define memcheck(ptr, msg) _memcheck(ptr, msg, __FILE__, __LINE__, 0)
|
||||
void *_kmalloc(int size, enum ihk_mc_ap_flag flag, char *file, int line);
|
||||
void *_kmalloc(int size, ihk_mc_ap_flag flag, char *file, int line);
|
||||
void _kfree(void *ptr, char *file, int line);
|
||||
void *__kmalloc(int size, enum ihk_mc_ap_flag flag);
|
||||
void *__kmalloc(int size, ihk_mc_ap_flag flag);
|
||||
void __kfree(void *ptr);
|
||||
|
||||
int _memcheck(void *ptr, char *msg, char *file, int line, int free);
|
||||
|
||||
20
kernel/mem.c
20
kernel/mem.c
@ -65,12 +65,12 @@ extern void early_alloc_invalidate(void);
|
||||
|
||||
static char *memdebug = NULL;
|
||||
|
||||
static void *___kmalloc(int size, enum ihk_mc_ap_flag flag);
|
||||
static void *___kmalloc(int size, ihk_mc_ap_flag flag);
|
||||
static void ___kfree(void *ptr);
|
||||
|
||||
static void *___ihk_mc_alloc_aligned_pages_node(int npages,
|
||||
int p2align, enum ihk_mc_ap_flag flag, int node);
|
||||
static void *___ihk_mc_alloc_pages(int npages, enum ihk_mc_ap_flag flag);
|
||||
int p2align, ihk_mc_ap_flag flag, int node);
|
||||
static void *___ihk_mc_alloc_pages(int npages, ihk_mc_ap_flag flag);
|
||||
static void ___ihk_mc_free_pages(void *p, int npages);
|
||||
|
||||
/*
|
||||
@ -152,7 +152,7 @@ struct pagealloc_track_entry *__pagealloc_track_find_entry(
|
||||
|
||||
/* Top level routines called from macros */
|
||||
void *_ihk_mc_alloc_aligned_pages_node(int npages, int p2align,
|
||||
enum ihk_mc_ap_flag flag, int node, char *file, int line)
|
||||
ihk_mc_ap_flag flag, int node, char *file, int line)
|
||||
{
|
||||
unsigned long irqflags;
|
||||
struct pagealloc_track_entry *entry;
|
||||
@ -445,7 +445,7 @@ void pagealloc_memcheck(void)
|
||||
|
||||
/* Actual allocation routines */
|
||||
static void *___ihk_mc_alloc_aligned_pages_node(int npages, int p2align,
|
||||
enum ihk_mc_ap_flag flag, int node)
|
||||
ihk_mc_ap_flag flag, int node)
|
||||
{
|
||||
if (pa_ops)
|
||||
return pa_ops->alloc_page(npages, p2align, flag, node);
|
||||
@ -453,7 +453,7 @@ static void *___ihk_mc_alloc_aligned_pages_node(int npages, int p2align,
|
||||
return early_alloc_pages(npages);
|
||||
}
|
||||
|
||||
static void *___ihk_mc_alloc_pages(int npages, enum ihk_mc_ap_flag flag)
|
||||
static void *___ihk_mc_alloc_pages(int npages, ihk_mc_ap_flag flag)
|
||||
{
|
||||
return ___ihk_mc_alloc_aligned_pages_node(npages, PAGE_P2ALIGN, flag, -1);
|
||||
}
|
||||
@ -491,7 +491,7 @@ static void reserve_pages(struct ihk_page_allocator_desc *pa_allocator,
|
||||
|
||||
extern int cpu_local_var_initialized;
|
||||
static void *mckernel_allocate_aligned_pages_node(int npages, int p2align,
|
||||
enum ihk_mc_ap_flag flag, int pref_node)
|
||||
ihk_mc_ap_flag flag, int pref_node)
|
||||
{
|
||||
unsigned long pa = 0;
|
||||
int i, node;
|
||||
@ -1463,7 +1463,7 @@ struct kmalloc_track_entry *__kmalloc_track_find_entry(
|
||||
}
|
||||
|
||||
/* Top level routines called from macro */
|
||||
void *_kmalloc(int size, enum ihk_mc_ap_flag flag, char *file, int line)
|
||||
void *_kmalloc(int size, ihk_mc_ap_flag flag, char *file, int line)
|
||||
{
|
||||
unsigned long irqflags;
|
||||
struct kmalloc_track_entry *entry;
|
||||
@ -1653,7 +1653,7 @@ void kmalloc_memcheck(void)
|
||||
}
|
||||
|
||||
/* Redirection routines registered in alloc structure */
|
||||
void *__kmalloc(int size, enum ihk_mc_ap_flag flag)
|
||||
void *__kmalloc(int size, ihk_mc_ap_flag flag)
|
||||
{
|
||||
return kmalloc(size, flag);
|
||||
}
|
||||
@ -1751,7 +1751,7 @@ void kmalloc_consolidate_free_list(void)
|
||||
#define KMALLOC_MIN_MASK (KMALLOC_MIN_SIZE - 1)
|
||||
|
||||
/* Actual low-level allocation routines */
|
||||
static void *___kmalloc(int size, enum ihk_mc_ap_flag flag)
|
||||
static void *___kmalloc(int size, ihk_mc_ap_flag flag)
|
||||
{
|
||||
struct kmalloc_header *chunk_iter;
|
||||
struct kmalloc_header *chunk = NULL;
|
||||
|
||||
@ -40,12 +40,17 @@ enum ihk_mc_ma_type {
|
||||
IHK_MC_MA_SPECIAL,
|
||||
};
|
||||
|
||||
enum ihk_mc_ap_flag {
|
||||
IHK_MC_AP_FLAG,
|
||||
IHK_MC_AP_CRITICAL, /* panic on no memory space */
|
||||
IHK_MC_AP_NOWAIT, /* error return on no memory space */
|
||||
IHK_MC_AP_WAIT /* wait on no memory space */
|
||||
};
|
||||
typedef unsigned long ihk_mc_ap_flag;
|
||||
/* Panic on no memory space */
|
||||
#define IHK_MC_AP_CRITICAL 0x000001
|
||||
/* Error return on no memory space */
|
||||
#define IHK_MC_AP_NOWAIT 0x000002
|
||||
/* Wait on no memory space */
|
||||
#define IHK_MC_AP_WAIT 0x000004
|
||||
#define IHK_MC_AP_USER 0x001000
|
||||
|
||||
#define IHK_MC_AP_BANDWIDTH 0x010000
|
||||
#define IHK_MC_AP_LATENCY 0x020000
|
||||
|
||||
enum ihk_mc_pt_prepare_flag {
|
||||
IHK_MC_PT_FIRST_LEVEL,
|
||||
@ -79,10 +84,10 @@ void ihk_mc_reserve_arch_pages(struct ihk_page_allocator_desc *pa_allocator,
|
||||
unsigned long, unsigned long, int));
|
||||
|
||||
struct ihk_mc_pa_ops {
|
||||
void *(*alloc_page)(int, int, enum ihk_mc_ap_flag, int node);
|
||||
void *(*alloc_page)(int, int, ihk_mc_ap_flag, int node);
|
||||
void (*free_page)(void *, int);
|
||||
|
||||
void *(*alloc)(int, enum ihk_mc_ap_flag);
|
||||
void *(*alloc)(int, ihk_mc_ap_flag);
|
||||
void (*free)(void *);
|
||||
};
|
||||
|
||||
@ -104,7 +109,7 @@ int ihk_mc_free_micpa(unsigned long mic_pa);
|
||||
void ihk_mc_clean_micpa(void);
|
||||
|
||||
void *_ihk_mc_alloc_aligned_pages_node(int npages, int p2align,
|
||||
enum ihk_mc_ap_flag flag, int node, char *file, int line);
|
||||
ihk_mc_ap_flag flag, int node, char *file, int line);
|
||||
#define ihk_mc_alloc_aligned_pages_node(npages, p2align, flag, node) ({\
|
||||
void *r = _ihk_mc_alloc_aligned_pages_node(npages, p2align, flag, node, __FILE__, __LINE__);\
|
||||
r;\
|
||||
@ -163,7 +168,7 @@ int visit_pte_range(page_table_t pt, void *start, void *end, int pgshift,
|
||||
int move_pte_range(page_table_t pt, struct process_vm *vm,
|
||||
void *src, void *dest, size_t size);
|
||||
|
||||
struct page_table *ihk_mc_pt_create(enum ihk_mc_ap_flag ap_flag);
|
||||
struct page_table *ihk_mc_pt_create(ihk_mc_ap_flag ap_flag);
|
||||
/* XXX: proper use of struct page_table and page_table_t is unknown */
|
||||
void ihk_mc_pt_destroy(struct page_table *pt);
|
||||
void ihk_mc_load_page_table(struct page_table *pt);
|
||||
|
||||
Reference in New Issue
Block a user