From patchwork Tue Feb 15 10:15:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Fancellu X-Patchwork-Id: 12746857 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8B922C433EF for ; Tue, 15 Feb 2022 10:16:19 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.272924.467947 (Exim 4.92) (envelope-from ) id 1nJusT-0003if-RO; Tue, 15 Feb 2022 10:16:09 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 272924.467947; Tue, 15 Feb 2022 10:16:09 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nJusT-0003iR-Nc; Tue, 15 Feb 2022 10:16:09 +0000 Received: by outflank-mailman (input) for mailman id 272924; Tue, 15 Feb 2022 10:16:07 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nJusR-0002aj-Js for xen-devel@lists.xenproject.org; Tue, 15 Feb 2022 10:16:07 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-flk1.inumbo.com (Halon) with ESMTP id 49757801-8e48-11ec-b215-9bbe72dcb22c; Tue, 15 Feb 2022 11:16:06 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0D7F11063; Tue, 15 Feb 2022 02:16:06 -0800 (PST) Received: from e125770.cambridge.arm.com (e125770.cambridge.arm.com [10.1.195.16]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id ACF783F66F; Tue, 15 Feb 2022 02:16:04 -0800 (PST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 49757801-8e48-11ec-b215-9bbe72dcb22c From: Luca Fancellu To: xen-devel@lists.xenproject.org Cc: wei.chen@arm.com, George Dunlap , Dario Faggioli , Andrew Cooper , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu Subject: [PATCH 3/5] xen/sched: retrieve scheduler id by name Date: Tue, 15 Feb 2022 10:15:49 +0000 Message-Id: <20220215101551.23101-4-luca.fancellu@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220215101551.23101-1-luca.fancellu@arm.com> References: <20220215101551.23101-1-luca.fancellu@arm.com> Add a public function to retrieve the scheduler id by the scheduler name. Signed-off-by: Luca Fancellu --- xen/common/sched/core.c | 11 +++++++++++ xen/include/xen/sched.h | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/xen/common/sched/core.c b/xen/common/sched/core.c index 8f4b1ca10d1c..9696d3c1d769 100644 --- a/xen/common/sched/core.c +++ b/xen/common/sched/core.c @@ -2947,6 +2947,17 @@ void scheduler_enable(void) scheduler_active = true; } +int __init sched_get_id_by_name(const char *sched_name) +{ + unsigned int i; + + for ( i = 0; i < NUM_SCHEDULERS; i++ ) + if ( schedulers[i] && !strcmp(schedulers[i]->opt_name, sched_name) ) + return schedulers[i]->sched_id; + + return -1; +} + /* Initialise the data structures. */ void __init scheduler_init(void) { diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index a50df1bccdc0..a67a9eb2fe9d 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -756,6 +756,17 @@ void sched_destroy_domain(struct domain *d); long sched_adjust(struct domain *, struct xen_domctl_scheduler_op *); long sched_adjust_global(struct xen_sysctl_scheduler_op *); int sched_id(void); + +/* + * sched_get_id_by_name - retrieves a scheduler id given a scheduler name + * @sched_name: scheduler name as a string + * + * returns: + * positive value being the scheduler id, on success + * negative value if the scheduler name is not found. + */ +int sched_get_id_by_name(const char *sched_name); + void vcpu_wake(struct vcpu *v); long vcpu_yield(void); void vcpu_sleep_nosync(struct vcpu *v);