aboutsummaryrefslogtreecommitdiffstats
path: root/include/drm/ttm
diff options
context:
space:
mode:
authorThomas Hellstrom <thellstrom@vmware.com>2009-08-17 10:28:39 -0400
committerDave Airlie <airlied@linux.ie>2009-08-19 02:09:53 -0400
commit5fd9cbad3a4ae82c83c55b9c621d156c326724ef (patch)
tree1a0868a3bd2751fa861c083aeb3ac27f3f695694 /include/drm/ttm
parente9840be8c23601285a70520b4898818f28ce8c2b (diff)
drm/ttm: Memory accounting rework.
Use inclusive zones to simplify accounting and its sysfs representation. Use DMA32 accounting where applicable. Add a sysfs interface to make the heuristically determined limits readable and configurable. Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com> Signed-off-by: Dave Airlie <airlied@linux.ie>
Diffstat (limited to 'include/drm/ttm')
-rw-r--r--include/drm/ttm/ttm_memory.h43
-rw-r--r--include/drm/ttm/ttm_module.h2
2 files changed, 26 insertions, 19 deletions
diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
index d8b8f042c4f1..6983a7cf4da4 100644
--- a/include/drm/ttm/ttm_memory.h
+++ b/include/drm/ttm/ttm_memory.h
@@ -32,6 +32,7 @@
32#include <linux/spinlock.h> 32#include <linux/spinlock.h>
33#include <linux/wait.h> 33#include <linux/wait.h>
34#include <linux/errno.h> 34#include <linux/errno.h>
35#include <linux/kobject.h>
35 36
36/** 37/**
37 * struct ttm_mem_shrink - callback to shrink TTM memory usage. 38 * struct ttm_mem_shrink - callback to shrink TTM memory usage.
@@ -60,34 +61,33 @@ struct ttm_mem_shrink {
60 * @queue: Wait queue for processes suspended waiting for memory. 61 * @queue: Wait queue for processes suspended waiting for memory.
61 * @lock: Lock to protect the @shrink - and the memory accounting members, 62 * @lock: Lock to protect the @shrink - and the memory accounting members,
62 * that is, essentially the whole structure with some exceptions. 63 * that is, essentially the whole structure with some exceptions.
63 * @emer_memory: Lowmem memory limit available for root. 64 * @zones: Array of pointers to accounting zones.
64 * @max_memory: Lowmem memory limit available for non-root. 65 * @num_zones: Number of populated entries in the @zones array.
65 * @swap_limit: Lowmem memory limit where the shrink workqueue kicks in. 66 * @zone_kernel: Pointer to the kernel zone.
66 * @used_memory: Currently used lowmem memory. 67 * @zone_highmem: Pointer to the highmem zone if there is one.
67 * @used_total_memory: Currently used total (lowmem + highmem) memory. 68 * @zone_dma32: Pointer to the dma32 zone if there is one.
68 * @total_memory_swap_limit: Total memory limit where the shrink workqueue
69 * kicks in.
70 * @max_total_memory: Total memory available to non-root processes.
71 * @emer_total_memory: Total memory available to root processes.
72 * 69 *
73 * Note that this structure is not per device. It should be global for all 70 * Note that this structure is not per device. It should be global for all
74 * graphics devices. 71 * graphics devices.
75 */ 72 */
76 73
74#define TTM_MEM_MAX_ZONES 2
75struct ttm_mem_zone;
77struct ttm_mem_global { 76struct ttm_mem_global {
77 struct kobject kobj;
78 struct ttm_mem_shrink *shrink; 78 struct ttm_mem_shrink *shrink;
79 struct workqueue_struct *swap_queue; 79 struct workqueue_struct *swap_queue;
80 struct work_struct work; 80 struct work_struct work;
81 wait_queue_head_t queue; 81 wait_queue_head_t queue;
82 spinlock_t lock; 82 spinlock_t lock;
83 uint64_t emer_memory; 83 struct ttm_mem_zone *zones[TTM_MEM_MAX_ZONES];
84 uint64_t max_memory; 84 unsigned int num_zones;
85 uint64_t swap_limit; 85 struct ttm_mem_zone *zone_kernel;
86 uint64_t used_memory; 86#ifdef CONFIG_HIGHMEM
87 uint64_t used_total_memory; 87 struct ttm_mem_zone *zone_highmem;
88 uint64_t total_memory_swap_limit; 88#else
89 uint64_t max_total_memory; 89 struct ttm_mem_zone *zone_dma32;
90 uint64_t emer_total_memory; 90#endif
91}; 91};
92 92
93/** 93/**
@@ -146,8 +146,13 @@ static inline void ttm_mem_unregister_shrink(struct ttm_mem_global *glob,
146extern int ttm_mem_global_init(struct ttm_mem_global *glob); 146extern int ttm_mem_global_init(struct ttm_mem_global *glob);
147extern void ttm_mem_global_release(struct ttm_mem_global *glob); 147extern void ttm_mem_global_release(struct ttm_mem_global *glob);
148extern int ttm_mem_global_alloc(struct ttm_mem_global *glob, uint64_t memory, 148extern int ttm_mem_global_alloc(struct ttm_mem_global *glob, uint64_t memory,
149 bool no_wait, bool interruptible, bool himem); 149 bool no_wait, bool interruptible);
150extern void ttm_mem_global_free(struct ttm_mem_global *glob, 150extern void ttm_mem_global_free(struct ttm_mem_global *glob,
151 uint64_t amount, bool himem); 151 uint64_t amount);
152extern int ttm_mem_global_alloc_page(struct ttm_mem_global *glob,
153 struct page *page,
154 bool no_wait, bool interruptible);
155extern void ttm_mem_global_free_page(struct ttm_mem_global *glob,
156 struct page *page);
152extern size_t ttm_round_pot(size_t size); 157extern size_t ttm_round_pot(size_t size);
153#endif 158#endif
diff --git a/include/drm/ttm/ttm_module.h b/include/drm/ttm/ttm_module.h
index 889a4c7958ae..0a72ac7c7e58 100644
--- a/include/drm/ttm/ttm_module.h
+++ b/include/drm/ttm/ttm_module.h
@@ -32,6 +32,7 @@
32#define _TTM_MODULE_H_ 32#define _TTM_MODULE_H_
33 33
34#include <linux/kernel.h> 34#include <linux/kernel.h>
35struct kobject;
35 36
36#define TTM_PFX "[TTM]" 37#define TTM_PFX "[TTM]"
37 38
@@ -54,5 +55,6 @@ extern void ttm_global_init(void);
54extern void ttm_global_release(void); 55extern void ttm_global_release(void);
55extern int ttm_global_item_ref(struct ttm_global_reference *ref); 56extern int ttm_global_item_ref(struct ttm_global_reference *ref);
56extern void ttm_global_item_unref(struct ttm_global_reference *ref); 57extern void ttm_global_item_unref(struct ttm_global_reference *ref);
58extern struct kobject *ttm_get_kobj(void);
57 59
58#endif /* _TTM_MODULE_H_ */ 60#endif /* _TTM_MODULE_H_ */