]> asedeno.scripts.mit.edu Git - linux.git/commit
drm/ttm: check if free mem space is under the lower limit
authorRoger He <Hongbo.He@amd.com>
Mon, 5 Feb 2018 09:57:07 +0000 (17:57 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 27 Feb 2018 04:09:46 +0000 (23:09 -0500)
commitec3fe391bdb321b1629cfb0ddbb9fcc114b579bc
tree7dc2b835f377a0d88f0948c4bf5e5d9ae0c53efd
parent724daa4fd65d927e406f2cc0661c9a329876267b
drm/ttm: check if free mem space is under the lower limit

the free mem space and the lower limit both include two parts:
system memory and swap space.

For the OOM triggered by TTM, that is the case as below:
first swap space is full of swapped out pages and soon
system memory also is filled up with ttm pages. and then
any memory allocation request will run into OOM.

to cover two cases:
a. if no swap disk at all or free swap space is under swap mem
   limit but available system mem is bigger than sys mem limit,
   allow TTM allocation;

b. if the available system mem is less than sys mem limit but
   free swap space is bigger than swap mem limit, allow TTM
   allocation.

v2: merge two memory limit(swap and system) into one
v3: keep original behavior except ttm_opt_ctx->flags with
    TTM_OPT_FLAG_FORCE_ALLOC
v4: always set force_alloc as tx->flags & TTM_OPT_FLAG_FORCE_ALLOC
v5: add an attribute for lower_mem_limit
v6: set lower_mem_limit as 0 to keep original behavior

Signed-off-by: Roger He <Hongbo.He@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/ttm/ttm_memory.c
drivers/gpu/drm/ttm/ttm_page_alloc.c
drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
include/drm/ttm/ttm_memory.h