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

fix(2036): fix statistics bugs #2109

Merged
merged 7 commits into from
Jun 4, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 17 additions & 3 deletions fw/apm.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ typedef struct {
char __reset_from[0];
unsigned long tot_cnt;
unsigned long tot_val;
unsigned long min_val;
unsigned long max_val;
unsigned int min_val;
unsigned int max_val;
unsigned long cnt[TFW_STATS_RANGES][TFW_STATS_BCKTS];
char __reset_till[0];
} TfwPcntRanges __attribute__((aligned(L1_CACHE_BYTES)));
Expand Down Expand Up @@ -323,8 +323,9 @@ static inline bool
tfw_stats_adj_min(TfwPcntRanges *rng, unsigned int r_time)
{
if (r_time < rng->min_val) {
bool ret = rng->min_val != UINT_MAX;
rng->min_val = r_time;
return true;
return ret;
}
return false;
}
Expand Down Expand Up @@ -768,6 +769,7 @@ tfw_apm_prnctl_calc(TfwApmRBuf *rbuf, TfwApmRBCtl *rbctl, TfwPrcntlStats *pstats
TfwApmRBEState st[TFW_APM_MAX_TMWSCALE];
TfwPcntRanges *pcntrng;
TfwApmRBEnt *rbent = rbuf->rbent;
unsigned int max_val = 0;

for (i = 0; i < rbuf->rbufsz; i++) {
pcntrng = &rbent[i].pcntrng;
Expand All @@ -780,6 +782,11 @@ tfw_apm_prnctl_calc(TfwApmRBuf *rbuf, TfwApmRBCtl *rbctl, TfwPrcntlStats *pstats
if (!pval[i])
pstats->val[p++] = 0;
}
for (i = 0; i < rbuf->rbufsz; i++) {
pcntrng = &rbent[i].pcntrng;
if (max_val < pcntrng->max_val)
max_val = pcntrng->max_val;
}
while (p < T_PSZ) {
int v_min = USHRT_MAX;
for (i = 0; i < rbuf->rbufsz; i++) {
Expand All @@ -794,6 +801,9 @@ tfw_apm_prnctl_calc(TfwApmRBuf *rbuf, TfwApmRBCtl *rbctl, TfwPrcntlStats *pstats
cnt += pcntrng->cnt[st[i].r][st[i].b];
tfw_apm_state_next(pcntrng, &st[i]);
}
if (v_min > max_val) {
v_min = max_val;
}
for ( ; p < T_PSZ && pval[p] <= cnt; ++p)
pstats->val[p] = v_min;
}
Expand All @@ -809,6 +819,10 @@ tfw_apm_prnctl_calc(TfwApmRBuf *rbuf, TfwApmRBCtl *rbctl, TfwPrcntlStats *pstats
cnt += pcntrng->tot_cnt;
val += pcntrng->tot_val;
}

if (pstats->val[IDX_MIN] == UINT_MAX)
pstats->val[IDX_MIN] = 0;

if (likely(cnt))
pstats->val[IDX_AVG] = val / cnt;

Expand Down
8 changes: 2 additions & 6 deletions fw/procfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ static int
tfw_perfstat_seq_show(struct seq_file *seq, void *off)
{
#define SPRNE(m, e) seq_printf(seq, m": %llu\n", e)
#define SPRNED(m, e) seq_printf(seq, m": %dms\n", e)
#define SPRNED(m, e) seq_printf(seq, m": %ums\n", e)
#define SPRN(m, c) seq_printf(seq, m": %llu\n", stat.c)

int i;
Expand Down Expand Up @@ -158,10 +158,6 @@ tfw_perfstat_seq_show(struct seq_file *seq, void *off)
seq_printf(seq, "SS backlog's sizes\t\t\t: n/a\n");
}

/* Socket buffers kernel statistics. */
seq_printf(seq, "Socket buffers in flight\t\t: %ld\n",
__get_skb_count());

/* Cache statistics. */
SPRN("Cache hits\t\t\t\t", cache.hits);
SPRN("Cache misses\t\t\t\t", cache.misses);
Expand Down Expand Up @@ -222,7 +218,7 @@ tfw_perfstat_seq_open(struct inode *inode, struct file *file)
static int
tfw_srvstats_seq_show(struct seq_file *seq, void *off)
{
#define SPRNE(m, e) seq_printf(seq, m": %dms\n", e)
#define SPRNE(m, e) seq_printf(seq, m": %ums\n", e)

size_t i, rc;
TfwSrvConn *srv_conn;
Expand Down