Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp1628489pxb; Fri, 1 Oct 2021 15:21:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNCYEn1MT/If9okLaosWgnhG13VM7NXvDCQPEo/lATZiUKp79RVHJQnwdStMFDVPrShTBQ X-Received: by 2002:a63:aa0b:: with SMTP id e11mr398112pgf.128.1633126877757; Fri, 01 Oct 2021 15:21:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633126877; cv=none; d=google.com; s=arc-20160816; b=RX2NisJGrW43I10/OVP9Wd9uJTo8/xpbGvnOThkO6L3LataIs73r/QkDWDWSEpfYoZ Qy5s8gqSw24Jpi2ydY6RsWvUktuTB6f1zX6g0rWZQln4d2Q7aRObJQWW5EH0kIrlnZXl sYqSdHTAyF+guuhzF2QjPfqYw1RgymD9Iqc/XWZTOshWc5rVdGMiYE+9Ln9J0kEU8qXg 7+33HFCiFarl/NnnETpm2qczmk4APDlTjKOdHb6OMhbZ1ojm/o1muUyA1qSFfyUvcD4h 2i3+9+Uu3UTuxVXMwqZ68x97HCe0vCzRfXhIE7H3VJCl1XWwNDD7pU8wWcVjaa2AN4sH bDfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Dlj3GwcHZB/hfgpWys67iaiDnLMMEzD7BT0/JUJOZSA=; b=Xkh+IXHNgFf9ZtZ6Xb0sT77yjNsFc91hg3KY3uo5/MWIuIS4zE3VuZhvC1IehUhJ1w D6VTdDBoSFy31TprL41Uka6XnDewQjxBvSFfFxjZ4eLw1KYy/vcZiYVX+Ojbt3m7d1w/ r+vkGtY/60p7SOrhkMLs9a7FA97G2cU7PYlLXWVdQl5Tce7jGGtiDaMEiMX/EsDjpUax N4vmPC4a935tKI5ssqLoqciVKEjUYxTVl87FCHzYUvkrI+48ToJcIKxgETDLcE6vdZjP XreGVEFk7e4uxDv8hWML1Lnbjdi2Juw7XLSSp+TDfpJZ2h8xbrINZQ+4TpO7MLBUd6K5 En1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=EYJBCgdx; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f33si9187050pgb.580.2021.10.01.15.21.04; Fri, 01 Oct 2021 15:21:17 -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=@ziepe.ca header.s=google header.b=EYJBCgdx; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229727AbhJAWPx (ORCPT + 99 others); Fri, 1 Oct 2021 18:15:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354768AbhJAWPw (ORCPT ); Fri, 1 Oct 2021 18:15:52 -0400 Received: from mail-qv1-xf31.google.com (mail-qv1-xf31.google.com [IPv6:2607:f8b0:4864:20::f31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0556C06177F for ; Fri, 1 Oct 2021 15:14:07 -0700 (PDT) Received: by mail-qv1-xf31.google.com with SMTP id n6so6453496qvp.7 for ; Fri, 01 Oct 2021 15:14:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Dlj3GwcHZB/hfgpWys67iaiDnLMMEzD7BT0/JUJOZSA=; b=EYJBCgdxRWFQwama5Ss0sx2D4qnIU/NFx7XF8E6GPLVVfNfvYaFMHC2BJIcCXsVoIF iCVvjpeBI3ImpoxruP60EpxdKHxMF088MpggWRWO7IYnFWYmW7H6nN3tO2gp7dE0tPcr PZxWZiHqQ0kOXeNKhD0DGvipG0AB/RuuNPtsQvgGuq0gEvYHfaW0BPvSOUVVBNQSYbh9 0YWWGW3L+w61nc7KMA8GAJec757jPzc4w6+ESAcdFTN5R3q4fIgS/oiFDTnJz8JfMv7h ts1ZBK4JepAEgYw1PQejU7GFCd4skwXqph1TdAhgLH6c2/iHJ7h16XxYT4AhYwcn5M99 FT8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Dlj3GwcHZB/hfgpWys67iaiDnLMMEzD7BT0/JUJOZSA=; b=DX4K8NUbBo7/AdCAwzy/GRBugXbtsZIZ0pHlU58B4Ul0YjLoxQRh631CnzHQv8jMBn NFDFgx0wT+DV2yxuNu6VtaQ/QfsulMBDCR0Iv7mL7OrN8d5wONmtkhVXF4tyebj0ufwW RwrfhKgPMD84bC3lebe5hM/rI6sR37N3qLOV7CyrKvrCwJM/BS12YQMP9WR20D/23vQs MKQMxFgEdDL0Xl1KwBTj/DVNOGGpAIMMS/9npLM3itdYQj3odJK4BwVRPlAuTYqLiNFs B5nSwRVVWeAbjWDWzDVuPdXQgcqc01QGxqpSfUkQIN9o1OVYbsmpn67Nycd/X78lFBD4 J2GQ== X-Gm-Message-State: AOAM533AcoAIp2BTOV0ZEg1iC57NwqYZb0zPEq3PrX6n7snLqK1b8SSV 2uMWyCriqujeiCImrivcliGcjw== X-Received: by 2002:a05:6214:dac:: with SMTP id h12mr7351043qvh.39.1633126446714; Fri, 01 Oct 2021 15:14:06 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-142-162-113-129.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.162.113.129]) by smtp.gmail.com with ESMTPSA id p9sm3635312qkm.23.2021.10.01.15.14.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Oct 2021 15:14:05 -0700 (PDT) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1mWQn7-009XgW-9E; Fri, 01 Oct 2021 19:14:05 -0300 Date: Fri, 1 Oct 2021 19:14:05 -0300 From: Jason Gunthorpe To: Logan Gunthorpe Cc: Alistair Popple , Felix Kuehling , Christoph Hellwig , Dan Williams , linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, linux-mm@kvack.org, iommu@lists.linux-foundation.org, Stephen Bates , Christian =?utf-8?B?S8O2bmln?= , John Hubbard , Don Dutile , Matthew Wilcox , Daniel Vetter , Jakowski Andrzej , Minturn Dave B , Jason Ekstrand , Dave Hansen , Xiong Jianxin , Bjorn Helgaas , Ira Weiny , Robin Murphy , Martin Oliveira , Chaitanya Kulkarni Subject: Re: [PATCH v3 19/20] PCI/P2PDMA: introduce pci_mmap_p2pmem() Message-ID: <20211001221405.GR3544071@ziepe.ca> References: <8d386273-c721-c919-9749-fc0a7dc1ed8b@deltatee.com> <20210929230543.GB3544071@ziepe.ca> <32ce26d7-86e9-f8d5-f0cf-40497946efe9@deltatee.com> <20210929233540.GF3544071@ziepe.ca> <20210930003652.GH3544071@ziepe.ca> <20211001134856.GN3544071@ziepe.ca> <4fdd337b-fa35-a909-5eee-823bfd1e9dc4@deltatee.com> <20211001174511.GQ3544071@ziepe.ca> <95ada0ac-08cc-5b77-8675-b955b1b6d488@deltatee.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <95ada0ac-08cc-5b77-8675-b955b1b6d488@deltatee.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 01, 2021 at 02:13:14PM -0600, Logan Gunthorpe wrote: > > > On 2021-10-01 11:45 a.m., Jason Gunthorpe wrote: > >> Before the invalidation, an active flag is cleared to ensure no new > >> mappings can be created while the unmap is proceeding. > >> unmap_mapping_range() should sequence itself with the TLB flush and > > > > AFIAK unmap_mapping_range() kicks off the TLB flush and then > > returns. It doesn't always wait for the flush to fully finish. Ie some > > cases use RCU to lock the page table against GUP fast and so the > > put_page() doesn't happen until the call_rcu completes - after a grace > > period. The unmap_mapping_range() does not wait for grace periods. > > Admittedly, the tlb flush code isn't the easiest code to understand. > But, yes it seems at least on some arches the pages are freed by > call_rcu(). But can't this be fixed easily by adding a synchronize_rcu() > call after calling unmap_mapping_range()? Certainly after a > synchronize_rcu(), the TLB has been flushed and it is safe to free those > pages. It would close this issue, however synchronize_rcu() is very slow (think > 1second) in some cases and thus cannot be inserted here. I'm also not completely sure that rcu is the only case, I don't know how every arch handles its gather structure.. I have a feeling the general intention was for this to be asynchronous My preferences are to either remove devmap from gup_fast, or fix it to not use special pages - the latter being obviously better. Jason