ttm: Make parts of a struct ttm_bo_device global.
Common resources, like memory accounting and swap lists should be global and not per device. Introduce a struct ttm_bo_global to accomodate this, and register it with sysfs. Add a small sysfs interface to return the number of active buffer objects. Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com> Signed-off-by: Dave Airlie <airlied@linux.ie>
This commit is contained in:

committed by
Dave Airlie

parent
5fd9cbad3a
commit
a987fcaa80
@@ -166,7 +166,7 @@ static void ttm_tt_free_user_pages(struct ttm_tt *ttm)
|
||||
set_page_dirty_lock(page);
|
||||
|
||||
ttm->pages[i] = NULL;
|
||||
ttm_mem_global_free(ttm->bdev->mem_glob, PAGE_SIZE);
|
||||
ttm_mem_global_free(ttm->glob->mem_glob, PAGE_SIZE);
|
||||
put_page(page);
|
||||
}
|
||||
ttm->state = tt_unpopulated;
|
||||
@@ -177,8 +177,7 @@ static void ttm_tt_free_user_pages(struct ttm_tt *ttm)
|
||||
static struct page *__ttm_tt_get_page(struct ttm_tt *ttm, int index)
|
||||
{
|
||||
struct page *p;
|
||||
struct ttm_bo_device *bdev = ttm->bdev;
|
||||
struct ttm_mem_global *mem_glob = bdev->mem_glob;
|
||||
struct ttm_mem_global *mem_glob = ttm->glob->mem_glob;
|
||||
int ret;
|
||||
|
||||
while (NULL == (p = ttm->pages[index])) {
|
||||
@@ -348,7 +347,7 @@ static void ttm_tt_free_alloced_pages(struct ttm_tt *ttm)
|
||||
printk(KERN_ERR TTM_PFX
|
||||
"Erroneous page count. "
|
||||
"Leaking pages.\n");
|
||||
ttm_mem_global_free_page(ttm->bdev->mem_glob,
|
||||
ttm_mem_global_free_page(ttm->glob->mem_glob,
|
||||
cur_page);
|
||||
__free_page(cur_page);
|
||||
}
|
||||
@@ -394,7 +393,7 @@ int ttm_tt_set_user(struct ttm_tt *ttm,
|
||||
struct mm_struct *mm = tsk->mm;
|
||||
int ret;
|
||||
int write = (ttm->page_flags & TTM_PAGE_FLAG_WRITE) != 0;
|
||||
struct ttm_mem_global *mem_glob = ttm->bdev->mem_glob;
|
||||
struct ttm_mem_global *mem_glob = ttm->glob->mem_glob;
|
||||
|
||||
BUG_ON(num_pages != ttm->num_pages);
|
||||
BUG_ON((ttm->page_flags & TTM_PAGE_FLAG_USER) == 0);
|
||||
@@ -439,8 +438,7 @@ struct ttm_tt *ttm_tt_create(struct ttm_bo_device *bdev, unsigned long size,
|
||||
if (!ttm)
|
||||
return NULL;
|
||||
|
||||
ttm->bdev = bdev;
|
||||
|
||||
ttm->glob = bdev->glob;
|
||||
ttm->num_pages = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
|
||||
ttm->first_himem_page = ttm->num_pages;
|
||||
ttm->last_lomem_page = -1;
|
||||
|
Reference in New Issue
Block a user