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=-6.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 C7D73C433ED for ; Wed, 19 May 2021 14:04:40 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 49D9E6108D for ; Wed, 19 May 2021 14:04:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 49D9E6108D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id BA2D46B0036; Wed, 19 May 2021 10:04:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B2C646B006E; Wed, 19 May 2021 10:04:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 958126B0070; Wed, 19 May 2021 10:04:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0060.hostedemail.com [216.40.44.60]) by kanga.kvack.org (Postfix) with ESMTP id 5E10F6B0036 for ; Wed, 19 May 2021 10:04:39 -0400 (EDT) Received: from smtpin35.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id DC44EAC0B for ; Wed, 19 May 2021 14:04:38 +0000 (UTC) X-FDA: 78158151036.35.729B002 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf01.hostedemail.com (Postfix) with ESMTP id 8563C5001645 for ; Wed, 19 May 2021 14:04:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621433076; 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=q0X6ufyJH5fadmIknxn4nGcWs1xnqbL6wQGkTAtdW1c=; b=Tw8RKgQRCXH+fmkXIrxv+lnkjg+Y1aqhfdZycLors3SXtB9ey72H2FSEA15QtBFt/+IlF3 R1XyJO7Cp3tReLJlLHbQCHo5Agiw0KsQ8CaUrG4VXnHM8sn8Z3wJ29NKAFT3e1Xgs7DlU2 hUOR2RpO1DWbuVpTmx1jVrMrIRr/Cm4= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-397-pq9X2lzXOJaJHIXB93dfUw-1; Wed, 19 May 2021 10:04:34 -0400 X-MC-Unique: pq9X2lzXOJaJHIXB93dfUw-1 Received: by mail-qv1-f69.google.com with SMTP id l19-20020a0ce5130000b02901b6795e3304so10413156qvm.2 for ; Wed, 19 May 2021 07:04:34 -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=q0X6ufyJH5fadmIknxn4nGcWs1xnqbL6wQGkTAtdW1c=; b=ep1O6ypHVE13stQ6q5N1b4GK8O039kxl1FUzq7gjTDewvW/x09zBorYCxuZuRwC/TL SzCKumt+gqqNY3in9QawYYY5z0AboATn+D4CjtoUmZEQ6h+kv21ffWFwyEl4uEP10auv an/DbzBo/Kh2EBzL7FZn02lcXKVTu71m012LmpIAUI50lg56D8UM7SflegQvWetoX2J9 xW54L1DE9ZV/oPct8QUUNWmJpHySpDrJV2ISO3zRKm5vQ1PwtZcy9fftosWVaqxuXK8M btmDuWXWAWTkO4+7t/hE1YdVAnGXK3iBCMVm9DyyDF8+zoNbv2DWuDucixeQC+PcUrT1 kTvQ== X-Gm-Message-State: AOAM531XdjAXqGiu+6Bk92E2lat+hN+9XfJyXx5Lm/H3o+O95rkl/R++ xK2KuEsd9JjOFBR6KUelNrVk9cUrJ1hEL/wrSsvWzNfDVR3fxeZ5+p5G1Okxvftv8CVqqJpEk8F yD6MTw21AwSQ= X-Received: by 2002:a05:6214:d87:: with SMTP id e7mr13037376qve.53.1621433074138; Wed, 19 May 2021 07:04:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6J2iQWttFbTggjwn9zrUjjmVN+9VOim38VY5Z448bl6PpUs3xqQHJcSoYTLuhDbSvYY+iNA== X-Received: by 2002:a05:6214:d87:: with SMTP id e7mr13037337qve.53.1621433073770; Wed, 19 May 2021 07:04:33 -0700 (PDT) Received: from t490s (bras-base-toroon474qw-grc-72-184-145-4-219.dsl.bell.ca. [184.145.4.219]) by smtp.gmail.com with ESMTPSA id b13sm802748qkl.16.2021.05.19.07.04.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 May 2021 07:04:33 -0700 (PDT) Date: Wed, 19 May 2021 10:04:32 -0400 From: Peter Xu To: Alistair Popple Cc: Jason Gunthorpe , linux-mm@kvack.org, nouveau@lists.freedesktop.org, bskeggs@redhat.com, akpm@linux-foundation.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, jhubbard@nvidia.com, rcampbell@nvidia.com, jglisse@redhat.com, hch@infradead.org, daniel@ffwll.ch, willy@infradead.org, bsingharora@gmail.com, Christoph Hellwig Subject: Re: [PATCH v8 5/8] mm: Device exclusive memory access Message-ID: References: <20210407084238.20443-1-apopple@nvidia.com> <2235357.HsqDk0zIjc@nvdebian> <2569629.VzlulnA7BY@nvdebian> MIME-Version: 1.0 In-Reply-To: <2569629.VzlulnA7BY@nvdebian> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Tw8RKgQR; spf=none (imf01.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 216.205.24.124) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 8563C5001645 X-Stat-Signature: 3y8ku5m1ch3k8fepy3ktadn9j1qka7sq X-HE-Tag: 1621433077-898911 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, May 19, 2021 at 11:11:55PM +1000, Alistair Popple wrote: > On Wednesday, 19 May 2021 10:15:41 PM AEST Peter Xu wrote: > > External email: Use caution opening links or attachments > > > > On Wed, May 19, 2021 at 09:04:53PM +1000, Alistair Popple wrote: > > > Failing fork() because we couldn't take a lock doesn't seem like the right > > > approach though, especially as there is already existing code that > > > retries. I get this adds complexity though, so would be happy to take a > > > look at cleaning copy_pte_range() up in future. > > > > Yes, I proposed that as this one won't affect any existing applications > > (unlike the existing ones) but only new userspace driver apps that will use > > this new atomic feature. > > > > IMHO it'll be a pity to add extra complexity and maintainance burden into > > fork() if only for keeping the "logical correctness of fork()" however the > > code never triggers. If we start with trylock we'll know whether people > > will use it, since people will complain with a reason when needed; however > > I still doubt whether a sane userspace device driver should fork() within > > busy interaction with the device underneath.. > > I will refrain from commenting on the sanity or otherwise of doing that :-) > > Agree such a scenario seems unlikely in practice (and possibly unreasonable). > Keeping the "logical correctness of fork()" still seems worthwhile to me, but > if the added complexity/maintenance burden for an admittedly fairly specific > feature is going to stop progress here I am happy to take the fail fork > approach. I could then possibly fix it up as a future clean up to > copy_pte_range(). Perhaps others have thoughts? Yes, it's more about making this series easier to be accepted, and it'll be great to have others' input. Btw, just to mention that I don't even think fail fork() on failed trylock() is against "logical correctness of fork()": IMHO it's still 100% correct just like most syscalls can return with -EAGAIN, that suggests the userspace to try again the syscall, and I hope that also works for fork(). I'd be more than glad to be corrected too. -- Peter Xu