summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Hellstrom <thellstrom-at-vmware-dot-com>2009-02-17 09:07:49 +0100
committerThomas Hellstrom <thellstrom-at-vmware-dot-com>2009-02-17 09:07:49 +0100
commit875a6ae21755bd92e875cb136c58537082320572 (patch)
tree1fabe62466b8cb4c0232cf91ecebe2bbff506671
parente8eb30ad8bf2bbd84155cd27a9dbd5e0b0f5bb36 (diff)
ttm: Adjust swapping target so that current allocation will succeed.
-rw-r--r--linux-core/ttm/ttm_memory.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/linux-core/ttm/ttm_memory.c b/linux-core/ttm/ttm_memory.c
index 6478ed89c..73c45ed73 100644
--- a/linux-core/ttm/ttm_memory.c
+++ b/linux-core/ttm/ttm_memory.c
@@ -42,7 +42,8 @@
* many threads may try to swap out at any given time.
*/
-static void ttm_shrink(struct ttm_mem_global *glob, bool from_workqueue)
+static void ttm_shrink(struct ttm_mem_global *glob, bool from_workqueue,
+ uint64_t extra)
{
int ret;
struct ttm_mem_shrink *shrink;
@@ -64,6 +65,9 @@ static void ttm_shrink(struct ttm_mem_global *glob, bool from_workqueue)
target = glob->max_memory;
}
+ total_target = (extra >= total_target) ? 0: total_target - extra;
+ target = (extra >= target) ? 0: target - extra;
+
while (glob->used_memory > target ||
glob->used_total_memory > total_target) {
shrink = glob->shrink;
@@ -82,7 +86,7 @@ static void ttm_shrink_work(struct work_struct *work)
struct ttm_mem_global *glob =
container_of(work, struct ttm_mem_global, work);
- ttm_shrink(glob, true);
+ ttm_shrink(glob, true, 0ULL);
}
int ttm_mem_global_init(struct ttm_mem_global *glob)
@@ -203,7 +207,7 @@ int ttm_mem_global_alloc(struct ttm_mem_global *glob, uint64_t memory,
return -ENOMEM;
if (unlikely(count-- == 0))
return -ENOMEM;
- ttm_shrink(glob, false);
+ ttm_shrink(glob, false, memory + (memory >> 2) + 16);
}
return 0;