From patchwork Sat Apr 20 15:24:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dario Faggioli X-Patchwork-Id: 10910353 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 529D4922 for ; Sat, 20 Apr 2019 15:27:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 431FF28698 for ; Sat, 20 Apr 2019 15:27:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3722D289A3; Sat, 20 Apr 2019 15:27:18 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C1D9128698 for ; Sat, 20 Apr 2019 15:27:17 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hHrrJ-0004AS-C1; Sat, 20 Apr 2019 15:24:53 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hHrrI-0004AK-0D for xen-devel@lists.xenproject.org; Sat, 20 Apr 2019 15:24:52 +0000 X-Inumbo-ID: 702e8544-6380-11e9-92d7-bc764e045a96 Received: from mail-wr1-f65.google.com (unknown [209.85.221.65]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 702e8544-6380-11e9-92d7-bc764e045a96; Sat, 20 Apr 2019 15:24:50 +0000 (UTC) Received: by mail-wr1-f65.google.com with SMTP id c12so4224711wrt.8 for ; Sat, 20 Apr 2019 08:24:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=HdwtS9Q12sY8RiIdCGepx9QrSu+Ygt1WZ4O5X6T9wI0=; b=AiOkrZIc77wiWqliNuGunz1NI+3IOE7vUD4lqwUQscaOQgvekn4cIz98As4yxhwwgp FNBn3NiE5MPzhw5vMA1R4On6DbjD8g7bo5A3FWS4wmYOvoGyXJIQzuXJoUnTVBiYxVcT 2eT42qXglKrRJOPQMn7QU41nwAn+QJISZLU6itg47YocTBPLZ7dgIRoIla658U8mGB/T 2Vi5uZJrkU7Tti/liy3SxNYvFyd2BTT/gFSb5jkNQs32A9BzVsdElTrSknA8VjLHc85t nq1+4njB7+wcOkdw7O+saFC5gV8D3cYw7N2ou4eyD5tgcZZGCxKH01JPwfhbASefwZU0 +gmg== X-Gm-Message-State: APjAAAV7muYkPUSsCzAN+iRplNOU2SABJRHRQ05cKpv6VrwMPoCJdnfG OvsBixswtHTKcQndaUvcD5M= X-Google-Smtp-Source: APXvYqx3EkjjqVALgHPJoh2cJLbVZN00oylHQa2+zn9b2uliM3IIy7YPVpB+7a99kd2t6JCOy943Dw== X-Received: by 2002:a5d:4742:: with SMTP id o2mr6291485wrs.298.1555773889569; Sat, 20 Apr 2019 08:24:49 -0700 (PDT) Received: from [127.0.0.1] (87.78.186.89.cust.ip.kpnqwest.it. [89.186.78.87]) by smtp.gmail.com with ESMTPSA id j3sm10471589wre.51.2019.04.20.08.24.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 20 Apr 2019 08:24:48 -0700 (PDT) From: Dario Faggioli To: xen-devel@lists.xenproject.org Date: Sat, 20 Apr 2019 17:24:47 +0200 Message-ID: <155577388740.25746.3780283868034526234.stgit@wayrath> In-Reply-To: <155577364571.25746.11988517450711182732.stgit@wayrath> References: <155577364571.25746.11988517450711182732.stgit@wayrath> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 2/2] xen: sched: we never get into context_switch() with prev==next X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Stefano Stabellini , Wei Liu , Andrew Cooper , George Dunlap , Julien Grall , Jan Beulich , Roger Pau =?utf-8?b?TW9ubsOp?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP In schedule(), if we pick, as the next vcpu to run (next) the same one that is running already (prev), we never get to call context_switch(). We can, therefore, get rid of all the `if`-s testing prev and next being different, trading them with an ASSERT() (on ARM, the ASSERT() was even already there!) Signed-off-by: Dario Faggioli Suggested-by: Juergen Gross Acked-by: Julien Grall Reviewed-by: Andrii Anisov Acked-by: Andrew Cooper --- Cc: Stefano Stabellini Cc: Julien Grall Cc: Jan Beulich Cc: Andrew Cooper Cc: Wei Liu Cc: "Roger Pau Monné" Cc: George Dunlap Cc: Juergen Gross --- xen/arch/arm/domain.c | 3 +-- xen/arch/x86/domain.c | 22 ++++++++-------------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 6dc633ed50..915ae0b4c6 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -343,8 +343,7 @@ void context_switch(struct vcpu *prev, struct vcpu *next) ASSERT(prev != next); ASSERT(!vcpu_cpu_dirty(next)); - if ( prev != next ) - update_runstate_area(prev); + update_runstate_area(prev); local_irq_disable(); diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 9eaa978ce5..d2d9f2fc3c 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -1721,6 +1721,7 @@ void context_switch(struct vcpu *prev, struct vcpu *next) const struct domain *prevd = prev->domain, *nextd = next->domain; unsigned int dirty_cpu = next->dirty_cpu; + ASSERT(prev != next); ASSERT(local_irq_is_enabled()); get_cpu_info()->use_pv_cr3 = false; @@ -1732,12 +1733,9 @@ void context_switch(struct vcpu *prev, struct vcpu *next) flush_mask(cpumask_of(dirty_cpu), FLUSH_VCPU_STATE); } - if ( prev != next ) - { - _update_runstate_area(prev); - vpmu_switch_from(prev); - np2m_schedule(NP2M_SCHEDLE_OUT); - } + _update_runstate_area(prev); + vpmu_switch_from(prev); + np2m_schedule(NP2M_SCHEDLE_OUT); if ( is_hvm_domain(prevd) && !list_empty(&prev->arch.hvm.tm_list) ) pt_save_timer(prev); @@ -1794,14 +1792,10 @@ void context_switch(struct vcpu *prev, struct vcpu *next) context_saved(prev); - if ( prev != next ) - { - _update_runstate_area(next); - - /* Must be done with interrupts enabled */ - vpmu_switch_to(next); - np2m_schedule(NP2M_SCHEDLE_IN); - } + _update_runstate_area(next); + /* Must be done with interrupts enabled */ + vpmu_switch_to(next); + np2m_schedule(NP2M_SCHEDLE_IN); /* Ensure that the vcpu has an up-to-date time base. */ update_vcpu_system_time(next);