Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp1147845ybs; Mon, 25 May 2020 08:14:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwK9gFjnDYU8faDgq4MZcsieMfehlnPAF9HaUsiEVan3aT6PDVhkJdUYTmjeYr/pNCG2Bqx X-Received: by 2002:a17:906:55c4:: with SMTP id z4mr20237775ejp.332.1590419662339; Mon, 25 May 2020 08:14:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590419662; cv=none; d=google.com; s=arc-20160816; b=P17pec1bsMLxvw1W0123Ce/Y3jc7Ln1xOLlR9AkE9Po1Jm064Dp99xyQCN9j7mzRmh mfbDWIlMh/OjLvTxT5K8TJARpxAiL0N+AOdn3A1qmvUE2wUuOM2cTVfwiZFijYzVOL3H 1CAVkjcz8RUeHgEUN2lixaSsfpy2dC3rcrOXXaQHUAycWl2Nty058HrMlfsmGqNEkTDy E9jVe68M1fcSIXismQ1M84e2BrmQy72Jb7ZXRs1R/kFj4Lq5S1sPHiOpe2aEnk+fQfcc RA3hJnOxxkbzVJlqb/iN/6Ir9NX6zWGfobf6V+0rln8k2yZ9A18iPesXWMSSuFjyrE+S GDpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=3mpYWtKyRgORiVGPfs1mMYQZAQgnaA9yUkeL6coUBH0=; b=kqibaLXFc0E+AkixZ7d8yI2LB4RUQAAN/VEllJypb+zdhzyHFpg/RqVjlRyQD3nuxB LB+mkXRvRceKlxdt2WjIgLmjJfr5zOJB/46YD9XypTzxYW3ocRMr/QuD93uMmm6VebrJ 890JoDFbP2OiSCSENFEqlNBOxxPkCMS/pCoiKKgifmYWQLEtqa0HkQ29PfoTZCv0UK87 Si6XBUsWFQbh0nrNLIISXOYRW9alQ1W8NfbO3ggAvHSQPkCMQrcAXNFrp9CiZMpyiraO EDo0hcN1rSl0Z/K4jREFgajWjdlMP1KEguOe7RPkH64/XXhZJHHFL5+AaM1Q0svNWXw6 cMYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WuCC54AT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i27si9779294ejb.63.2020.05.25.08.13.59; Mon, 25 May 2020 08:14:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WuCC54AT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391041AbgEYPLt (ORCPT + 99 others); Mon, 25 May 2020 11:11:49 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:21207 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2390998AbgEYPLt (ORCPT ); Mon, 25 May 2020 11:11:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590419508; 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: in-reply-to:in-reply-to:references:references; bh=3mpYWtKyRgORiVGPfs1mMYQZAQgnaA9yUkeL6coUBH0=; b=WuCC54ATOIHN21rZB4BaKG/Bp5ZNMBT5LZDbbYhQwgA6j+wD1LXQRqfrgS/pCuB+3lLs4k pTwExkxCdkCBLkIm9EgSt7WdVWScS8kEoY+Csm3+gAdcluGsVhdX7/T7whxJ+0y9n5i0yl DdvdT1dSoGdnSLtpNcOmmiZgeL24mAE= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-419-YeQcFF8wNpG0aAjtHkXCbQ-1; Mon, 25 May 2020 11:11:45 -0400 X-MC-Unique: YeQcFF8wNpG0aAjtHkXCbQ-1 Received: by mail-qk1-f197.google.com with SMTP id d190so7407936qkc.20 for ; Mon, 25 May 2020 08:11:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=3mpYWtKyRgORiVGPfs1mMYQZAQgnaA9yUkeL6coUBH0=; b=lwjrkNo5CusnBtrJ7IET+XEe4p8bfWghvWUlngHKyOAT11lWdfgo54DlzRQ5iCPzi4 1mzkHurIIEvCRsWio0Uxkr8msk/Xg6KY3Xif/kwVKiLbuBujMjjN+2Y1mlMHStO0Hoqc YIVgT301XenngTAa/9l3IMFp2cBGB7zBp4b0/e317imyUE40R9U+RZqnapp20DfIYbLT L24kxXoFReMAvkbloZdxSnxrIs575NLeWt8apKBZnTofy3UCri5BFMZ0VfC6LC+LLVYI 4GoIzRiZdwC+Tz9XVSdM+Q5/iz1h+edCTYgfitVefKV2ZqZs5da2RbAOdqgc6QkOoRwN henQ== X-Gm-Message-State: AOAM5309LsqTZwSwHY64vZaOKP2mcYeaZfWODMR4gMrFn4cWwu45U/2+ kVKOjYKkVPrHfgcIl6nvvA9Bt6wCo3rEbkRi0juOEhRbGpK2G4jjeHD2CLVAV07jffDyrdm6Fih k2PEfDdtUn+sa3ErNSGEjOsaI X-Received: by 2002:aed:3f55:: with SMTP id q21mr14841977qtf.190.1590419505320; Mon, 25 May 2020 08:11:45 -0700 (PDT) X-Received: by 2002:aed:3f55:: with SMTP id q21mr14841935qtf.190.1590419505005; Mon, 25 May 2020 08:11:45 -0700 (PDT) Received: from xz-x1 ([2607:9880:19c0:32::2]) by smtp.gmail.com with ESMTPSA id f14sm10796275qka.70.2020.05.25.08.11.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 May 2020 08:11:44 -0700 (PDT) Date: Mon, 25 May 2020 11:11:42 -0400 From: Peter Xu To: Jason Gunthorpe Cc: Alex Williamson , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, cohuck@redhat.com, cai@lca.pw, Andrea Arcangeli Subject: Re: [PATCH v3 3/3] vfio-pci: Invalidate mmaps and block MMIO access on disabled memory Message-ID: <20200525151142.GE1058657@xz-x1> References: <159017449210.18853.15037950701494323009.stgit@gimli.home> <159017506369.18853.17306023099999811263.stgit@gimli.home> <20200523193417.GI766834@xz-x1> <20200523170602.5eb09a66@x1.home> <20200523235257.GC939059@xz-x1> <20200525122607.GC744@ziepe.ca> <20200525142806.GC1058657@xz-x1> <20200525144651.GE744@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200525144651.GE744@ziepe.ca> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 25, 2020 at 11:46:51AM -0300, Jason Gunthorpe wrote: > On Mon, May 25, 2020 at 10:28:06AM -0400, Peter Xu wrote: > > On Mon, May 25, 2020 at 09:26:07AM -0300, Jason Gunthorpe wrote: > > > On Sat, May 23, 2020 at 07:52:57PM -0400, Peter Xu wrote: > > > > > > > For what I understand now, IMHO we should still need all those handlings of > > > > FAULT_FLAG_RETRY_NOWAIT like in the initial version. E.g., IIUC KVM gup will > > > > try with FOLL_NOWAIT when async is allowed, before the complete slow path. I'm > > > > not sure what would be the side effect of that if fault() blocked it. E.g., > > > > the caller could be in an atomic context. > > > > > > AFAICT FAULT_FLAG_RETRY_NOWAIT only impacts what happens when > > > VM_FAULT_RETRY is returned, which this doesn't do? > > > > Yes, that's why I think we should still properly return VM_FAULT_RETRY if > > needed.. because IMHO it is still possible that the caller calls with > > FAULT_FLAG_RETRY_NOWAIT. > > > > My understanding is that FAULT_FLAG_RETRY_NOWAIT majorly means: > > > > - We cannot release the mmap_sem, and, > > - We cannot sleep > > Sleeping looks fine, look at any FS implementation of fault, say, > xfs. The first thing it does is xfs_ilock() which does down_write(). Yeah. My wild guess is that maybe fs code will always be without FAULT_FLAG_RETRY_NOWAIT so it's safe to sleep unconditionally (e.g., I think the general #PF should be fine to sleep in fault(); gup should be special, but I didn't observe any gup code called upon file systems)? Or I must have missed something important... Thanks, -- Peter Xu