From patchwork Wed Feb 24 22:50:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: gary.robertson@linaro.org X-Patchwork-Id: 62842 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp2679452lbl; Wed, 24 Feb 2016 14:53:15 -0800 (PST) X-Received: by 10.140.102.142 with SMTP id w14mr43354573qge.58.1456354394910; Wed, 24 Feb 2016 14:53:14 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id b53si5007835qga.33.2016.02.24.14.53.14; Wed, 24 Feb 2016 14:53:14 -0800 (PST) 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 84B2962EF6; Wed, 24 Feb 2016 22:53:14 +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, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, 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 4403C65074; Wed, 24 Feb 2016 22:50:49 +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 72E6163015; Wed, 24 Feb 2016 22:50:22 +0000 (UTC) Received: from mail-oi0-f44.google.com (mail-oi0-f44.google.com [209.85.218.44]) by lists.linaro.org (Postfix) with ESMTPS id 2843363646 for ; Wed, 24 Feb 2016 22:50:19 +0000 (UTC) Received: by mail-oi0-f44.google.com with SMTP id j125so28287664oih.0 for ; Wed, 24 Feb 2016 14:50:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SOApzn6DFtsZQYjAFFTK2Oee6Pwhj18zmASCcYy7xWI=; b=FyzmpJ/0kRC7WhNDtPtHiiYQ5fzUIPAR4g2vft4eTmpr2JL6LG4LJR7WKx026DLb6q PTwULpqRn4sn0D73mw1LVRkXAnSrmjsQ4bcIbFvgKty/Kb6hceDbcTSQObITTwu6bBDU DJJt5KleGqxxsOZV+c/h/uP9rmHNEUm43Rd+GS9R6D5ztqIG7Rkb3+z5//535fo49l/O wy33Q44A/phml92WjYFvIlNtvfUj0cu93UWP62OBmUm1t2NM1p2E0EpyWSYN4Z6P/RjY 1QbwS3cjvZ9DmbeK9+C1naYGmPxr10hU0mYInXguO2a15w0IvOQwIsBW6EY60tUIoouj ho0A== X-Gm-Message-State: AG10YORPDCVnSRG3WSN9OJPzilxATVccLCZHQPgtVh+n4p76IvCQa0IdVueQowm+aMiel08tb84= X-Received: by 10.202.201.216 with SMTP id z207mr33962882oif.98.1456354218768; Wed, 24 Feb 2016 14:50:18 -0800 (PST) Received: from honkintosh.cybertech.lan (65-120-133-114.dia.static.qwest.net. [65.120.133.114]) by smtp.googlemail.com with ESMTPSA id qs6sm3271948oeb.3.2016.02.24.14.50.17 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 24 Feb 2016 14:50:18 -0800 (PST) From: "Gary S. Robertson" To: mike.holmes@linaro.org, bill.fischofer@linaro.org, maxim.uvarov@linaro.org, anders.roxell@linaro.org, petri.savolainen@linaro.org Date: Wed, 24 Feb 2016 16:50:01 -0600 Message-Id: <1456354201-31304-5-git-send-email-gary.robertson@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1456354201-31304-1-git-send-email-gary.robertson@linaro.org> References: <1456354201-31304-1-git-send-email-gary.robertson@linaro.org> X-Topics: patch Cc: lng-odp@lists.linaro.org Subject: [lng-odp] [API-NEXT PATCH 4/4] linux-generic: add support for initial cpumasks 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: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" These code changes depend on the addition of control and worker cpumask pointers to the ODP initialization parameter data structure, and implement the change in behavior suggested with that patch. They serve as the 'glue' between the input of the new ODP API initial cpuset masks and the use of those new cpumasks by the ODP application or instance. Specifically: if both of the cpumask pointers are NULL or if neither of the new cpumasks are populated prior to calling odp_init_global(), then the behavior for allocation of control and worker cpumasks is unchanged from its current (pre-patch) state. However, if the cpumasks are populated and their pointers initialized prior to calling odp_init_global() then that routine saves their contents into global variables for later reference. Then when odp_cpumask_default_control() or odp_cpumask_default_worker() are called they build the caller's cpumasks based on the saved contents of the pre-populated cpumask input. These changes allow multiple concurrent ODP applications or instances to be given CPU resources which do not conflict with one another, so multiple ODP instances can coexist harmoniously with any isolation support on the underlying platform as well as with one another. Signed-off-by: Gary S. Robertson --- platform/linux-generic/odp_init.c | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/platform/linux-generic/odp_init.c b/platform/linux-generic/odp_init.c index 5433eec..371b76c 100644 --- a/platform/linux-generic/odp_init.c +++ b/platform/linux-generic/odp_init.c @@ -98,16 +98,43 @@ int odp_init_global(const odp_init_t *params, odp_global_data.log_fn = odp_override_log; odp_global_data.abort_fn = odp_override_abort; + /* + * Default to allowing all installed CPUs for both + * control and worker cpumasks. + * If externally specified cpumasks are provided, + * we will use the installed CPU masks to confine + * the specified cpumasks to CPUs actually installed. + */ + if (get_installed_cpus()) { + ODP_ERR("ODP cpumask init failed.\n"); + goto init_failed; + } + if (params != NULL) { if (params->log_fn != NULL) odp_global_data.log_fn = params->log_fn; if (params->abort_fn != NULL) odp_global_data.abort_fn = params->abort_fn; - } - if (get_installed_cpus()) { - ODP_ERR("ODP cpumask init failed.\n"); - goto init_failed; + /* + * If either control or worker cpumasks were specified, + * 'AND' the specified cpumasks with the masks of + * installed CPUs to ensure only installed CPUs are + * specified as available. + * Save the control and / or worker cpumask contents + * in globally accessible data structures + * so odp_cpumask_default_control(), + * odp_cpumask_default_worker(), and any + * isolation support logic may reference them later. + */ + if (params->control_cpus) + odp_cpumask_and(&odp_global_data.control_cpus, + &odp_global_data.control_cpus, + params->control_cpus); + if (params->worker_cpus) + odp_cpumask_and(&odp_global_data.worker_cpus, + &odp_global_data.worker_cpus, + params->worker_cpus); } if (odp_time_init_global()) {