From patchwork Fri Mar 2 15:00:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 130558 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp1387481lja; Fri, 2 Mar 2018 07:19:36 -0800 (PST) X-Google-Smtp-Source: AG47ELtQnsc1T/yZWvKn/Fh7zBVTPQoipwbw+QqWBYQLi1RH/BwuqkPupkRQYTmePYiYpFFybABw X-Received: by 10.13.202.1 with SMTP id m1mr3798969ywd.67.1520003976050; Fri, 02 Mar 2018 07:19:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520003976; cv=none; d=google.com; s=arc-20160816; b=pN9yHlSNnMx2rWWK17USmVjK+4x7gb7f3nwaKu4e1gIezuQgm5uQmfsIVDIdroGoYN MoI8QpBRmhVG4zYmbqLW3nJYtdZBrrc+IPKFBoRaYfZlxP27+2KwyktYxIC1laZEMuV4 8zMQdfmA9tpUkz7OwfhG0z42R/53x8AR5N83bgsXH9xYvQ742Nc1aU8PDjzvF6FuMRlr fQBIzYIUI0cHdIhgPrzbI3GOiB7o/JihziEelGCW2T50t/UzsGogzXurW+WVgHts5mk3 srmq5/JAhaihreSDuxYFbQXwxICV6b7QgEE38zdH07ZY4tkK/0O94951COtC/sXbUYjb aKIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=W0KT2esX8OdVd3dT8AyQoWe3RE1HupNVgMiKuMCtnKA=; b=vnYbj9SZSqWMxpOR1/2cQnj9WAsSL/kkvK1NphMLyi8Grw2puoI7w+MdRorAyVB5fJ m7a7a8hjjacRaXAEt/X4IZzQ5Bh59zYwIlrRBtItsY7B4+D2/8PAkvi0qGOqAFB+u9c7 EUE17Fp8hePMhHar/Nf0m2QmbbFT/yBHD2MA778Ce6zPKWad40PIUfacMcg0O/NYaHEU +PD9/Joyny2IxIJnf1HqSOZSbycUeSSpwC3TYm277G42qCjtnw5Qr/Hw9l6egJcjbzUN 1m2xJEZo9AqwGqfb61t7VV9k+MoLJpru1W2wtqvDfvTAAmxAemze09dasgtxDx1VTKTQ TSjw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id p7si115518qkp.395.2018.03.02.07.19.35; Fri, 02 Mar 2018 07:19:36 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 8F6B0627CF; Fri, 2 Mar 2018 15:19:35 +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=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 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 0DC296276F; Fri, 2 Mar 2018 15:04:26 +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 6BF3A6276F; Fri, 2 Mar 2018 15:04:08 +0000 (UTC) Received: from forward105p.mail.yandex.net (forward105p.mail.yandex.net [77.88.28.108]) by lists.linaro.org (Postfix) with ESMTPS id 181A8607C4 for ; Fri, 2 Mar 2018 15:00:35 +0000 (UTC) Received: from mxback1g.mail.yandex.net (mxback1g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:162]) by forward105p.mail.yandex.net (Yandex) with ESMTP id 38C9140815FF for ; Fri, 2 Mar 2018 18:00:21 +0300 (MSK) Received: from smtp2j.mail.yandex.net (smtp2j.mail.yandex.net [2a02:6b8:0:801::ac]) by mxback1g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id BZFp7SbrJS-0LKGANjp; Fri, 02 Mar 2018 18:00:21 +0300 Received: by smtp2j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id ChbgkO0UiZ-0K2mhhZ6; Fri, 02 Mar 2018 18:00:20 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Fri, 2 Mar 2018 18:00:14 +0300 Message-Id: <1520002815-30682-6-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520002815-30682-1-git-send-email-odpbot@yandex.ru> References: <1520002815-30682-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 504 Subject: [lng-odp] [PATCH v2 5/6] linux-gen: sched: use stash prefix 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: Petri Savolainen Use consistently stash_ prefix for thread local variables related to event stashing. Signed-off-by: Petri Savolainen --- /** Email created from pull request 504 (psavol:master-sched-optim-2) ** https://github.com/Linaro/odp/pull/504 ** Patch: https://github.com/Linaro/odp/pull/504.patch ** Base sha: e1c0e4570a45d05dd9f2e8e052ce71164209d112 ** Merge commit sha: 964132736e0785222be184065d6ac73121cd46ac **/ platform/linux-generic/odp_schedule_basic.c | 59 +++++++++++++++-------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/platform/linux-generic/odp_schedule_basic.c b/platform/linux-generic/odp_schedule_basic.c index d662bd6a4..b3c913bb6 100644 --- a/platform/linux-generic/odp_schedule_basic.c +++ b/platform/linux-generic/odp_schedule_basic.c @@ -114,13 +114,14 @@ ODP_STATIC_ASSERT(sizeof(lock_called_t) == sizeof(uint32_t), /* Scheduler local data */ typedef struct { int thr; - int num; - int index; + int stash_num; + int stash_index; int pause; uint16_t round; - uint32_t queue_index; - odp_queue_t queue; - odp_event_t ev_stash[MAX_DEQ]; + uint32_t stash_qi; + odp_queue_t stash_queue; + odp_event_t stash_ev[MAX_DEQ]; + struct { /* Source queue index */ uint32_t src_queue; @@ -228,9 +229,9 @@ static void sched_local_init(void) memset(&sched_local, 0, sizeof(sched_local_t)); - sched_local.thr = odp_thread_id(); - sched_local.queue = ODP_QUEUE_INVALID; - sched_local.queue_index = PRIO_QUEUE_EMPTY; + sched_local.thr = odp_thread_id(); + sched_local.stash_queue = ODP_QUEUE_INVALID; + sched_local.stash_qi = PRIO_QUEUE_EMPTY; sched_local.ordered.src_queue = NULL_INDEX; id = sched_local.thr & (QUEUES_PER_PRIO - 1); @@ -364,7 +365,7 @@ static int schedule_init_local(void) static int schedule_term_local(void) { - if (sched_local.num) { + if (sched_local.stash_num) { ODP_ERR("Locally pre-scheduled events exist.\n"); return -1; } @@ -536,9 +537,9 @@ static void schedule_pktio_start(int pktio_index, int num_pktin, static void schedule_release_atomic(void) { - uint32_t qi = sched_local.queue_index; + uint32_t qi = sched_local.stash_qi; - if (qi != PRIO_QUEUE_EMPTY && sched_local.num == 0) { + if (qi != PRIO_QUEUE_EMPTY && sched_local.stash_num == 0) { int grp = sched->queue[qi].grp; int prio = sched->queue[qi].prio; int queue_per_prio = sched->queue[qi].queue_per_prio; @@ -546,7 +547,7 @@ static void schedule_release_atomic(void) /* Release current atomic queue */ ring_enq(ring, RING_MASK, qi); - sched_local.queue_index = PRIO_QUEUE_EMPTY; + sched_local.stash_qi = PRIO_QUEUE_EMPTY; } } @@ -634,7 +635,7 @@ static void schedule_release_ordered(void) queue_index = sched_local.ordered.src_queue; - if (odp_unlikely((queue_index == NULL_INDEX) || sched_local.num)) + if (odp_unlikely((queue_index == NULL_INDEX) || sched_local.stash_num)) return; release_ordered(); @@ -648,14 +649,14 @@ static inline void schedule_release_context(void) schedule_release_atomic(); } -static inline int copy_events(odp_event_t out_ev[], unsigned int max) +static inline int copy_from_stash(odp_event_t out_ev[], unsigned int max) { int i = 0; - while (sched_local.num && max) { - out_ev[i] = sched_local.ev_stash[sched_local.index]; - sched_local.index++; - sched_local.num--; + while (sched_local.stash_num && max) { + out_ev[i] = sched_local.stash_ev[sched_local.stash_index]; + sched_local.stash_index++; + sched_local.stash_num--; max--; i++; } @@ -743,7 +744,7 @@ static inline int poll_pktin(uint32_t qi, int stash) if (stash) { for (i = 0; i < num; i++) - sched_local.ev_stash[i] = event_from_buf_hdr(b_hdr[i]); + sched_local.stash_ev[i] = event_from_buf_hdr(b_hdr[i]); return num; } @@ -829,7 +830,7 @@ static inline int do_schedule_grp(odp_queue_t *out_queue, odp_event_t out_ev[], pktin = queue_is_pktin(qi); - num = sched_cb_queue_deq_multi(qi, sched_local.ev_stash, + num = sched_cb_queue_deq_multi(qi, sched_local.stash_ev, max_deq, !pktin); if (num < 0) { @@ -883,17 +884,17 @@ static inline int do_schedule_grp(odp_queue_t *out_queue, odp_event_t out_ev[], } else if (queue_is_atomic(qi)) { /* Hold queue during atomic access */ - sched_local.queue_index = qi; + sched_local.stash_qi = qi; } else { /* Continue scheduling the queue */ ring_enq(ring, RING_MASK, qi); } - handle = queue_from_index(qi); - sched_local.num = num; - sched_local.index = 0; - sched_local.queue = handle; - ret = copy_events(out_ev, max_num); + handle = queue_from_index(qi); + sched_local.stash_num = num; + sched_local.stash_index = 0; + sched_local.stash_queue = handle; + ret = copy_from_stash(out_ev, max_num); /* Output the source queue handle */ if (out_queue) @@ -918,11 +919,11 @@ static inline int do_schedule(odp_queue_t *out_queue, odp_event_t out_ev[], uint16_t round; uint32_t epoch; - if (sched_local.num) { - ret = copy_events(out_ev, max_num); + if (sched_local.stash_num) { + ret = copy_from_stash(out_ev, max_num); if (out_queue) - *out_queue = sched_local.queue; + *out_queue = sched_local.stash_queue; return ret; }