Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default CPU Cores for Manager #219

Merged
merged 26 commits into from
Jul 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3749d0d
Added improvements in #190
EthanBaron14 Jun 5, 2020
3678ef8
User can now use 1-8 cores with input checking. Updated usage instruc…
EthanBaron14 Jun 5, 2020
59cb522
Changed message for using default cores from WARNING to INFO
EthanBaron14 Jun 5, 2020
f2262fe
Updated documentation for new manager syntax
EthanBaron14 Jun 5, 2020
acc9bea
Updated dependency information in docs
EthanBaron14 Jun 5, 2020
19bc6c1
Flag syntax implemented. Checks for dependency bc. Syntax checking
EthanBaron14 Jun 5, 2020
330d33a
Updated documentation for new syntax
EthanBaron14 Jun 5, 2020
597e307
Ensures flags can be entered out of order in new syntax
EthanBaron14 Jun 9, 2020
ebd067d
Fixed bug in #228
EthanBaron14 Jun 11, 2020
9626bdd
Changed dependency checking to be more OS-agnostic
EthanBaron14 Jun 12, 2020
7272aaf
Forcing workflow rerun
EthanBaron14 Jun 12, 2020
c6c2640
Forcing workflow rerun
EthanBaron14 Jun 12, 2020
77760af
Improved dependency check and stored regex match result in variables
EthanBaron14 Jun 13, 2020
130c386
Just learned Bash does not assume false if variable does not exist
EthanBaron14 Jun 13, 2020
f2e2dbb
Improved dependency check
EthanBaron14 Jun 13, 2020
74f4b94
Simplified port counting
EthanBaron14 Jun 16, 2020
99a4373
Added comments for port conversions
EthanBaron14 Jun 16, 2020
83b19b7
Moved port check to prevent future merge conflict
EthanBaron14 Jun 16, 2020
4cde0d0
Fixed merge conflict arising from PR 229
EthanBaron14 Jun 16, 2020
c7c563b
Merge branch 'develop' of https://github.com/sdnfv/openNetVM into def…
EthanBaron14 Jun 23, 2020
291ca4f
Added usage on error and fixed merge conflicts
EthanBaron14 Jun 23, 2020
4cd5583
Added usage on error and fixed merge conflicts
EthanBaron14 Jun 23, 2020
768bb7c
Improved if statement logic, information printing
EthanBaron14 Jun 24, 2020
285d19b
Fixed syntax checking expression to match switching positions
EthanBaron14 Jun 24, 2020
ffe7a9c
Fixed logic
EthanBaron14 Jun 24, 2020
13e871b
Last documentation updates
EthanBaron14 Jun 28, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/Examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ In this example, we will be setting up a chain of NFs. The length of the chain
The manager needs three cores, one for NIC RX, one for statistics, and one for NIC TX.
2. Run Manager:
- Run the manager in dynamic mode with the following command. We are using a corelist here to manually pin the manager to specific cores, a portmask to decide which NIC ports to use, and configuring it display manager statistics to stdout:
- `# onvm/go.sh 0,1,2 1 0x3F8 -s stdout`
- `# onvm/go.sh -k 1 -n 0xF8 -s stdout -m 0,1,2`
3. Start NFs:
- First, start at most `n-1` simple_forward NFs, where `n` corresponds to the total number of NFs that the system can handle. This is determined from the `scripts/coremask.py` helper script. We will only start two NFs for convenience.
- Simple forward's arguments are core to pin it to, service ID, and
Expand Down Expand Up @@ -128,7 +128,7 @@ In this example, we can set up a circular chain of NFs. Here, traffic does not
The manager needs three cores, one for NIC RX, one for statistics, and one for NIC TX.
2. Run Manager:
- Run the manager in dynamic mode with the following command. We are using a corelist here to manually pin the manager to specific cores, a portmask to decide which NIC ports to use, and configuring it display manager statistics to stdout:
- `# onvm/go.sh 0,1,2 1 0x3F8 -s stdout`
- `# onvm/go.sh -k 1 -n 0x3F8 -s stdout -m 0,1,2`
3. Start NFs:
- First, start up to n-1 simple_forward NFs. For simplicity, we'll start one simple_forward NF.
- The NF will have service ID of 2. It also forwards packets to the NF with service ID 1.
Expand Down
8 changes: 4 additions & 4 deletions docs/Install.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Check System

Install the Linux Kernel headers package for your kernel version.
```sh
sudo apt-get install build-essential linux-headers-$(uname -r) git
sudo apt-get install build-essential linux-headers-$(uname -r) git bc
```
If your distribution didn't come with Python or came with an earlier version, you will need to install Python 3 v3.4+.

