From nobody Wed Oct 8 18:54:50 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1589196542; cv=none; d=zohomail.com; s=zohoarc; b=izkHBs8O8ajYFHadzutz9VnPkYSQCo2vHbCqI4rKDxjYw2tc9AdDig0q6VCb+e+PkwZxigBumSCiJ7ii2oOoHo8Z+MPu6Au4NWINOd7fRQf9TXBYXY2mWw/7HrM57NxYPn0feH+QGyeS4OvAMBEtDhV7tAiR/WZn6O8+K23A4sQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589196542; h=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; bh=RGmkL+FNO8UE5osky0A7jNUhPX6pYu2+wrqVfUmxuJA=; b=UtFISY3lRjehDH0yUrlZxjoK+zj6IozW5jWr/gujzdBGJE8avv6eWoeSeMshOx4vLxRy+D1uVSQFvZB1zBX9rbMKPEsCrlYfmobRFgbbHTdFzSZdRW86tZfvT8NsPtZTKOzstyIXdAsNpQ73mJ9ceoMwBprgVwcbLt64OZwV3sE= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) 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 1589196542736443.31777816058025; Mon, 11 May 2020 04:29:02 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jY6bx-0001fw-8p; Mon, 11 May 2020 11:28:41 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jY6bv-0001fi-IU for xen-devel@lists.xenproject.org; Mon, 11 May 2020 11:28:39 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 8c28f088-937a-11ea-9887-bc764e2007e4; Mon, 11 May 2020 11:28:34 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 63D35AECD; Mon, 11 May 2020 11:28:35 +0000 (UTC) X-Inumbo-ID: 8c28f088-937a-11ea-9887-bc764e2007e4 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Subject: [PATCH v2 1/3] xen/sched: allow rcu work to happen when syncing cpus in core scheduling Date: Mon, 11 May 2020 13:28:27 +0200 Message-Id: <20200511112829.5500-2-jgross@suse.com> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200511112829.5500-1-jgross@suse.com> References: <20200511112829.5500-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Sergey Dyasli , Stefano Stabellini , Julien Grall , Wei Liu , Andrew Cooper , Ian Jackson , George Dunlap , Dario Faggioli , Jan Beulich Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Content-Type: text/plain; charset="utf-8" With RCU barriers moved from tasklets to normal RCU processing cpu offlining in core scheduling might deadlock due to cpu synchronization required by RCU processing and core scheduling concurrently. Fix that by bailing out from core scheduling synchronization in case of pending RCU work. Additionally the RCU softirq is now required to be of higher priority than the scheduling softirqs in order to do RCU processing before entering the scheduler again, as bailing out from the core scheduling synchronization requires to raise another softirq SCHED_SLAVE, which would bypass RCU processing again. Reported-by: Sergey Dyasli Tested-by: Sergey Dyasli Signed-off-by: Juergen Gross Acked-by: Dario Faggioli --- V2: - add BUILD_BUG_ON() and comment (Dario Faggioli) --- xen/common/sched/core.c | 13 ++++++++++--- xen/include/xen/softirq.h | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/xen/common/sched/core.c b/xen/common/sched/core.c index d94b95285f..5df66cbf9b 100644 --- a/xen/common/sched/core.c +++ b/xen/common/sched/core.c @@ -2457,13 +2457,20 @@ static struct sched_unit *sched_wait_rendezvous_in(= struct sched_unit *prev, v =3D unit2vcpu_cpu(prev, cpu); } /* - * Coming from idle might need to do tasklet work. + * Check for any work to be done which might need cpu synchronizat= ion. + * This is either pending RCU work, or tasklet work when coming fr= om + * idle. It is mandatory that RCU softirqs are of higher priority + * than scheduling ones as otherwise a deadlock might occur. * In order to avoid deadlocks we can't do that here, but have to - * continue the idle loop. + * schedule the previous vcpu again, which will lead to the desired + * processing to be done. * Undo the rendezvous_in_cnt decrement and schedule another call = of * sched_slave(). */ - if ( is_idle_unit(prev) && sched_tasklet_check_cpu(cpu) ) + BUILD_BUG_ON(RCU_SOFTIRQ > SCHED_SLAVE_SOFTIRQ || + RCU_SOFTIRQ > SCHEDULE_SOFTIRQ); + if ( rcu_pending(cpu) || + (is_idle_unit(prev) && sched_tasklet_check_cpu(cpu)) ) { struct vcpu *vprev =3D current; =20 diff --git a/xen/include/xen/softirq.h b/xen/include/xen/softirq.h index b4724f5c8b..1f6c4783da 100644 --- a/xen/include/xen/softirq.h +++ b/xen/include/xen/softirq.h @@ -4,10 +4,10 @@ /* Low-latency softirqs come first in the following list. */ enum { TIMER_SOFTIRQ =3D 0, + RCU_SOFTIRQ, SCHED_SLAVE_SOFTIRQ, SCHEDULE_SOFTIRQ, NEW_TLBFLUSH_CLOCK_PERIOD_SOFTIRQ, - RCU_SOFTIRQ, TASKLET_SOFTIRQ, NR_COMMON_SOFTIRQS }; --=20 2.26.1