Skip to content

Commit

Permalink
program.ipfix.probe_rss: make CPU-pinning configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandergall committed Nov 5, 2020
1 parent bc9211f commit 5a47fde
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/program/ipfix/probe_rss/probe_rss.lua
Expand Up @@ -16,6 +16,7 @@ local main_config = {
hw_rss_scaling = { default = 1 },
rss = { required = true },
cpu_pool = { default = {} },
rss_pin_cpu = { default = false },
rss_jit = { default = nil },
ipfix = { required = true }
}
Expand Down Expand Up @@ -54,7 +55,8 @@ local instance_config = {
embed = { default = true },
weight = { default = 1 },
jit = { default = nil },
busywait = { default = nil }
busywait = { default = nil },
pin_cpu = { default = false },
}
local jit_config = {
v = { default = nil },
Expand Down Expand Up @@ -159,7 +161,8 @@ local function create_workers (probe_config, duration, busywait, jit, logger, lo
end
local node = numa.choose_numa_node_for_pci_addresses(pci_addrs)
local cpu_pool_size = #main.cpu_pool
local function cpu_for_node ()
local function cpu_for_node (activate)
if not activate then return nil end
for n, cpu in ipairs(main.cpu_pool) do
local cpu_node = numa.cpu_get_numa_node(cpu)
if cpu_node == node then
Expand All @@ -168,8 +171,8 @@ local function create_workers (probe_config, duration, busywait, jit, logger, lo
end
return nil
end
local function log_cpu_choice (pid, cpu)
if cpu_pool_size == 0 then return end
local function log_cpu_choice (pid, cpu, activate)
if cpu_pool_size == 0 or not activate then return end
if cpu then
logger:log(string.format("Binding #%d to CPU %d, "
.."NUMA node %d",
Expand Down Expand Up @@ -269,7 +272,7 @@ local function create_workers (probe_config, duration, busywait, jit, logger, lo

local jit = override_jit(jit, instance.jit, od)

local cpu = cpu_for_node()
local cpu = cpu_for_node(instance.pin_cpu)
local worker_expr = string.format(
'require("program.ipfix.lib").run(%s, %s, %s, %s, %s)',
probe.value_to_string(iconfig), tostring(duration),
Expand All @@ -285,7 +288,7 @@ local function create_workers (probe_config, duration, busywait, jit, logger, lo
.."for process #%d ",
collector.ip, collector.port, pool,
pid))
log_cpu_choice(pid, cpu)
log_cpu_choice(pid, cpu, instance.pin_cpu)
shm.create("ipfix_workers/"..pid, "uint64_t")
end,
function(pid)
Expand All @@ -297,7 +300,7 @@ local function create_workers (probe_config, duration, busywait, jit, logger, lo
end
end

local cpu = cpu_for_node()
local cpu = cpu_for_node(main.rss_pin_cpu)
local worker_expr = string.format(
'require("program.ipfix.lib").run_rss(%s, %s, %s, %s, %s, %s, %s)',
probe.value_to_string(main.rss), probe.value_to_string(inputs),
Expand All @@ -310,7 +313,7 @@ local function create_workers (probe_config, duration, busywait, jit, logger, lo
function(pid)
logger:log(string.format("Launched RSS worker process #%d",
pid))
log_cpu_choice(pid, cpu)
log_cpu_choice(pid, cpu, main.rss_pin_cpu)
shm.create("rss_workers/"..pid, "uint64_t")
end,
function(pid)
Expand Down

0 comments on commit 5a47fde

Please sign in to comment.