From patchwork Mon Apr 24 20:58:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Brooks X-Patchwork-Id: 98156 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp1661065qgf; Mon, 24 Apr 2017 14:00:09 -0700 (PDT) X-Received: by 10.36.237.69 with SMTP id r66mr15371976ith.109.1493067608847; Mon, 24 Apr 2017 14:00:08 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id l184si620863itb.84.2017.04.24.14.00.08; Mon, 24 Apr 2017 14:00:08 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 15F7760C51; Mon, 24 Apr 2017 21:00:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id C05BE6067A; Mon, 24 Apr 2017 20:59:58 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 012B6608B4; Mon, 24 Apr 2017 20:59:56 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.101.70]) by lists.linaro.org (Postfix) with ESMTP id E688460647 for ; Mon, 24 Apr 2017 20:59:55 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AD39315A1; Mon, 24 Apr 2017 13:59:54 -0700 (PDT) Received: from localhost.localdomain (unknown [10.119.48.47]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5F2F03F3E1; Mon, 24 Apr 2017 13:59:54 -0700 (PDT) From: Brian Brooks To: lng-odp@lists.linaro.org Date: Mon, 24 Apr 2017 15:58:53 -0500 Message-Id: <20170424205853.7145-1-brian.brooks@arm.com> X-Mailer: git-send-email 2.12.2 Cc: Ola Liljedahl Subject: [lng-odp] [PATCH] test: odp_sched_latency: robust draining of queues X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Ola Liljedahl In order to robustly drain all queues when the benchmark has ended, we enqueue a special event on every queue and invoke the scheduler until all such events have been received. Signed-off-by: Ola Liljedahl Reviewed-by: Brian Brooks --- test/common_plat/performance/odp_sched_latency.c | 51 ++++++++++++++++++------ 1 file changed, 38 insertions(+), 13 deletions(-) -- 2.12.2 Signed-off-by: Ola Liljedahl Reviewed-by: Brian Brooks diff --git a/test/common_plat/performance/odp_sched_latency.c b/test/common_plat/performance/odp_sched_latency.c index 2b28cd7b..7ba99fc6 100644 --- a/test/common_plat/performance/odp_sched_latency.c +++ b/test/common_plat/performance/odp_sched_latency.c @@ -57,9 +57,10 @@ ODP_STATIC_ASSERT(LO_PRIO_QUEUES <= MAX_QUEUES, "Too many LO priority queues"); /** Test event types */ typedef enum { - WARM_UP, /**< Warm up event */ - TRAFFIC, /**< Event used only as traffic load */ - SAMPLE /**< Event used to measure latency */ + WARM_UP, /**< Warm up event */ + COOL_DOWN,/**< Last event on queue */ + TRAFFIC, /**< Event used only as traffic load */ + SAMPLE /**< Event used to measure latency */ } event_type_t; /** Test event */ @@ -114,16 +115,40 @@ typedef struct { * * Retry to be sure that all buffers have been scheduled. */ -static void clear_sched_queues(void) +static void clear_sched_queues(test_globals_t *globals) { odp_event_t ev; + odp_buffer_t buf; + test_event_t *event; + int i, j; + uint32_t numtogo = 0; - while (1) { - ev = odp_schedule(NULL, ODP_SCHED_NO_WAIT); - - if (ev == ODP_EVENT_INVALID) - break; - + /* Enqueue special cool_down events on all queues (one per queue) */ + for (i = 0; i < NUM_PRIOS; i++) { + for (j = 0; j < globals->args.prio[i].queues; j++) { + buf = odp_buffer_alloc(globals->pool); + if (buf == ODP_BUFFER_INVALID) { + LOG_ERR("Buffer alloc failed.\n"); + return; + } + event = odp_buffer_addr(buf); + event->type = COOL_DOWN; + ev = odp_buffer_to_event(buf); + if (odp_queue_enq(globals->queue[i][j], ev)) { + LOG_ERR("Queue enqueue failed.\n"); + odp_event_free(ev); + return; + } + numtogo++; + } + } + /* Invoke scheduler until all cool_down events have been received */ + while (numtogo != 0) { + ev = odp_schedule(NULL, ODP_SCHED_WAIT); + buf = odp_buffer_from_event(ev); + event = odp_buffer_addr(buf); + if (event->type == COOL_DOWN) + numtogo--; odp_event_free(ev); } } @@ -394,10 +419,10 @@ static int test_schedule(int thr, test_globals_t *globals) odp_barrier_wait(&globals->barrier); - clear_sched_queues(); - - if (thr == MAIN_THREAD) + if (thr == MAIN_THREAD) { + clear_sched_queues(globals); print_results(globals); + } return 0; }