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

Merge with lwaftr v2019.06.01 #1448

Merged
merged 110 commits into from
Nov 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
a805f92
Re-enable NUMA memory binding on newer kernels
wingo Feb 21, 2019
3809be2
Detect version mismatch when loading compiled YANG configurations
wingo Mar 5, 2019
69764b5
Remove bogus lwaftr benchmarking file
wingo Mar 5, 2019
e7e0f8e
Merge pull request #1210 from Igalia/remove-bogus-benchdata
wingo Mar 5, 2019
e90e492
Merge pull request #1209 from Igalia/revision-in-compiled-file
wingo Mar 5, 2019
a5ddf2f
Merge pull request #1207 from Igalia/revisit-numa-bitmasks
wingo Mar 5, 2019
7f2a1d2
Fix PCI affinity check for --preferred NUMA binding
wingo Mar 5, 2019
9f37939
Merge pull request #1211 from Igalia/affinity-check
wingo Mar 5, 2019
a27d8b3
Add more system performance diagnostics
wingo Mar 5, 2019
89e855c
Merge pull request #1212 from Igalia/isolcpus-check
wingo Mar 5, 2019
ecd443c
Detect irqbalance presence and suggest remedy
wingo Mar 5, 2019
9f7177b
Fix uninstall advice for irqbalance
wingo Mar 6, 2019
7ab4ff9
Merge pull request #1213 from Igalia/irqbalance-check
wingo Mar 6, 2019
e1af4f9
Improve snabb lwaftr run --help
wingo Mar 7, 2019
a004e9a
Fixup to snabb lwaftr run --help
wingo Mar 7, 2019
8894c8f
Merge pull request #1214 from Igalia/lwaftr-help
wingo Mar 7, 2019
fbf585e
Refactor packetblaster lwaftr to re-use vlan, arp, ndp, v4v6
wingo Mar 8, 2019
7886344
Separate B4 and internet lwaftr load generation apps
wingo Mar 8, 2019
14c7255
Allow different IPv4 MAC addresses and VLAN tags; fix bugs
wingo Mar 8, 2019
b63f196
Fix whitespace
wingo Mar 8, 2019
1b74cf9
Fix source IPv6 from B4, and better interleaving of streams
wingo Mar 8, 2019
e7a60d3
Fix frame sizes. Update test files for fresh checksums. Allow for o…
wingo Mar 8, 2019
94d123a
Fix inc_ipv4
wingo Mar 8, 2019
f1050ec
Start ingress drop monitor in grace period
wingo Mar 15, 2019
bd822d9
Bump snabb-softwire-v2 revision dateD
wingo Mar 15, 2019
516306a
Add v2018.09.03 changelog
wingo Mar 15, 2019
daa47c7
Merge pull request #1217 from Igalia/ingress-drop-grace
wingo Mar 15, 2019
02a00e9
Merge pull request #1219 from Igalia/changelog-2018.09.03
wingo Mar 15, 2019
e531713
Merge pull request #1215 from Igalia/packetblaster-lwaftr
wingo Mar 15, 2019
2fdb05b
Merge pull request #1218 from Igalia/schema-version
wingo Mar 15, 2019
acd54d9
Update version to v2018.09.03
wingo Mar 15, 2019
3e73c2f
Merge pull request #1220 from Igalia/update-version
wingo Mar 15, 2019
707aee5
lib.rrd: fix a bug due to implicit casting
eugeneia Sep 7, 2019
05be3a0
lwaftr/apps: add memory_info.MemoryLog app to log mem in use to RRD
eugeneia Sep 7, 2019
7d56e51
lwaftr: configure MemoryLog app for lwaftr instances
eugeneia Sep 9, 2019
286a31f
lwaftr: replace MemoryLog w/ MemoryCounter (ptree man. gen. rrd)
eugeneia Sep 10, 2019
e3ed4ea
Merge Snabb release v2019.06 "Deltadromeus" into lwaftr
eugeneia Sep 12, 2019
848ed4a
lib.gauge: add SHM object type for gauge values
eugeneia Sep 13, 2019
77b1400
apps.lwaftr.memory_info: use lib.gauge to expose a gauge SHM object
eugeneia Sep 13, 2019
4c22c41
lib.pree: support aggregating and RRD generation for SHM gauges
eugeneia Sep 13, 2019
bb05b5b
Merge branch 'lwaftr-memory-info' into lwaftr
eugeneia Sep 13, 2019
983094a
Add new ietf-softwire-br, ietf-softwire-common schemas
eugeneia Sep 16, 2019
b019947
Add discontinuity-time to snabb-softwire-v2's softwire-state
eugeneia Sep 17, 2019
a39495e
lwaftr: updates for draft-ietf-softwire-yang-16
eugeneia Sep 17, 2019
d3a641d
ietf-softwire-br: temp. patch around unsupported if-feature bool exp
eugeneia Sep 17, 2019
b188164
program.lwaftr.tests.propbased.genyang: fix a bug wrt empty structs
eugeneia Sep 17, 2019
2e51c86
lib.ptree.support.snabb-softwrite-v2: add test cases, fix bugs
eugeneia Sep 18, 2019
d6b6ea0
lwaftr: map ietf instance name to (singleton) lwaftr name
eugeneia Sep 19, 2019
5a29720
lib.ptree: pass current config to translator.get_state
eugeneia Sep 19, 2019
d3d1f04
lwaftr/tests/test_env.py: add opt. expected ret. code arg to run_cmd
eugeneia Sep 19, 2019
80ac638
lwaftr: add more test cases, bug fixes for support.snabb-softwire-v2
eugeneia Sep 19, 2019
7a17eba
snabb-softwire-v2.yang: declare softwire/b4-ipv6 unique
eugeneia Sep 19, 2019
189c482
src/Makefile: s/-/_/g in TESTMODS to allow selftests...
eugeneia Sep 19, 2019
7f00119
lib.ptree.support.snabb-softwire-v2: remove left over debug prints
eugeneia Sep 19, 2019
fc0877e
lib.ptree.support.snabb-softwire-v2: fix error reporting bugs
eugeneia Sep 19, 2019
59d5f38
Revert "ietf-softwire-br: temp. patch around unsupported if-feature b…
eugeneia Sep 20, 2019
f8da9c7
lib.maxpc: add match.string
eugeneia Sep 20, 2019
caf686d
lib.yang.schema: implement parsing of YANG 1.1 if-feature expressions
eugeneia Sep 20, 2019
c3df85a
lib.yang.schema: remove debug tracing (see previous commit)
eugeneia Sep 20, 2019
48bdf76
Merge branch 'lwaftr-softwire-16' into lwaftr-next
eugeneia Sep 23, 2019
2a73e9e
Add `snabb rrdcat' tool to summarize RRD archives
eugeneia Sep 24, 2019
68faaa9
Merge branch 'lwaftr-drop-journal' into lwaftr-next
eugeneia Sep 25, 2019
7b9fb52
intel_mp: count total packets dropped in rxdrop counter
eugeneia Sep 25, 2019
cb17d43
intel_mp: include sum of all queue drop counters in rxdrop
eugeneia Sep 25, 2019
bea697a
Merge branch 'intel_mp-82599-rxdrop-fix' into lwaftr-next
eugeneia Sep 25, 2019
433f716
snabb rrdcat: plot error lines only when bounds are known
eugeneia Sep 26, 2019
cd916f6
Merge branch 'lwaftr-drop-journal' into lwaftr-next
eugeneia Sep 26, 2019
555e4c8
lib.ctable: avoid GC in lookup streamer
eugeneia Oct 4, 2019
ac65ee0
BTLookupQueue: avoid cdata allocation by get_lookup
eugeneia Oct 7, 2019
daf7bdb
lib.binary_search: cache and reuse generated variants
eugeneia Oct 8, 2019
f7d0f8c
lwaftr.rangemap: cache and reuse entry types to avoid leak of ctypes
eugeneia Oct 8, 2019
616067e
lib.multi_copy: cache and reuse generated variants to avoid leaks
eugeneia Oct 8, 2019
83a8fd0
lib.hash.siphash: cache and reuse generated variants to avoid leaks
eugeneia Oct 8, 2019
c170809
lib.ctable: remove redundant memoization of binary_search.gen
eugeneia Oct 8, 2019
06f8396
lib.yang, lib.ptree: cleanup temporary SHM files after use
eugeneia Oct 8, 2019
0f695d9
timers.ingress_drop_monitor: use app:get_rxstats() (was app:rxdrop())
eugeneia Oct 8, 2019
0c93c41
lib.ptree: do not aggregate (ignore) counters that are symlinks
eugeneia Oct 8, 2019
fac8f71
Merge branch 'lwaftr-issue-1221' into lwaftr-next
eugeneia Oct 9, 2019
1771279
Merge branch 'lwaftr-ingress-drop-monitor-per-queue' into lwaftr-next
eugeneia Oct 9, 2019
ddd5339
Merge branch 'lwaftr-ptree-no-counter-symlinks' into lwaftr-next
eugeneia Oct 9, 2019
9df4d19
Merge branch 'lwaftr-sink' into lwaftr-next
eugeneia Oct 9, 2019
b4c9073
Fix promotion of lib.fibers.timer events from outer to inner wheel
wingo Oct 14, 2019
b07e542
Merge PR #1231 (fibers: fix timer ev. promotion) into lwaftr-next
eugeneia Oct 14, 2019
20c303c
Make previous commit (0c93c4187) robust against races.
eugeneia Oct 14, 2019
f3a4bfa
Merge branch 'lwaftr-ptree-no-counter-symlinks' into lwaftr-next
eugeneia Oct 14, 2019
2b02bbd
Merge pull request #1231 from Igalia/fix-timer-underflow
wingo Oct 14, 2019
775fd28
Revert "snabb-softwire-v2.yang: declare softwire/b4-ipv6 unique"
eugeneia Oct 15, 2019
791a8a9
snabb-softwire-v2: warn on duplicate b4-ipv6 when transl. to ietf
eugeneia Oct 15, 2019
9b2af04
Merge branch 'lwaftr-softwire-16' into lwaftr-next
eugeneia Oct 15, 2019
b3916a2
support.snabb-softwire-v2: make sure instances share no state
eugeneia Oct 15, 2019
f37a745
Merge branch 'lwaftr-softwire-16' into lwaftr-next
eugeneia Oct 15, 2019
47c2a1f
Merge pull request #1230 from eugeneia/lwaftr-ptree-no-counter-symlinks
wingo Oct 25, 2019
0e9e5d9
Make memory monitor a timer instead of an app
wingo Oct 25, 2019
edc4b9a
Merge remote-tracking branch 'eugeneia/lwaftr-softwire-16' into lwaftr
wingo Oct 25, 2019
cfceaf4
Merge pull request #16 from Igalia/lwaftr-memory-info
eugeneia Oct 25, 2019
cc4acb5
Revert "lib.ptree: do not aggregate (ignore) counters that are symlinks"
wingo Oct 25, 2019
15cdb3e
Merge pull request #1232 from Igalia/revert-1230-lwaftr-ptree-no-coun…
wingo Oct 25, 2019
a124d45
Merge remote-tracking branch 'eugeneia/lwaftr-memory-info' into lwaftr
wingo Oct 25, 2019
143c9a8
Merge pull request #1225 from eugeneia/lwaftr-drop-journal
wingo Oct 25, 2019
1146b27
Merge remote-tracking branch 'upstream/revert-1230-lwaftr-ptree-no-co…
eugeneia Oct 25, 2019
4f796e0
Merge pull request #1228 from eugeneia/lwaftr-issue-1221
wingo Oct 25, 2019
8ff1565
Merge pull request #1229 from eugeneia/lwaftr-ingress-drop-monitor-pe…
wingo Oct 25, 2019
19e5c3d
Merge remote-tracking branch 'eugeneia/lwaftr-next' into lwaftr
wingo Oct 25, 2019
79075f5
Snabb lwAFTR 2019.06.01
wingo Oct 25, 2019
1577238
Fix markdown syntax
wingo Oct 25, 2019
be06560
Add link to upstream release notes
wingo Oct 25, 2019
a283e7b
Add link to YANG module
wingo Oct 25, 2019
831ce6c
Merge pull request #1234 from Igalia/changelog-2019.06.01
wingo Oct 25, 2019
c2015ea
Fix release benchmarks to always specify CPU
wingo Oct 28, 2019
c5191f6
Merge pull request #1235 from Igalia/release-benchmarks
wingo Oct 28, 2019
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
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2019.01
2019.06.01
27 changes: 12 additions & 15 deletions lib/ljsyscall/syscall/linux/syscalls.lua
Original file line number Diff line number Diff line change
Expand Up @@ -483,33 +483,30 @@ local function get_maxnumnodes()
return math.floor(((#line+1)/9)*32)
end
end
-- If we don't know, guess that the system has a max of 1024 nodes.
return 1024
end

local function ensure_bitmask(mask, size)
if ffi.istype(t.bitmask, mask) then return mask end
return t.bitmask(mask, size or get_maxnumnodes())
end

function S.get_mempolicy(mode, mask, addr, flags)
mode = mode or t.int1()
local size
if ffi.istype(t.bitmask, mask) then
-- if mask was provided by the caller, then use its size
-- and let the syscall error if it's too small
size = ffi.cast("uint64_t", tonumber(mask.size))
else
local mask_for_size = t.bitmask(mask)
-- Size should be at least equals to maxnumnodes.
size = ffi.cast("uint64_t", math.max(tonumber(mask_for_size.size), get_maxnumnodes()))
mask = t.bitmask(mask, tonumber(size))
end
local ret, err = C.get_mempolicy(mode, mask.mask, size, addr or 0, c.MPOL_FLAG[flags])
mask = ensure_bitmask(mask);
local ret, err = C.get_mempolicy(mode, mask.mask, mask.size, addr or 0, c.MPOL_FLAG[flags])
if ret == -1 then return nil, t.error(err or errno()) end
return { mode=mode[0], mask=mask }
end
function S.set_mempolicy(mode, mask)
mask = mktype(t.bitmask, mask)
mask = ensure_bitmask(mask);
return retbool(C.set_mempolicy(c.MPOL_MODE[mode], mask.mask, mask.size))
end

function S.migrate_pages(pid, from, to)
from = mktype(t.bitmask, from)
to = mktype(t.bitmask, to)
from = ensure_bitmask(from);
to = ensure_bitmask(to, from.size)
assert(from.size == to.size, "incompatible nodemask sizes")
return retbool(C.migrate_pages(pid or 0, from.size, from.mask, to.mask))
end
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ LUAJIT_A := ../lib/luajit/src/raptorjit.a
# for each module that has a top-level selftest () function.
TESTMODS = $(shell find . -regex '[^\#]*\.\(lua\|dasl\)' -printf '%P ' | \
xargs grep -s -l '^function selftest *[[:punct:]]' | \
sed -e 's_\.lua__' -e 's_\.dasl__' -e 's_/_._g')
sed -e 's_\.lua__' -e 's_\.dasl__' -e 's_/_._g' -e 's/-/_/g')

# TESTSCRIPTS expands to:
# lib/watchdog/selftest.sh ...
Expand Down
8 changes: 7 additions & 1 deletion src/apps/intel_mp/intel_mp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,14 @@ EEC 0x10010 - RW EEPROM/Flash Control Register
EIMC 0x00888 - RW Extended Interrupt Mask Clear
ERRBC 0x04008 - RC Error Byte Count
FCCFG 0x03D00 - RW Flow Control Configuration
FCOERPDC 0x0241C - RC Rx Packets Dropped Count
FCTRL 0x05080 - RW Filter Control
HLREG0 0x04240 - RW MAC Core Control 0
ILLERRC 0x04004 - RC Illegal Byte Error Count
LINKS 0x042A4 - RO Link Status Register
MAXFRS 0x04268 - RW Max Frame Size
MFLCN 0x04294 - RW MAC Flow Control Register
MNGPDC 0x040B8 - RO Management Packets Dropped Count
MRQC 0x0EC80 - RW Multiple Receive Queues Command Register
MTQC 0x08120 - RW Multiple Transmit Queues Command Register
PFVTCTL 0x051B0 - RW PF Virtual Control Register
Expand Down Expand Up @@ -1336,7 +1338,11 @@ function Intel82599:promisc ()
return band(self.r.FCTRL(), lshift(1, 9)) ~= 0ULL
end
function Intel82599:rxbytes () return self.r.GORC64() end
function Intel82599:rxdrop () return self.r.QPRDC[0]() end
function Intel82599:rxdrop ()
local rxdrop = self.r.MNGPDC() + self.r.FCOERPDC()
for i=0,15 do rxdrop = rxdrop + self.r.QPRDC[i]() end
return rxdrop
end
function Intel82599:rxerrors ()
return self.r.CRCERRS() + self.r.ILLERRC() + self.r.ERRBC() +
self.r.RUC() + self.r.RFC() + self.r.ROC() + self.r.RJC()
Expand Down
1 change: 0 additions & 1 deletion src/apps/lwaftr/binding_table.lua
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ function BTLookupQueue:get_lookup(n)
local streamer = self.streamer
local pkt, b4_ipv6, br_ipv6
pkt = self.packet_queue[n]
self.packet_queue[n] = nil
if not streamer:is_empty(n) then
b4_ipv6 = streamer.entries[n].value.b4_ipv6
br_ipv6 = streamer.entries[n].value.br_address
Expand Down
10 changes: 9 additions & 1 deletion src/apps/lwaftr/rangemap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ local function make_entry_type(value_type)
value_type)
end

local entry_type_cache = {}
local function get_entry_type(value_type)
if not entry_type_cache[value_type] then
entry_type_cache[value_type] = make_entry_type(value_type)
end
return entry_type_cache[value_type]
end

local function make_entries_type(entry_type)
return ffi.typeof('$[?]', entry_type)
end
Expand Down Expand Up @@ -63,7 +71,7 @@ end
function RangeMapBuilder.new(value_type)
local builder = {}
builder.value_type = value_type
builder.entry_type = make_entry_type(builder.value_type)
builder.entry_type = get_entry_type(builder.value_type)
builder.type = make_entries_type(builder.entry_type)
builder.equal_fn = make_equal_fn(builder.value_type)
builder.entries = {}
Expand Down
23 changes: 22 additions & 1 deletion src/lib/README.numa.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@ for some reason the current process is not bound to a NUMA node. See
[../doc/performance-tuning.md] for more notes on getting good
performance out of your Snabb program.

— Function **bind_to_cpu** *cpu*
— Function **bind_to_cpu** *cpu* *skip_perf_checks*
Bind the current process to *cpu*, arranging for it to only ever be
run on that CPU. Additionally, call **bind_to_numa_node** on the NUMA
node corresponding to *cpu*.

Unless the optional argument *skip_perf_checks* is true, also run some
basic checks to verify that the given core is suitable for processing
low-latency network traffic: that the CPU has the `performance` scaling
governor, that it has been reserved from the kernel scheduler, and so
on, printing out any problems to `stderr`.

— Function **bind_to_numa_node** *node*
Bind the current process to NUMA node *node*, arranging for it to only
ever allocate memory local to that NUMA node. Additionally, migrate
Expand Down Expand Up @@ -55,3 +61,18 @@ node bound by **bind_to_numa_node**, if present, and in any case that
all *addrs* are on the same NUMA node. If *require_affinity* is true
(not the default), then error if a problem is detected, otherwise just
print a warning to the console.

— Function **parse_cpuset** *cpus*
A helper function to parse a CPU set from a string. A CPU set is either
the number of a CPU, a range of CPUs, or two or more CPU sets joined by
commas. The result is a table whose keys are the CPUs and whose values
are true (a set). For example, q`parse_cpuset("1-3,5")` will return a
table with keys 1, 2, 3, and 5 bound to `true`.

— Function **node_cpus** *node*
Return a set of CPUs belonging to NUMA node *node*, in the same format
as in **parse_cpuset**.

— Function **isolated_cpus**
Return a set of CPUs that have been "isolated" away from the kernel at
boot via the `isolcpus` kernel boot parameter.
17 changes: 14 additions & 3 deletions src/lib/binary_search.dasl
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ local function assemble (name, prototype, generator)
return ffi.cast(prototype, mcode)
end

local gencache = {} -- Cache for generated variants (reuse if possible.)
function gen(count, entry_type)
local function gen_binary_search(Dst)
if count == 1 then
Expand Down Expand Up @@ -80,9 +81,19 @@ function gen(count, entry_type)
| mov rax, rdi
| ret
end
return assemble("binary_search_"..count,
ffi.typeof("$*(*)($*, uint32_t)", entry_type, entry_type),
gen_binary_search)
-- Assemble binary search variant and cache it unless it has not been
-- previously generated.
if not gencache[entry_type] then
gencache[entry_type] = {}
end
if not gencache[entry_type][count] then
gencache[entry_type][count] =
assemble("binary_search_"..count,
ffi.typeof("$*(*)($*, uint32_t)", entry_type, entry_type),
gen_binary_search)
end
-- Return (now) cached routine.
return gencache[entry_type][count]
end

function selftest ()
Expand Down
63 changes: 3 additions & 60 deletions src/lib/cpuset.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,53 +19,7 @@ do
end
end

local function trim (str)
return str:gsub("^%s", ""):gsub("%s$", "")
end

local function parse_cpulist (cpus)
local ret = {}
cpus = trim(cpus)
if #cpus == 0 then return ret end
for range in cpus:split(',') do
local lo, hi = range:match("^%s*([^%-]*)%s*-%s*([^%-%s]*)%s*$")
if lo == nil then lo = range:match("^%s*([^%-]*)%s*$") end
assert(lo ~= nil, 'invalid range: '..range)
lo = assert(tonumber(lo), 'invalid range begin: '..lo)
assert(lo == math.floor(lo), 'invalid range begin: '..lo)
if hi ~= nil then
hi = assert(tonumber(hi), 'invalid range end: '..hi)
assert(hi == math.floor(hi), 'invalid range end: '..hi)
assert(lo < hi, 'invalid range: '..range)
else
hi = lo
end
for cpu=lo,hi do table.insert(ret, cpu) end
end
return ret
end

local function parse_cpulist_from_file (path)
local fd = assert(io.open(path))
if not fd then return {} end
local ret = parse_cpulist(fd:read("*all"))
fd:close()
return ret
end

local function available_cpus (node)
local function set (t)
local ret = {}
for _,v in pairs(t) do ret[tostring(v)] = true end
return ret
end
local function cpus_in_node (node)
local node_path = '/sys/devices/system/node/node'..node
return set(parse_cpulist_from_file(node_path..'/cpulist'))
end
local function isolated_cpus ()
return set(parse_cpulist_from_file('/sys/devices/system/cpu/isolated'))
end
local function subtract (s, t)
local ret = {}
for k,_ in pairs(s) do
Expand All @@ -75,7 +29,7 @@ local function available_cpus (node)
return ret
end
-- XXX: Add sched_getaffinity cpus.
return subtract(cpus_in_node(node), isolated_cpus())
return subtract(numa.node_cpus(node), numa.isolated_cpus())
end

function CPUSet:bind_to_numa_node()
Expand All @@ -87,7 +41,7 @@ function CPUSet:bind_to_numa_node()
numa.bind_to_numa_node(nodes[1])
local cpus = available_cpus(nodes[1])
assert(#cpus > 0, 'Not available CPUs')
numa.bind_to_cpu(cpus)
numa.bind_to_cpu(cpus, 'skip-perf-checks')
print(("Bound main process to NUMA node: %s (CPU %s)"):format(nodes[1], cpus[1]))
else
print("CPUs available from multiple NUMA nodes: "..table.concat(nodes, ","))
Expand All @@ -96,7 +50,7 @@ function CPUSet:bind_to_numa_node()
end

function CPUSet:add_from_string(cpus)
for _, cpu in ipairs(parse_cpulist(cpus)) do
for cpu,_ in pairs(numa.parse_cpuset(cpus)) do
self:add(cpu)
end
end
Expand Down Expand Up @@ -157,14 +111,3 @@ function CPUSet:release(cpu)
end
error('CPU not found on NUMA node: '..cpu..', '..node)
end

function selftest ()
print('selftest: cpuset')
local cpus = parse_cpulist("0-5,7")
assert(#cpus == 7 and cpus[6] == 5 and cpus[7] == 7)
cpus = parse_cpulist("1")
assert(#cpus == 1 and cpus[1] == 1)
assert(#parse_cpulist("\n") == 0)
assert(#parse_cpulist("") == 0)
print('selftest: ok')
end
31 changes: 8 additions & 23 deletions src/lib/ctable.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@ local ffi = require("ffi")
local C = ffi.C
local S = require("syscall")
local lib = require("core.lib")
local util = require("lib.yang.util")
local binary_search = require("lib.binary_search")
local multi_copy = require("lib.multi_copy")
local siphash = require("lib.hash.siphash")

-- TODO: Move to core/lib.lua.
local memoize = util.memoize
local min, max, floor, ceil = math.min, math.max, math.floor, math.ceil

CTable = {}
Expand Down Expand Up @@ -430,21 +427,6 @@ function CTable:remove(key, missing_allowed)
return true
end

local function generate_multi_copy(width, size)
return multi_copy.gen(width, size)
end
generate_multi_copy = memoize(generate_multi_copy)

local function generate_multi_hash(self, width)
return self.make_multi_hash_fn(width)
end
generate_multi_hash = memoize(generate_multi_hash)

local function generate_binary_search(entries_per_lookup, entry_type)
return binary_search.gen(entries_per_lookup, entry_type)
end
generate_binary_search = memoize(generate_binary_search)

function CTable:make_lookup_streamer(width)
assert(width > 0 and width <= 262144, "Width value out of range: "..width)
local res = {
Expand All @@ -463,6 +445,9 @@ function CTable:make_lookup_streamer(width)
-- more entry.
stream_entries = self.type(width * (self.max_displacement + 1) + 1)
}
-- Pointer to first entry key (cache to avoid cdata allocation.)
local key_offset = 4 -- Skip past uint32_t hash.
res.keys = ffi.cast('uint8_t*', res.entries) + key_offset
-- Give res.pointers sensible default values in case the first lookup
-- doesn't fill the pointers vector.
for i = 0, width-1 do res.pointers[i] = self.entries end
Expand All @@ -475,23 +460,23 @@ function CTable:make_lookup_streamer(width)
-- Compile multi-copy and binary-search procedures that are
-- specialized for this table and this width.
local entry_size = ffi.sizeof(self.entry_type)
res.multi_copy = generate_multi_copy(width, res.entries_per_lookup * entry_size)
res.multi_hash = generate_multi_hash(self, width)
res.binary_search = generate_binary_search(res.entries_per_lookup, self.entry_type)
res.multi_copy = multi_copy.gen(width, res.entries_per_lookup * entry_size)
res.multi_hash = self.make_multi_hash_fn(width)
res.binary_search = binary_search.gen(res.entries_per_lookup, self.entry_type)

return setmetatable(res, { __index = LookupStreamer })
end

function LookupStreamer:stream()
local width = self.width
local entries = self.entries
local keys = self.keys
local pointers = self.pointers
local stream_entries = self.stream_entries
local entries_per_lookup = self.entries_per_lookup
local equal_fn = self.equal_fn

local key_offset = 4 -- Skip past uint32_t hash.
self.multi_hash(ffi.cast('uint8_t*', entries) + key_offset, self.hashes)
self.multi_hash(self.keys, self.hashes)

for i=0,width-1 do
local hash = self.hashes[i]
Expand Down
4 changes: 2 additions & 2 deletions src/lib/fibers/timer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ local function tick_outer(inner, outer)
local ent = pop_node(head)
local idx = math.floor((ent.time - outer.now) * inner.rate)
-- Because of floating-point imprecision it's possible to get an
-- index that is too large by 1.
idx = math.min(idx, WHEEL_SLOTS-1)
-- index that falls just outside [0,WHEEL_SLOTS-1].
idx = math.max(math.min(idx, WHEEL_SLOTS-1), 0)
push_node(ent, inner.slots[idx])
end
outer.cur = band(outer.cur + 1, SLOT_INDEX_MASK)
Expand Down
Loading