Changeset 12ae766


Ignore:
Timestamp:
02/11/15 11:09:31 (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:
1b59edf
Parents:
858ce90
Message:

Move pthread register outside of the libtrace lock.
DAG does a decent amount of work in this step, which
can be done in parallel. Instead let formats grab a
lock if they need it.

Location:
lib
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • lib/format_dpdk.c

    r75e088f r12ae766  
    14191419 * gives it.
    14201420 *
    1421  * We then allow a mapper thread to be started on every real core as DPDK would
     1421 * We then allow a mapper thread to be started on every real core as DPDK would,
    14221422 * we also bind these to the corresponding CPU cores.
    14231423 *
     
    14371437    // in this case physical cores on the system will not exist so we don't bind
    14381438    // these to any particular physical core
     1439    pthread_mutex_lock(&libtrace->libtrace_lock);
    14391440    if (reading) {
    14401441#if HAVE_LIBNUMA
     
    14721473        // TODO proper libtrace style error here!!
    14731474        fprintf(stderr, "Too many threads for DPDK!!\n");
     1475        pthread_mutex_unlock(&libtrace->libtrace_lock);
    14741476        return -1;
    14751477    }
     
    14961498        if (i != 0) {
    14971499            fprintf(stderr, "Warning pthread_setaffinity_np failed\n");
     1500            pthread_mutex_unlock(&libtrace->libtrace_lock);
    14981501            return -1;
    14991502        }
     
    15081511        }
    15091512    }
     1513    pthread_mutex_unlock(&libtrace->libtrace_lock);
    15101514    return 0;
    15111515}
     
    15231527
    15241528    assert(rte_lcore_id() < RTE_MAX_LCORE);
    1525 
     1529    pthread_mutex_lock(&libtrace->libtrace_lock);
    15261530    // Skip if master!!
    15271531    if (rte_lcore_id() == rte_get_master_lcore()) {
    15281532        fprintf(stderr, "INFO: we are skipping unregistering the master lcore\n");
     1533        pthread_mutex_unlock(&libtrace->libtrace_lock);
    15291534        return;
    15301535    }
     
    15351540    RTE_PER_LCORE(_lcore_id) = -1; // Might make the world burn if used again
    15361541    assert(cfg->lcore_count >= 1); // We cannot unregister the master LCORE!!
     1542    pthread_mutex_unlock(&libtrace->libtrace_lock);
    15371543    return;
    15381544}
  • lib/libtrace_int.h

    r858ce90 r12ae766  
    932932        /**
    933933         * Register a thread for use with the format or using the packets produced
    934          * by it. This is NOT only used for threads reading packets infact all
     934         * by it. This is NOT only used for threads reading packets in fact all
    935935         * threads use this.
     936         *
     937         * The libtrace lock is not held by this format but can be aquired
     938         * by the format.
    936939         *
    937940         * Some use cases include setting up any thread local storage required for
  • lib/trace_parallel.c

    r858ce90 r12ae766  
    526526        }
    527527        //printf("Yay Started perpkt thread #%d\n", (int) get_thread_table_num(trace));
     528        ASSERT_RET(pthread_mutex_unlock(&trace->libtrace_lock), == 0);
     529
    528530        if (trace->format->pregister_thread) {
    529531                trace->format->pregister_thread(trace, t, !trace_has_dedicated_hasher(trace));
    530532        }
    531         ASSERT_RET(pthread_mutex_unlock(&trace->libtrace_lock), == 0);
    532533
    533534        /* Fill our buffer with empty packets */
     
    696697        libtrace_packet_t * packet;
    697698        libtrace_message_t message = {0};
     699        int pkt_skipped = 0;
    698700
    699701        assert(trace_has_dedicated_hasher(trace));
     
    709711
    710712        printf("Hasher Thread started\n");
     713        ASSERT_RET(pthread_mutex_unlock(&trace->libtrace_lock), == 0);
     714
    711715        if (trace->format->pregister_thread) {
    712716                trace->format->pregister_thread(trace, t, true);
    713717        }
    714         ASSERT_RET(pthread_mutex_unlock(&trace->libtrace_lock), == 0);
    715         int pkt_skipped = 0;
     718
    716719        /* Read all packets in then hash and queue against the correct thread */
    717720        while (1) {
Note: See TracChangeset for help on using the changeset viewer.