From nobody Tue Nov 11 15:38:43 2025 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1555774200; cv=none; d=zoho.com; s=zohoarc; b=VZMWO8X49putEf/ck4xKY1mjPiX6pDurgJ39wFxP91flBCox9bxd06TbO7/sPCe/bl1R/4h2kOl7MltN/K1A7IPvGAaA5Upo9LGQKbDfa2VwV+svKndfroAFVWAYBd4XVKuQFge2MSi5RVnvdbDzZAm6QvCmEb077y937pg9g3U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555774200; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=PLNrgH1rOXFMqWk4Hou9yF/5aJfXchVozWgT4vnfu7s=; b=Vc5fK3UR9Obx1illpXMpWsmSttWbehmRcSsx9WBkbMQK2fCqEWtWImB3vOx7dIRIi14tut/e5GYdtKdk878M9g0WwgkHp6mP3KpRhatVTNLbLv8ioL3zLtvIgqzWtS/L/sx2vs+exx37JTpz00t/if9PAnImlPAI1btxt1uJq98= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1555774200604615.4308875617778; Sat, 20 Apr 2019 08:30:00 -0700 (PDT) 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 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) 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) X-Inumbo-ID: 702e8544-6380-11e9-92d7-bc764e045a96 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) 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?= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" 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: Andrew Cooper Acked-by: Julien Grall Reviewed-by: Andrii Anisov --- Cc: Stefano Stabellini Cc: Julien Grall Cc: Jan Beulich Cc: Andrew Cooper Cc: Wei Liu Cc: "Roger Pau Monn=C3=A9" 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 *nex= t) ASSERT(prev !=3D next); ASSERT(!vcpu_cpu_dirty(next)); =20 - if ( prev !=3D next ) - update_runstate_area(prev); + update_runstate_area(prev); =20 local_irq_disable(); =20 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 *n= ext) const struct domain *prevd =3D prev->domain, *nextd =3D next->domain; unsigned int dirty_cpu =3D next->dirty_cpu; =20 + ASSERT(prev !=3D next); ASSERT(local_irq_is_enabled()); =20 get_cpu_info()->use_pv_cr3 =3D false; @@ -1732,12 +1733,9 @@ void context_switch(struct vcpu *prev, struct vcpu *= next) flush_mask(cpumask_of(dirty_cpu), FLUSH_VCPU_STATE); } =20 - if ( prev !=3D 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); =20 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) =20 context_saved(prev); =20 - if ( prev !=3D 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); =20 /* Ensure that the vcpu has an up-to-date time base. */ update_vcpu_system_time(next); _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel