From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DDCB13EA94E for ; Wed, 20 May 2026 14:12:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779286333; cv=none; b=m+/4idQotXYFXkeGkkjBTpNugKZMwq8CWSBB/tavqKeQLWR3g8y8nEjlzn+7CjNHhyejRRl94+lc0zTJG5mWcNnENrE4tOITvE4qlJa2orYpVwFR4loGvqNHniWZ8PhgFLztg5wjxWkywNuJeaUluldhcgPO4fYBzkjWUgMd2Lk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779286333; c=relaxed/simple; bh=Hku7iw2KEqrZ7TZptQoS4RN+VfpKa32KnGUgF8cA5z8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=fybkZjUteD2/1Joe22E0RMq0y64cm0VaekIjWN8ipnJAlMCECnXCO5Rx1vVtYkzhVD8zXS2N2unZoIKAzE+PuodIBeh8Rk8zeO43cTVtSfjqj5U2vUqWR/nhPjv8bmNBo8g9OO3g+j1BLiNPjvAKLfEtx2TxHRXeM4b4oOYoN6E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=W7fZr7Tu; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="W7fZr7Tu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 602D01F000E9; Wed, 20 May 2026 14:12:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779286331; bh=4BwtuGhKRqhUfLo4ezfAwb95AAgH5cTZ0Hpq1p4rSZE=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=W7fZr7TuFaqW247q3d7K7U3D3tFz6x5sVp3HxBOnmQ/AoV7C8sOrDRHB035EqFsru ShutoDC4USUxyChCjMw6zf0G1mKbUWnn77Hr96bal31Q9uUQXx0zC+W4OGfixe3JMX 4y2MXKHI/qthLTTIbu36n2VnQ7/ZXweY70lmOmLigxw1gI2hfNW//yAjt8kMuVoe4q Xrmu+/IZ1ybmSqZST7lqjgLCIrMca+hdSXvhYCt86kLP+Y+cGNKZ3Ehz+MZhmHavHH 6qNpOdc5BbLElbCMXXhT1JcFP/J4c1f75TkmFLwbBCpQSFepK3LE9kZJOmgXxQVEU6 vEzuPgS2GaxyA== Date: Wed, 20 May 2026 17:12:04 +0300 From: Mike Rapoport To: "David Hildenbrand (Arm)" Cc: Andrew Morton , David Carlier , Heechan Kang , "Liam R. Howlett" , Lorenzo Stoakes , Michael Bommarito , Peter Xu , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH RESEND] userfaultfd: snapshot VMA state across UFFDIO_COPY retry Message-ID: References: <20260519052516.3315196-1-rppt@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Wed, May 20, 2026 at 03:48:02PM +0200, David Hildenbrand (Arm) wrote: > On 5/20/26 14:53, Mike Rapoport wrote: > > On Wed, May 20, 2026 at 01:09:04PM +0200, David Hildenbrand (Arm) wrote: > >> On 5/19/26 07:25, Mike Rapoport wrote: > > > > Do you mean per-VMA? > > Per-MM counter would capture unrelated changes, e.g. an masvise() for > > unrelated range. > > I was thinking about a per-MM thing for simplicity. If there were any changes, > we'd retry (-EAGAIN). > > IOW, something like &mm->mm_lock_seq, which we have for per-vma locks already. > > Not sure if unrelated changes would really be a problem in practice (another > thread gabbing the mmap_lock in write mode until we serviced the fault). Let me reiterate: A thread doing UFFDIO_COPY releases the VMA in mfill_copy_folio_retry(), re-gets the VMA and checks if the per-MM counter stayed the same. If another thread makes any change to VMA while mfill_copy_folio_retry() waits to re-get the VMA, the counter would be incremented by another thread. mfill_copy_folio_retry() will see the change after mfill_get_vma() and will bail out with -EAGAIN. So if another thread does, e.g. MADV_DONTFORK on completely unrelated VMA, mfill_copy_folio_retry() will return -EAGAIN and I'm not sure we'll not break the existing userspace by this. > -- > Cheers, > > David -- Sincerely yours, Mike.