Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp622479imp; Wed, 20 Feb 2019 06:16:24 -0800 (PST) X-Google-Smtp-Source: AHgI3IZTTqiW3cswk4q3FOzAyjgC1vDAyqqXNnS30lBw3dkVlSQRToWz+aaDCyohDUy7K1UBiPKc X-Received: by 2002:a62:ca13:: with SMTP id n19mr26028835pfg.221.1550672184165; Wed, 20 Feb 2019 06:16:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550672184; cv=none; d=google.com; s=arc-20160816; b=GnCBnmC+KNwA8i1Jv2jrsLvfy47808mW9uEv6zYlc4EDwu1EoMcJQvTlXzn9p5wCAA bWvl4KOx3wYBXd7yaberoKjh6B7i74R4SlC4ZaGjd9hAQH9UIGBdrLAXoNaEB/uUbuoK oHjblNgZoP/7q3Qwx6D4IFCpdwMapUpu25IOy6/g6wx1+5zWpdhIyZ09WsxBNaAoT+Bm WJYVEIO9e6HqPNEwHwo8lDGCuRUzSln3/dd9L9TYJM81sj9/mWz6SvD9FOlyr+s8w7BG eL/QNi36eOwomL0l4zztF+bTcfJyNRcFic402mEwmYIdvtiZ9hJ1bwfQPJn33zzuc6gt xusQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=kwzaQ7PDmIxJWhSBOBZWv5L9s0nn2lyMfYXs7BhpGPQ=; b=bt9KCt04ds5BMqcx+M71sCE9UvTfSaP3/YwCx0XkDneFqx2II+1SgCrN93Sr7P9ChY QZTlDQ1oOd8dGydPwUL/K0pbMlogSVpnZAOJ1LteyOUfQT1p6xxAyBC4XnQR381jwa4m sdB66rczgOYF2uvJOyfTbzEU4eGVj5c+y5eCAIX/Jncnu+1O+ZFVUaBJ4OT8hebJYfry vTrBUhxkd+9uIOcqQY39KzDC5UZQDlx4j4oimD60paAzNIKreqGL8td62NaOfMwKp66p P+eloB4q18iZ1ODmkdOXCrkCBkRdlhvloqvp8wUEGg/PJpDlCXfEMKNHaaZQ3/g6emGB PTlw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g28si3873606pgm.455.2019.02.20.06.16.08; Wed, 20 Feb 2019 06:16:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726902AbfBTOPD (ORCPT + 99 others); Wed, 20 Feb 2019 09:15:03 -0500 Received: from foss.arm.com ([217.140.101.70]:58456 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726030AbfBTOPC (ORCPT ); Wed, 20 Feb 2019 09:15:02 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 84AF1EBD; Wed, 20 Feb 2019 06:15:02 -0800 (PST) Received: from [10.1.196.50] (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 74E5F3F690; Wed, 20 Feb 2019 06:15:01 -0800 (PST) Subject: Re: xen/evtchn and forced threaded irq To: Boris Ostrovsky Cc: Juergen Gross , Stefano Stabellini , xen-devel , "linux-kernel@vger.kernel.org" , Dave P Martin References: <5e256d9a-572c-e01e-7706-407f99245b00@arm.com> <20190220000209.GA4091@localhost.localdomain> From: Julien Grall Message-ID: Date: Wed, 20 Feb 2019 14:15:00 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 In-Reply-To: <20190220000209.GA4091@localhost.localdomain> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Boris, Thank you for your answer. On 20/02/2019 00:02, Boris Ostrovsky wrote: > On Tue, Feb 19, 2019 at 05:31:10PM +0000, Julien Grall wrote: >> Hi all, >> >> I have been looking at using Linux RT in Dom0. Once the guest is started, >> the console is ending to have a lot of warning (see trace below). >> >> After some investigation, this is because the irq handler will now be threaded. >> I can reproduce the same error with the vanilla Linux when passing the option >> 'threadirqs' on the command line (the trace below is from 5.0.0-rc7 that has >> not RT support). >> >> FWIW, the interrupt for port 6 is used to for the guest to communicate with >> xenstore. >> >> From my understanding, this is happening because the interrupt handler is now >> run in a thread. So we can have the following happening. >> >> Interrupt context | Interrupt thread >> | >> receive interrupt port 6 | >> clear the evtchn port | >> set IRQF_RUNTHREAD | >> kick interrupt thread | >> | clear IRQF_RUNTHREAD >> | call evtchn_interrupt >> receive interrupt port 6 | >> clear the evtchn port | >> set IRQF_RUNTHREAD | >> kick interrupt thread | >> | disable interrupt port 6 >> | evtchn->enabled = false >> | [....] >> | >> | *** Handling the second interrupt *** >> | clear IRQF_RUNTHREAD >> | call evtchn_interrupt >> | WARN(...) >> >> I am not entirely sure how to fix this. I have two solutions in mind: >> >> 1) Prevent the interrupt handler to be threaded. We would also need to >> switch from spin_lock to raw_spin_lock as the former may sleep on RT-Linux. >> >> 2) Remove the warning > > I think access to evtchn->enabled is racy so (with or without the warning) we can't use it reliably. Thinking about it, it would not be the only issue. The ring is sized to contain only one instance of the same event. So if you receive twice the event, you may overflow the ring. > > Another alternative could be to queue the irq if !evtchn->enabled and handle it in evtchn_write() (which is where irq is supposed to be re-enabled). What do you mean by queue? Is it queueing in the ring? If so, wouldn't it be racy as described above? Cheers, -- Julien Grall