Skip to content

Commit

Permalink
Monitor ingress packet drops and jit flush if threshold exceeded
Browse files Browse the repository at this point in the history
  • Loading branch information
dpino committed May 2, 2016
1 parent 38d4585 commit 22b4a8f
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/apps/intel/intel10g.lua
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ do
end
end

function M_sf:ingress_packet_drops ()
return self.qs.QPRDC[0]()
end

function M_sf:init_snmp ()
-- Rudimentary population of a row in the ifTable MIB. Allocation
-- of the ifIndex is delegated to the SNMP agent via the name of
Expand Down Expand Up @@ -717,6 +721,7 @@ M_pf.set_promiscuous_mode = M_sf.set_promiscuous_mode
M_pf.init_receive = M_sf.init_receive
M_pf.init_transmit = M_sf.init_transmit
M_pf.wait_linkup = M_sf.wait_linkup
M_pf.ingress_packet_drops = M_sf.ingress_packet_drops

function M_pf:set_vmdq_mode ()
self.r.RTTDCS(bits{VMPAC=1,ARBDIS=6,BDPM=22}) -- clear TDPAC,TDRM=4, BPBFSM
Expand Down Expand Up @@ -1171,6 +1176,9 @@ function M_vf:set_tx_rate (limit, priority)
return self
end

function M_vf:ingress_packet_drops ()
return self.pf:ingress_packet_drops()
end

rxdesc_t = ffi.typeof [[
union {
Expand Down
4 changes: 4 additions & 0 deletions src/apps/intel/intel_app.lua
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ function Intel82599:pull ()
self:add_receive_buffers()
end

function Intel82599:ingress_packet_drops ()
return self.dev:ingress_packet_drops()
end

function Intel82599:add_receive_buffers ()
-- Generic buffers
while self.dev:can_add_receive_buffer() do
Expand Down
40 changes: 40 additions & 0 deletions src/core/app.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,36 @@ link_table, link_array = {}, {}

configuration = config.new()

-- Ingress packet drop monitor.
ingress_drop_monitor = {
threshold = 100000,
wait = 20,
last_flush = 0,
last_value = ffi.new('uint64_t[1]'),
current_value = ffi.new('uint64_t[1]')
}

function ingress_drop_monitor:sample()
local sum = self.current_value
sum[0] = 0
for i = 1, #app_array do
local app = app_array[i]
if app.ingress_packet_drops and not app.dead then
sum[0] = sum[0] + app:ingress_packet_drops()
end
end
end

function ingress_drop_monitor:jit_flush_if_needed()
if self.current_value[0] - self.last_value[0] < self.threshold then return end
if app.now() - self.last_flush < self.wait then return end
self.last_flush = app.now()
self.last_value[0] = self.current_value[0]
jit.flush()
print("jit.flush")
--- TODO: Change last_flush, last_value and current_value fields to be counters.
end

-- Counters for statistics.
breaths = counter.open("engine/breaths") -- Total breaths taken
frees = counter.open("engine/frees") -- Total packets freed
Expand Down Expand Up @@ -246,6 +276,16 @@ function main (options)
breathe = latency:wrap_thunk(breathe, now)
end

if options.ingress_drop_monitor or options.ingress_drop_monitor == nil then
local interval = 1e8 -- Every 100 milliseconds.
local function fn()
ingress_drop_monitor:sample()
ingress_drop_monitor:jit_flush_if_needed()
end
local t = timer.new("ingress drop monitor", fn, interval, "repeating")
timer.activate(t)
end

monotonic_now = C.get_monotonic_time()
repeat
breathe()
Expand Down

0 comments on commit 22b4a8f

Please sign in to comment.