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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 759F4EB64DC for ; Thu, 29 Jun 2023 16:34:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232144AbjF2QeC (ORCPT ); Thu, 29 Jun 2023 12:34:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231557AbjF2QeB (ORCPT ); Thu, 29 Jun 2023 12:34:01 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C4D430DD for ; Thu, 29 Jun 2023 09:33:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688056389; 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=T9WhCFKDeQiwQ9P8Z4ZmNdOekWIBt/DtpJr87ziAM18=; b=fp8jzEMhzvbV4l+FKW2NZh8kWsKhJ3KsiUUroab52WjR2TzXTia1usPRyr8UlW3jemzOBa 3oF9ynfM7XE9qNYh6CC+sDI8RYHofN8TmXxwOUeumerc1295wDGLzZWHKGa+xVgegipy0a /fENGhzWkn1wUHzlKrEJ/IuNTnY6yVk= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-657--vIucNaYNZKreSezZNbTyw-1; Thu, 29 Jun 2023 12:33:07 -0400 X-MC-Unique: -vIucNaYNZKreSezZNbTyw-1 Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-74faf5008bbso19161385a.0 for ; Thu, 29 Jun 2023 09:33:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688056387; x=1690648387; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=T9WhCFKDeQiwQ9P8Z4ZmNdOekWIBt/DtpJr87ziAM18=; b=kibXnI4ut9fOXRiyYFcz1dPUoECF77tYYhbP/n3PJiSyjT5nCFqvlC9mxLE48RNgCB Nk+14orE2QKA1TMv66LUjupnLoMCvX/8c7NT2nFwIgc8n2pLU/xrVxtT+nncgEQd9v18 jsbEgaWPPQt9D3RzFiIe74Ev1/NqNRB+NV51d/R6aA/YfAXzL4pBKru05U8/Z89xFefx 0Qg8kFWy8MHwaoPTr9t4dDfgn5AP3/U0IehuLrP83svjZaiHdCFkChcCXXQWRi/iajIi 9T06SD0iSSZnYCPzyv1nQk698Rh0Z4DrA7Mg9N8rYR5REEQVRjZa7vQTJ3oiXc+5z5x5 g7Kg== X-Gm-Message-State: ABy/qLZZs3D6/a2/OYh4bY7v7otqgExWiZW/QC2PkIoZk0sDlr4FVYF+ ZxUwHH9ogDlmtio1dusAzts4e/xhkd4RyBRwocLW5OWYuefiDyYVCnliPMSqxGvQsqe2P5LnonI ty7d4G8OhLG3Fv3gIfpaln+gvsA== X-Received: by 2002:a0c:fbcf:0:b0:62b:5410:322d with SMTP id n15-20020a0cfbcf000000b0062b5410322dmr183800qvp.6.1688056387479; Thu, 29 Jun 2023 09:33:07 -0700 (PDT) X-Google-Smtp-Source: APBJJlEsboSyRALJa4QGaJl+D6XdcWr9w6NJmcI+LBYwqVfR+4ZEGxEM7LvIqdoVBmRJd0KtsVwtMg== X-Received: by 2002:a0c:fbcf:0:b0:62b:5410:322d with SMTP id n15-20020a0cfbcf000000b0062b5410322dmr183772qvp.6.1688056387069; Thu, 29 Jun 2023 09:33:07 -0700 (PDT) Received: from x1n (cpe5c7695f3aee0-cm5c7695f3aede.cpe.net.cable.rogers.com. [99.254.144.39]) by smtp.gmail.com with ESMTPSA id w2-20020a0cfc42000000b005ef81cc63ccsm7174643qvp.117.2023.06.29.09.33.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jun 2023 09:33:06 -0700 (PDT) Date: Thu, 29 Jun 2023 12:32:56 -0400 From: Peter Xu To: Suren Baghdasaryan Cc: akpm@linux-foundation.org, willy@infradead.org, hannes@cmpxchg.org, mhocko@suse.com, josef@toxicpanda.com, jack@suse.cz, ldufour@linux.ibm.com, laurent.dufour@fr.ibm.com, michel@lespinasse.org, liam.howlett@oracle.com, jglisse@google.com, vbabka@suse.cz, minchan@google.com, dave@stgolabs.net, punit.agrawal@bytedance.com, lstoakes@gmail.com, hdanton@sina.com, apopple@nvidia.com, ying.huang@intel.com, david@redhat.com, yuzhao@google.com, dhowells@redhat.com, hughd@google.com, viro@zeniv.linux.org.uk, brauner@kernel.org, pasha.tatashin@soleen.com, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@android.com Subject: Re: [PATCH v5 6/6] mm: handle userfaults under VMA lock Message-ID: References: <20230628172529.744839-1-surenb@google.com> <20230628172529.744839-7-surenb@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Wed, Jun 28, 2023 at 05:19:31PM -0700, Suren Baghdasaryan wrote: > On Wed, Jun 28, 2023 at 10:32 AM Peter Xu wrote: > > > > On Wed, Jun 28, 2023 at 10:25:29AM -0700, Suren Baghdasaryan wrote: > > > Enable handle_userfault to operate under VMA lock by releasing VMA lock > > > instead of mmap_lock and retrying. Note that FAULT_FLAG_RETRY_NOWAIT > > > should never be used when handling faults under per-VMA lock protection > > > because that would break the assumption that lock is dropped on retry. > > > > > > Signed-off-by: Suren Baghdasaryan > > > > Maybe the sanitize_fault_flags() changes suite more in patch 3, but not a > > big deal I guess. > > IIUC FAULT_FLAG_RETRY_NOWAIT comes into play in this patchset only in > the context of uffds, therefore that check seems to be needed when we > enable per-VMA lock uffd support, which is this patch. Does that make > sense? I don't see why uffd is special in this regard, as e.g. swap also checks NOWAIT when folio_lock_or_retry() so I assume it's also used there. IMHO the "NOWAIT should never apply with VMA_LOCK so far" assumption starts from patch 3 where it conditionally releases the vma lock when !(RETRY|COMPLETE); that is the real place where it can start to go wrong if anyone breaks the assumption. Thanks, -- Peter Xu