Expand Down Expand Up @@ -116,7 +116,7 @@ Set up Environment

7. Disable ASLR since it makes sharing memory with NFs harder:
```sh
sudo sh -c "echo 0 > /proc/sys/kernel/randomize_va_space"
sudo sh -c "echo 0 > /proc/sys/kernel/randomize_va_space"
```

Configure and compile DPDK
Expand Down Expand Up @@ -174,10 +174,10 @@ Make and test openNetVM

3. Run openNetVM manager

Run openNetVM manager to use 3 cores (1 for displaying statistics, 1 for handling TX queues, 1 for handling manager RX queues), to use 1 NIC port (hexadecimal portmask), 0xF8 for the NF coremask (cores 3, 4, 5, 6, 7), and to use stdout for the statistics console:
Run openNetVM manager to use 3 cores (1 for displaying statistics, 1 for handling TX queues, 1 for handling manager RX queues; set to cores 0, 1 and 2, respectively, by default), to use 1 NIC port (hexadecimal portmask), 0xF8 for the NF coremask (cores 3, 4, 5, 6, 7), and to use stdout for the statistics console:

```sh
./onvm/go.sh 0,1,2 1 0xF8 -s stdout
./onvm/go.sh -k 1 -n 0xF8 -s stdout
```

You should see information regarding the NIC port that openNetVM is using, and openNetVM manager statistics will be displayed.
Expand Down
2 changes: 1 addition & 1 deletion onvm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Options:
Usage
--
The manager default base virtual address is by default set to `0x7f000000000`. To configure to a specific address please use '--base-virtaddr' option, please use the `-a` flag for the onvm_mgr:
- `onvm/go.sh 0,1,2 1 0x3F8 -s stdout -a 0x7f000000000`
- `onvm/go.sh -k 1 -n 0x3F8 -s stdout -a 0x7f000000000`

NF Library
--
Expand Down
216 changes: 183 additions & 33 deletions onvm/go.sh
Original file line number Diff line number Diff line change
@@ -1,37 +1,101 @@
#!/bin/bash

function usage {
echo "$0 CPU-LIST PORTMASK NF-COREMASK [-r NUM-SERVICES] [-d DEFAULT-SERVICE] [-s STATS-OUTPUT] [-p WEB-PORT-NUMBER] [-z STATS-SLEEP-TIME]"
echo "$0 -k PORTMASK -n NF-COREMASK [-m MANAGER CORES] [-r NUM-SERVICES] [-d DEFAULT-SERVICE] [-s STATS-OUTPUT] [-p WEB-PORT-NUMBER] [-z STATS-SLEEP-TIME]"
# this works well on our 2x6-core nodes
echo "$0 0,1,2,3 3 0xF0 --> cores 0,1,2 and 3 with ports 0 and 1, with NFs running on cores 4,5,6,7"
echo -e "\tCores will be used as follows in numerical order:"
echo "$0 -k 3 -n 0xF0 --> cores 0,1,2, with ports 0 and 1, with NFs running on cores 4,5,6,7"
echo -e "\tBy default, cores will be used as follows in numerical order:"
echo -e "\t\tRX thread, TX thread, ..., TX thread for last NF, Stats thread"
echo -e "$0 0,1,2,3 3 0xF0 -s web"
echo -e "$0 -k 3 -n 0xF0 -m 2,3,4"
echo -e "\tRuns ONVM the same way as above, but manually configures cores 2, 3 and 4 to be used as stated"
echo -e "$0 -k 3 -n 0xF0 -m 2,3,4 -s web"
echo -e "\tRuns ONVM the same way as above, but prints statistics to the web browser"
echo -e "$0 0,1,2,3 3 0xF0 -s web -p 9000"
echo -e "$0 -k 3 -n 0xF0 -m 2,3,4 -s web -p 9000"
echo -e "\tRuns OVNM the same as above, but runs the web stats on port 9000 instead of defaulting to 8080"
echo -e "$0 0,1,2,3 3 0xF0 -s stdout"
echo -e "$0 -k 3 -n 0xF0 -m 2,3,4 -s stdout"
echo -e "\tRuns ONVM the same way as above, but prints statistics to stdout"
echo -e "$0 0,1,2,3 3 0xF0 -s stdout -c"
echo -e "$0 -k 3 -n 0xF0 -m 2,3,4 -s stdout -c"
echo -e "\tRuns ONVM the same way as above, but enables shared cpu support"
echo -e "$0 0,1,2,3 3 0xF0 -s stdout -t 42"
echo -e "$0 -k 3 -n 0xF0 -m 2,3,4 -s stdout -t 42"
echo -e "\tRuns ONVM the same way as above, but shuts down after 42 seconds"
echo -e "$0 0,1,2,3 3 0xF0 -s stdout -l 64"
echo -e "$0 -k 3 -n 0xF0 -m 2,3,4 -s stdout -l 64"
echo -e "\tRuns ONVM the same way as above, but shuts down after receiving 64 million packets"
echo -e "$0 0,1,2,3 3 0xF0 -s stdout -v"
echo -e "$0 -k 3 -n 0xF0 -m 2,3,4 -s stdout -v"
echo -e "\tRuns ONVM the same way as above, but prints statistics to stdout in extra verbose mode"
echo -e "$0 0,1,2,3 3 0xF0 -s stdout -vv"
echo -e "$0 -k 3 -n 0xF0 -m 2,3,4 -s stdout -vv"
echo -e "\tRuns ONVM the same way as above, but prints statistics to stdout in raw data dump mode"
echo -e "$0 0,1,2,3 3 0xF0 -a 0x7f000000000 -s stdout"
echo -e "$0 -k 3 -n 0xF0 -m 2,3,4 -a 0x7f000000000 -s stdout"
echo -e "\tRuns ONVM the same way as above, but adds a --base-virtaddr dpdk parameter to overwrite default address"
echo -e "$0 0,1,2,3 3 0xF0 -r 10 -d 2"
echo -e "$0 -k 3 -n 0xF0 -m 2,3,4 -r 10 -d 2"
echo -e "\tRuns ONVM the same way as above, but limits max service IDs to 10 and uses service ID 2 as the default"
exit 1
}

