From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 5EEB14A32; Thu, 5 Mar 2026 08:44:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772700270; cv=none; b=NNHcEZfKCh2vckJmKrMsnz/Oxn+83EeWDGHahhEbnlbJzPSzngzrnF1S733/gvjTXpvHDFuEqG+122vZGW4vNg9c9RBzfJE5Ej5fMShoDy0W4uafGZ+TdmxY5GkmQuepI1Fx7clufPG/2BsdYH5DLdevI9BuRo/jk6UalIl+5Vo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772700270; c=relaxed/simple; bh=bH9cDEIzoCAFMzWyAswOZriFHl7uowmtWVbYD6aUiPc=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=C2mjLCrEibSox6AbT6UEDMW7YjIVzkn5Eqicz5gtCtaPCHpcCANUGmNNYXYMdhl126QYYW7U6gh/qYNQqi4oxx3XyCbR67VPha0+Y42WLKw+WqNWQdp+Mad+svOn6h/BkadoblpbTi1ksAnPHPkGJxbNrvtMvqmQOToNjqXtsPM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QBHe1YUN; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QBHe1YUN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9A0E2C116C6; Thu, 5 Mar 2026 08:44:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1772700269; bh=bH9cDEIzoCAFMzWyAswOZriFHl7uowmtWVbYD6aUiPc=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=QBHe1YUNJiQ+6UejpGKx+tebrfGn9jf8j3uuRBXc4sWUkfNMp6Q30TP/qYJik3o2C mEZqPHcxH/xhXBIn9s1P0m1DvEf3k4NuqFGoHaxxW08bu82RbdznjqB3rcvDgpcW4n jDjUUA28aBgVuXGCBUl+kcQgBcXdmpH4k/+9797n97FU+adelLp8mXPsIBvF2Hyrn9 IunwyChSXuK7NHkRD3TWzQrTJ7ZyAxBrNZTScxbJ2wksi7s5eWYd5xI/VeACBqXvej iIX+AEkkXe2lx4rGcvaOu6MpUd0MIsWfcXAl+2LAQxri0F6BiuJpT9UEKmPZ4boM5r Deh6yxR+68nuw== From: Pratyush Yadav To: Mike Rapoport Cc: Pratyush Yadav , Pasha Tatashin , Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, stable@vger.kernel.org Subject: Re: [PATCH 2/2] mm: memfd_luo: always dirty all folios In-Reply-To: (Mike Rapoport's message of "Wed, 25 Feb 2026 10:58:34 +0200") References: <20260223173931.2221759-1-pratyush@kernel.org> <20260223173931.2221759-3-pratyush@kernel.org> Date: Thu, 05 Mar 2026 09:44:27 +0100 Message-ID: <2vxzv7fabr84.fsf@kernel.org> User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain Hi Mike, On Wed, Feb 25 2026, Mike Rapoport wrote: > On Mon, Feb 23, 2026 at 06:39:29PM +0100, Pratyush Yadav wrote: [...] >> - if (folio_test_dirty(folio)) >> - flags |= MEMFD_LUO_FOLIO_DIRTY; >> + /* >> + * A dirty folio is one which has been written to. A clean folio >> + * is its opposite. Since a clean folio does not carry user >> + * data, it can be freed by page reclaim under memory pressure. >> + * >> + * Saving the dirty flag at prepare() time doesn't work since it >> + * can change later. Saving it at freeze() also won't work >> + * because the dirty bit is normally synced at unmap and there >> + * might still be a mapping of the file at freeze(). >> + * >> + * To see why this is a problem, say a folio is clean at >> + * preserve, but gets dirtied later. The pfolio flags will mark >> + * it as clean. After retrieve, the next kernel might try to >> + * reclaim this folio under memory pressure, losing user data. >> + * >> + * Unconditionally mark it dirty to avoid this problem. This >> + * comes at the cost of making clean folios un-reclaimable after >> + * live update. >> + */ > > Can we make the comment here shorter to only contain the gist of the issue? Is this any better? Or should I try to make it shorter still? /* * Tracking the dirty flag of the folio is difficult since it is * normally synced at unmap and there might still be mappings of * the file alive. * * Not tracking it correctly can cause a dirty folio to be * restored as clean after KHO. The next kernel might then try * to reclaim it, losing user data. * * Unconditionally mark the folio dirty to avoid this. This * comes at the cost of making clean folios un-reclaimable. */ [...] -- Regards, Pratyush Yadav