]> granicus.if.org Git - sysstat/commitdiff
A_NET_SOFT: Slight optimization in get_global_soft_statistics() function
authorSebastien GODARD <sysstat@users.noreply.github.com>
Sun, 20 Feb 2022 08:02:10 +0000 (09:02 +0100)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Sun, 20 Feb 2022 08:02:10 +0000 (09:02 +0100)
Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
sa_common.c

index ff8a49dd125573ba9c32c49456b77e62159c3701..7a116c24a8854689bca7944694fe08ad4b31530f 100644 (file)
@@ -3237,6 +3237,18 @@ void get_global_soft_statistics(struct activity *a, int prev, int curr,
                 ssnc = (struct stats_softnet *) ((char *) a->buf[curr] + i * a->msize);
                 ssnp = (struct stats_softnet *) ((char *) a->buf[prev] + i * a->msize);
 
+               if ((ssnp->processed + ssnp->dropped + ssnp->time_squeeze +
+                   ssnp->received_rps + ssnp->flow_limit == 0) && !WANT_SINCE_BOOT(flags)) {
+                       /*
+                        * No previous sample for current CPU: Don't display it unless
+                        * we want stats since last boot time.
+                        * (CPU may be online but we don't display it because all
+                        * its counters would appear to jump from zero...)
+                        */
+                       offline_cpu_bitmap[i >> 3] |= 1 << (i & 0x07);
+                       continue;
+               }
+
                if (ssnc->processed + ssnc->dropped + ssnc->time_squeeze +
                    ssnc->received_rps + ssnc->flow_limit == 0) {
                        /* Assume current CPU is offline */
@@ -3244,13 +3256,6 @@ void get_global_soft_statistics(struct activity *a, int prev, int curr,
                        offline_cpu_bitmap[i >> 3] |= 1 << (i & 0x07);
                }
 
-               if ((ssnp->processed + ssnp->dropped + ssnp->time_squeeze +
-                   ssnp->received_rps + ssnp->flow_limit == 0) && !WANT_SINCE_BOOT(flags)) {
-                       /* Current CPU back online but no previous sample for it */
-                       offline_cpu_bitmap[i >> 3] |= 1 << (i & 0x07);
-                       continue;
-               }
-
                ssnc_all->processed += ssnc->processed;
                ssnc_all->dropped += ssnc->dropped;
                ssnc_all->time_squeeze += ssnc->time_squeeze;