• Roger He's avatar
    drm/ttm: check if free mem space is under the lower limit · ec3fe391
    Roger He authored
    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: default avatarRoger He <Hongbo.He@amd.com>
    Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
    Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
    ec3fe391
ttm_page_alloc.c 29.2 KB