Lines Matching refs:glob
46 struct ttm_mem_global *glob; member
94 spin_lock(&zone->glob->lock); in ttm_mem_zone_show()
105 spin_unlock(&zone->glob->lock); in ttm_mem_zone_show()
111 static void ttm_check_swapping(struct ttm_mem_global *glob);
131 spin_lock(&zone->glob->lock); in ttm_mem_zone_store()
144 spin_unlock(&zone->glob->lock); in ttm_mem_zone_store()
146 ttm_check_swapping(zone->glob); in ttm_mem_zone_store()
180 struct ttm_mem_global *glob = in ttm_mem_global_show() local
184 spin_lock(&glob->lock); in ttm_mem_global_show()
185 val = glob->lower_mem_limit; in ttm_mem_global_show()
186 spin_unlock(&glob->lock); in ttm_mem_global_show()
201 struct ttm_mem_global *glob = in ttm_mem_global_store() local
212 spin_lock(&glob->lock); in ttm_mem_global_store()
213 glob->lower_mem_limit = val64; in ttm_mem_global_store()
214 spin_unlock(&glob->lock); in ttm_mem_global_store()
221 struct ttm_mem_global *glob = in ttm_mem_global_kobj_release() local
224 kfree(glob); in ttm_mem_global_kobj_release()
243 static bool ttm_zones_above_swap_target(struct ttm_mem_global *glob, in ttm_zones_above_swap_target() argument
250 for (i = 0; i < glob->num_zones; ++i) { in ttm_zones_above_swap_target()
251 zone = glob->zones[i]; in ttm_zones_above_swap_target()
275 static void ttm_shrink(struct ttm_mem_global *glob, bool from_wq, in ttm_shrink() argument
280 spin_lock(&glob->lock); in ttm_shrink()
282 while (ttm_zones_above_swap_target(glob, from_wq, extra)) { in ttm_shrink()
283 spin_unlock(&glob->lock); in ttm_shrink()
284 ret = ttm_bo_swapout(glob->bo_glob, ctx); in ttm_shrink()
285 spin_lock(&glob->lock); in ttm_shrink()
290 spin_unlock(&glob->lock); in ttm_shrink()
299 struct ttm_mem_global *glob = in ttm_shrink_work() local
302 ttm_shrink(glob, true, 0ULL, &ctx); in ttm_shrink_work()
305 static int ttm_mem_init_kernel_zone(struct ttm_mem_global *glob, in ttm_mem_init_kernel_zone() argument
324 zone->glob = glob; in ttm_mem_init_kernel_zone()
325 glob->zone_kernel = zone; in ttm_mem_init_kernel_zone()
327 &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name); in ttm_mem_init_kernel_zone()
332 glob->zones[glob->num_zones++] = zone; in ttm_mem_init_kernel_zone()
337 static int ttm_mem_init_highmem_zone(struct ttm_mem_global *glob, in ttm_mem_init_highmem_zone() argument
360 zone->glob = glob; in ttm_mem_init_highmem_zone()
361 glob->zone_highmem = zone; in ttm_mem_init_highmem_zone()
363 &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", in ttm_mem_init_highmem_zone()
369 glob->zones[glob->num_zones++] = zone; in ttm_mem_init_highmem_zone()
373 static int ttm_mem_init_dma32_zone(struct ttm_mem_global *glob, in ttm_mem_init_dma32_zone() argument
408 zone->glob = glob; in ttm_mem_init_dma32_zone()
409 glob->zone_dma32 = zone; in ttm_mem_init_dma32_zone()
411 &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name); in ttm_mem_init_dma32_zone()
416 glob->zones[glob->num_zones++] = zone; in ttm_mem_init_dma32_zone()
421 int ttm_mem_global_init(struct ttm_mem_global *glob) in ttm_mem_global_init() argument
428 spin_lock_init(&glob->lock); in ttm_mem_global_init()
429 glob->swap_queue = create_singlethread_workqueue("ttm_swap"); in ttm_mem_global_init()
430 INIT_WORK(&glob->work, ttm_shrink_work); in ttm_mem_global_init()
432 &glob->kobj, &ttm_mem_glob_kobj_type, ttm_get_kobj(), "memory_accounting"); in ttm_mem_global_init()
434 kobject_put(&glob->kobj); in ttm_mem_global_init()
441 glob->lower_mem_limit = 0; in ttm_mem_global_init()
443 ret = ttm_mem_init_kernel_zone(glob, &si); in ttm_mem_global_init()
447 ret = ttm_mem_init_highmem_zone(glob, &si); in ttm_mem_global_init()
451 ret = ttm_mem_init_dma32_zone(glob, &si); in ttm_mem_global_init()
455 for (i = 0; i < glob->num_zones; ++i) { in ttm_mem_global_init()
456 zone = glob->zones[i]; in ttm_mem_global_init()
460 ttm_page_alloc_init(glob, glob->zone_kernel->max_mem/(2*PAGE_SIZE)); in ttm_mem_global_init()
461 ttm_dma_page_alloc_init(glob, glob->zone_kernel->max_mem/(2*PAGE_SIZE)); in ttm_mem_global_init()
464 ttm_mem_global_release(glob); in ttm_mem_global_init()
469 void ttm_mem_global_release(struct ttm_mem_global *glob) in ttm_mem_global_release() argument
478 flush_workqueue(glob->swap_queue); in ttm_mem_global_release()
479 destroy_workqueue(glob->swap_queue); in ttm_mem_global_release()
480 glob->swap_queue = NULL; in ttm_mem_global_release()
481 for (i = 0; i < glob->num_zones; ++i) { in ttm_mem_global_release()
482 zone = glob->zones[i]; in ttm_mem_global_release()
486 kobject_del(&glob->kobj); in ttm_mem_global_release()
487 kobject_put(&glob->kobj); in ttm_mem_global_release()
491 static void ttm_check_swapping(struct ttm_mem_global *glob) in ttm_check_swapping() argument
497 spin_lock(&glob->lock); in ttm_check_swapping()
498 for (i = 0; i < glob->num_zones; ++i) { in ttm_check_swapping()
499 zone = glob->zones[i]; in ttm_check_swapping()
506 spin_unlock(&glob->lock); in ttm_check_swapping()
509 (void)queue_work(glob->swap_queue, &glob->work); in ttm_check_swapping()
513 static void ttm_mem_global_free_zone(struct ttm_mem_global *glob, in ttm_mem_global_free_zone() argument
520 spin_lock(&glob->lock); in ttm_mem_global_free_zone()
521 for (i = 0; i < glob->num_zones; ++i) { in ttm_mem_global_free_zone()
522 zone = glob->zones[i]; in ttm_mem_global_free_zone()
527 spin_unlock(&glob->lock); in ttm_mem_global_free_zone()
530 void ttm_mem_global_free(struct ttm_mem_global *glob, in ttm_mem_global_free() argument
533 return ttm_mem_global_free_zone(glob, NULL, amount); in ttm_mem_global_free()
548 ttm_check_under_lowerlimit(struct ttm_mem_global *glob, in ttm_check_under_lowerlimit() argument
559 if (available < glob->lower_mem_limit) in ttm_check_under_lowerlimit()
566 static int ttm_mem_global_reserve(struct ttm_mem_global *glob, in ttm_mem_global_reserve() argument
575 spin_lock(&glob->lock); in ttm_mem_global_reserve()
576 for (i = 0; i < glob->num_zones; ++i) { in ttm_mem_global_reserve()
577 zone = glob->zones[i]; in ttm_mem_global_reserve()
589 for (i = 0; i < glob->num_zones; ++i) { in ttm_mem_global_reserve()
590 zone = glob->zones[i]; in ttm_mem_global_reserve()
599 spin_unlock(&glob->lock); in ttm_mem_global_reserve()
600 ttm_check_swapping(glob); in ttm_mem_global_reserve()
606 static int ttm_mem_global_alloc_zone(struct ttm_mem_global *glob, in ttm_mem_global_alloc_zone() argument
613 while (unlikely(ttm_mem_global_reserve(glob, in ttm_mem_global_alloc_zone()
621 ttm_shrink(glob, false, memory + (memory >> 2) + 16, ctx); in ttm_mem_global_alloc_zone()
627 int ttm_mem_global_alloc(struct ttm_mem_global *glob, uint64_t memory, in ttm_mem_global_alloc() argument
635 return ttm_mem_global_alloc_zone(glob, NULL, memory, ctx); in ttm_mem_global_alloc()
639 int ttm_mem_global_alloc_page(struct ttm_mem_global *glob, in ttm_mem_global_alloc_page() argument
651 if (PageHighMem(page) && glob->zone_highmem != NULL) in ttm_mem_global_alloc_page()
652 zone = glob->zone_highmem; in ttm_mem_global_alloc_page()
654 if (glob->zone_dma32 && page_to_pfn(page) > 0x00100000UL) in ttm_mem_global_alloc_page()
655 zone = glob->zone_kernel; in ttm_mem_global_alloc_page()
657 return ttm_mem_global_alloc_zone(glob, zone, size, ctx); in ttm_mem_global_alloc_page()
660 void ttm_mem_global_free_page(struct ttm_mem_global *glob, struct page *page, in ttm_mem_global_free_page() argument
666 if (PageHighMem(page) && glob->zone_highmem != NULL) in ttm_mem_global_free_page()
667 zone = glob->zone_highmem; in ttm_mem_global_free_page()
669 if (glob->zone_dma32 && page_to_pfn(page) > 0x00100000UL) in ttm_mem_global_free_page()
670 zone = glob->zone_kernel; in ttm_mem_global_free_page()
672 ttm_mem_global_free_zone(glob, zone, size); in ttm_mem_global_free_page()
693 uint64_t ttm_get_kernel_zone_memory_size(struct ttm_mem_global *glob) in ttm_get_kernel_zone_memory_size() argument
695 return glob->zone_kernel->max_mem; in ttm_get_kernel_zone_memory_size()