diff options
author | Thomas Hellstrom <thellstrom@vmware.com> | 2009-08-17 10:28:39 -0400 |
---|---|---|
committer | Dave Airlie <airlied@linux.ie> | 2009-08-19 02:09:53 -0400 |
commit | 5fd9cbad3a4ae82c83c55b9c621d156c326724ef (patch) | |
tree | 1a0868a3bd2751fa861c083aeb3ac27f3f695694 /include/drm/ttm/ttm_memory.h | |
parent | e9840be8c23601285a70520b4898818f28ce8c2b (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/ttm_memory.h')
-rw-r--r-- | include/drm/ttm/ttm_memory.h | 43 |
1 files changed, 24 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 | ||
75 | struct ttm_mem_zone; | ||
77 | struct ttm_mem_global { | 76 | struct 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, | |||
146 | extern int ttm_mem_global_init(struct ttm_mem_global *glob); | 146 | extern int ttm_mem_global_init(struct ttm_mem_global *glob); |
147 | extern void ttm_mem_global_release(struct ttm_mem_global *glob); | 147 | extern void ttm_mem_global_release(struct ttm_mem_global *glob); |
148 | extern int ttm_mem_global_alloc(struct ttm_mem_global *glob, uint64_t memory, | 148 | extern 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); |
150 | extern void ttm_mem_global_free(struct ttm_mem_global *glob, | 150 | extern void ttm_mem_global_free(struct ttm_mem_global *glob, |
151 | uint64_t amount, bool himem); | 151 | uint64_t amount); |
152 | extern int ttm_mem_global_alloc_page(struct ttm_mem_global *glob, | ||
153 | struct page *page, | ||
154 | bool no_wait, bool interruptible); | ||
155 | extern void ttm_mem_global_free_page(struct ttm_mem_global *glob, | ||
156 | struct page *page); | ||
152 | extern size_t ttm_round_pot(size_t size); | 157 | extern size_t ttm_round_pot(size_t size); |
153 | #endif | 158 | #endif |