From patchwork Thu Feb 9 13:58:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Faggioli X-Patchwork-Id: 9564637 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 3F4AB601C3 for ; Thu, 9 Feb 2017 14:01:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A33A28499 for ; Thu, 9 Feb 2017 14:01:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1D831284D1; Thu, 9 Feb 2017 14:01:52 +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 4849528499 for ; Thu, 9 Feb 2017 14:01:50 +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 1cbpFE-0003tD-Rp; Thu, 09 Feb 2017 13:58:44 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cbpFD-0003sv-KO for xen-devel@lists.xenproject.org; Thu, 09 Feb 2017 13:58:43 +0000 Received: from [85.158.139.211] by server-3.bemta-5.messagelabs.com id C0/34-01943-2957C985; Thu, 09 Feb 2017 13:58:42 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpmleJIrShJLcpLzFFi42K5GNpwRHdi6Zw Igz39Qhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa0brvDVMBQeVK9Y/+8XYwLhCtouRi0NIYAaj xOTtn9hBHBaBNawSM67OBXMkBC6xSnTsaGPsYuQEcmIkZs16DZTgALIrJebfrwYJCwmoSNzcv ooJYtIvRomN838ygSSEBfQkjhz9wQ5hR0s8v3MMLM4mYCDxZsdeVhBbREBJ4t6qyWBxZoEoiT PLm5lBbBYBVYmdv1aD1fAKeErcWb4LrIZTwFvi/b217BCLvSSW/V3KAmKLCshJrLzcAlUvKHF y5hMWkDuZBTQl1u/ShxgvL7H97RzmCYwis5BUzUKomoWkagEj8ypG9eLUorLUIl0TvaSizPSM ktzEzBxdQwNTvdzU4uLE9NScxKRiveT83E2MwOBnAIIdjLf6nA8xSnIwKYnyyhbMiRDiS8pPq cxILM6ILyrNSS0+xKjBwSEw4ezc6UxSLHn5ealKErw9JUB1gkWp6akVaZk5wPiEKZXg4FES4Y 0ESfMWFyTmFmemQ6ROMRpz9HSdfsnEsWfX5ZdMQmCTpMR5q0BKBUBKM0rz4AbB0sYlRlkpYV5 GoDOFeApSi3IzS1DlXzGKczAqCfN+KwaawpOZVwK37xXQKUxAp1w/PQvklJJEhJRUAyN3XneH e/FOphNP1n459L90kqxhz+uEt1OlpnKyThfLNjzwdsHVX51bftgfuCZUbb3BYe7FJZlnI/8lf P4xRXuP1G6RvYyvI7TlZn6tmtpuzeGzuHB/ocuD2KpPme1hwW3GehOK7ty/8HQ5+1an7RLsC6 fOd8yQZeNpULvVoT1h0dYpNZpiNgJKLMUZiYZazEXFiQAK2waFFgMAAA== X-Env-Sender: raistlin.df@gmail.com X-Msg-Ref: server-2.tower-206.messagelabs.com!1486648721!63487393!1 X-Originating-IP: [209.85.128.196] 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 30940 invoked from network); 9 Feb 2017 13:58:41 -0000 Received: from mail-wr0-f196.google.com (HELO mail-wr0-f196.google.com) (209.85.128.196) by server-2.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 9 Feb 2017 13:58:41 -0000 Received: by mail-wr0-f196.google.com with SMTP id 89so12019543wrr.1 for ; Thu, 09 Feb 2017 05:58:41 -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=cJTJahLQSh+gKIu9IVXvphzqxidhYCB4U8zXQfZoCMA=; b=GW9drSZIQH7F3HTHgzueitXXfKFwAATg1dtKePbFozt3xyKYR/EhmAMloe53yQNAkf kt8o15eglCBTsyFRkXOykQMbxSM2V9t1i207Xw7b4CQaAYHXGL+dHv6ix2xOIgNxVrlv lNO/Vfdaho4bg1ITew85l7MFYVDrw78/epFlRzopwA32BjGfUx19pYsIMSAJP3qu1sOW OOJ2YYIYQVFexb7G5S4O9Z+peWspTUQy+W95BHy248+uV2g5ZoRzmSE9Tyoh5AFDW0t/ YqCQ5levqOMS8qF9sCMT6MR0cAxRnf35g2Y3kMG6L6jKH478VPy3fpARrpKrVt0x92e3 yeNA== 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=cJTJahLQSh+gKIu9IVXvphzqxidhYCB4U8zXQfZoCMA=; b=WLPNwgql+n2KV/apqdRq3ZGt02bEowudpHxLcnIaSLr3gQtAI6VtY0KeJNUIAH9oBC siyNygI3mFin+vS67K9mXPQPMMeL23DvOzr4VL/4CEKmb32yiKBtYmY/86d4xZTvQyU8 YfyVe19bhspJpF/HfcaEnVReTifmcfF7xqKUywcKylduw2xdaM+Oj45SIgKPeGblDVyh ZIrzKh76ViQAXv5d5qVQ/Jh17AfJwqRioDZqMHFGLTmTkMtVuKMwKaPDmA7vPOW558iS PHCbcz188zHBA0GeOsrrtXG2INVj5VxwrjwEp5EwJh6ihIbyaVD+CxU1+hY1BKHGAgjW s/fQ== X-Gm-Message-State: AMke39kZSwZY1ZVDXOHtnmlVfCNPLjceyCn551Cupda+n5Of5t8wQK7mFiGJdhyKXCLkAA== X-Received: by 10.223.155.135 with SMTP id d7mr2809739wrc.99.1486648720767; Thu, 09 Feb 2017 05:58:40 -0800 (PST) Received: from Solace.fritz.box ([80.66.223.139]) by smtp.gmail.com with ESMTPSA id h3sm18749894wrb.31.2017.02.09.05.58.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Feb 2017 05:58:40 -0800 (PST) From: Dario Faggioli To: xen-devel@lists.xenproject.org Date: Thu, 09 Feb 2017 14:58:38 +0100 Message-ID: <148664871841.595.8990926016843027402.stgit@Solace.fritz.box> In-Reply-To: <148664844741.595.10506268024432565895.stgit@Solace.fritz.box> References: <148664844741.595.10506268024432565895.stgit@Solace.fritz.box> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Cc: George Dunlap , Anshul Makkar Subject: [Xen-devel] [PATCH v2 03/10] 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 Reviewed-by: George Dunlap --- 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 920a7ce..b482990 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);