Changeset 526d9d0 for lib/trace.c


Ignore:
Timestamp:
02/24/15 17:18:21 (6 years ago)
Author:
Richard Sanger <rsangerarj@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
116f970
Parents:
10c47a0
Message:

Move the accepted packet count to dispatching packets for threads.
Accounting for the doubled count when using a single threaded format.

Rework statistics logic slightly to remove duplicated code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/trace.c

    r694823f r526d9d0  
    20272027        assert(trace);
    20282028        int i = 0;
    2029         uint64_t ret = trace->accepted_packets;
     2029        uint64_t ret = 0;
     2030        /* We always add to a thread's accepted count before dispatching the
     2031         * packet to the user. However if the underlying trace is single
     2032         * threaded it will also be increasing the global count. So if we
     2033         * find perpkt ignore the global count.
     2034         */
    20302035        for (i = 0; i < trace->perpkt_thread_count; i++) {
    20312036                ret += trace->perpkt_threads[i].accepted_packets;
    20322037        }
    2033         return ret;
     2038        return ret ? ret : trace->accepted_packets;
    20342039}
    20352040
     
    20612066        LIBTRACE_STAT_FIELDS;
    20622067#undef X
    2063         if (trace->format->get_statistics) {
    2064                 trace->format->get_statistics(trace, stat);
    2065                 ret = trace_get_accepted_packets(trace);
    2066                 if (ret != UINT64_MAX) {
    2067                         stat->accepted_valid = 1;
    2068                         stat->accepted = ret;
    2069                 }
    2070                 /* Now add on any library filtered packets */
    2071                 if (stat->filtered_valid) {
    2072                         stat->filtered += trace->filtered_packets;
    2073                         for (i = 0; i < trace->perpkt_thread_count; i++) {
    2074                                 stat->filtered += trace->perpkt_threads[i].filtered_packets;
    2075                         }
    2076                 }
    2077                 return stat;
    2078         }
     2068        /* Both accepted and filtered are stored against in the library */
    20792069        ret = trace_get_accepted_packets(trace);
    20802070        if (ret != UINT64_MAX) {
     
    20822072                stat->accepted = ret;
    20832073        }
    2084         ret = trace_get_received_packets(trace);
    2085         if (ret != UINT64_MAX) {
    2086                 stat->received_valid = 1;
    2087                 stat->received = ret;
    2088         }
    2089         /* Fallback to the old way */
    2090         ret = trace_get_dropped_packets(trace);
    2091         if (ret != UINT64_MAX) {
    2092                 stat->dropped_valid = 1;
    2093                 stat->dropped = ret;
    2094         }
    2095         ret = trace_get_filtered_packets(trace);
    2096         if (ret != UINT64_MAX) {
    2097                 stat->filtered_valid = 1;
    2098                 stat->filtered = ret;
     2074
     2075        stat->filtered_valid = 1;
     2076        stat->filtered = trace->filtered_packets;
     2077        for (i = 0; i < trace->perpkt_thread_count; i++) {
     2078                stat->filtered += trace->perpkt_threads[i].filtered_packets;
     2079        }
     2080
     2081        if (trace->format->get_statistics) {
     2082                trace->format->get_statistics(trace, stat);
     2083        } else {
     2084                /* Fallback to the old way */
     2085                ret = trace_get_received_packets(trace);
     2086                if (ret != UINT64_MAX) {
     2087                        stat->received_valid = 1;
     2088                        stat->received = ret;
     2089                }
     2090                ret = trace_get_dropped_packets(trace);
     2091                if (ret != UINT64_MAX) {
     2092                        stat->dropped_valid = 1;
     2093                        stat->dropped = ret;
     2094                }
    20992095        }
    21002096        return stat;
     
    21122108        LIBTRACE_STAT_FIELDS;
    21132109#undef X
    2114         if (trace->format->get_thread_statistics) {
     2110        stat->accepted_valid = 1;
     2111        stat->accepted = t->accepted_packets;
     2112        stat->filtered_valid = 1;
     2113        stat->filtered = t->filtered_packets;
     2114        if (!trace_has_dedicated_hasher(trace) && trace->format->get_thread_statistics) {
    21152115                trace->format->get_thread_statistics(trace, t, stat);
    2116         }
    2117         if (t->accepted_packets != UINT64_MAX) {
    2118                 stat->accepted_valid = 1;
    2119                 stat->accepted = t->accepted_packets;
    2120         }
    2121         /* Now add on any library filtered packets */
    2122         if (stat->filtered_valid) {
    2123                 stat->filtered += t->filtered_packets;
    21242116        }
    21252117        return;
Note: See TracChangeset for help on using the changeset viewer.