cpu=$1
ports=$2
nf_cores=$3
# User can still use legacy syntax for backwards compatibility. Check syntax of input
# Check validity of core input
core_check="^([0-8]+,){2}([0-8]+)(,[0-8]+)*$"
EthanBaron14 marked this conversation as resolved.
Show resolved Hide resolved
port_check="^[0-9]+$"
nf_check="^0x[0-9A-F]+$"
flag_check="^-[a-z]$"
# Check for argument matches
[[ $1 =~ $core_check ]]
if [[ -n ${BASH_REMATCH[0]} ]]
then
core_match=true
else
core_match=false
fi
[[ $2 =~ $port_check ]]
if [[ -n ${BASH_REMATCH[0]} ]]
then
port_match=true
else
port_match=false
fi
[[ $3 =~ $nf_check ]]
if [[ -n ${BASH_REMATCH[0]} ]]
then
nf_match=true
else
nf_match=false
fi

# Make sure someone isn't inputting the cores incorrectly and they are using legacy syntax
# The flag regex check ensures that the user is trying to input a flag, which is an indicator that they are using the new syntax
if [[ ! $1 =~ $flag_check ]] && (! $core_match || ! $port_match || ! $nf_match)
then
if ( ! $core_match && ( $port_match || $nf_match ))
then
# This verifies that the user actually tried to input the cores but did so incorrectly
echo "Error: Invalid Manager Cores. Proper syntax: $0 <cores> <port mask> <NF cores> [OPTIONS]"
echo "Example: $0 0,1,2 1 0xF8 -s stdout"
exit 1
elif ( ! $port_match && ( $core_match || $nf_match ))
then
# This verifies that the user actually tried to input the port mask but did so incorrectly
echo "Error: Invalid Port Mask. Proper syntax: $0 <cores> <port mask> <NF cores> [OPTIONS]"
echo "Example: $0 0,1,2 1 0xF8 -s stdout"
exit 1
elif ( ! $nf_match && ($core_match || $port_match ))
then
# This verifies that the user actually tried to input the NF core mask but did so incorrectly
echo "Error: Invalid NF Core Mask. Proper syntax: $0 <cores> <port mask> <NF cores> [OPTIONS]"
echo "Example: $0 0,1,2 1 0xF8 -s stdout"
exit 1
# We should never get here, but just a catch-all situation
else
echo "Error: Invalid input."
echo ""
usage
fi
elif $core_match && $port_match && $nf_match
then
script_name=$0
cpu=$1
ports=$2
nf_cores=$3
shift 3
fi

SCRIPT=$(readlink -f "$0")
SCRIPTPATH=$(dirname "$SCRIPT")
Expand All @@ -46,23 +110,7 @@ then
exit 1
fi

shift 3

