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=-5.4 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no 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 4D1A5C00A89 for ; Mon, 2 Nov 2020 13:53:26 +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 D40E9208B6 for ; Mon, 2 Nov 2020 13:53:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="SQLG6KFm" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D40E9208B6 Authentication-Results: mail.kernel.org; dmarc=fail (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 list by lists.xenproject.org with outflank-mailman.17666.42467 (Exim 4.92) (envelope-from ) id 1kZaGZ-0003NT-Kr; Mon, 02 Nov 2020 13:52:59 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 17666.42467; Mon, 02 Nov 2020 13:52:59 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kZaGZ-0003NM-Ht; Mon, 02 Nov 2020 13:52:59 +0000 Received: by outflank-mailman (input) for mailman id 17666; Mon, 02 Nov 2020 13:52:58 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kZaGX-0003NA-W6 for xen-devel@lists.xenproject.org; Mon, 02 Nov 2020 13:52:58 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTP id 4e8783a3-702b-43c5-8cf2-555bb8e3d1b8; Mon, 02 Nov 2020 13:52:57 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 90768AC3F; Mon, 2 Nov 2020 13:52:56 +0000 (UTC) Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kZaGX-0003NA-W6 for xen-devel@lists.xenproject.org; Mon, 02 Nov 2020 13:52:58 +0000 X-Inumbo-ID: 4e8783a3-702b-43c5-8cf2-555bb8e3d1b8 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTP id 4e8783a3-702b-43c5-8cf2-555bb8e3d1b8; Mon, 02 Nov 2020 13:52:57 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1604325176; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Gza3k4FbBeMI9MxVAdSOqIzM9oPUqn08pyvWUJUwN6g=; b=SQLG6KFm2DbYucRpb6FNU4zfsmj3kJRm7yV8j0v3YF5IxxOjPBCvOXPWACa9eOzUiK6EVk ca8lfycYzPS1kEtGY1dBRmmnkGDqGZEE/YarWjBAg0UUpr5PLmhEa7fpj1wb2P/Qk4O0Ko l55+FSvUB5bvWPPIbtSCLssVZSubeaQ= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 90768AC3F; Mon, 2 Nov 2020 13:52:56 +0000 (UTC) Subject: Re: [PATCH v3 2/2] xen/evtchn: rework per event channel lock To: =?UTF-8?B?SsO8cmdlbiBHcm/Dnw==?= Cc: xen-devel@lists.xenproject.org, Andrew Cooper , =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= , Wei Liu , George Dunlap , Ian Jackson , Julien Grall , Stefano Stabellini References: <20201016105839.14796-1-jgross@suse.com> <20201016105839.14796-3-jgross@suse.com> <0c5975b1-97ec-9bbb-0ed9-9055556215cd@suse.com> <0c39eb60-9843-9659-f7c5-4e2c3e697ee0@suse.com> From: Jan Beulich Message-ID: Date: Mon, 2 Nov 2020 14:52:55 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 MIME-Version: 1.0 In-Reply-To: <0c39eb60-9843-9659-f7c5-4e2c3e697ee0@suse.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit On 02.11.2020 14:41, Jürgen Groß wrote: > On 20.10.20 11:28, Jan Beulich wrote: >> On 16.10.2020 12:58, Juergen Gross wrote: >>> --- a/xen/arch/x86/pv/shim.c >>> +++ b/xen/arch/x86/pv/shim.c >>> @@ -660,11 +660,12 @@ void pv_shim_inject_evtchn(unsigned int port) >>> if ( port_is_valid(guest, port) ) >>> { >>> struct evtchn *chn = evtchn_from_port(guest, port); >>> - unsigned long flags; >>> >>> - spin_lock_irqsave(&chn->lock, flags); >>> - evtchn_port_set_pending(guest, chn->notify_vcpu_id, chn); >>> - spin_unlock_irqrestore(&chn->lock, flags); >>> + if ( evtchn_read_trylock(chn) ) >>> + { >>> + evtchn_port_set_pending(guest, chn->notify_vcpu_id, chn); >>> + evtchn_read_unlock(chn); >>> + } >> >> Does this want some form of else, e.g. at least a printk_once()? > > No, I don't think so. > > This is just a race with the port_is_valid() test above where the > port is just being switched to invalid. This may be such a race yes, but why do you think it _will_ be? Any holding of the lock for writing (or in fact, any pending acquire in write mode) will make this fail, which - if it's not such a race - will mean an event which wasn't sent when it should have been, with potentially fatal (to the guest) consequences. >>> @@ -360,7 +352,7 @@ static long evtchn_bind_interdomain(evtchn_bind_interdomain_t *bind) >>> if ( rc ) >>> goto out; >>> >>> - flags = double_evtchn_lock(lchn, rchn); >>> + double_evtchn_lock(lchn, rchn); >> >> This introduces an unfortunate conflict with my conversion of >> the per-domain event lock to an rw one: It acquires rd's lock >> in read mode only, while the requirements here would not allow >> doing so. (Same in evtchn_close() then.) > > Is it a problem to use write mode for those cases? "Problem" can have a wide range of meanings - it's not going to be the end of the world, but I view any use of a write lock as a problem when a read lock would suffice. This can still harm parallelism. Jan