Skip to content

Commit

Permalink
Merge branch 'softnet-backlog'
Browse files Browse the repository at this point in the history
  • Loading branch information
natoscott committed Mar 28, 2024
2 parents 6a05057 + cf234b8 commit 80b04b9
Show file tree
Hide file tree
Showing 8 changed files with 163 additions and 13 deletions.
8 changes: 7 additions & 1 deletion qa/1030
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ $sudo rm -rf $tmp.* $seq.full
trap "cd $here; rm -rf $tmp.*; exit \$status" 0 1 2 3 15

# create some data files for testing - from various kernels
cat <<EOF > $tmp.el9
001ab57c 00000000 000002d0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000003 00000000 00000001 00000002
00041adb 00000000 0000005b 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000003 00000001 00000003 00000000
00045167 00000000 0000005f 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000002 00000000 00000000
0003f85b 00000000 0000005b 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000003 00000000 00000000
EOF
cat <<EOF > $tmp.el7
0010c333 00000002 00000003 00000001 00000001 00000001 00000001 00000001 00000004 00000005 00000006
000ee8f7 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
Expand Down Expand Up @@ -48,7 +54,7 @@ pmda=$PCP_PMDAS_DIR/linux/pmda_linux.so,linux_init
metrics=`pminfo network.softnet | grep -v percpu | LC_COLLATE=POSIX sort`
cd $here

for file in el7 el6 el5
for file in el9 el7 el6 el5
do
rm -fr $root
mkdir -p $root/proc/net || _fail "root in use when preparing $file"
Expand Down
58 changes: 58 additions & 0 deletions qa/1030.out
Original file line number Diff line number Diff line change
@@ -1,4 +1,35 @@
QA output created by 1030
== Checking metric values - el9

network.softnet.cpu_collision
value 0

network.softnet.dropped
value 0

network.softnet.flow_limit_count
value 0

network.softnet.input_qlen
value 4

network.softnet.process_qlen
value 2

network.softnet.processed
value 2562585

network.softnet.received_rps
value 0

network.softnet.time_squeeze
value 997

network.softnet.total_backlog
value 6

== done

== Checking metric values - el7

network.softnet.cpu_collision
Expand All @@ -10,6 +41,12 @@ network.softnet.dropped
network.softnet.flow_limit_count
value 6

network.softnet.input_qlen
Error: Metric not supported by this version of monitored application

network.softnet.process_qlen
Error: Metric not supported by this version of monitored application

network.softnet.processed
value 6647645

Expand All @@ -19,6 +56,9 @@ network.softnet.received_rps
network.softnet.time_squeeze
value 3

network.softnet.total_backlog
Error: Metric not supported by this version of monitored application

== done

== Checking metric values - el6
Expand All @@ -32,6 +72,12 @@ network.softnet.dropped
network.softnet.flow_limit_count
Error: Metric not supported by this version of monitored application

network.softnet.input_qlen
Error: Metric not supported by this version of monitored application

network.softnet.process_qlen
Error: Metric not supported by this version of monitored application

network.softnet.processed
value 43552

Expand All @@ -41,6 +87,9 @@ network.softnet.received_rps
network.softnet.time_squeeze
value 3

network.softnet.total_backlog
Error: Metric not supported by this version of monitored application

== done

== Checking metric values - el5
Expand All @@ -54,6 +103,12 @@ network.softnet.dropped
network.softnet.flow_limit_count
Error: Metric not supported by this version of monitored application

network.softnet.input_qlen
Error: Metric not supported by this version of monitored application

network.softnet.process_qlen
Error: Metric not supported by this version of monitored application

network.softnet.processed
value 9009

Expand All @@ -63,5 +118,8 @@ Error: Metric not supported by this version of monitored application
network.softnet.time_squeeze
value 3

network.softnet.total_backlog
Error: Metric not supported by this version of monitored application

== done

6 changes: 6 additions & 0 deletions src/pmdas/linux/help
Original file line number Diff line number Diff line change
Expand Up @@ -1581,6 +1581,9 @@ See also network.interface.speed for the Megabytes/second value.
@ network.softnet.cpu_collision number of times that two cpus collided trying to get the device queue lock
@ network.softnet.received_rps number of times rps_trigger_softirq has been called
@ network.softnet.flow_limit_count softnet_data flow limit counter
@ network.softnet.total_backlog sum of softnet input and process queue lengths
@ network.softnet.input_qlen softnet input packet queue length
@ network.softnet.process_qlen softnet process queue length
@ network.softnet.percpu.processed number of packets (not including netpoll) received by the interrupt handler
@ network.softnet.percpu.dropped number of packets that were dropped because netdev_max_backlog was exceeded
@ network.softnet.percpu.time_squeeze number of times ksoftirq ran out of netdev_budget or time slice with work remaining
Expand All @@ -1591,6 +1594,9 @@ The network stack has to drop packets when a receive processing a CPUs
backlog reaches netdev_max_backlog. The flow_limit_count counter is
the number of times very active flows have dropped their traffic earlier
to maintain capacity for other less active flows.
@ network.softnet.percpu.total_backlog sum of softnet input and process queue lengths
@ network.softnet.percpu.input_qlen softnet input packet queue length
@ network.softnet.percpu.process_qlen softnet process queue length

