From patchwork Thu Jan 26 00:29:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Faggioli X-Patchwork-Id: 9538191 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 80DB4604A7 for ; Thu, 26 Jan 2017 00:32:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 741C126B39 for ; Thu, 26 Jan 2017 00:32:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6950427F85; Thu, 26 Jan 2017 00:32:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RCVD_IN_SORBS_SPAM,T_DKIM_INVALID autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id D35C827E33 for ; Thu, 26 Jan 2017 00:32:08 +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 1cWXws-0005IE-7g; Thu, 26 Jan 2017 00:29:58 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cWXwq-0005I2-TN for xen-devel@lists.xenproject.org; Thu, 26 Jan 2017 00:29:57 +0000 Received: from [85.158.137.68] by server-13.bemta-3.messagelabs.com id 96/C5-25657-40349885; Thu, 26 Jan 2017 00:29:56 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrLIsWRWlGSWpSXmKPExsXiVRvkosvs3Bl h8OmJjMX3LZOZHBg9Dn+4whLAGMWamZeUX5HAmjH11QvmgoPKFRd3XWdvYFwh28XIxSEkMINR YtmEZ0wgDovAGlaJiWvesII4EgKXWCUub25n62LkBHJiJA4e/c4CYZdLbJl1lhHEFhJQkbi5f RUT1Cgmic9Ln4MVCQvoSRw5+oMdwg6TWPF6OVgDm4CBxJsde1lBbBEBJYl7qyYzgdjMAlESZ5 Y3M3cxcgCdoSrxbbYpSJhXwEui6ek+sHJOAW+JGZM/MIGUCAHFpx3IAQmLCshJrLzcwgpRLih xcuYTFpASZgFNifW79CGGy0tsfzuHeQKjyCwkVbMQqmYhqVrAyLyKUaM4tagstUjX0FQvqSgz PaMkNzEzR9fQwFgvN7W4ODE9NScxqVgvOT93EyMw+BmAYAfjmu2ehxglOZiURHlvandGCPEl5 adUZiQWZ8QXleakFh9i1ODgEJhwdu50JimWvPy8VCUJXhsnoDrBotT01Iq0zBxgfMKUSnDwKI nweoKkeYsLEnOLM9MhUqcYdTl27br8kkkIbIaUOK8dSJEASFFGaR7cCFiquMQoKyXMywh0oBB PQWpRbmYJqvwrRnEORiVhXg+QKTyZeSVwm14BHcEEdMQF5naQI0oSEVJSDYyhLVPehrjJX417 VirTOFfrbW3RY0FlbZm9C1t60m/aFbjcOL6iWK3489mDGf/ij7Bv1Cpr0tgoOvfCNSM151j+l PzSB1HzQmTD3AIdZ4f/af55IGvTHYaF3jumZ85Y6T0lP0eGmY3nYodWwcWvXMsmK7OWzmJRn5 vzUtSR7+MptZgqsVY3VSWW4oxEQy3mouJEAM0acP4QAwAA X-Env-Sender: raistlin.df@gmail.com X-Msg-Ref: server-7.tower-31.messagelabs.com!1485390595!74858733!1 X-Originating-IP: [74.125.82.68] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.1.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 2798 invoked from network); 26 Jan 2017 00:29:55 -0000 Received: from mail-wm0-f68.google.com (HELO mail-wm0-f68.google.com) (74.125.82.68) by server-7.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 26 Jan 2017 00:29:55 -0000 Received: by mail-wm0-f68.google.com with SMTP id c85so46331880wmi.1 for ; Wed, 25 Jan 2017 16:29:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=dAh+0NEAseSpm+U0nNALKDlO0XWHkgQopshZu7CntCI=; b=maaLAvnm4EzA2DoWsPK5D5Aqc0n3LkcFO+9sgiI/T4hp/xqNlEDlWxeASJheDb9B69 lucTDAgGkNc6qRpCUwM2wCsQqFrWcIQV6gkVGOB1fyx1IxP8xsl5AjFt7vHH7OLU/H4f TbCtPon958bSC4k8aC9jp/A5+33d1S6DN7fNVRXOYrd3F9JT7QElkoBa9O18VbCWKTUg RiHa4rDttcIebwxYOO3s1jlB6qdodK2Sye/Sdg2clcLKQaBA0s254SjTgr5jSg0M/T07 pMHY55tbiJND2xo46x1JB93EDZKgQjHOC+qE6Ecj4gcpNbhIDgP0XuHMtPSOD0B7BgsW 0KbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:cc:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=dAh+0NEAseSpm+U0nNALKDlO0XWHkgQopshZu7CntCI=; b=C9J0buz6h53ycmF7B3UEqSKzf61yhjgrwGFe8Xgnft4kHYg/Vx1Leqhv8AFHnlNzZq yOlmBflMkd2A1KaKkbobtIKuFAkfsj2x47pOsYTm82eRQU6AjZ4UHPa3ctqqxxmQR9wg zUoxJkXs7b5b5ym8G7MPWNR1oV/y0+qPzkyBvH50NQP0mrR7kZm5FMX54WOvCc6kDe6y m+msph39u7zckpIgXSaNbVUmo2QbII6XgNuVsEfxyEE5ejsevjXswXc29yUDGEL0kYrC IZs25tXiNXrZfQNC3d/CREUB4ti2srxrl2d73scL6YWudOWZcv9HmEDHYbYhGltF81XW krmg== X-Gm-Message-State: AIkVDXKj3H006E39MRF9irMBasPZEucT666prM6supiFiAvger1M65tybvHe/ZLXlLNKEg== X-Received: by 10.28.4.10 with SMTP id 10mr15844280wme.142.1485390594884; Wed, 25 Jan 2017 16:29:54 -0800 (PST) Received: from Solace.fritz.box (58-209-66-80.hosts.abilene.it. [80.66.209.58]) by smtp.gmail.com with ESMTPSA id a13sm34039439wma.0.2017.01.25.16.29.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Jan 2017 16:29:54 -0800 (PST) From: Dario Faggioli To: xen-devel@lists.xenproject.org Date: Thu, 26 Jan 2017 01:29:52 +0100 Message-ID: <148539059285.5464.9430356870545052516.stgit@Solace.fritz.box> In-Reply-To: <148539008889.5464.5896389113741708672.stgit@Solace.fritz.box> References: <148539008889.5464.5896389113741708672.stgit@Solace.fritz.box> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Cc: George Dunlap , Anshul Makkar Subject: [Xen-devel] [PATCH 1/9] xen: credit2: improve comments' style and definition of CSFLAG-s 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: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Most of the comments describing the meaning of the vCPU flags used by the scheduler miss the 'wings' (or have other minor style issues). Also, use 1U (instead of 1) as the base of shiftings. No functional change intended. Signed-off-by: Dario Faggioli --- Cc: George Dunlap Cc: Anshul Makkar --- xen/common/sched_credit2.c | 54 ++++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c index 2ce738d..322cf6b 100644 --- a/xen/common/sched_credit2.c +++ b/xen/common/sched_credit2.c @@ -129,35 +129,47 @@ /* * Basic constants */ -/* Default weight: How much a new domain starts with */ +/* Default weight: How much a new domain starts with. */ #define CSCHED2_DEFAULT_WEIGHT 256 -/* Min timer: Minimum length a timer will be set, to - * achieve efficiency */ +/* + * Min timer: Minimum length a timer will be set, to + * achieve efficiency. + */ #define CSCHED2_MIN_TIMER MICROSECS(500) -/* Amount of credit VMs begin with, and are reset to. +/* + * Amount of credit VMs begin with, and are reset to. * ATM, set so that highest-weight VMs can only run for 10ms - * before a reset event. */ + * before a reset event. + */ #define CSCHED2_CREDIT_INIT MILLISECS(10) -/* Carryover: How much "extra" credit may be carried over after - * a reset. */ +/* + * Amount of credit the idle vcpus have. It never changes, as idle + * vcpus does not consume credits, and it must be lower than whatever + * amount of credit 'regular' vcpu would end up with. + */ +#define CSCHED2_IDLE_CREDIT (-(1U<<30)) +/* + * Carryover: How much "extra" credit may be carried over after + * a reset. + */ #define CSCHED2_CARRYOVER_MAX CSCHED2_MIN_TIMER -/* Stickiness: Cross-L2 migration resistance. Should be less than - * MIN_TIMER. */ +/* + * Stickiness: Cross-L2 migration resistance. Should be less than + * MIN_TIMER. + */ #define CSCHED2_MIGRATE_RESIST ((opt_migrate_resist)*MICROSECS(1)) -/* How much to "compensate" a vcpu for L2 migration */ +/* How much to "compensate" a vcpu for L2 migration. */ #define CSCHED2_MIGRATE_COMPENSATION MICROSECS(50) /* Reset: Value below which credit will be reset. */ #define CSCHED2_CREDIT_RESET 0 /* Max timer: Maximum time a guest can be run for. */ #define CSCHED2_MAX_TIMER CSCHED2_CREDIT_INIT - -#define CSCHED2_IDLE_CREDIT (-(1<<30)) - /* * Flags */ -/* CSFLAG_scheduled: Is this vcpu either running on, or context-switching off, +/* + * CSFLAG_scheduled: Is this vcpu either running on, or context-switching off, * a physical cpu? * + Accessed only with runqueue lock held * + Set when chosen as next in csched2_schedule(). @@ -167,8 +179,9 @@ * + Checked to be false in runq_insert. */ #define __CSFLAG_scheduled 1 -#define CSFLAG_scheduled (1<<__CSFLAG_scheduled) -/* CSFLAG_delayed_runq_add: Do we need to add this to the runqueue once it'd done +#define CSFLAG_scheduled (1U<<__CSFLAG_scheduled) +/* + * CSFLAG_delayed_runq_add: Do we need to add this to the runqueue once it'd done * being context switched out? * + Set when scheduling out in csched2_schedule() if prev is runnable * + Set in csched2_vcpu_wake if it finds CSFLAG_scheduled set @@ -176,20 +189,21 @@ * clears the bit. */ #define __CSFLAG_delayed_runq_add 2 -#define CSFLAG_delayed_runq_add (1<<__CSFLAG_delayed_runq_add) -/* CSFLAG_runq_migrate_request: This vcpu is being migrated as a result of a +#define CSFLAG_delayed_runq_add (1U<<__CSFLAG_delayed_runq_add) +/* + * CSFLAG_runq_migrate_request: This vcpu is being migrated as a result of a * credit2-initiated runq migrate request; migrate it to the runqueue indicated * in the svc struct. */ #define __CSFLAG_runq_migrate_request 3 -#define CSFLAG_runq_migrate_request (1<<__CSFLAG_runq_migrate_request) +#define CSFLAG_runq_migrate_request (1U<<__CSFLAG_runq_migrate_request) /* * CSFLAG_vcpu_yield: this vcpu was running, and has called vcpu_yield(). The * scheduler is invoked to see if we can give the cpu to someone else, and * get back to the yielding vcpu in a while. */ #define __CSFLAG_vcpu_yield 4 -#define CSFLAG_vcpu_yield (1<<__CSFLAG_vcpu_yield) +#define CSFLAG_vcpu_yield (1U<<__CSFLAG_vcpu_yield) static unsigned int __read_mostly opt_migrate_resist = 500; integer_param("sched_credit2_migrate_resist", opt_migrate_resist);