From patchwork Mon Mar 20 10:08:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hunt, David" X-Patchwork-Id: 22015 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 3CD71D088; Mon, 20 Mar 2017 18:08:42 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id DF74A47CD for ; Mon, 20 Mar 2017 18:08:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1490029691; x=1521565691; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=tqlBHasY1QFY1C1qGmyA8Uk/04xxe6MVRkDkqJeI9rY=; b=Kwr3nrzPrSXV1QNdCddq/ahMvErBAvg1WWd6RsaBcpnb6tpHlWSx4oSG xym4dRU/9bZf9F/inJma4FE3ta3NQA==; Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Mar 2017 10:08:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,195,1486454400"; d="scan'208";a="69068981" Received: from silpixa00397515.ir.intel.com (HELO silpixa00397515.ger.corp.intel.com) ([10.237.223.14]) by orsmga004.jf.intel.com with ESMTP; 20 Mar 2017 10:08:09 -0700 From: David Hunt To: dev@dpdk.org Cc: bruce.richardson@intel.com, David Hunt Date: Mon, 20 Mar 2017 10:08:34 +0000 Message-Id: <1490004522-183515-11-git-send-email-david.hunt@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1490004522-183515-1-git-send-email-david.hunt@intel.com> References: <1489558767-56329-2-git-send-email-david.hunt@intel.com> <1490004522-183515-1-git-send-email-david.hunt@intel.com> Subject: [dpdk-dev] [PATCH v11 10/18] test: add perf test for distributor burst mode X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Signed-off-by: David Hunt Acked-by: Bruce Richardson --- test/test/test_distributor_perf.c | 75 ++++++++++++++++++++++++++------------- 1 file changed, 51 insertions(+), 24 deletions(-) diff --git a/test/test/test_distributor_perf.c b/test/test/test_distributor_perf.c index 1dd326b..732d86d 100644 --- a/test/test/test_distributor_perf.c +++ b/test/test/test_distributor_perf.c @@ -1,7 +1,7 @@ /*- * BSD LICENSE * - * Copyright(c) 2010-2014 Intel Corporation. All rights reserved. + * Copyright(c) 2010-2017 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,8 +41,9 @@ #include #include -#define ITER_POWER 20 /* log 2 of how many iterations we do when timing. */ -#define BURST 32 +#define ITER_POWER_CL 25 /* log 2 of how many iterations for Cache Line test */ +#define ITER_POWER 21 /* log 2 of how many iterations we do when timing. */ +#define BURST 64 #define BIG_BATCH 1024 /* static vars - zero initialized by default */ @@ -54,7 +55,8 @@ struct worker_stats { } __rte_cache_aligned; struct worker_stats worker_stats[RTE_MAX_LCORE]; -/* worker thread used for testing the time to do a round-trip of a cache +/* + * worker thread used for testing the time to do a round-trip of a cache * line between two cores and back again */ static void @@ -69,7 +71,8 @@ flip_bit(volatile uint64_t *arg) } } -/* test case to time the number of cycles to round-trip a cache line between +/* + * test case to time the number of cycles to round-trip a cache line between * two cores and back again. */ static void @@ -86,7 +89,7 @@ time_cache_line_switch(void) rte_pause(); const uint64_t start_time = rte_rdtsc(); - for (i = 0; i < (1 << ITER_POWER); i++) { + for (i = 0; i < (1 << ITER_POWER_CL); i++) { while (*pdata) rte_pause(); *pdata = 1; @@ -98,13 +101,14 @@ time_cache_line_switch(void) *pdata = 2; rte_eal_wait_lcore(slaveid); printf("==== Cache line switch test ===\n"); - printf("Time for %u iterations = %"PRIu64" ticks\n", (1<> ITER_POWER); + (end_time-start_time) >> ITER_POWER_CL); } -/* returns the total count of the number of packets handled by the worker +/* + * returns the total count of the number of packets handled by the worker * functions given below. */ static unsigned @@ -123,7 +127,8 @@ clear_packet_count(void) memset(&worker_stats, 0, sizeof(worker_stats)); } -/* this is the basic worker function for performance tests. +/* + * This is the basic worker function for performance tests. * it does nothing but return packets and count them. */ static int @@ -151,14 +156,15 @@ handle_work(void *arg) return 0; } -/* this basic performance test just repeatedly sends in 32 packets at a time +/* + * This basic performance test just repeatedly sends in 32 packets at a time * to the distributor and verifies at the end that we got them all in the worker * threads and finally how long per packet the processing took. */ static inline int perf_test(struct rte_distributor *d, struct rte_mempool *p) { - unsigned i; + unsigned int i; uint64_t start, end; struct rte_mbuf *bufs[BURST]; @@ -181,7 +187,8 @@ perf_test(struct rte_distributor *d, struct rte_mempool *p) rte_distributor_process(d, NULL, 0); } while (total_packet_count() < (BURST << ITER_POWER)); - printf("=== Performance test of distributor ===\n"); + rte_distributor_clear_returns(d); + printf("Time per burst: %"PRIu64"\n", (end - start) >> ITER_POWER); printf("Time per packet: %"PRIu64"\n\n", ((end - start) >> ITER_POWER)/BURST); @@ -201,9 +208,10 @@ perf_test(struct rte_distributor *d, struct rte_mempool *p) static void quit_workers(struct rte_distributor *d, struct rte_mempool *p) { - const unsigned num_workers = rte_lcore_count() - 1; - unsigned i; + const unsigned int num_workers = rte_lcore_count() - 1; + unsigned int i; struct rte_mbuf *bufs[RTE_MAX_LCORE]; + rte_mempool_get_bulk(p, (void *)bufs, num_workers); quit = 1; @@ -222,7 +230,8 @@ quit_workers(struct rte_distributor *d, struct rte_mempool *p) static int test_distributor_perf(void) { - static struct rte_distributor *d; + static struct rte_distributor *ds; + static struct rte_distributor *db; static struct rte_mempool *p; if (rte_lcore_count() < 2) { @@ -233,17 +242,28 @@ test_distributor_perf(void) /* first time how long it takes to round-trip a cache line */ time_cache_line_switch(); - if (d == NULL) { - d = rte_distributor_create("Test_perf", rte_socket_id(), + if (ds == NULL) { + ds = rte_distributor_create("Test_perf", rte_socket_id(), rte_lcore_count() - 1, RTE_DIST_ALG_SINGLE); - if (d == NULL) { + if (ds == NULL) { printf("Error creating distributor\n"); return -1; } } else { - rte_distributor_flush(d); - rte_distributor_clear_returns(d); + rte_distributor_clear_returns(ds); + } + + if (db == NULL) { + db = rte_distributor_create("Test_burst", rte_socket_id(), + rte_lcore_count() - 1, + RTE_DIST_ALG_BURST); + if (db == NULL) { + printf("Error creating burst distributor\n"); + return -1; + } + } else { + rte_distributor_clear_returns(db); } const unsigned nb_bufs = (511 * rte_lcore_count()) < BIG_BATCH ? @@ -257,10 +277,17 @@ test_distributor_perf(void) } } - rte_eal_mp_remote_launch(handle_work, d, SKIP_MASTER); - if (perf_test(d, p) < 0) + printf("=== Performance test of distributor (single mode) ===\n"); + rte_eal_mp_remote_launch(handle_work, ds, SKIP_MASTER); + if (perf_test(ds, p) < 0) + return -1; + quit_workers(ds, p); + + printf("=== Performance test of distributor (burst mode) ===\n"); + rte_eal_mp_remote_launch(handle_work, db, SKIP_MASTER); + if (perf_test(db, p) < 0) return -1; - quit_workers(d, p); + quit_workers(db, p); return 0; }