# Verify that bc is installed
if [[ -z $(command -v bc) ]]
then
echo "Error: bc is not installed. Install using:"
echo " sudo apt-get install bc"
echo "See dependencies for more information"
exit 1
fi

if [ -z "$nf_cores" ]
then
usage
fi

while getopts "a:r:d:s:t:l:p:z:cv" opt; do
while getopts "a:r:d:s:t:l:p:z:cvm:k:n:" opt; do
EthanBaron14 marked this conversation as resolved.
Show resolved Hide resolved
case $opt in
a) virt_addr="--base-virtaddr=$OPTARG";;
r) num_srvc="-r $OPTARG";;
Expand All @@ -74,11 +122,97 @@ while getopts "a:r:d:s:t:l:p:z:cv" opt; do
z) stats_sleep_time="-z $OPTARG";;
c) shared_cpu_flag="-c";;
v) verbosity=$((verbosity+1));;
m)
# User is trying to set CPU cores but has already done so using legacy syntax
if [[ -n $cpu ]]
then
echo "Error: Cannot use manual manager core flag with legacy syntax. Proper syntax: $script_name <cores> <port mask> <NF cores> [OPTIONS]"
echo "Example: $script_name 0,1,2 1 0xF8 -s stdout"
exit 1
else
cpu=$OPTARG
fi;;
k)
# User is trying to set port mask but has already done so using legacy syntax
if [[ -n $ports ]]
then
echo "Error: Cannot use manual port mask flag with legacy syntax. Proper syntax: $script_name <cores> <port mask> <NF cores> [OPTIONS]"
echo "Example: $script_name 0,1,2 1 0xF8 -s stdout"
exit 1
else
ports=$OPTARG
fi;;
n)
# User is trying to set NF core mask but has already done so using legacy syntax
if [[ -n $nf_cores ]]
then
echo "Error: Cannot use manual NF core mask flag with legacy syntax. Proper syntax: $script_name <cores> <port mask> <NF cores> [OPTIONS]"
echo "Example: $script_name 0,1,2 1 0xF8 -s stdout"
exit 1
else
nf_cores=$OPTARG
fi;;
\?) echo "Unknown option -$OPTARG" && usage
;;
esac
done

# Verify that dependency bc is installed
if [[ -z $(command -v bc) ]]
then
echo "Error: bc is not installed. Install using:"
echo " sudo apt-get install bc"
echo "See dependencies for more information"
exit 1
fi

# Check for ports flag
if [ -z "$ports" ]
then
echo "Error: Port Mask not set. openNetVM requires that a Port Mask be set using -k <port mask> using a hexadecimal number (without 0x)"
echo ""
usage
# Check port mask
elif [[ ! $ports =~ $port_check ]]
then
echo "Error: Invalid port mask. Check input and try again."
echo ""
usage
fi

# Check for nf_cores flag
if [ -z "$nf_cores" ]
then
echo "Error: NF Core Mask not set. openNetVM requires that a NF Core Mask be set using -n <nf mask> using a hexadecimal number (starting with 0x)"
echo ""
usage
# Check NF core mask
elif [[ ! $nf_cores =~ $nf_check ]]
then
echo "Error: Invalid NF core mask. Check input and try again."
echo ""
usage
fi

# Check for CPU core flag
if [ -z "$cpu" ]
then
echo "INFO: Using default CPU cores 0,1,2"
echo ""
cpu="0,1,2"
# Check CPU cores
elif [[ ! $cpu =~ $core_check ]]
then
echo "Error: Invalid CPU cores. openNetVM accepts 3 or more cores. Check input and try again."
echo ""
usage
fi

if [ -z "$nf_cores" ]
then
usage
fi

# Convert the port mask to binary
# Using bc where obase=2 indicates the output is base 2 and ibase=16 indicates the output is base 16
ports_bin=$(echo "obase=2; ibase=16; $ports" | bc)
Expand All @@ -94,6 +228,22 @@ then
exit 1
fi

# Trim 0x from NF mask
nf_cores_trimmed=${nf_cores:2}
# Convert nf_cores to compare to cpu
nf_cores_trimmed=$(echo "obase=10; ibase=16; $nf_cores_trimmed" | bc)
# Convert cpu to separate
cpu_separated=$(echo $cpu | tr "," "\n")
for core in $cpu_separated
do
if (( nf_cores_trimmed & (1 << (core)) ))
then
echo "WARNING: Manager and NF cores overlap."
echo ""
break
fi
done

verbosity_level="-v $verbosity"

# If base virtual address has not been set by the user, set to default.
Expand Down