Received: by 10.192.165.148 with SMTP id m20csp4729537imm; Tue, 24 Apr 2018 07:32:13 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+EpNtBaDOsGk4kygK2uw9JVqIDVhWLhaCcFOWuWe4bZM80bQ1yZuIwXlfjHPlL1QYqjjJr X-Received: by 10.99.152.84 with SMTP id l20mr20072993pgo.16.1524580333434; Tue, 24 Apr 2018 07:32:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524580333; cv=none; d=google.com; s=arc-20160816; b=HA++DQCRiGdAOMbC9u9oJZmdru/v1xvmj24MlSws4tKK4mPFPTt7P+2EPnDmQY/DSf vUXn2aGila50cUyi0BcVyWRq8HLIyUmrQ6Z10nfsgQsUdRzVauOAav68IYipXB2GtLf8 Xuoml5gVbyaJ17IhZGdO7Zc2fkPGvyEyQWhbQTBqP6tI56rGP/Jt4wItOXrG65TOaDGB D/+j6h5EBmbirTs8OJYFZA1+a2jehsHFjSzrAjNj2bNSmaThARZZwglFj9uWemWiaX76 mUhKx4/jS/CSetJdLbj6AsCS99fXTV9mGrb9IAVCVCl9FTA2zaPk/Omjv/b/CNc2acJt oLtA== 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:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:arc-authentication-results; bh=O3ELC/UnKgzi0v0n1gdke1M/EDcSmsP5BEMiJvqfaoU=; b=iRcCqR83HntzWtVW1Db5bGAphbC2h+DU/Yo8I+HtUB/eXsHjMx04OVylgICctsKyPd gpChWA6OAMnwHXdYYwUoSKi1AjPo6xACytCfsBoXVJlfXWT3wpyUnKWXtFoBTl4l+B50 Q0RB0tEQlBZk/oc6qRXEbiB1vopHWnao9ML5Bb1qGe/Kns0uBlrG5hbj9PKiPqdSMIdb G/k4js+PqpAKuXCgSyLdp3IiNJOFuc1yt7Lz+/TN+hJkIYdDL7tYKseOKOXsQBUQf6rB S8CvobheAtkVunQA58Kju/ZWM7XVBMUtTk0wdgHpZfB04y/wCG1s8JJ2pJ0GVFlECX4p 5FsA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u8-v6si758711plz.392.2018.04.24.07.31.58; Tue, 24 Apr 2018 07:32:13 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757275AbeDXLzm (ORCPT + 99 others); Tue, 24 Apr 2018 07:55:42 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:58356 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753120AbeDXLzh (ORCPT ); Tue, 24 Apr 2018 07:55:37 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A0D3E81A88B6; Tue, 24 Apr 2018 11:55:36 +0000 (UTC) Received: from gondolin (dhcp-192-222.str.redhat.com [10.33.192.222]) by smtp.corp.redhat.com (Postfix) with ESMTP id A5A801102E2B; Tue, 24 Apr 2018 11:55:35 +0000 (UTC) Date: Tue, 24 Apr 2018 13:55:33 +0200 From: Cornelia Huck To: Pierre Morel Cc: Dong Jia Shi , pasic@linux.vnet.ibm.com, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Subject: Re: [PATCH 01/10] vfio: ccw: Moving state change out of IRQ context Message-ID: <20180424135533.2e9d03dc.cohuck@redhat.com> In-Reply-To: References: <1524149293-12658-1-git-send-email-pmorel@linux.vnet.ibm.com> <1524149293-12658-2-git-send-email-pmorel@linux.vnet.ibm.com> <20180424065442.GV12194@bjsdjshi@linux.vnet.ibm.com> <20180424115929.5b5e1ff0.cohuck@redhat.com> Organization: Red Hat GmbH MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 24 Apr 2018 11:55:36 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 24 Apr 2018 11:55:36 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'cohuck@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 24 Apr 2018 13:49:14 +0200 Pierre Morel wrote: > On 24/04/2018 11:59, Cornelia Huck wrote: > > On Tue, 24 Apr 2018 10:40:56 +0200 > > Pierre Morel wrote: > > > >> On 24/04/2018 08:54, Dong Jia Shi wrote: > >>> * Pierre Morel [2018-04-19 16:48:04 +0200]: > >>> > >>> [...] > >>> > >>>> @@ -94,9 +83,15 @@ static void vfio_ccw_sch_io_todo(struct work_struct *work) > >>>> static void vfio_ccw_sch_irq(struct subchannel *sch) > >>>> { > >>>> struct vfio_ccw_private *private = dev_get_drvdata(&sch->dev); > >>>> + struct irb *irb = this_cpu_ptr(&cio_irb); > >>>> > >>>> inc_irq_stat(IRQIO_CIO); > >>>> - vfio_ccw_fsm_event(private, VFIO_CCW_EVENT_INTERRUPT); > >>>> + memcpy(&private->irb, irb, sizeof(*irb)); > >>>> + > >>>> + WARN_ON(work_pending(&private->io_work)); > >>> Hmm, why do we need this? > >> The current design insure that we have not two concurrent SSCH requests. > >> How ever I want here to track spurious interrupt. > >> If we implement cancel, halt or clear requests, we also may trigger (AFAIU) > >> a second interrupts depending on races between instructions, controller > >> and device. > > You won't get an interrupt for a successful cancel. If you do a > > halt/clear, you will make the subchannel halt/clear pending in addition > > to start pending and you'll only get one interrupt (if the I/O has > > progressed far enough, you won't be able to issue a hsch). The > > interesting case is: > > - guest does a ssch, we do a ssch on the device > > - the guest does a csch before it got the interrupt for the ssch > > - before we do the csch on the device, the subchannel is already status > > pending with completion of the ssch > > - after we issue the csch, we get a second interrupt (for the csch) > > We agree. > > > > > I think we should present two interrupts to the guest in that case. > > Races between issuing ssch/hsch/csch and the subchannel becoming status > > pending happen on real hardware as well, we're just more likely to see > > them with the vfio layer in between. > > Yes, agreed too. > > > > > (I'm currently trying to recall what we're doing with unsolicited > > interrupts. These are fun wrt deferred cc 1; I'm not sure if there are > > cases where we want to present a deferred cc to the guest.) > > This patch does not change the current functionalities, only > consolidates the FSM. > The current way to handle unsolicited interrupts is to report them to > the guest > along with the deferred code AFAIU. My question was more along the line of "do we actually want to _generate_ a deferred cc1 or unsolicited interrupt, based upon what we do in our state machine". My guess is no, regardless of the changes you do in this series. > > > > > Also, doing a second ssch before we got final state for the first one > > is perfectly valid. Linux just does not do it, so I'm not sure if we > > should invest too much time there. > > I agree too, it would just make things unnecessary complicated. I'm a big fan of just throwing everything at the hardware and let it sort out any races etc. We just need to be sure we don't mix up interrupts :)