From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f66.google.com (mail-pj1-f66.google.com [209.85.216.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 61F81175D53 for ; Tue, 18 Aug 2026 01:13:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.66 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787015586; cv=none; b=tUmYxlYwUnZEs2feAnGqNQsSsZ+urGTgXQp8jaR+vKRJVuSjbWJ6BzebkZoTNsONJy3I/F8aKH75zdDd3wgs3zVgfIQ44Cnyt01F3mr+WsQtim0ZpOioT7/Bl2A63rRfXCaeobg7lLh0iZ/LDIltNmQXO7ZOT1XkcgJvbH3V96g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787015586; c=relaxed/simple; bh=l2XU7D+HRtpcIBDHftFS4BZVidsDvj0PkF49WJjS6oQ=; h=From:Date:To:cc:Subject:In-Reply-To:Message-ID:References: MIME-Version:Content-Type; b=giRULUFTUSsV4CDkSg7oasoisl4rTq5fC6XDzbA6GjBHNfDBnVXOGtsKjosdNw6QGy7MWG5Pk9zY1SVd64cz02dM+GBlPbybm5h8RtvQxRs9Tqp6v41RLnU8DQ2BQu0FZP+TpsDtdiyjxAZ9Uy+us6sdVV0DWiT14q5CqkJ42nk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=cBsVgowD; arc=none smtp.client-ip=209.85.216.66 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cBsVgowD" Received: by mail-pj1-f66.google.com with SMTP id 98e67ed59e1d1-38f0f132f56so394972a91.0 for ; Mon, 17 Aug 2026 18:13:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787015585; x=1787620385; darn=vger.kernel.org; h=content-type:mime-version:references:message-id:in-reply-to:subject :cc:to:date:from:from:to:cc:subject:date:message-id:reply-to :content-type; bh=UVdCmxrOU73gzkdYKIQmTJ04meQlGgXgR2+JhAxJ3is=; b=cBsVgowDla1JJwG6hfwtc7gFn9q4rElOib54QGc7ymTeAzG4H8jV64b5NHF18a6ASj sjMmJBtHE9ZM8I3RdlbUsDA3TmSSWda0Acxvtb9XfY9x/5sFScHtrL6SqorxFP395Ch8 5G3JV1cm86NU1t2JBXrQtofJ0SSNwgXLJw+LfOGvblTrlYTvN5t6K57wADxgqala8v7b 4bi3SKDqPDiwSo1/58wMZCgs2mPqjVPeW0KqOJ6dUe6w0jUa8HVxXlo2ZDGXbgCoTbqU 0/xRA0tTbxllHdRPbNzfK46EyQc4lyAAbh4KlG7ObMDbY8nC35eoXaUXVHG+/f6GUTDF mjjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787015585; x=1787620385; h=content-type:mime-version:references:message-id:in-reply-to:subject :cc:to:date:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=UVdCmxrOU73gzkdYKIQmTJ04meQlGgXgR2+JhAxJ3is=; b=Wm3rQ2vlvMmNpXJC4wOjpvg7fGyl6RGu1UlL2DRWoEBZqd/RvgYvaziA4/q+XJgrP5 RtRg/ml604Gk5GBRDnvwq49SFU2UIasNrSoQDNbOuZi/mWzcF0s+tDoAo0s7Sfe9IlLP BppamOpK2gjkqr4ofIr5jYvuB0wf4TN8lBBTyLytznovf8wA3P3oAtS8KEAxtQ0iacL7 Am0nOugmoz6JP6jeDzB5cG0/9ZAKQmyPkAPYKgZ+qRqnACdah75Mgo5W2htAa83cTB1E p+YO8T5hZ5jCKBd03GY1xHhT4jeRB2BD4p2os/BYd0+LKnw94GDI+1eC0I9TAvWxTpSV dDwA== X-Forwarded-Encrypted: i=1; AHgh+RoWY2er6SvuX5psBrFTD3FqoQ9KZjVXRz5bg0CXHX3qCxqqkmQDwt7qeBz36/nVpZ0MnYoeGKpekRIRWcY=@vger.kernel.org X-Gm-Message-State: AOJu0YyfeUXMmhSKOFUhdVvGyE7QA8bAnSPWeWjlLkj9zPxqqHiSd3TN d9Q5oBrIxXU3egocohuablmkTkyDzO3+9nsgXx7n9L0/g3abGz8cDCuL X-Gm-Gg: AR+sD12yZmhP8idoAGHODFJWG4LqWj82iN3wvqHruQoEaS5nHpplwdZpxwO2h404gxN 6UjWV7Z0lDInFfVKs85IaDqbUKk2YaNCm7dUMvfWa22JPOvwDg1VixI7RjioBoySpl4ohPa5RGU dNx71efFmoP55j0lGm7JoV9Ync8ptLn8+m5GweqtjNESgmtbJkPDKGL9N+C+s32DEUFg4jZyemY BmnbkxWQc0rvWFeo3YhFuR46AlSPTvzYzqwxsEU6fWPOE1zkY097BtbKzREFGDPFTAvS7iGlpZ7 2NgGL+YXT1UXPUI4uxMXamA1ZOduUeqaCf6L5FCAJTtVf+BECOwNFP3r924cVcZhgWbfzV72ufO sM6biyhUdS42SybWE3aiFucHt4/pEV4rq6IrwkjnOtN7JXHyt0rp3ss3T5JbiOIVbPtmkse0mi5 xv5MKfzDou6+CmxQahWVytTELaUZEV5Mf2F/xAiAr5w4KFoo/+DnR3NmvwftpEXRZMLy0= X-Received: by 2002:a17:90b:1dc4:b0:38e:a52e:a3c9 with SMTP id 98e67ed59e1d1-3955f0f209amr2677133a91.8.1787015584591; Mon, 17 Aug 2026 18:13:04 -0700 (PDT) Received: from 192.168.1.6 ([140.213.202.182]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-326793c43b7sm10302470eec.7.2026.08.17.18.13.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2026 18:13:04 -0700 (PDT) From: Foxie Flakey X-Google-Original-From: Foxie Flakey Date: Tue, 18 Aug 2026 08:13:00 +0700 (WIB) To: Andrew Morton cc: Foxie Flakey , rppt@kernel.org, peterx@redhat.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] userfaultfd: reset err to be 0 when move_pages_ptes succeeded In-Reply-To: <20260817152605.5d2bee3fbf1a2bace4c0eff1@linux-foundation.org> Message-ID: References: <9c936a9f-ed27-e510-872f-5b3b8c680975@gmail.com> <20260817152605.5d2bee3fbf1a2bace4c0eff1@linux-foundation.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 Hi, Andrew. On Mon, 17 Aug 2026, Andrew Morton wrote: > On Sat, 15 Aug 2026 17:42:12 +0700 (WIB) Foxie Flakey wrote: > > > > > An fix for edge case can occur if move_pages_ptes return -EAGAIN, later > > when checked and it is EAGAIN, outer loop would retry again on same page > > and succeeded but the err isn't reset so the outer loop would think need > > to retry again so it goes back again and move pages again. On third attempt > > move_pages_ptes will fail because it already moved and returns an error > > that is not EAGAIN when outer loop checks again it sees non EAGAIN so it > > dont retry and break out of loop. When loop is terminated it did not update > > the "moved" variable from successful 2nd iteration. > > > > That behaviour manifested into this at userspace > > > > Source: [ .. unmapped .. ][ .. mapped ..] > > Destination: [ .. mapped .. ][ .. unmapped ..] > > ^ ^ > > \ Kernel moved this far in actuality > > What is reported to userspace on struct > > uffdio_move's move field > > > > When the previous behaviour is > > Source: [ .. unmapped .. ][ .. mapped ..] > > Destination: [ .. mapped .. ][ .. unmapped ..] > > ^ > > Reported to user space via uffdio_move's > > move field > > Thanks. > > The text is a bit hard to follow. I asked Gemini to redo it and > perhaps you prefer that? https://share.gemini.google/cOWn3pQadvVw Yes, thanks. I have already make cleaner text from feedback on other branch of mails with Suren. > > Fixes: 50944692052b ("userfaultfd: opportunistic TLB-flush batching for present pages in MOVE") > > Signed-off-by: Foxie Flakey > > Yes, the pseudonym is problematic - it is contrary to our written > rules. But I'm a sucker for fixes, sigh. Perhaps if someone else were > to send me your patch with their signoff also, the rules would be less > offended. I see, I'll post the updated patch and work on signoff issue later (there has been updates, I haven't posted v2 which updates the patch and description following a feedback. Why I didn't? mainly I'm not sure with answer for signoff) > > --- a/mm/userfaultfd.c > > +++ b/mm/userfaultfd.c > > @@ -2069,10 +2069,12 @@ static ssize_t move_pages(struct userfaultfd_ctx *ctx, unsigned long dst_start, > > ret = move_pages_ptes(mm, dst_pmd, src_pmd, > > dst_vma, src_vma, dst_addr, > > src_addr, src_end - src_addr, mode); > > - if (ret < 0) > > + if (ret < 0) { > > err = ret; > > - else > > + } else { > > + err = 0; > > step_size = ret; > > + } > > } > > > > cond_resched(); > > Maintainers, when reviewing this please let me know whether you think > it should be backported. > > Sashiko did what it usually does when we make it look at uffd: > https://sashiko.dev/#/patchset/9c936a9f-ed27-e510-872f-5b3b8c680975@gmail.com >