From patchwork Tue Feb 20 16:00:16 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: 128921 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp4796350ljc; Tue, 20 Feb 2018 08:06:49 -0800 (PST) X-Google-Smtp-Source: AH8x227kwtMLsXdpb9qBEk2axasD5VZlUTQ5ZvJzz7C8eona5y2oMTdppaGuvPfxlhcznTrLMqY2 X-Received: by 10.237.33.228 with SMTP id m33mr229341qtc.30.1519142809266; Tue, 20 Feb 2018 08:06:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519142809; cv=none; d=google.com; s=arc-20160816; b=Hh+5wacvhOFISbAlbI+nFUpFzHaEbd0GYki3auy09rHuGDSKhJonRh/zUK0HD45HJL xOsvIXnQBSuS+d4vhp12Vz+GSdfy8U5Glrd12xWOoDqw0pnwjdW7l1LIBz4fNoz5/qmk 8hl79xLbufofzrHn1clbX/bwhdIGPsWsI0ijQETAkJblKIo8U9Y9wlitveEJ9ibgQWB9 jSNAA2bsVjvUjmjIeWK5zPZHxOUax5b/wOAgopoRT1l8qIB8rkp6r1RurrWnYQOt4IVQ OegO2AouFNqRZ/eTcBxjDiGIbBkVHb9T0crDRaFwzMgUQTU1YQoA2UajitSAzIIQvsmM sghQ== 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=qromIoQgZRVQVAkTfRG8J0w1DbQOfkoWCiLYMV8xwaQ=; b=rzaE0ZqXv5pT1/Oh4J2DVTcgUlZB6tn6TokQE/xpNTJGXLfXtKRYM2c+g0Dourkudt z9+v414ICL8M5GCrsU+tVhplvtcXIOYagsLyn/nB2HZCaA7bEi8Dz3tBdj82mWbhx9LR MSN3zrHSaMgH+s/neuZ4t7ULU458VG1HonnOhvdxeffVOL+viBxwhPi/XTC4VkYS7FH0 1hGMTmEDj7apb5C9qM0UiC/1GX797kMftsrDNbX2pi+6kdV/f6B/tokBUd3IJ8H4OXip ikteIbuYbYmBcuNyNKSxhqitbs2vacz8Ji5YxDcCQaa4L6XJVPyJ5kM0fhbB6v6nGNud MCEA== 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 i62si2430685qtb.25.2018.02.20.08.06.48; Tue, 20 Feb 2018 08:06:49 -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 BB47B60B04; Tue, 20 Feb 2018 16:06:48 +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 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 C00F7608D9; Tue, 20 Feb 2018 16:01:04 +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 656FE60809; Tue, 20 Feb 2018 16:00:39 +0000 (UTC) Received: from forward106o.mail.yandex.net (forward106o.mail.yandex.net [37.140.190.187]) by lists.linaro.org (Postfix) with ESMTPS id C31C46150C for ; Tue, 20 Feb 2018 16:00:23 +0000 (UTC) Received: from mxback5g.mail.yandex.net (mxback5g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:166]) by forward106o.mail.yandex.net (Yandex) with ESMTP id B2500781F33 for ; Tue, 20 Feb 2018 19:00:22 +0300 (MSK) Received: from smtp4p.mail.yandex.net (smtp4p.mail.yandex.net [2a02:6b8:0:1402::15:6]) by mxback5g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id JPghvRPM8d-0MQipqeD; Tue, 20 Feb 2018 19:00:22 +0300 Received: by smtp4p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 1BLM25rTar-0LTGSqV7; Tue, 20 Feb 2018 19:00:21 +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: Tue, 20 Feb 2018 19:00:16 +0300 Message-Id: <1519142419-2141-5-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519142419-2141-1-git-send-email-odpbot@yandex.ru> References: <1519142419-2141-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 467 Subject: [lng-odp] [PATCH v3 4/7] linux-gen: schedule, queue: select scheduler/queue via environment 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: Dmitry Eremin-Solenikov Use ODP_SCHEDULER environment variable to select scheduler/queue implementation. Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 467 (lumag:sched-env) ** https://github.com/Linaro/odp/pull/467 ** Patch: https://github.com/Linaro/odp/pull/467.patch ** Base sha: d5419e8857b2bc61d3be17fe53f171550fee426b ** Merge commit sha: e203ffe9c0a48b78cb0d0f4aadbb16bb1f840b3c **/ platform/linux-generic/m4/odp_schedule.m4 | 29 +++++---------------- platform/linux-generic/odp_queue_if.c | 31 +++++++++++++++++----- platform/linux-generic/odp_schedule_if.c | 43 +++++++++++++++++++++---------- 3 files changed, 60 insertions(+), 43 deletions(-) diff --git a/platform/linux-generic/m4/odp_schedule.m4 b/platform/linux-generic/m4/odp_schedule.m4 index 087cff87f..70be5a7d6 100644 --- a/platform/linux-generic/m4/odp_schedule.m4 +++ b/platform/linux-generic/m4/odp_schedule.m4 @@ -1,23 +1,6 @@ -AC_ARG_ENABLE([schedule-sp], - [ --enable-schedule-sp enable strict priority scheduler], - [if test x$enableval = xyes; then - schedule_sp_enabled=yes - AC_DEFINE([ODP_SCHEDULE_SP], [1], - [Define to 1 to enable strict priority scheduler]) - fi]) - -AC_ARG_ENABLE([schedule-iquery], - [ --enable-schedule-iquery enable interests query (sparse bitmap) scheduler], - [if test x$enableval = xyes; then - schedule_iquery_enabled=yes - AC_DEFINE([ODP_SCHEDULE_IQUERY], [1], - [Define to 1 to enable interests query scheduler]) - fi]) - -AC_ARG_ENABLE([schedule_scalable], - [ --enable-schedule-scalable enable scalable scheduler], - [if test x$enableval = xyes; then - schedule_scalable_enabled=yes - AC_DEFINE([ODP_SCHEDULE_SCALABLE], [1], - [Define to 1 to enable scalable scheduler]) - fi]) +AC_ARG_ENABLE([scheduler-default], + [AS_HELP_STRING([enable-scheduler-default], + [Choose default scheduler (default is basic)])], + [], [enable_scheduler_default=basic]) +AC_DEFINE_UNQUOTED([ODP_SCHEDULE_DEFAULT], ["$enable_scheduler_default"], + [Define to name default scheduler]) diff --git a/platform/linux-generic/odp_queue_if.c b/platform/linux-generic/odp_queue_if.c index d1c468485..08076ab3a 100644 --- a/platform/linux-generic/odp_queue_if.c +++ b/platform/linux-generic/odp_queue_if.c @@ -8,6 +8,10 @@ #include #include +#include + +#include +#include extern const queue_api_t queue_scalable_api; extern const queue_fn_t queue_scalable_fn; @@ -15,13 +19,8 @@ extern const queue_fn_t queue_scalable_fn; extern const queue_api_t queue_basic_api; extern const queue_fn_t queue_basic_fn; -#ifdef ODP_SCHEDULE_SCALABLE -const queue_api_t *queue_api = &queue_scalable_api; -const queue_fn_t *queue_fn = &queue_scalable_fn; -#else -const queue_api_t *queue_api = &queue_basic_api; -const queue_fn_t *queue_fn = &queue_basic_fn; -#endif +const queue_api_t *queue_api; +const queue_fn_t *queue_fn; odp_queue_t odp_queue_create(const char *name, const odp_queue_param_t *param) { @@ -115,6 +114,24 @@ int odp_queue_info(odp_queue_t queue, odp_queue_info_t *info) int _odp_queue_init_global(void) { + const char *sched = getenv("ODP_SCHEDULER"); + + if (sched == NULL || !strcmp(sched, "default")) + sched = ODP_SCHEDULE_DEFAULT; + + if (!strcmp(sched, "basic") || + !strcmp(sched, "sp") || + !strcmp(sched, "iquery")) { + queue_fn = &queue_basic_fn; + queue_api = &queue_basic_api; + } else if (!strcmp(sched, "scalable")) { + queue_fn = &queue_scalable_fn; + queue_api = &queue_scalable_api; + } else { + ODP_ABORT("Unknown scheduler specified via ODP_SCHEDULER\n"); + return -1; + } + return queue_fn->init_global(); } diff --git a/platform/linux-generic/odp_schedule_if.c b/platform/linux-generic/odp_schedule_if.c index 049777516..2244eb557 100644 --- a/platform/linux-generic/odp_schedule_if.c +++ b/platform/linux-generic/odp_schedule_if.c @@ -8,6 +8,10 @@ #include #include +#include + +#include +#include extern const schedule_fn_t schedule_sp_fn; extern const schedule_api_t schedule_sp_api; @@ -21,19 +25,8 @@ extern const schedule_api_t schedule_iquery_api; extern const schedule_fn_t schedule_scalable_fn; extern const schedule_api_t schedule_scalable_api; -#ifdef ODP_SCHEDULE_SP -const schedule_fn_t *sched_fn = &schedule_sp_fn; -const schedule_api_t *sched_api = &schedule_sp_api; -#elif defined(ODP_SCHEDULE_IQUERY) -const schedule_fn_t *sched_fn = &schedule_iquery_fn; -const schedule_api_t *sched_api = &schedule_iquery_api; -#elif defined(ODP_SCHEDULE_SCALABLE) -const schedule_fn_t *sched_fn = &schedule_scalable_fn; -const schedule_api_t *sched_api = &schedule_scalable_api; -#else -const schedule_fn_t *sched_fn = &schedule_basic_fn; -const schedule_api_t *sched_api = &schedule_basic_api; -#endif +const schedule_fn_t *sched_fn; +const schedule_api_t *sched_api; uint64_t odp_schedule_wait_time(uint64_t ns) { @@ -138,6 +131,30 @@ void odp_schedule_order_unlock_lock(uint32_t unlock_index, uint32_t lock_index) int _odp_schedule_init_global(void) { + const char *sched = getenv("ODP_SCHEDULER"); + + if (sched == NULL || !strcmp(sched, "default")) + sched = ODP_SCHEDULE_DEFAULT; + + ODP_PRINT("Using scheduler '%s'\n", sched); + + if (!strcmp(sched, "basic")) { + sched_fn = &schedule_basic_fn; + sched_api = &schedule_basic_api; + } else if (!strcmp(sched, "sp")) { + sched_fn = &schedule_sp_fn; + sched_api = &schedule_sp_api; + } else if (!strcmp(sched, "iquery")) { + sched_fn = &schedule_iquery_fn; + sched_api = &schedule_iquery_api; + } else if (!strcmp(sched, "scalable")) { + sched_fn = &schedule_scalable_fn; + sched_api = &schedule_scalable_api; + } else { + ODP_ABORT("Unknown scheduler specified via ODP_SCHEDULER\n"); + return -1; + } + return sched_fn->init_global(); }