Skip to content

Commit

Permalink
More debug of netflow_scan_and_export worker.
Browse files Browse the repository at this point in the history
Output string of markers why scan export is terminated:

  s - hash table is empty (started but never entered the loop);
  T - trylock of hash based flow bucket is failed;
  E - all exported successfully (loop is exhausted);
  A - active flows ahead (because flow list is sorted by activity time).

Markers are recent to older from left to right in "Flows" line.
  • Loading branch information
aabc committed May 30, 2014
1 parent dd686f8 commit bedba68
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions ipt_NETFLOW.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ static struct flowset_data *pdu_flowset = NULL; /* current data flowset */

static unsigned long wk_start; /* last start of worker (jiffies) */
static unsigned long wk_busy; /* last work busy time (jiffies) */
static unsigned int wk_count; /* how much of ipt_netflow_list is scanned */
static unsigned int wk_count; /* how much of ipt_netflow_list is scanned */
static char wk_abort[16]; /* reason why last export scan is aborted */
static void (*netflow_export_flow)(struct ipt_netflow *nf);
static void (*netflow_export_pdu)(void); /* called on timeout */
static void netflow_switch_version(int ver);
Expand Down Expand Up @@ -317,15 +318,16 @@ static int nf_seq_show(struct seq_file *seq, void *v)
seq_printf(seq, "ipt_NETFLOW version " IPT_NETFLOW_VERSION ", srcversion %s\n",
THIS_MODULE->srcversion);
seq_printf(seq, "Flows: active %u (peak %u reached %ud%uh%um ago), mem %uK, worker delay %d/%d"
" (%u ms, %u us, %u).\n",
" (%u ms, %u us, %u: %.*s).\n",
nr_flows,
peakflows,
peak / (60 * 60 * 24), (peak / (60 * 60)) % 24, (peak / 60) % 60,
(unsigned int)((nr_flows * sizeof(struct ipt_netflow)) >> 10),
worker_delay, HZ,
jiffies_to_msecs(jiffies - wk_start),
jiffies_to_usecs(wk_busy),
wk_count);
wk_count,
(int)sizeof(wk_abort), wk_abort);

for_each_present_cpu(cpu) {
struct ipt_netflow_stat *st = &per_cpu(ipt_netflow_stat, cpu);
Expand Down Expand Up @@ -2013,6 +2015,7 @@ static int netflow_scan_and_export(const int flush)
nf = list_entry(ipt_netflow_list.prev, struct ipt_netflow, list);
if (!spin_trylock(nf->lock)) {
trylock_failed = 1;
*wk_abort = 'T';
break;
}
/* Note: i_timeout checked with >= to allow specifying zero timeout
Expand All @@ -2029,13 +2032,15 @@ static int netflow_scan_and_export(const int flush)
NETFLOW_STAT_ADD(pkt_out, nf->nr_packets);
NETFLOW_STAT_ADD(traf_out, nf->nr_bytes);
netflow_export_flow(nf);
*wk_abort = 'E';

local_bh_disable();
spin_lock(&hlist_lock);
} else {
spin_unlock(nf->lock);
/* all flows which need to be exported is always at the tail
* so if no more exportable flows we can break */
*wk_abort = 'A';
break;
}
}
Expand Down Expand Up @@ -2072,6 +2077,8 @@ static void netflow_work_fn(struct work_struct *dummy)
int status;

wk_count = 0;
memmove(wk_abort + 1, wk_abort, sizeof(wk_abort) - 1);
*wk_abort = 's';
wk_start = jiffies;
status = netflow_scan_and_export(DONT_FLUSH);
_schedule_scan_worker(status);
Expand Down

0 comments on commit bedba68

Please sign in to comment.