From nobody Mon Feb 9 08:11:52 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; 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 ARC-Seal: i=1; a=rsa-sha256; t=1584104830; cv=none; d=zohomail.com; s=zohoarc; b=MqUFLsqjnrj8MUun0Av1Yxn/WCo9koUWb2Sg+FA7ZKcPjoQhSxXXJbpogUfHITWP4ImTtJkDPgyJmfP+LsxVSRTEbJuIx/P5dwZUP8Wyh0QHAh5GmmBcNRCZRq3brcCscE7jfsvTmEprYJFSMKOcjgM34w6aeMS67xMiccwN69I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584104830; 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; bh=lpHZ0Urnq95QkupODe3x22/SDsgJMnThWeB2Wj8YdSM=; b=GfUwPBE2x5/6MQ7u8BL55Q45ADTInzhMmzfUFuvwZ4neNEzmDhE9rVit+rA1OymD/KGiWm50wk1i81PThe91bpCDR7LlZhqIvqBhyUZ920EnsnFHy4zZPsmZia4i2NAQ0NPlHbtj2u1zEPmmNhTA7LWyCg4JS+MdGZSO8b+LbHA= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1584104830864181.8120631321898; Fri, 13 Mar 2020 06:07:10 -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 1jCk15-00018T-3m; Fri, 13 Mar 2020 13:06:19 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jCk14-00018L-9h for xen-devel@lists.xenproject.org; Fri, 13 Mar 2020 13:06:18 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 6cdf3c78-652b-11ea-b34e-bc764e2007e4; Fri, 13 Mar 2020 13:06:17 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 03F05AFDC; Fri, 13 Mar 2020 13:06:17 +0000 (UTC) X-Inumbo-ID: 6cdf3c78-652b-11ea-b34e-bc764e2007e4 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Fri, 13 Mar 2020 14:06:12 +0100 Message-Id: <20200313130614.27265-3-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20200313130614.27265-1-jgross@suse.com> References: <20200313130614.27265-1-jgross@suse.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v6 2/4] xen: don't process rcu callbacks when holding a rcu_read_lock() 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 , Julien Grall , Wei Liu , Andrew Cooper , Ian Jackson , George Dunlap , Jan Beulich Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Some keyhandlers are calling process_pending_softirqs() while holding a rcu_read_lock(). This is wrong, as process_pending_softirqs() might activate rcu calls which should not happen inside a rcu_read_lock(). For that purpose modify process_pending_softirqs() to not allow rcu callback processing when a rcu_read_lock() is being held. Signed-off-by: Juergen Gross Reviewed-by: Jan Beulich --- V3: - add RCU_SOFTIRQ to ignore in process_pending_softirqs_norcu() (Roger Pau Monn=C3=A9) V5: - block rcu processing depending on rch_read_lock() being held or not (Jan Beulich) --- xen/common/softirq.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/xen/common/softirq.c b/xen/common/softirq.c index b83ad96d6c..00d676b62c 100644 --- a/xen/common/softirq.c +++ b/xen/common/softirq.c @@ -29,6 +29,7 @@ static void __do_softirq(unsigned long ignore_mask) { unsigned int i, cpu; unsigned long pending; + bool rcu_allowed =3D !(ignore_mask & (1ul << RCU_SOFTIRQ)); =20 for ( ; ; ) { @@ -38,7 +39,7 @@ static void __do_softirq(unsigned long ignore_mask) */ cpu =3D smp_processor_id(); =20 - if ( rcu_pending(cpu) ) + if ( rcu_allowed && rcu_pending(cpu) ) rcu_check_callbacks(cpu); =20 if ( ((pending =3D (softirq_pending(cpu) & ~ignore_mask)) =3D=3D 0) @@ -53,9 +54,16 @@ static void __do_softirq(unsigned long ignore_mask) =20 void process_pending_softirqs(void) { + unsigned long ignore_mask =3D (1ul << SCHEDULE_SOFTIRQ) | + (1ul << SCHED_SLAVE_SOFTIRQ); + + /* Block RCU processing in case of rcu_read_lock() held. */ + if ( preempt_count() ) + ignore_mask |=3D 1ul << RCU_SOFTIRQ; + ASSERT(!in_irq() && local_irq_is_enabled()); /* Do not enter scheduler as it can preempt the calling context. */ - __do_softirq((1ul << SCHEDULE_SOFTIRQ) | (1ul << SCHED_SLAVE_SOFTIRQ)); + __do_softirq(ignore_mask); } =20 void do_softirq(void) --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel