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

Deprecate reconfigurable flag #903

Merged
merged 2 commits into from
Aug 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 0 additions & 3 deletions src/program/lwaftr/bench/README
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ Usage: bench CONF IPV4-IN.PCAP IPV6-IN.PCAP
as the identifier. This must be unique amongst
other snabb processes.
--cpu <cpu> Bind lwAFTR bench to the given CPU
--reconfigurable Allow run-time configuration query and update.
This runs as two processes, a leader and a
follower, rather than just one.

Run the lwAFTR with input from IPV4-IN.PCAP and IPV6-IN.PCAP. The bench
command is used to get an idea of the raw speed of the lwaftr without
Expand Down
43 changes: 14 additions & 29 deletions src/program/lwaftr/bench/bench.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@ function parse_args(args)
function handlers.b(arg) opts.bench_file = arg end
function handlers.y() opts.hydra = true end
function handlers.h() show_usage(0) end
function handlers.reconfigurable() opts.reconfigurable = true end
args = lib.dogetopt(args, handlers, "n:hyb:D:", {
help="h", hydra="y", ["bench-file"]="b", duration="D", name="n", cpu=1,
reconfigurable = 0 })
help="h", hydra="y", ["bench-file"]="b", duration="D", name="n", cpu=1})
if #args ~= 3 then show_usage(1) end
return opts, scheduling, unpack(args)
end
Expand All @@ -50,13 +48,8 @@ function run(args)
end

local graph = config.new()
if opts.reconfigurable then
setup.reconfigurable(scheduling, setup.load_bench, graph, conf,
inv4_pcap, inv6_pcap, 'sinkv4', 'sinkv6')
else
setup.apply_scheduling(scheduling)
setup.load_bench(graph, conf, inv4_pcap, inv6_pcap, 'sinkv4', 'sinkv6')
end
setup.reconfigurable(scheduling, setup.load_bench, graph, conf,
inv4_pcap, inv6_pcap, 'sinkv4', 'sinkv6')
app.configure(graph)

local function start_sampling_for_pid(pid)
Expand All @@ -65,27 +58,19 @@ function run(args)
csv:add_app('sinkv6', { 'input' }, { input=opts.hydra and 'encap' or 'Encap.' })
csv:activate()
end
if opts.reconfigurable then
for _,pid in ipairs(app.configuration.apps['leader'].arg.follower_pids) do
-- The worker will be fed its configuration by the
-- leader, but we don't know when that will all be ready.
-- Just retry if this doesn't succeed.
local function start_sampling()
if not pcall(start_sampling_for_pid, pid) then
io.stderr:write("Waiting on follower "..pid.." to start "..
"before recording statistics...\n")
timer.activate(timer.new('retry_csv', start_sampling, 1e9))
end
end
timer.activate(timer.new('spawn_csv_stats', start_sampling, 10e6))
for _,pid in ipairs(app.configuration.apps['leader'].arg.follower_pids) do
-- The worker will be fed its configuration by the
-- leader, but we don't know when that will all be ready.
-- Just retry if this doesn't succeed.
local function start_sampling()
if not pcall(start_sampling_for_pid, pid) then
io.stderr:write("Waiting on follower "..pid.." to start "..
"before recording statistics...\n")
timer.activate(timer.new('retry_csv', start_sampling, 1e9))
end
end
else
start_sampling_for_pid(S.getpid())
timer.activate(timer.new('spawn_csv_stats', start_sampling, 10e6))
end

if not opts.reconfigurable then
-- The leader does not need all the CPU, only the followers do.
app.busywait = true
end
app.main({duration=opts.duration})
end
5 changes: 5 additions & 0 deletions src/program/lwaftr/doc/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## [2017.07.02]

* Deprecate the --reconfigurable flags in favour of the lwaftr always
being reconfigurable.

## [2017.07.01] - 2017-08-04

* New YANG schema snabb-softwire-v2 replaces old snabb-softwire-v1
Expand Down
3 changes: 0 additions & 3 deletions src/program/lwaftr/run/README
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ Required arguments:
--on-a-stick <pci-addr> One single NIC for INET-side and B4-side

Optional arguments:
--reconfigurable Allow run-time configuration query and update.
This runs as two processes, a leader and a
follower, rather than just one.
--virtio Use virtio-net interfaces instead of Intel 82599
--ring-buffer-size <size> Set Intel 82599 receive buffer size
--cpu <cpu> Bind the lwAFTR to the given CPU
Expand Down
55 changes: 19 additions & 36 deletions src/program/lwaftr/run/run.lua
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ function parse_args(args)
.." (valid values: flush, warn, off)")
end
end
function handlers.reconfigurable() opts.reconfigurable = true end
function handlers.reconfigurable()
io.stderr:write("Warning: the --reconfigurable flag has been deprecated")
io.stderr:write(" as the lwaftr is now always reconfigurable.\n")
end
function handlers.h() show_usage(0) end
lib.dogetopt(args, handlers, "b:c:vD:yhir:n:",
{ conf = "c", v4 = 1, v6 = 1, ["v4-pci"] = 1, ["v6-pci"] = 1,
Expand Down Expand Up @@ -172,13 +175,7 @@ function run(args)
setup_fn, setup_args = setup.load_phy, { 'inetNic', 'b4sideNic' }
end

if opts.reconfigurable then
setup.reconfigurable(scheduling, setup_fn, c, conf, unpack(setup_args))
else
setup.apply_scheduling(scheduling)
setup_fn(c, conf, unpack(setup_args))
end

setup.reconfigurable(scheduling, setup_fn, c, conf, unpack(setup_args))
engine.configure(c)

if opts.verbosity >= 2 then
Expand Down Expand Up @@ -206,40 +203,26 @@ function run(args)
end
csv:activate()
end
if opts.reconfigurable then
local pids = engine.configuration.apps['leader'].arg.follower_pids
for _,pid in ipairs(pids) do
local function start_sampling()
-- The worker will be fed its configuration by the
-- leader, but we don't know when that will all be ready.
-- Just retry if this doesn't succeed.
if not pcall(add_csv_stats_for_pid, pid) then
io.stderr:write("Waiting on follower "..pid.." to start "..
"before recording statistics...\n")
timer.activate(timer.new('retry_csv', start_sampling, 2e9))
end
end
timer.activate(timer.new('spawn_csv_stats', start_sampling, 50e6))
end
else
add_csv_stats_for_pid(S.getpid())
local pids = engine.configuration.apps['leader'].arg.follower_pids
for _,pid in ipairs(pids) do
local function start_sampling()
-- The worker will be fed its configuration by the
-- leader, but we don't know when that will all be ready.
-- Just retry if this doesn't succeed.
if not pcall(add_csv_stats_for_pid, pid) then
io.stderr:write("Waiting on follower "..pid.." to start "..
"before recording statistics...\n")
timer.activate(timer.new('retry_csv', start_sampling, 2e9))
end
end
timer.activate(timer.new('spawn_csv_stats', start_sampling, 50e6))
end
end

if opts.ingress_drop_monitor then
if opts.reconfigurable then
io.stderr:write("Warning: Ingress drop monitor not yet supported "..
"in multiprocess mode.\n")
else
local mon = ingress_drop_monitor.new({action=opts.ingress_drop_monitor})
timer.activate(mon:timer())
end
io.stderr:write("Warning: Ingress drop monitor not yet supported\n")
end

if not opts.reconfigurable then
-- The leader does not need all the CPU, only the followers do.
engine.busywait = true
end
if opts.duration then
engine.main({duration=opts.duration, report={showlinks=true}})
else
Expand Down
6 changes: 3 additions & 3 deletions src/program/lwaftr/tests/propbased/common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ function make_handle_prop_args(name, duration, pidbox)
print("Usage: snabb lwaftr quickcheck prop_sameval PCI_ADDR")
os.exit(1)
end

local pci_addr = prop_args[1]
assert(S.stat(pci.path(pci_addr)),
string.format("Invalid PCI address: %s", pci_addr))

local pid = S.fork()
if pid == 0 then
local cmdline = {"snabb", "lwaftr", "run", "-D", tostring(duration),
"--conf", "program/lwaftr/tests/data/icmp_on_fail.conf",
"--reconfigurable", "--on-a-stick", pci_addr}
"--on-a-stick", pci_addr}
lib.execv(("/proc/%d/exe"):format(S.getpid()), cmdline)
else
pidbox[1] = pid
Expand Down
11 changes: 2 additions & 9 deletions src/program/lwaftr/tests/subcommands/bench_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,12 @@ class TestBench(BaseTestCase):
str(BENCHDATA_DIR / 'ipv6-0550.pcap'),
]

def execute_bench_test(self, cmd_args):
self.run_cmd(cmd_args)
def test_bench(self):
self.run_cmd(self.cmd_args)
self.assertTrue(BENCHMARK_PATH.is_file(),
'Cannot find {}'.format(BENCHMARK_PATH))
BENCHMARK_PATH.unlink()

def test_bench_not_reconfigurable(self):
self.execute_bench_test(self.cmd_args)

def test_bench_reconfigurable(self):
reconf_args = list(self.cmd_args)
reconf_args.insert(3, '--reconfigurable')
self.execute_bench_test(reconf_args)

if __name__ == '__main__':
unittest.main()
2 changes: 1 addition & 1 deletion src/program/lwaftr/tests/subcommands/config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

DAEMON_PROC_NAME = 'config-test-daemon'
DAEMON_ARGS = [
str(SNABB_CMD), 'lwaftr', 'bench', '--reconfigurable',
str(SNABB_CMD), 'lwaftr', 'bench',
'--bench-file', '/dev/null',
'--name', DAEMON_PROC_NAME,
str(DATA_DIR / 'icmp_on_fail.conf'),
Expand Down
28 changes: 7 additions & 21 deletions src/program/lwaftr/tests/subcommands/query_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
RUN_DIR = Path('/var/run/snabb')

@unittest.skipUnless(SNABB_PCI0 and SNABB_PCI1, 'NICs not configured')
class TestQueryStandard(BaseTestCase):
class TestQuery(BaseTestCase):

daemon_args = (
str(SNABB_CMD), 'lwaftr', 'run',
Expand Down Expand Up @@ -71,27 +71,13 @@ def test_query_by_name(self):
name_args.extend(('--name', DAEMON_PROC_NAME))
self.execute_query_test(name_args)


@unittest.skipUnless(SNABB_PCI0 and SNABB_PCI1, 'NICs not configured')
class TestQueryReconfigurable(TestQueryStandard):

daemon_args = (
str(SNABB_CMD), 'lwaftr', 'run', '--reconfigurable',
'--name', DAEMON_PROC_NAME,
'--conf', str(DATA_DIR / 'no_icmp.conf'),
'--v4', SNABB_PCI0,
'--v6', SNABB_PCI1,
)

def get_all_leader_pids(self):
output = str(self.run_cmd(('ps', 'aux')), ENC)
pids = []
for line in output.splitlines():
if ((SNABB_PCI0 in line) and
('--reconfigurable' in line) and
('grep' not in line)):
pids.append(line.split()[1])
return pids
leaders = []
for instance in RUN_DIR.iterdir():
group = RUN_DIR / instance.name / 'group'
if not group.is_symlink():
leaders.append(instance.name)
return leaders

def get_leader_pid(self):
for pid in self.get_all_leader_pids():
Expand Down
12 changes: 2 additions & 10 deletions src/program/lwaftr/tests/subcommands/run_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,10 @@ class TestRun(BaseTestCase):
'--v6', SNABB_PCI1
)

def execute_run_test(self, cmd_args):
output = self.run_cmd(cmd_args)
def test_run(self):
output = self.run_cmd(self.cmd_args)
self.assertIn(b'link report', output,
b'\n'.join((b'OUTPUT', output)))

def test_run_not_reconfigurable(self):
self.execute_run_test(self.cmd_args)

def test_run_reconfigurable(self):
reconf_args = list(self.cmd_args)
reconf_args.insert(3, '--reconfigurable')
self.execute_run_test(reconf_args)

if __name__ == '__main__':
unittest.main()