From patchwork Wed Mar 16 16:47:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chong Li X-Patchwork-Id: 8602541 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3A090C0553 for ; Wed, 16 Mar 2016 16:50:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 474802022A for ; Wed, 16 Mar 2016 16:50:30 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4F177202F0 for ; Wed, 16 Mar 2016 16:50:29 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1agEcB-0002A9-VE; Wed, 16 Mar 2016 16:48:07 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1agEcA-000295-Q3 for xen-devel@lists.xen.org; Wed, 16 Mar 2016 16:48:06 +0000 Received: from [85.158.137.68] by server-2.bemta-3.messagelabs.com id 67/70-03293-54E89E65; Wed, 16 Mar 2016 16:48:05 +0000 X-Env-Sender: lichong659@gmail.com X-Msg-Ref: server-13.tower-31.messagelabs.com!1458146884!29026916!1 X-Originating-IP: [209.85.223.169] X-SpamReason: No, hits=0.3 required=7.0 tests=MAILTO_TO_SPAM_ADDR X-StarScan-Received: X-StarScan-Version: 8.11; banners=-,-,- X-VirusChecked: Checked Received: (qmail 23275 invoked from network); 16 Mar 2016 16:48:04 -0000 Received: from mail-io0-f169.google.com (HELO mail-io0-f169.google.com) (209.85.223.169) by server-13.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 16 Mar 2016 16:48:04 -0000 Received: by mail-io0-f169.google.com with SMTP id n190so66537055iof.0 for ; Wed, 16 Mar 2016 09:48:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4mp9R9xQG0+I1xIPCAO98jYLVm0qCcOVAb8dSUMKbGc=; b=fdXcj4q/vUuJflB7wW/3LPIkxXe8PNGNW++lHJp2EV88RBKIN8P5S0ZGC49SS96w4s e7PmC3GxzH2tf9mlUeuUlGIsRa3p0nPl8aG19UvG7jaG1ymUTYuRLgfZFOn2zeT2Css9 oifzDGH2h3aI9K1OC5Aw94Gcik5hyFQee3CdC6EFHBoqTOV1jTWaq/uugABYL52z/yof YqSezDRAvMHOyR/gLCYuWHkT3QHoUE3Mh6qdljTbfMScZbbdF5VcaYJL1k81Y71zbCPc Bvci4pbfM5ymYZ5nGzqw3CIJ7tgtCl8E/jwxagqXuRKBoS9RDjKiMwJOvKYew4gYV8iI ZmQw== 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=4mp9R9xQG0+I1xIPCAO98jYLVm0qCcOVAb8dSUMKbGc=; b=LvMSaUeWtzx73/ktJP3hi1WqV1l3Q56XFRYRE50hWQ5C0O3jVwib6mq+JZqZNLv+zt qIWVCM5ghaPYWmMvBw2G2iQq/AwvhiLPMTsCu9P90OrfQ2rugqNBm41EZXTXG0uF45ew c8S0EsZP7E4VQGCNlNKkmdj4OaJrclh116DWS6QuY62jfeVLrlUqoZitfPXw7dDCIFzp mBV37QA4Y5kA3ovS/VBfWMi9kwr+OaOV+ijRYSRsWMXGKnvs4/U6DndCBrmkN745uhXS GZn0fK4zPYvGiFnKSKLPIN6rOl41Spd9DSPeRxjVaWuVqXyJiCisyA95ZpfOkq8cjb2f D4ig== X-Gm-Message-State: AD7BkJKozVmaRcUiE/mGMVgoj68cT0xb8k+JPIT7vn0Ih5G3ew6YYYetfu/WWnCZlVBvAQ== X-Received: by 10.107.43.2 with SMTP id r2mr4868695ior.156.1458146883974; Wed, 16 Mar 2016 09:48:03 -0700 (PDT) Received: from chong-OptiPlex-960.seas.wustl.edu (admin998.cec.wustl.edu. [128.252.20.193]) by smtp.googlemail.com with ESMTPSA id p8sm6838976igi.2.2016.03.16.09.48.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 16 Mar 2016 09:48:02 -0700 (PDT) From: Chong Li To: xen-devel@lists.xen.org Date: Wed, 16 Mar 2016 11:47:49 -0500 Message-Id: <1458146871-2813-3-git-send-email-lichong659@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1458146871-2813-1-git-send-email-lichong659@gmail.com> References: <1458146871-2813-1-git-send-email-lichong659@gmail.com> Cc: Chong Li , wei.liu2@citrix.com, Sisu Xi , george.dunlap@eu.citrix.com, dario.faggioli@citrix.com, Meng Xu , lichong659@gmail.com, dgolomb@seas.upenn.edu Subject: [Xen-devel] [PATCH v7 for Xen 4.7 2/4] libxc: enable per-VCPU parameter settings for RTDS scheduler X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add xc_sched_rtds_vcpu_get/set functions to interact with Xen to get/set a domain's per-VCPU parameters. Signed-off-by: Chong Li Signed-off-by: Meng Xu Signed-off-by: Sisu Xi Acked-by: Wei Liu Reviewed-by: Dario Faggioli --- Changes on PATCH v6: 1) Resolve some coding sytle issues Changes on PATCH v5: 1) In xc_sched_rtds_vcpu_get/set, re-issueing the hypercall if it is preempted. Changes on PATCH v4: 1) Minor modifications on the function parameters. Changes on PATCH v2: 1) Minor modifications due to the change of struct xen_domctl_scheduler_op. CC: CC: CC: CC: CC: CC: --- tools/libxc/include/xenctrl.h | 8 +++++ tools/libxc/xc_rt.c | 68 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h index 01a6dda..4567585 100644 --- a/tools/libxc/include/xenctrl.h +++ b/tools/libxc/include/xenctrl.h @@ -893,6 +893,14 @@ int xc_sched_rtds_domain_set(xc_interface *xch, int xc_sched_rtds_domain_get(xc_interface *xch, uint32_t domid, struct xen_domctl_sched_rtds *sdom); +int xc_sched_rtds_vcpu_set(xc_interface *xch, + uint32_t domid, + struct xen_domctl_schedparam_vcpu *vcpus, + uint32_t num_vcpus); +int xc_sched_rtds_vcpu_get(xc_interface *xch, + uint32_t domid, + struct xen_domctl_schedparam_vcpu *vcpus, + uint32_t num_vcpus); int xc_sched_arinc653_schedule_set( diff --git a/tools/libxc/xc_rt.c b/tools/libxc/xc_rt.c index d59e5ce..d1d1aa5 100644 --- a/tools/libxc/xc_rt.c +++ b/tools/libxc/xc_rt.c @@ -62,3 +62,71 @@ int xc_sched_rtds_domain_get(xc_interface *xch, return rc; } + +int xc_sched_rtds_vcpu_set(xc_interface *xch, + uint32_t domid, + struct xen_domctl_schedparam_vcpu *vcpus, + uint32_t num_vcpus) +{ + int rc = 0; + unsigned processed = 0; + DECLARE_DOMCTL; + DECLARE_HYPERCALL_BOUNCE(vcpus, sizeof(*vcpus) * num_vcpus, + XC_HYPERCALL_BUFFER_BOUNCE_IN); + + if ( xc_hypercall_bounce_pre(xch, vcpus) ) + return -1; + + domctl.cmd = XEN_DOMCTL_scheduler_op; + domctl.domain = (domid_t) domid; + domctl.u.scheduler_op.sched_id = XEN_SCHEDULER_RTDS; + domctl.u.scheduler_op.cmd = XEN_DOMCTL_SCHEDOP_putvcpuinfo; + + while ( processed < num_vcpus ) + { + domctl.u.scheduler_op.u.v.nr_vcpus = num_vcpus - processed; + set_xen_guest_handle_offset(domctl.u.scheduler_op.u.v.vcpus, vcpus, + processed); + if ( (rc = do_domctl(xch, &domctl)) != 0 ) + break; + processed += domctl.u.scheduler_op.u.v.nr_vcpus; + } + + xc_hypercall_bounce_post(xch, vcpus); + + return rc; +} + +int xc_sched_rtds_vcpu_get(xc_interface *xch, + uint32_t domid, + struct xen_domctl_schedparam_vcpu *vcpus, + uint32_t num_vcpus) +{ + int rc; + unsigned processed = 0; + DECLARE_DOMCTL; + DECLARE_HYPERCALL_BOUNCE(vcpus, sizeof(*vcpus) * num_vcpus, + XC_HYPERCALL_BUFFER_BOUNCE_BOTH); + + if ( xc_hypercall_bounce_pre(xch, vcpus) ) + return -1; + + domctl.cmd = XEN_DOMCTL_scheduler_op; + domctl.domain = (domid_t) domid; + domctl.u.scheduler_op.sched_id = XEN_SCHEDULER_RTDS; + domctl.u.scheduler_op.cmd = XEN_DOMCTL_SCHEDOP_getvcpuinfo; + + while ( processed < num_vcpus ) + { + domctl.u.scheduler_op.u.v.nr_vcpus = num_vcpus - processed; + set_xen_guest_handle_offset(domctl.u.scheduler_op.u.v.vcpus, vcpus, + processed); + if ( (rc = do_domctl(xch, &domctl)) != 0 ) + break; + processed += domctl.u.scheduler_op.u.v.nr_vcpus; + } + + xc_hypercall_bounce_post(xch, vcpus); + + return rc; +}