X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=linux_module%2Fbuddy.c;h=ed692c8ef4730851eb48192ca0d468362a3ba8de;hb=devel;hp=26a70212ba590e85aeea87a4fd27271a6c060af8;hpb=0b2115047303e779be8578e9802cfa55d1767c7b;p=palacios.git diff --git a/linux_module/buddy.c b/linux_module/buddy.c index 26a7021..ed692c8 100644 --- a/linux_module/buddy.c +++ b/linux_module/buddy.c @@ -285,13 +285,14 @@ int buddy_remove_pool(struct buddy_memzone * zone, * Arguments: * [IN] mp: Buddy system memory allocator object. * [IN] order: Block size to allocate (2^order bytes). - * [IN] constraints: bitmmask showing restrictions for scan. currently: 0=none, or LWK_BUDDY_CONSTRAINT_4GB + * [IN] filter_func: returns nonzero if given paddr is OK to use + * [IN] filter_state: opaque argument to filter_func * Returns: * Success: Pointer to the start of the allocated memory block. * Failure: NULL */ uintptr_t -buddy_alloc(struct buddy_memzone *zone, unsigned long order, int constraints) +buddy_alloc(struct buddy_memzone *zone, unsigned long order, int (*filter_func)(void *paddr, void *filter_state), void *filter_state) { unsigned long j; struct buddy_mempool * mp = NULL; @@ -301,11 +302,6 @@ buddy_alloc(struct buddy_memzone *zone, unsigned long order, int constraints) struct block * buddy_block = NULL; unsigned long flags = 0; - if (constraints && constraints!=LWK_BUDDY_CONSTRAINT_4GB) { - ERROR("Do not know how to satisfy constraint mask 0x%x\n", constraints); - return (uintptr_t) NULL; - } - BUG_ON(zone == NULL); BUG_ON(order > zone->max_order); @@ -333,23 +329,22 @@ buddy_alloc(struct buddy_memzone *zone, unsigned long order, int constraints) list_for_each(cur, list) { block = list_entry(cur, struct block, link); - if (!constraints) { - // without a constraint, we just want the first one + if (!filter_func) { + // without a filter, we just want the first one break; - } - - if (constraints & LWK_BUDDY_CONSTRAINT_4GB) { - // under this constraint, we will only use if the entirity - // of the allocation within the block will be below 4 GB + } else { + void *block_pa = (void*)__pa(block); - if ((block_pa + (1ULL<data); - return single_open(filp, zone_mem_show, proc_entry->data); + struct proc_dir_entry * proc_entry = PAL_PDE(inode); + INFO("proc_entry at %p, data at %p\n", proc_entry, PAL_PROC_GETDATA(inode)); + return single_open(filp, zone_mem_show, PAL_PROC_GETDATA(inode)); } @@ -618,7 +613,7 @@ void buddy_deinit(struct buddy_memzone * zone, int (*free_callback)(void *user_m char proc_file_name[128]; memset(proc_file_name, 0, 128); - snprintf(proc_file_name, 128, "v3-mem%d", zone->node_id); + snprintf(proc_file_name, 128, "v3-mem%u", zone->node_id); remove_proc_entry(proc_file_name, palacios_get_procdir()); } @@ -660,6 +655,8 @@ buddy_init( { struct buddy_memzone * zone = NULL; unsigned long i; + struct proc_dir_entry * zone_entry = NULL; + char proc_file_name[128]; DEBUG("Initializing Memory zone with up to %lu bit blocks on Node %d\n", max_order, node_id); @@ -710,23 +707,17 @@ buddy_init( INFO("Allocated zone at %p\n", zone); - { - struct proc_dir_entry * zone_entry = NULL; - char proc_file_name[128]; memset(proc_file_name, 0, 128); snprintf(proc_file_name, 128, "v3-mem%u", zone->node_id); - zone_entry = create_proc_entry(proc_file_name, 0444, palacios_get_procdir()); - if (zone_entry) { - zone_entry->proc_fops = &zone_proc_ops; - zone_entry->data = zone; + PAL_PROC_CREATE_DATA(zone_entry, proc_file_name, 0444, palacios_get_procdir(), &zone_proc_ops, zone); + if (zone_entry) { INFO("Successfully created /proc/v3vee/v3-mem%d\n", zone->node_id); } else { ERROR("Cannot create /proc/v3vee/v3-mem%d\n", zone->node_id); } - } return zone; }