Changeset 21c0d70


Ignore:
Timestamp:
10/14/15 15:24:10 (6 years ago)
Author:
Shane Alcock <salcock@…>
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:
b24d186, f0cb0d4, f72e13d
Parents:
44f9892
Message:

Fix memory leak with heavily filtered RT inputs

Bucket buffers that contained entirely filtered packets were never
being freed if they weren't at the front of our bucket list, which would
chew through memory very quickly as soon as we had a non-empty bucket at
the front of the list but not enough packets to result in a batch being
spread amongst the processing threads.

Location:
lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • lib/combiner_ordered.c

    r44f9892 r21c0d70  
    126126        uint64_t key[trace_get_perpkt_threads(trace)]; // Cached keys
    127127        uint64_t min_key = UINT64_MAX;
    128         uint64_t prev_min = 0;
    129128        uint64_t peeked = 0;
    130129        int min_queue = -1;
     
    133132        for (i = 0; i < trace_get_perpkt_threads(trace); ++i) {
    134133                libtrace_queue_t *v = &queues[i];
    135                 if (libtrace_deque_get_size(v) != 0 &&
     134                if (libtrace_deque_get_size(v) != 0 &&
    136135                                peek_queue(trace, c, v, &peeked, NULL)) {
    137136                        live_count ++;
     
    186185                        key[min_queue] = 0;
    187186                        live_count--;
    188                         prev_min = min_key;
    189187                        min_key = UINT64_MAX; // Update our minimum
    190188                        min_queue = -1;
  • lib/data-struct/buckets.c

    r348396b r21c0d70  
    5252DLLEXPORT void libtrace_create_new_bucket(libtrace_bucket_t *b, void *buffer) {
    5353
     54        libtrace_bucket_node_t tmp;
    5455        libtrace_bucket_node_t *bnode = (libtrace_bucket_node_t *)malloc(
    5556                        sizeof(libtrace_bucket_node_t));
     57
     58        /* If the last node was never used, i.e. all packets within that node
     59         * buffer were filtered, we need to make sure we free the buffer
     60         * before we lose track of it.
     61         */
     62        pthread_mutex_lock(&b->lock);
     63        if (b->node && b->node->startindex == 0) {
     64                clear_bucket_node(b->node);
     65                libtrace_list_pop_back(b->nodelist, &tmp);
     66                free(b->node);
     67        }
     68        pthread_mutex_unlock(&b->lock);
     69
    5670
    5771        bnode->startindex = 0;
     
    159173        assert(s < bnode->slots);
    160174        assert(bnode->released[s] != 0);
    161        
     175
    162176
    163177        if (bnode->released[s] == 1) {
     
    170184                        b->nextid = previd;
    171185                        bnode->released[s] = 0;
     186                        if (id == bnode->startindex)
     187                                bnode->startindex = 0;
    172188                } else {
    173189                        bnode->released[s] = 2;
Note: See TracChangeset for help on using the changeset viewer.