Index: graphics/drm-next-kmod/Makefile =================================================================== --- graphics/drm-next-kmod/Makefile +++ graphics/drm-next-kmod/Makefile @@ -3,7 +3,7 @@ PORTNAME= drm-next-kmod PORTVERSION= 4.11.g20181027 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= graphics MAINTAINER= jmd@FreeBSD.org Index: graphics/drm-next-kmod/files/patch-drm__ttm__ttm_memory.c =================================================================== --- /dev/null +++ graphics/drm-next-kmod/files/patch-drm__ttm__ttm_memory.c @@ -0,0 +1,51 @@ +--- drm/ttm/ttm_memory.c.orig 2018-10-25 02:29:04.000000000 -0700 ++++ drm/ttm/ttm_memory.c +@@ -263,6 +263,9 @@ + #ifdef __linux__ + uint64_t mem; + #endif ++#ifdef __FreeBSD__ ++ uint64_t maxmem; ++#endif + int ret; + + if (unlikely(!zone)) +@@ -274,6 +277,16 @@ + #endif + + zone->name = "kernel"; ++#ifdef __FreeBSD__ ++ /* ++ * As a hack workaround for the lack of good backpressure system ++ * between FreeBSD pagedaemon and the TTM cache, just allow users to ++ * impose an arbitrary limit on the big TTM cache size. ++ */ ++ if (getenv_uint64("dev.drm.ttm_kernel_zone_maxmem", &maxmem) && ++ (mem >> 1) > maxmem) ++ mem = maxmem << 1; ++#endif + zone->zone_mem = mem; + zone->max_mem = mem >> 1; + zone->emer_mem = (mem >> 1) + (mem >> 2); +@@ -339,6 +352,9 @@ + #ifdef __linux__ + uint64_t mem; + #endif ++#ifdef __FreeBSD__ ++ uint64_t maxmem; ++#endif + int ret; + + if (unlikely(!zone)) +@@ -366,6 +382,11 @@ + + mem = ((uint64_t) 1ULL << 32); + zone->name = "dma32"; ++#ifdef __FreeBSD__ ++ if (getenv_uint64("dev.drm.ttm_dma32_zone_maxmem", &maxmem) && ++ (mem >> 1) > maxmem) ++ mem = maxmem << 1; ++#endif + zone->zone_mem = mem; + zone->max_mem = mem >> 1; + zone->emer_mem = (mem >> 1) + (mem >> 2); Index: graphics/drm-next-kmod/pkg-message =================================================================== --- graphics/drm-next-kmod/pkg-message +++ graphics/drm-next-kmod/pkg-message @@ -13,3 +13,14 @@ Older generations are supported by the legacy kms modules (radeonkms / i915kms) in base or by installing graphics/drm-legacy-kmod. + +The radeon and amdgpu drivers rely on a memory backpressure system to release +memory when the system is at capacity. Currently, the integration between +native FreeBSD memory pressure and that linuxkpi subsystem is poor. The +symptom of this condition is top(1) showing about half of memory in the "Wired" +state, as well as low Free and Buffer cache numbers and regular allocation +failures (i.e., "swap_pager_getswapspace(...): failed" in dmesg(8)). + +As a short-term workaround, radeon and amdgpu users can set the tunables +"dev.drm.ttm_dma32_zone_maxmem" and "dev.drm.ttm_kernel_zone_maxmem" to limit +the maximum memory (in bytes) used by the corresponding zones.