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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF421E77184 for ; Thu, 19 Dec 2024 16:22:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 73D316B0083; Thu, 19 Dec 2024 11:22:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6ED496B0085; Thu, 19 Dec 2024 11:22:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5B5206B0088; Thu, 19 Dec 2024 11:22:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 3BC3A6B0083 for ; Thu, 19 Dec 2024 11:22:40 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id F3768B0E57 for ; Thu, 19 Dec 2024 16:22:39 +0000 (UTC) X-FDA: 82912225578.13.4504FC6 Received: from out-174.mta1.migadu.com (out-174.mta1.migadu.com [95.215.58.174]) by imf30.hostedemail.com (Postfix) with ESMTP id AE02F80010 for ; Thu, 19 Dec 2024 16:21:34 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=fJS1fZcG; spf=pass (imf30.hostedemail.com: domain of shakeel.butt@linux.dev designates 95.215.58.174 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734625335; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=492fyIcDZR0RXpAoh3ANPc363L8kEgmZve/YJhkN9Hc=; b=qWXVBOWmzh/YkUD0QA6zTy0VkSQ5Zrklw3mA2OivVFejO+3K0Ke4oVn+aJoFGejFPXCwED +kwSzn3nJJIGfUafNGGPCatOgjY69Dtdb6NPxiQj4bckBZIUOoUms7re2gH8eIWFVR02/P WCOiJKU0nhTvv94yLFti2nsMD1+bb6E= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=fJS1fZcG; spf=pass (imf30.hostedemail.com: domain of shakeel.butt@linux.dev designates 95.215.58.174 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734625335; a=rsa-sha256; cv=none; b=YW+sNC5u2aHXmqUBrK+BLKmZL11RuKza+Ezn2MzQQK4QMq8xxphxIxc6vJ5JR98U2b+uo/ EdqDOW/uJzDfVJrrkuz+UdI1c4irmzOnKMxolyv1AQTy4aXmohYO+fa6TDUgM8475Nobim 5BY0VNkjiDUN+BGz2KwUOWIYbxMSGkY= Date: Thu, 19 Dec 2024 08:22:30 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1734625356; 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=492fyIcDZR0RXpAoh3ANPc363L8kEgmZve/YJhkN9Hc=; b=fJS1fZcGhQTNqd6lOMcOggQJX3WqRMss1RqIkRiHLqkJEPaZY0lOemOyFwVLx2OCTKcaRP 0FbCrJJeggXD/2Z9NQ6R7KuBbb+Ea1Quyghnk6Jy3t34o+17Z3UnmC2gXdaXgPKfnqt18G AJocp3U59oUsNr/DpASos5BSTMUqFC8= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Shakeel Butt To: Zi Yan Cc: David Hildenbrand , Joanne Koong , miklos@szeredi.hu, linux-fsdevel@vger.kernel.org, jefflexu@linux.alibaba.com, josef@toxicpanda.com, bernd.schubert@fastmail.fm, linux-mm@kvack.org, kernel-team@meta.com, Matthew Wilcox , Oscar Salvador , Michal Hocko Subject: Re: [PATCH v6 4/5] mm/migrate: skip migrating folios under writeback with AS_WRITEBACK_INDETERMINATE mappings Message-ID: References: <20241122232359.429647-1-joannelkoong@gmail.com> <20241122232359.429647-5-joannelkoong@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Rspamd-Server: rspam05 X-Stat-Signature: dczq8gok5bj3d9erhsctgns91nbdunb9 X-Rspamd-Queue-Id: AE02F80010 X-Rspam-User: X-HE-Tag: 1734625294-712031 X-HE-Meta: U2FsdGVkX19lXjLSwnBSLCtbbzCd/vv0V4s2KrQS4byMfGoknAz93BvUaF/4WRXfL7q0Xnzad7WBNP0JzKtKMJh+p6yBzWM96MVfHs0DoxxPLZHfDUqwc+zZFjCvknecrVOK7xhIh3340iOgdW9WmjEQefYlw5nwbhOY+1qJINrnLVj8N9Aqea+HCinT3U7sKXHTQJF3jDD1RlYP+2UJ9cgaAvWP2JKjL6yS8YJ1ptZUw0oFI9euFlBIQcnTiwauQu4tpooAS0OG1u0k3yBbUr7AXZPmO9mlv1Kr7kt11SqKCASCnEaMA59fQICs+EmebJgWLgcoY6WbOK6+Uo9cxR4GAFXWJ8Bspqv/1NjruYNMZZPZOf+/CQ7yr/rT4iNv7YLQBuDiaGnKvfsj1vxde8g7CArcvczU1hN0Nqvpn4ulXunb5YSL43pQLj68SG5TGuW9ywyWgUATZ/Kiq8D9oNHREU0TyExeEdP+PWrIOoJ4ogl3U6J+bUM5Xd2T28KTA3etncE43ifSyDAhn25rrUEREm9WAHIAdHbf7qTLW0cE4V41Uxs6Zg7ji3zSD2MrSQV/6Hjk5Aeg26oWlc4dfvAHUc34fOvsJRR0DoOq5YosDuG5fQTDlu16LC9AuLkAVS1ShhGmEssL2xeKKVbTsItdcnhz+ds/SBRwTwF3/8vsA/ZwZMg83EddKrstVwV3HTY0aYfl1DFSuu7fy4SNgxMi5+sKVft7uZ0nVBDa5DzxvMp/j4sj254BXBcWTg3uwAjs1EPxJDl+jFw9BsOQ6EufMy4ey0LDFigd4epihxlWsXMIGf9oNQMOrCUDdaK03eChj7As/XC/yogRgzG1EY/92WSezVCrYyOnAKKbCJVqki//YmcPyI4ZJGBWHqz8abt3v9qIy486CaTwb6lW+8smeQ9hqW7crPBAqc8PEdinnQU24xpjELyiMwhk34DZdyhkM3GL4Ng6TKGLHh2 em7HC2ph 7dqFM20HqRL2EDNgywKHDjockOtXZhEM6AMezImZUDgpami9efX7XliDfqF6WorQRlJftlLVmAng4kBr4q7HxAU7PLE4eceNUXIJd75ISketXtcQqxNgko+y/xJV+HVc6gxF90NrzT8D7j6MCCOc40bikGGqA+wi52PF4OxamBMlQWixMuKnypTwmFOqlGhfi58/61UELQrAtjb4rAI5NLJk5jwEMz0Up1NH4 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: List-Subscribe: List-Unsubscribe: On Thu, Dec 19, 2024 at 10:55:10AM -0500, Zi Yan wrote: > On 19 Dec 2024, at 10:53, Shakeel Butt wrote: > > > On Thu, Dec 19, 2024 at 04:47:18PM +0100, David Hildenbrand wrote: > >> On 19.12.24 16:43, Shakeel Butt wrote: > >>> On Thu, Dec 19, 2024 at 02:05:04PM +0100, David Hildenbrand wrote: > >>>> On 23.11.24 00:23, Joanne Koong wrote: > >>>>> For migrations called in MIGRATE_SYNC mode, skip migrating the folio if > >>>>> it is under writeback and has the AS_WRITEBACK_INDETERMINATE flag set on its > >>>>> mapping. If the AS_WRITEBACK_INDETERMINATE flag is set on the mapping, the > >>>>> writeback may take an indeterminate amount of time to complete, and > >>>>> waits may get stuck. > >>>>> > >>>>> Signed-off-by: Joanne Koong > >>>>> Reviewed-by: Shakeel Butt > >>>>> --- > >>>>> mm/migrate.c | 5 ++++- > >>>>> 1 file changed, 4 insertions(+), 1 deletion(-) > >>>>> > >>>>> diff --git a/mm/migrate.c b/mm/migrate.c > >>>>> index df91248755e4..fe73284e5246 100644 > >>>>> --- a/mm/migrate.c > >>>>> +++ b/mm/migrate.c > >>>>> @@ -1260,7 +1260,10 @@ static int migrate_folio_unmap(new_folio_t get_new_folio, > >>>>> */ > >>>>> switch (mode) { > >>>>> case MIGRATE_SYNC: > >>>>> - break; > >>>>> + if (!src->mapping || > >>>>> + !mapping_writeback_indeterminate(src->mapping)) > >>>>> + break; > >>>>> + fallthrough; > >>>>> default: > >>>>> rc = -EBUSY; > >>>>> goto out; > >>>> > >>>> Ehm, doesn't this mean that any fuse user can essentially completely block > >>>> CMA allocations, memory compaction, memory hotunplug, memory poisoning... ?! > >>>> > >>>> That sounds very bad. > >>> > >>> The page under writeback are already unmovable while they are under > >>> writeback. This patch is only making potentially unrelated tasks to > >>> synchronously wait on writeback completion for such pages which in worst > >>> case can be indefinite. This actually is solving an isolation issue on a > >>> multi-tenant machine. > >>> > >> Are you sure, because I read in the cover letter: > >> > >> "In the current FUSE writeback design (see commit 3be5a52b30aa ("fuse: > >> support writable mmap"))), a temp page is allocated for every dirty > >> page to be written back, the contents of the dirty page are copied over to > >> the temp page, and the temp page gets handed to the server to write back. > >> This is done so that writeback may be immediately cleared on the dirty > >> page," > >> > >> Which to me means that they are immediately movable again? > > > > Oh sorry, my mistake, yes this will become an isolation issue with the > > removal of the temp page in-between which this series is doing. I think > > the tradeoff is between extra memory plus slow write performance versus > > temporary unmovable memory. > > No, the tradeoff is slow FUSE performance vs whole system slowdown due to > memory fragmentation. AS_WRITEBACK_INDETERMINATE indicates it is not > temporary. If you check the code just above this patch, this mapping_writeback_indeterminate() check only happen for pages under writeback which is a temp state. Anyways, fuse folios should not be unmovable for their lifetime but only while under writeback which is same for all fs.