Skip to content

Commit

Permalink
add max-threads argument for nvidia-driver script commands so that th…
Browse files Browse the repository at this point in the history
…ere's an option to limit 'make -j' threads

Signed-off-by: Patrick Force <[email protected]>
  • Loading branch information
rockholla committed Feb 28, 2024
1 parent b17c140 commit 1ff2595
Show file tree
Hide file tree
Showing 13 changed files with 106 additions and 80 deletions.
14 changes: 8 additions & 6 deletions centos7/nvidia-driver
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ _create_driver_package() (
local nvidia_modeset_sign_args=""
local nvidia_uvm_sign_args=""

trap "make -s -j SYSSRC=/lib/modules/${KERNEL_VERSION}/build clean > /dev/null" EXIT
trap "make -s -j ${MAX_THREADS} SYSSRC=/lib/modules/${KERNEL_VERSION}/build clean > /dev/null" EXIT

echo "Compiling NVIDIA driver kernel modules..."
cd /usr/src/nvidia-${DRIVER_VERSION}/kernel
Expand All @@ -129,7 +129,7 @@ _create_driver_package() (
fi

export IGNORE_CC_MISMATCH=1
make -s -j SYSSRC=/lib/modules/${KERNEL_VERSION}/build nv-linux.o nv-modeset-linux.o > /dev/null
make -s -j ${MAX_THREADS} SYSSRC=/lib/modules/${KERNEL_VERSION}/build nv-linux.o nv-modeset-linux.o > /dev/null

echo "Relinking NVIDIA driver kernel modules..."
rm -f nvidia.ko nvidia-modeset.ko
Expand Down Expand Up @@ -527,8 +527,8 @@ usage() {
Usage: $0 COMMAND [ARG...]
Commands:
init [-a | --accept-license]
update [-k | --kernel VERSION] [-s | --sign KEYID] [-t | --tag TAG]
init [-a | --accept-license] [-m | --max-threads MAX_THREADS]
update [-k | --kernel VERSION] [-s | --sign KEYID] [-t | --tag TAG] [-m | --max-threads MAX_THREADS]
EOF
exit 1
}
Expand All @@ -538,8 +538,8 @@ if [ $# -eq 0 ]; then
fi
command=$1; shift
case "${command}" in
init) options=$(getopt -l accept-license -o a -- "$@") ;;
update) options=$(getopt -l kernel:,sign:,tag: -o k:s:t: -- "$@") ;;
init) options=$(getopt -l accept-license,max-threads: -o am: -- "$@") ;;
update) options=$(getopt -l kernel:,sign:,tag:,max-threads: -o k:s:t:m: -- "$@") ;;
reload_nvidia_peermem) options="" ;;
probe_nvidia_peermem) options="" ;;
*) usage ;;
Expand All @@ -550,6 +550,7 @@ fi
eval set -- "${options}"

