Skip to content

Commit

Permalink
drm/amdkcl: limit number of tests to number of CPU
Browse files Browse the repository at this point in the history
Limit the number of tests to be executed in parallel to the number of
processors available in the system. Checking for available memory may
cause a hang in the infinite loop on the system with small amount of
the system memory.

Signed-off-by: Slava Grigorev <slava.grigorev@amd.com>
Reviewed-by: Jeremy Newton <Jeremy.Newton@amd.com>
Reviewed-by: Slava Abramov <slava.abramov@amd.com>
Change-Id: I0217efee954b5a41cae2ad14cf2534f7032bae58
  • Loading branch information
Slava Grigorev authored and kent.russell@amd.com committed Sep 16, 2022
1 parent f40f201 commit 802e978
Showing 1 changed file with 9 additions and 23 deletions.
32 changes: 9 additions & 23 deletions drivers/gpu/drm/amd/dkms/m4/kernel.m4
Original file line number Diff line number Diff line change
Expand Up @@ -668,22 +668,6 @@ AC_DEFUN([AC_KERNEL_CHECK_HEADERS], [
AC_CHECK_HEADERS([$1],[AS_TR_CPP([HAVE_$1])=1],,[-])
])

dnl #
dnl # AC_KERNEL_FREE_MEM
dnl # return true if available memory >20%
dnl #
AC_DEFUN([AC_KERNEL_FREE_MEM], [
free_mem=$(free -t | awk '/^Total:/ {
printf("%d\n", $[4] / $[2] * 100)
}')
AS_IF([[[ $free_mem -gt 20 ]]], [
$1
], [
$2
])
])

dnl #
dnl # AC_KERNEL_DO_BACKGROUND
dnl # $1: contents to be executed
Expand All @@ -693,14 +677,16 @@ AC_DEFUN([AC_KERNEL_DO_BACKGROUND], [
AC_KERNEL_TMP_BUILD_DIR([$1])
}
while :
AC_CHECK_PROG(NPROC, nproc, yes)
AS_IF([test x"$NPROC" != x"yes"], [
ncpu=1
], [
ncpu=$(nproc)
])
while [[ $(jobs | wc -l) -gt $ncpu ]]
do
AC_KERNEL_FREE_MEM([rc=0], [rc=1])
if test $rc -ne 0; then :
sleep 1
else :
break
fi
sleep 0.1
done
do_background &
Expand Down

0 comments on commit 802e978

Please sign in to comment.