@ network.ip6.inreceives count of ip6 inreceives
@ network.ip6.inhdrerrors count of ip6 inhdrerrors
Expand Down
3 changes: 3 additions & 0 deletions src/pmdas/linux/linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,9 @@ typedef struct {
uint64_t cpu_collision;
uint64_t received_rps;
uint64_t flow_limit_count;
uint64_t total_backlog;
uint64_t input_qlen;
uint64_t process_qlen;
} softnet_t;

typedef struct {
Expand Down
60 changes: 60 additions & 0 deletions src/pmdas/linux/pmda.c
Original file line number Diff line number Diff line change
Expand Up @@ -7016,6 +7016,30 @@ static pmdaMetric metrictab[] = {
{ NULL, { PMDA_PMID(CLUSTER_NET_SOFTNET,11), PM_TYPE_U64, CPU_INDOM,
PM_SEM_COUNTER, PMDA_PMUNITS(0,0,1,0,0,PM_COUNT_ONE) }, },

/* network.softnet.total_backlog */
{ NULL, { PMDA_PMID(CLUSTER_NET_SOFTNET,12), PM_TYPE_U64, PM_INDOM_NULL,
PM_SEM_INSTANT, PMDA_PMUNITS(0,0,1,0,0,PM_COUNT_ONE) }, },

/* network.softnet.percpu.total_backlog */
{ NULL, { PMDA_PMID(CLUSTER_NET_SOFTNET,13), PM_TYPE_U64, CPU_INDOM,
PM_SEM_INSTANT, PMDA_PMUNITS(0,0,1,0,0,PM_COUNT_ONE) }, },

/* network.softnet.input_qlen */
{ NULL, { PMDA_PMID(CLUSTER_NET_SOFTNET,14), PM_TYPE_U64, PM_INDOM_NULL,
PM_SEM_INSTANT, PMDA_PMUNITS(0,0,1,0,0,PM_COUNT_ONE) }, },

/* network.softnet.percpu.input_qlen */
{ NULL, { PMDA_PMID(CLUSTER_NET_SOFTNET,15), PM_TYPE_U64, CPU_INDOM,
PM_SEM_INSTANT, PMDA_PMUNITS(0,0,1,0,0,PM_COUNT_ONE) }, },

/* network.softnet.process_qlen */
{ NULL, { PMDA_PMID(CLUSTER_NET_SOFTNET,16), PM_TYPE_U64, PM_INDOM_NULL,
PM_SEM_INSTANT, PMDA_PMUNITS(0,0,1,0,0,PM_COUNT_ONE) }, },

/* network.softnet.percpu.process_qlen */
{ NULL, { PMDA_PMID(CLUSTER_NET_SOFTNET,17), PM_TYPE_U64, CPU_INDOM,
PM_SEM_INSTANT, PMDA_PMUNITS(0,0,1,0,0,PM_COUNT_ONE) }, },

/*
* tapedev cluster
*/
Expand Down Expand Up @@ -9796,6 +9820,42 @@ linux_fetchCallBack(pmdaMetric *mdesc, unsigned int inst, pmAtomValue *atom)
return PM_ERR_INST;
atom->ull = cp->softnet->flow_limit_count;
break;
case 12: /* network.softnet.total_backlog */
if (!(proc_net_softnet.flags & SN_BACKLOG))
return PM_ERR_APPVERSION;
atom->ull = proc_net_softnet.total_backlog;
break;
case 13: /* network.softnet.percpu.total_backlog */
if (!(proc_net_softnet.flags & SN_BACKLOG))
return PM_ERR_APPVERSION;
if (pmdaCacheLookup(indom, inst, NULL, (void **)&cp) < 0)
return PM_ERR_INST;
atom->ull = cp->softnet->total_backlog;
break;
case 14: /* network.softnet.input_qlen */
if (!(proc_net_softnet.flags & SN_BACKLOG))
return PM_ERR_APPVERSION;
atom->ull = proc_net_softnet.input_qlen;
break;
case 15: /* network.softnet.percpu.input_qlen */
if (!(proc_net_softnet.flags & SN_BACKLOG))
return PM_ERR_APPVERSION;
if (pmdaCacheLookup(indom, inst, NULL, (void **)&cp) < 0)
return PM_ERR_INST;
atom->ull = cp->softnet->input_qlen;
break;
case 16: /* network.softnet.process_qlen */
if (!(proc_net_softnet.flags & SN_BACKLOG))
return PM_ERR_APPVERSION;
atom->ull = proc_net_softnet.process_qlen;
break;
case 17: /* network.softnet.percpu.process_qlen */
if (!(proc_net_softnet.flags & SN_BACKLOG))
return PM_ERR_APPVERSION;
if (pmdaCacheLookup(indom, inst, NULL, (void **)&cp) < 0)
return PM_ERR_INST;
atom->ull = cp->softnet->process_qlen;
break;
default:
return PM_ERR_PMID;
}
Expand Down
28 changes: 19 additions & 9 deletions src/pmdas/linux/proc_net_softnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,28 @@ refresh_proc_net_softnet(proc_net_softnet_t *all)
pmInDom cpus = INDOM(CPU_INDOM);
percpu_t *cp;
softnet_t *snp;
uint64_t filler;
uint64_t filler, id;
FILE *fp;
static int logonce;

/* size > (11*7)+1 bytes, where 7 == strlen("%08llx "), and +1 for '\0' */
/* size > (15*7)+1 bytes, where 7 == strlen("%08llx "), and +1 for '\0' */
static char fmt[128] = { '\0' };

if (fmt[0] == '\0') {
/*
* one trip initialization to decide the correct sscanf format
* for a uint64_t data type .. needs to be
* "%08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx"
* for a uint64_t data type .. needs to be either
* "%08lx %08lx ... %08lx %08lx"
* or
* "%08llx %08llx %08llx %08llx %08llx %08llx %08llx %08llx %08llx %08llx %08llx"
* "%08llx %08llx ... %08llx %08llx"
*/
fmt[0] = '\0';
if (strcmp(FMT_INT64, "lld") == 0) {
for (i = 0; i < 11; i++)
for (i = 0; i < 15; i++)
strcat(fmt, "%08llx ");
}
else {
for (i = 0; i < 11; i++)
for (i = 0; i < 15; i++)
strcat(fmt, "%08lx ");
}
/* chop off last ' ' */
Expand Down Expand Up @@ -74,22 +74,32 @@ refresh_proc_net_softnet(proc_net_softnet_t *all)
memset(snp, 0, sizeof(*snp));
i = sscanf(buf, fmt, &snp->processed, &snp->dropped, &snp->time_squeeze,
&filler, &filler, &filler, &filler, &filler,
&snp->cpu_collision, &snp->received_rps, &snp->flow_limit_count);
&snp->cpu_collision, &snp->received_rps, &snp->flow_limit_count,
&snp->total_backlog, &id, &snp->input_qlen, &snp->process_qlen);
if (i >= 13 && (int)id != cpu) {
fprintf(stderr, "refresh_proc_net_softnet: warning: inconsistent cpu %d not %d\n", cpu, (int)id);
logonce = 1;
}

/* update aggregate CPU stats as well */
all->processed += snp->processed;
all->dropped += snp->dropped;
all->time_squeeze += snp->time_squeeze;
all->cpu_collision += snp->cpu_collision;
all->cpu_collision += snp->cpu_collision; /* no longer used in kernel */
all->received_rps += snp->received_rps;
all->flow_limit_count += snp->flow_limit_count;
all->total_backlog += snp->total_backlog;
all->input_qlen += snp->input_qlen;
all->process_qlen += snp->process_qlen;

if (i >= 9)
snp->flags |= SN_PROCESSED | SN_DROPPED | SN_TIME_SQUEEZE | SN_CPU_COLLISION;
if (i >= 10)
snp->flags |= SN_RECEIVED_RPS;
if (i >= 11)
snp->flags |= SN_FLOW_LIMIT_COUNT;
if (i >= 15)
snp->flags |= SN_BACKLOG;

if (cpu > 0 && snp->flags != all->flags && logonce <= 1) {
fprintf(stderr, "refresh_proc_net_softnet: warning: inconsistent flags, cpu %d\n", cpu);
Expand Down
7 changes: 4 additions & 3 deletions src/pmdas/linux/proc_net_softnet.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
* Copyright (c) 2015-2017 Red Hat.
*
* Copyright (c) 2015-2017,2024 Red Hat.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
Expand All @@ -19,6 +19,7 @@ enum {
SN_CPU_COLLISION = 1<<3,
SN_RECEIVED_RPS = 1<<4,
SN_FLOW_LIMIT_COUNT = 1<<5,
SN_BACKLOG = 1<<6,
};

typedef softnet_t proc_net_softnet_t;
Expand Down
6 changes: 6 additions & 0 deletions src/pmdas/linux/root_linux
Original file line number Diff line number Diff line change
Expand Up @@ -1363,6 +1363,9 @@ network.softnet {
cpu_collision 60:57:3
received_rps 60:57:4
flow_limit_count 60:57:5
total_backlog 60:57:12
input_qlen 60:57:14
process_qlen 60:57:16
percpu
}

Expand All @@ -1373,6 +1376,9 @@ network.softnet.percpu {
cpu_collision 60:57:9
received_rps 60:57:10
flow_limit_count 60:57:11
total_backlog 60:57:13
input_qlen 60:57:15
process_qlen 60:57:17
}

network.ip6 {
Expand Down

0 comments on commit 80b04b9

Please sign in to comment.