ACCEPT_LICENSE=""
MAX_THREADS=""
KERNEL_VERSION=$(uname -r)
PRIVATE_KEY=""
PACKAGE_TAG=""
Expand All @@ -558,6 +559,7 @@ for opt in ${options}; do
case "$opt" in
-a | --accept-license) ACCEPT_LICENSE="yes"; shift 1 ;;
-k | --kernel) KERNEL_VERSION=$2; shift 2 ;;
-m | --max-threads) MAX_THREADS=$2; shift 2 ;;
-s | --sign) PRIVATE_KEY=$2; shift 2 ;;
-t | --tag) PACKAGE_TAG=$2; shift 2 ;;
--) shift; break ;;
Expand Down
14 changes: 8 additions & 6 deletions centos8/nvidia-driver
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,13 @@ _create_driver_package() (
local nvidia_modeset_sign_args=""
local nvidia_uvm_sign_args=""

trap "make -s -j SYSSRC=/lib/modules/${KERNEL_VERSION}/build clean > /dev/null" EXIT
trap "make -s -j ${MAX_THREADS} SYSSRC=/lib/modules/${KERNEL_VERSION}/build clean > /dev/null" EXIT

echo "Compiling NVIDIA driver kernel modules..."
cd /usr/src/nvidia-${DRIVER_VERSION}/kernel

export IGNORE_CC_MISMATCH=1
make -s -j SYSSRC=/lib/modules/${KERNEL_VERSION}/build nv-linux.o nv-modeset-linux.o > /dev/null
make -s -j ${MAX_THREADS} SYSSRC=/lib/modules/${KERNEL_VERSION}/build nv-linux.o nv-modeset-linux.o > /dev/null

echo "Relinking NVIDIA driver kernel modules..."
rm -f nvidia.ko nvidia-modeset.ko
Expand Down Expand Up @@ -349,8 +349,8 @@ usage() {
Usage: $0 COMMAND [ARG...]
Commands:
init [-a | --accept-license]
update [-k | --kernel VERSION] [-s | --sign KEYID] [-t | --tag TAG]
init [-a | --accept-license] [-m | --max-threads MAX_THREADS]
update [-k | --kernel VERSION] [-s | --sign KEYID] [-t | --tag TAG] [-m | --max-threads MAX_THREADS]
EOF
exit 1
}
Expand All @@ -360,8 +360,8 @@ if [ $# -eq 0 ]; then
fi
command=$1; shift
case "${command}" in
init) options=$(getopt -l accept-license -o a -- "$@") ;;
update) options=$(getopt -l kernel:,sign:,tag: -o k:s:t: -- "$@") ;;
init) options=$(getopt -l accept-license,max-threads: -o am: -- "$@") ;;
update) options=$(getopt -l kernel:,sign:,tag:,max-threads: -o k:s:t:m: -- "$@") ;;
*) usage ;;
esac
if [ $? -ne 0 ]; then
Expand All @@ -370,6 +370,7 @@ fi
eval set -- "${options}"

ACCEPT_LICENSE=""
MAX_THREADS=""
KERNEL_VERSION=$(uname -r)
PRIVATE_KEY=""
PACKAGE_TAG=""
Expand All @@ -378,6 +379,7 @@ for opt in ${options}; do
case "$opt" in
-a | --accept-license) ACCEPT_LICENSE="yes"; shift 1 ;;
-k | --kernel) KERNEL_VERSION=$2; shift 2 ;;
-m | --max-threads) MAX_THREADS=$2; shift 2 ;;
-s | --sign) PRIVATE_KEY=$2; shift 2 ;;
-t | --tag) PACKAGE_TAG=$2; shift 2 ;;
--) shift; break ;;
Expand Down
12 changes: 7 additions & 5 deletions coreos/nvidia-driver
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ cp /proc/version /usr/src/linux/proc/
echo "Compiling NVIDIA driver kernel modules with $(gcc --version | head -1)..."
cd /usr/src/nvidia-*/kernel
make -s -j SYSSRC=/usr/src/linux nv-linux.o nv-modeset-linux.o > /dev/null
make -s -j ${MAX_THREADS} SYSSRC=/usr/src/linux nv-linux.o nv-modeset-linux.o > /dev/null
EOF
mkdir -p /lib/modules/${KERNEL_VERSION}
cp /mnt/coreos/lib/modules/${KERNEL_VERSION}/modules.* /lib/modules/${KERNEL_VERSION}/
Expand Down Expand Up @@ -316,8 +316,8 @@ usage() {
Usage: $0 COMMAND [ARG...]
Commands:
init [-a | --accept-license]
update [-k | --kernel VERSION] [-s | --sign KEYID] [-t | --tag TAG]
init [-a | --accept-license] [-m | --max-threads MAX_THREADS]
update [-k | --kernel VERSION] [-s | --sign KEYID] [-t | --tag TAG] [-m | --max-threads MAX_THREADS]
EOF
exit 1
}
Expand All @@ -327,8 +327,8 @@ if [ $# -eq 0 ]; then
fi
command=$1; shift
case "${command}" in
init) options=$(getopt -l accept-license -o a -- "$@") ;;
update) options=$(getopt -l kernel:,sign:,tag: -o k:s:t: -- "$@") ;;
init) options=$(getopt -l accept-license,max-threads: -o am: -- "$@") ;;
update) options=$(getopt -l kernel:,sign:,tag:,max-threads: -o k:s:t:m: -- "$@") ;;
*) usage ;;
esac
if [ $? -ne 0 ]; then
Expand All @@ -337,6 +337,7 @@ fi
eval set -- "${options}"

