Commit 2e55b97d authored by Tomasz Zawadzki's avatar Tomasz Zawadzki
Browse files

setup.sh: execute checking ulimit as a user



When using vfio a warning for memlock limit is printed.
TARGET_USER is one set by caller when executing the script,
or set to user that called the script (even when using sudo).

Yet ulimit was printed for the one executing the script,
most likely root.

This patch verifies ulimit for a particular TARGET_USER.
Along with more explicit information which user the
information pertains to.

Signed-off-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: I20ad62109bc316295208e21f959ecfc263307e1c
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1964


Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 887531f6
Loading
Loading
Loading
Loading
+16 −17
Original line number Diff line number Diff line
@@ -417,24 +417,23 @@ function configure_linux() {
				chown "$TARGET_USER" "$mount"
				chmod g+w "$mount"
			done
		fi

		MEMLOCK_AMNT=$(ulimit -l)
		if [ "$MEMLOCK_AMNT" != "unlimited" ]; then
			MEMLOCK_AMNT=$(su "$TARGET_USER" -c "ulimit -l")
			if [[ $MEMLOCK_AMNT != "unlimited" ]]; then
				MEMLOCK_MB=$((MEMLOCK_AMNT / 1024))
			echo ""
			echo "Current user memlock limit: ${MEMLOCK_MB} MB"
			echo ""
			echo "This is the maximum amount of memory you will be"
			echo "able to use with DPDK and VFIO if run as current user."
			echo -n "To change this, please adjust limits.conf memlock "
			echo "limit for current user."

			if [ $MEMLOCK_AMNT -lt 65536 ]; then
				cat <<- MEMLOCK
					"$TARGET_USER" user memlock limit: $MEMLOCK_MB MB

					This is the maximum amount of memory you will be
					able to use with DPDK and VFIO if run as user "$TARGET_USER".
					To change this, please adjust limits.conf memlock limit for user "$TARGET_USER".
				MEMLOCK
				if ((MEMLOCK_AMNT < 65536)); then
					echo ""
					echo "## WARNING: memlock limit is less than 64MB"
					echo -n "## DPDK with VFIO may not be able to initialize "
				echo "if run as current user."
					echo "if run as user \"$TARGET_USER\"."
				fi
			fi
		fi
	fi