From patchwork Fri Apr 1 04:59:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chong Li X-Patchwork-Id: 8720221 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 A4E07C0553 for ; Fri, 1 Apr 2016 05:02:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A0C032037C for ; Fri, 1 Apr 2016 05:02:55 +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 982AF20279 for ; Fri, 1 Apr 2016 05:02:54 +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 1alrBp-00055a-1u; Fri, 01 Apr 2016 05:00:09 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1alrBn-00055G-Lb for xen-devel@lists.xen.org; Fri, 01 Apr 2016 05:00:07 +0000 Received: from [85.158.143.35] by server-1.bemta-6.messagelabs.com id 5B/9E-29237-6500EF65; Fri, 01 Apr 2016 05:00:06 +0000 X-Env-Sender: lichong659@gmail.com X-Msg-Ref: server-3.tower-21.messagelabs.com!1459486805!6430892!1 X-Originating-IP: [209.85.213.177] 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 14098 invoked from network); 1 Apr 2016 05:00:06 -0000 Received: from mail-ig0-f177.google.com (HELO mail-ig0-f177.google.com) (209.85.213.177) by server-3.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 1 Apr 2016 05:00:06 -0000 Received: by mail-ig0-f177.google.com with SMTP id l20so5441720igf.0 for ; Thu, 31 Mar 2016 22:00:06 -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=A6I/Ftl0IwYlpICffoD/nmvjrQlqZ5NeHe52NPzBb58=; b=jRX0aFV/TKyn92JAHaAXZMApl3BNv5NfpnxQGcknuRloESux4dxYaYIEpnB9aMfD+V KGZ5V4qaYXkjYzCrhtseR2rigTYQCIyFKt5l4z5YX5ymYm/MuvQXtyhQ5uNXcZCM7Wz4 nn7FldraCHPw5mpoz+Ozd4DpxntEysKKD3LUGIUubc4qckgkYGrJadQIrhFiUMee/Kgr qKYyKIWdK1Ww1WB2YxcybokwlyUePEVbQRxhYAwaZAnZul2xc21fSCf0ugglLxi4fV9t zWu2//yRTJuPXWXenf1Jy9ZRpotLCzYZJDGzfTlwNcIh9tBInir1Ch01eQXOnz6/5jyX pvyw== 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=A6I/Ftl0IwYlpICffoD/nmvjrQlqZ5NeHe52NPzBb58=; b=escM8ZolwfrDpzh+wp0XetBpn6UtQVCdjJckJ3ym3FdJHSSlDo3yJp5VT4hLygN9g/ hEfGP7tvCNxgsVx8R3neqbf6ARQ88nkaT+PC6rU1RNgLpB9PTNe9bwb4cjVwzZYF+uFH 0uwcr8F+QnX50G6Oc13ZhcDiEiZObwG0kRVOB78v+7uMkwcmz0mq8nvIzAuKHVJK1I5c yRKhXPUzygpc7/uZIQ7yCcHfDb1H4l46GvtwQcjBI8GwOnhtaABGgt9ut67neDnC/L9V aXStY7iwhcB3y2BbVKGRxTuUtaFSJwMYQh4EwZU/xtH8q5l/upNSMnzonJT/Qq1ajOzR 2EDQ== X-Gm-Message-State: AD7BkJIZfOKKfsI8mfMpTJM0QVi3PZxKXhc7Fj8thSepXIvH/5foLG7Dtgav5WKk+l+Q+w== X-Received: by 10.50.138.69 with SMTP id qo5mr1230337igb.17.1459486802926; Thu, 31 Mar 2016 22:00:02 -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 z200sm5192945iod.26.2016.03.31.22.00.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 31 Mar 2016 22:00:01 -0700 (PDT) From: Chong Li To: xen-devel@lists.xen.org Date: Thu, 31 Mar 2016 23:59:44 -0500 Message-Id: <1459486786-3085-3-git-send-email-lichong659@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1459486786-3085-1-git-send-email-lichong659@gmail.com> References: <1459486786-3085-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 v9 for Xen 4.7 2/4] libxc: enable per-VCPU parameter for RTDS 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=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable 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 v7: 1) rc in xc_sched_rtds_vcpu_set() should not be initialized to 0. It is fixed. 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 a9e4dc1..f430ef9 100644 --- a/tools/libxc/include/xenctrl.h +++ b/tools/libxc/include/xenctrl.h @@ -878,6 +878,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..221d17f 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; + 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; +}