ACCEPT_LICENSE=""
MAX_THREADS=""
KERNEL_VERSION=$(uname -r)
PRIVATE_KEY=""
PACKAGE_TAG=""
Expand All @@ -345,6 +346,7 @@ for opt in ${options}; do
case "$opt" in
-a | --accept-license) ACCEPT_LICENSE="yes"; shift 1 ;;
-k | --kernel) KERNEL_VERSION=$2; shift 2 ;;
-m | --max-threads) MAX_THREADS=$2; shift 2 ;;
-s | --sign) PRIVATE_KEY=$2; shift 2 ;;
-t | --tag) PACKAGE_TAG=$2; shift 2 ;;
--) shift; break ;;
Expand Down
18 changes: 10 additions & 8 deletions fedora/nvidia-driver
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ _create_driver_package() (
local nvidia_modeset_sign_args=""
local nvidia_uvm_sign_args=""

trap "make -s -j SYSSRC=/lib/modules/${KERNEL_VERSION}/build clean > /dev/null" EXIT
trap "make -s -j ${MAX_THREADS} SYSSRC=/lib/modules/${KERNEL_VERSION}/build clean > /dev/null" EXIT

echo "Compiling NVIDIA driver kernel modules..."
cd /usr/src/nvidia-${DRIVER_VERSION}/${KERNEL_TYPE}
Expand All @@ -247,7 +247,7 @@ _create_driver_package() (
fi
fi

make -s -j SYSSRC=/lib/modules/${KERNEL_VERSION}/build nv-linux.o nv-modeset-linux.o > /dev/null
make -s -j ${MAX_THREADS} SYSSRC=/lib/modules/${KERNEL_VERSION}/build nv-linux.o nv-modeset-linux.o > /dev/null

echo "Relinking NVIDIA driver kernel modules..."
rm -f nvidia.ko nvidia-modeset.ko
Expand Down Expand Up @@ -769,10 +769,10 @@ usage() {
Usage: $0 COMMAND [ARG...]
Commands:
init [-a | --accept-license] [-x]
build [-a | --accept-license]
init [-a | --accept-license] [-x] [-m | --max-threads MAX_THREADS]
build [-a | --accept-license] [-m | --max-threads MAX_THREADS]
load
update [-k | --kernel VERSION] [-s | --sign KEYID] [-t | --tag TAG]
update [-k | --kernel VERSION] [-s | --sign KEYID] [-t | --tag TAG] [-m | --max-threads MAX_THREADS]
EOF
exit 1
}
Expand All @@ -782,10 +782,10 @@ if [ $# -eq 0 ]; then
fi
command=$1; shift
case "${command}" in
init) options=$(getopt -l accept-license -o a:x -- "$@") ;;
build) options=$(getopt -l accept-license,tag: -o a:t -- "$@") ;;
init) options=$(getopt -l accept-license,max-threads: -o a:x:m: -- "$@") ;;
build) options=$(getopt -l accept-license,tag:,max-threads: -o a:t:m: -- "$@") ;;
load) options="" ;;
update) options=$(getopt -l kernel:,sign:,tag: -o k:s:t: -- "$@") ;;
update) options=$(getopt -l kernel:,sign:,tag:,max-threads: -o k:s:t:m: -- "$@") ;;
reload_nvidia_peermem) options="" ;;
probe_nvidia_peermem) options="" ;;
*) usage ;;
Expand All @@ -796,6 +796,7 @@ fi
eval set -- "${options}"

