From nobody Tue Apr 30 14:32:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1582133179; cv=none; d=zohomail.com; s=zohoarc; b=dwC3Qdslt0K2T30gF32e63CbwojMjcIbi0IjAkmHcqYFKunDk9zrmP4wWxw3uK9SrLPFy6qPrzFPmOxSoZU7WvGNUF3mfFAak155r3vaRVQdST1BI8mqkz/V8oa3zdcKOtJrBfTEbmFPszw6pkBfsbekUQhLtnZHidjuhdIpszM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582133179; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=khC+1DPEvAxu5YGEmQR6PlbMv1/73HGaLRVOCnZdBIY=; b=l+X/wbh2kfIya0C8KjOlw4LjiqhOj2xrXfpot7rk0yc1MHTNA50VhsFiuO6qQguCuirU40FGEDmvPo+1m2uCYHBwXlIy5XlhW3zuJ7vG7OXRz+0U6rowgPaGKLa+m+K22X1Yn90cJULjNx7PMqkFHjT64ymkHwcUk4Eblocgz/E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1582133179788449.2114032040606; Wed, 19 Feb 2020 09:26:19 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j4T6O-0008Eu-QR; Wed, 19 Feb 2020 17:25:36 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j4T6M-0008Ep-Va for xen-devel@lists.xenproject.org; Wed, 19 Feb 2020 17:25:35 +0000 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id d59c1de0-533c-11ea-83f1-12813bfff9fa; Wed, 19 Feb 2020 17:25:34 +0000 (UTC) X-Inumbo-ID: d59c1de0-533c-11ea-83f1-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1582133133; h=from:to:cc:subject:date:message-id:mime-version; bh=WroCCiRPtp9FjMzqexf2EswxzzUxjsQOvqA6gkNmxcs=; b=KwR5nsme3XTLr68TScwYTrS/f2RPnNOW3esiZulDJ0ZdvdAXlmcwN3id XgyhkawC7gTuajzdrWQRM9Y4oBYliZ+1QXa0dqdEgc1HW4qzQx0wg7HF8 3p9Dbjyy4PiWMivZy2OU/fzjtWUIEea3Y23Ddwwetepzo6ikFuLxXgk9a k=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=igor.druzhinin@citrix.com; spf=Pass smtp.mailfrom=igor.druzhinin@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: none (zohomail.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; Received-SPF: None (esa6.hc3370-68.iphmx.com: no sender authenticity information available from domain of igor.druzhinin@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa6.hc3370-68.iphmx.com; envelope-from="igor.druzhinin@citrix.com"; x-sender="igor.druzhinin@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa6.hc3370-68.iphmx.com: domain of igor.druzhinin@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa6.hc3370-68.iphmx.com; envelope-from="igor.druzhinin@citrix.com"; x-sender="igor.druzhinin@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa6.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa6.hc3370-68.iphmx.com; envelope-from="igor.druzhinin@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: 3D+XjovEfwAYIeYanAwAAIfSoyOGE2Tftn/6kTGLAtoRkKSqCY3LSfLW7UJL5B12ienmB+lpQd COkUxHXWdavE1HKOhHuAnVbdH8KAami5yhjwkBPBbdP4fiW7i8/FUpxgVsJH3dvfH43r6plUbQ Qbr25Vr/3/WjFwPUQNZ1QAVSath3bimz1nC64geD3q5QTRH9Vv/LuByfqOamxEwHd/srzVrRHg 5kBon1Hjoji2jjFuhDby86Nbpw0yMwSbdk4x2uw0eKInTMqACOxzXsFVQIJCqhHo2L9yrzZg8B bHM= X-SBRS: 2.7 X-MesageID: 13136189 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.70,461,1574139600"; d="scan'208";a="13136189" From: Igor Druzhinin To: Date: Wed, 19 Feb 2020 17:25:28 +0000 Message-ID: <1582133128-25638-1-git-send-email-igor.druzhinin@citrix.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v2] x86/cpu: Sync any remaining RCU callbacks after CPU up/down 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: jgross@suse.com, Igor Druzhinin , wl@xen.org, andrew.cooper3@citrix.com, jbeulich@suse.com, roger.pau@citrix.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) During CPU down operation RCU callbacks are scheduled to finish off some actions later as soon as CPU is fully dead (the same applies to CPU up operation in case error path is taken). If in the same grace period another CPU up operation is performed on the same CPU, RCU callback will be called later on a CPU in a potentially wrong (already up again instead of still being down) state leading to eventual state inconsistency and/or crash. In order to avoid it - flush RCU callbacks explicitly upon finishing off the current operation. Signed-off-by: Igor Druzhinin Reviewed-by: Juergen Gross --- This got discovered trying to resume PV shim with multiple vCPUs on AMD machine (where park_offline_cpus =3D=3D 0). RCU callback responsible for freeing percpu area on CPU offline got finally called after CPU went online again as the guest performed regular vCPU offline/online operations on resume. Note: this patch requires RCU series from Juergen to be applied - https://lists.xenproject.org/archives/html/xen-devel/2020-02/msg01221.html v2: changed rcu_barrier() position, updated description --- xen/arch/x86/sysctl.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/sysctl.c b/xen/arch/x86/sysctl.c index 4a76f0f..dd5a24f 100644 --- a/xen/arch/x86/sysctl.c +++ b/xen/arch/x86/sysctl.c @@ -78,8 +78,11 @@ static void l3_cache_get(void *arg) long cpu_up_helper(void *data) { unsigned int cpu =3D (unsigned long)data; - int ret =3D cpu_up(cpu); + int ret; =20 + /* Flush potentially scheduled RCU work from preceding CPU offline */ + rcu_barrier(); + ret =3D cpu_up(cpu); if ( ret =3D=3D -EBUSY ) { /* On EBUSY, flush RCU work and have one more go. */ @@ -104,7 +107,11 @@ long cpu_up_helper(void *data) long cpu_down_helper(void *data) { int cpu =3D (unsigned long)data; - int ret =3D cpu_down(cpu); + int ret; + + /* Flush potentially scheduled RCU work from preceding CPU online */ + rcu_barrier(); + ret =3D cpu_down(cpu); if ( ret =3D=3D -EBUSY ) { /* On EBUSY, flush RCU work and have one more go. */ --=20 2.7.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel