From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 61E16C43331 for ; Thu, 26 Mar 2020 09:19:41 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3B0CC20719 for ; Thu, 26 Mar 2020 09:19:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3B0CC20719 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jHOfj-0005am-6U; Thu, 26 Mar 2020 09:19:31 +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 1jHOfi-0005aI-40 for xen-devel@lists.xenproject.org; Thu, 26 Mar 2020 09:19:30 +0000 X-Inumbo-ID: e1ddaf35-6f42-11ea-877f-12813bfff9fa Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id e1ddaf35-6f42-11ea-877f-12813bfff9fa; Thu, 26 Mar 2020 09:19:24 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 1FF3FAF2C; Thu, 26 Mar 2020 09:19:23 +0000 (UTC) From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Thu, 26 Mar 2020 10:19:16 +0100 Message-Id: <20200326091918.12388-4-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20200326091918.12388-1-jgross@suse.com> References: <20200326091918.12388-1-jgross@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Xen-devel] [PATCH v8 3/5] 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 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é) 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 = !(ignore_mask & (1ul << RCU_SOFTIRQ)); for ( ; ; ) { @@ -38,7 +39,7 @@ static void __do_softirq(unsigned long ignore_mask) */ cpu = smp_processor_id(); - if ( rcu_pending(cpu) ) + if ( rcu_allowed && rcu_pending(cpu) ) rcu_check_callbacks(cpu); if ( ((pending = (softirq_pending(cpu) & ~ignore_mask)) == 0) @@ -53,9 +54,16 @@ static void __do_softirq(unsigned long ignore_mask) void process_pending_softirqs(void) { + unsigned long ignore_mask = (1ul << SCHEDULE_SOFTIRQ) | + (1ul << SCHED_SLAVE_SOFTIRQ); + + /* Block RCU processing in case of rcu_read_lock() held. */ + if ( preempt_count() ) + ignore_mask |= 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); } void do_softirq(void) -- 2.16.4