ACCEPT_LICENSE=""
MAX_THREADS=""
KERNEL_VERSION=$(uname -r)
PRIVATE_KEY=""
PACKAGE_TAG=""
Expand All @@ -804,6 +805,7 @@ for opt in ${options}; do
case "$opt" in
-a | --accept-license) ACCEPT_LICENSE="yes"; shift 1 ;;
-k | --kernel) KERNEL_VERSION=$2; shift 2 ;;
-m | --max-threads) MAX_THREADS=$2; shift 2 ;;
-s | --sign) PRIVATE_KEY=$2; shift 2 ;;
-t | --tag) PACKAGE_TAG=$2; shift 2 ;;
-x ) set -x; shift 1 ;;
Expand Down
12 changes: 7 additions & 5 deletions flatcar/nvidia-driver
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ cp /lib/modules/${KERNEL_VERSION}/build/scripts/module.lds /usr/src/nvidia-*/ker
cd /usr/src/nvidia-*/kernel
export IGNORE_CC_MISMATCH=1
export IGNORE_MISSING_MODULE_SYMVERS=1
make -s -j SYSSRC=/lib/modules/${KERNEL_VERSION}/source nv-linux.o nv-modeset-linux.o > /dev/null
make -s -j ${MAX_THREADS} SYSSRC=/lib/modules/${KERNEL_VERSION}/source nv-linux.o nv-modeset-linux.o > /dev/null
EOF
mkdir -p /lib/modules/${KERNEL_VERSION}
cp -r /mnt/coreos/lib/modules/${KERNEL_VERSION}/* /lib/modules/${KERNEL_VERSION}/
Expand Down Expand Up @@ -433,8 +433,8 @@ usage() {
Usage: $0 COMMAND [ARG...]
Commands:
init [-a | --accept-license]
update [-k | --kernel VERSION] [-s | --sign KEYID] [-t | --tag TAG]
init [-a | --accept-license] [-m | --max-threads MAX_THREADS]
update [-k | --kernel VERSION] [-s | --sign KEYID] [-t | --tag TAG] [-m | --max-threads MAX_THREADS]
EOF
exit 1
}
Expand All @@ -444,8 +444,8 @@ if [ $# -eq 0 ]; then
fi
command=$1; shift
case "${command}" in
init) options=$(getopt -l accept-license -o a -- "$@") ;;
update) options=$(getopt -l kernel:,sign:,tag: -o k:s:t: -- "$@") ;;
init) options=$(getopt -l accept-license,max-threads: -o am: -- "$@") ;;
update) options=$(getopt -l kernel:,sign:,tag:,max-threads: -o k:s:t:m: -- "$@") ;;
*) usage ;;
esac
if [ $? -ne 0 ]; then
Expand All @@ -454,6 +454,7 @@ fi
eval set -- "${options}"

ACCEPT_LICENSE=""
MAX_THREADS=""
KERNEL_VERSION=$(uname -r)
PRIVATE_KEY=""
PACKAGE_TAG=""
Expand All @@ -462,6 +463,7 @@ for opt in ${options}; do
case "$opt" in
-a | --accept-license) ACCEPT_LICENSE="yes"; shift 1 ;;
-k | --kernel) KERNEL_VERSION=$2; shift 2 ;;
-m | --max-threads) MAX_THREADS=$2; shift 2 ;;
-s | --sign) PRIVATE_KEY=$2; shift 2 ;;
-t | --tag) PACKAGE_TAG=$2; shift 2 ;;
--) shift; break ;;
Expand Down
14 changes: 8 additions & 6 deletions photon3.0/nvidia-driver
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ _create_driver_package() (
local nvidia_modeset_sign_args=""
local nvidia_uvm_sign_args=""

trap "make -s -j SYSSRC=/lib/modules/${KERNEL_VERSION}/build clean > /dev/null" EXIT
trap "make -s -j ${MAX_THREADS} SYSSRC=/lib/modules/${KERNEL_VERSION}/build clean > /dev/null" EXIT

echo "Compiling NVIDIA driver kernel modules..."
cd /usr/src/nvidia-${DRIVER_VERSION}/kernel
make -s -j SYSSRC=/lib/modules/${KERNEL_VERSION}/build nv-linux.o nv-modeset-linux.o > /dev/null
make -s -j ${MAX_THREADS} SYSSRC=/lib/modules/${KERNEL_VERSION}/build nv-linux.o nv-modeset-linux.o > /dev/null

echo "Relinking NVIDIA driver kernel modules..."
rm -f nvidia.ko nvidia-modeset.ko
Expand Down Expand Up @@ -335,8 +335,8 @@ usage() {
Usage: $0 COMMAND [ARG...]
Commands:
init [-a | --accept-license]
update [-k | --kernel VERSION] [-s | --sign KEYID] [-t | --tag TAG]
init [-a | --accept-license] [-m | --max-threads MAX_THREADS]
update [-k | --kernel VERSION] [-s | --sign KEYID] [-t | --tag TAG] [-m | --max-threads MAX_THREADS]
EOF
exit 1
}
Expand All @@ -346,8 +346,8 @@ if [ $# -eq 0 ]; then
fi
command=$1; shift
case "${command}" in
init) options=$(getopt -l accept-license -o a -- "$@") ;;
update) options=$(getopt -l kernel:,sign:,tag: -o k:s:t: -- "$@") ;;
init) options=$(getopt -l accept-license,max-threads: -o am: -- "$@") ;;
update) options=$(getopt -l kernel:,sign:,tag:,max-threads: -o k:s:t:m: -- "$@") ;;
*) usage ;;
esac
if [ $? -ne 0 ]; then
Expand All @@ -356,6 +356,7 @@ fi
eval set -- "${options}"

ACCEPT_LICENSE=""
MAX_THREADS=""
KERNEL_VERSION=$(uname -r)
PRIVATE_KEY=""
PACKAGE_TAG=""
Expand All @@ -364,6 +365,7 @@ for opt in ${options}; do
case "$opt" in
-a | --accept-license) ACCEPT_LICENSE="yes"; shift 1 ;;
-k | --kernel) KERNEL_VERSION=$2; shift 2 ;;
-m | --max-threads) MAX_THREADS=$2; shift 2 ;;
-s | --sign) PRIVATE_KEY=$2; shift 2 ;;
-t | --tag) PACKAGE_TAG=$2; shift 2 ;;
--) shift; break ;;
Expand Down
14 changes: 8 additions & 6 deletions rhel7/nvidia-driver
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,13 @@ _create_driver_package() (
local nvidia_modeset_sign_args=""
local nvidia_uvm_sign_args=""

trap "make -s -j SYSSRC=/lib/modules/${KERNEL_VERSION}/build clean > /dev/null" EXIT
trap "make -s -j ${MAX_THREADS} SYSSRC=/lib/modules/${KERNEL_VERSION}/build clean > /dev/null" EXIT

echo "Compiling NVIDIA driver kernel modules..."
cd /usr/src/nvidia-${DRIVER_VERSION}/kernel

export IGNORE_CC_MISMATCH=1
make -s -j SYSSRC=/lib/modules/${KERNEL_VERSION}/build nv-linux.o nv-modeset-linux.o > /dev/null
make -s -j ${MAX_THREADS} SYSSRC=/lib/modules/${KERNEL_VERSION}/build nv-linux.o nv-modeset-linux.o > /dev/null

echo "Relinking NVIDIA driver kernel modules..."
rm -f nvidia.ko nvidia-modeset.ko
Expand Down Expand Up @@ -372,8 +372,8 @@ usage() {
Usage: $0 COMMAND [ARG...]
Commands:
init [-a | --accept-license]
update [-k | --kernel VERSION] [-s | --sign KEYID] [-t | --tag TAG]
init [-a | --accept-license] [-m | --max-threads MAX_THREADS]
update [-k | --kernel VERSION] [-s | --sign KEYID] [-t | --tag TAG] [-m | --max-threads MAX_THREADS]
EOF
exit 1
}
Expand All @@ -383,8 +383,8 @@ if [ $# -eq 0 ]; then
fi
command=$1; shift
case "${command}" in
init) options=$(getopt -l accept-license -o a -- "$@") ;;
update) options=$(getopt -l kernel:,sign:,tag: -o k:s:t: -- "$@") ;;
init) options=$(getopt -l accept-license,max-threads: -o am: -- "$@") ;;
update) options=$(getopt -l kernel:,sign:,tag:,max-threads: -o k:s:t:m: -- "$@") ;;
*) usage ;;
esac
if [ $? -ne 0 ]; then
Expand All @@ -393,6 +393,7 @@ fi
eval set -- "${options}"

ACCEPT_LICENSE=""
MAX_THREADS=""
KERNEL_VERSION=$(uname -r)
PRIVATE_KEY=""
PACKAGE_TAG=""
Expand All @@ -401,6 +402,7 @@ for opt in ${options}; do
case "$opt" in
-a | --accept-license) ACCEPT_LICENSE="yes"; shift 1 ;;
-k | --kernel) KERNEL_VERSION=$2; shift 2 ;;
-m | --max-threads) MAX_THREADS=$2; shift 2 ;;
-s | --sign) PRIVATE_KEY=$2; shift 2 ;;
-t | --tag) PACKAGE_TAG=$2; shift 2 ;;
--) shift; break ;;
Expand Down
Loading

0 comments on commit 1ff2595

Please sign in to comment.