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 40286E7718A for ; Thu, 19 Dec 2024 18:11:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BF4746B007B; Thu, 19 Dec 2024 13:11:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BA49F6B0082; Thu, 19 Dec 2024 13:11:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A6C2F6B0083; Thu, 19 Dec 2024 13:11:31 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 898A76B007B for ; Thu, 19 Dec 2024 13:11:31 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 4DEBD140135 for ; Thu, 19 Dec 2024 18:11:31 +0000 (UTC) X-FDA: 82912498830.20.5EE7F20 Received: from out-188.mta0.migadu.com (out-188.mta0.migadu.com [91.218.175.188]) by imf14.hostedemail.com (Postfix) with ESMTP id 3E36A100007 for ; Thu, 19 Dec 2024 18:10:45 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="XWu/F61J"; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf14.hostedemail.com: domain of shakeel.butt@linux.dev designates 91.218.175.188 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734631852; a=rsa-sha256; cv=none; b=hwDRCFDpqpj1ApL+jXbVhE0c0u7wlDqzFfUsp0C2bOy4iPdstJE3KowWdYWlSNyzNoJMc1 nqeXvsiZS6kIiHc19n26ZDqKdUfnwzKaoI8C3q2Lcux6fqXEVLHxMMjqaIgDUyP31HrHOz /AyPP64W8baK8iP8MpcTtiVpVEjo6mI= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="XWu/F61J"; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf14.hostedemail.com: domain of shakeel.butt@linux.dev designates 91.218.175.188 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734631852; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=sjCPTeoBFBOxGbENHBqM+WQSgCJtTcDAl8A3/hfu7uQ=; b=RsOYvqbxGlu2qXinUlFD/nhCZvbX5gZXsAwzbKYvb0N/UE6lNhpRNDFmVbOIHikcPlEzfK dBcNGFjRIJEW4GdPZlgpDfYIx81eArio4/gu7BXnIoiTBzb2uQiry27+hDtnNH4PelW9Of S5HloDwgEJuEkF2c5hJT4kHkERrxp/8= Date: Thu, 19 Dec 2024 10:11:11 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1734631880; 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=sjCPTeoBFBOxGbENHBqM+WQSgCJtTcDAl8A3/hfu7uQ=; b=XWu/F61J1maGQXECTYk6663rMRiFmld5MkqcVVRrPxYSdtcXqMhA1XcEHLR3iMCBE9zrZl xIaQ+9F/pb5ndI45JMEq7ybSVYA2hRiCl19FEI0vXHug106+qTfZAF36zvdsQ0niBmkF9/ TnJ2wNn4aO3G2mRJm2ljLbgoKlvW+lw= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Shakeel Butt To: Bernd Schubert Cc: Joanne Koong , David Hildenbrand , Zi Yan , miklos@szeredi.hu, linux-fsdevel@vger.kernel.org, jefflexu@linux.alibaba.com, josef@toxicpanda.com, 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: <43e13556-18a4-4250-b4fe-7ab736ceba7d@redhat.com> <968d3543-d8ac-4b5a-af8e-e6921311d5cf@redhat.com> <7b6b8143-d7a4-439f-ae35-a91055f9d62a@redhat.com> <7810ab2c-1f80-4c78-9b75-db20a78af5e3@fastmail.fm> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <7810ab2c-1f80-4c78-9b75-db20a78af5e3@fastmail.fm> X-Migadu-Flow: FLOW_OUT X-Stat-Signature: k9zpy6ngi91995pojz8dfs43j1asqdmy X-Rspam-User: X-Rspamd-Queue-Id: 3E36A100007 X-Rspamd-Server: rspam08 X-HE-Tag: 1734631845-673716 X-HE-Meta: U2FsdGVkX18ZXryZmmiNEW6cB7HRAtBGE9ovLec+QIfBENK7c9ni7ZZQ7AwXszX4l5i5Nqm7PPQYPAJxAAlYXWZT185wJaNoMzxH8+JLWiGExskP3c5oBFTmva6+5LDXjDzUXwIRxTUtPn/YoMFsGWeSm5hdiLD9SJZ/l3x1gS0JtTM+YP/CU79vSmE5Ebooa/3T+EYgH/EgINR6lJUj7iGbuNBOJle+6cIHUwW0QQ/1OVGuR33UaL2yTZ+gLYcJe8Act0KWx+YX087msgXxfmWwpf4gUnFhsxtEVVn3RH7rWNJEV5AT+tNVxHr9pwT5NuNpE9YLOTdz506YxlHOj3Nzj6dThknSgrcA77q7599huzteZjucPxd1XW1J/+RzYdaDJTln01eoUZq9T1qqEcdmhNXDn8EVOYgMWPd2VQunGZRyQw79KN8XhwrYbYUUCfhVoV3R22XhaRYpNBQaaeb3Uh0oHqIdQj6F9hNweUvh9xGloGyaenvkh95ZNqfaDugMywNWEhEktSgXW8g2Rvnrm2EIvmMQlGvggP0TncTtu6xkYD1lzgewGLBHOG2tPUZhdrrfBBcck2ap9hEQtQWUjiUPDxMn5ZgJ92JaXBBeOGJwKMEVw80xbzD0FnQdlxUHtmnDlNA+yeYl6pNOtjIZN0S7/wO9axgAv+LKWTaeFsu+d8C4TzNYttQEFTTsC5jva6+PAZsvzcQVF4NVdEagWd+kdHKwlPh945pty8dak65O1MzCIN+0hbRayi8R3tRNeInn/5Sdf2gEW8vseL8o5g3JnN9EjgfqfqlpoMERi62whK/IVipfGp8OD74pKCa0/dhzrMsZ0DC+Secrg4gQWOcWAWmXJ9NMKHw7WI6MKsgjZ0cb3Wtndka0WeF8TKq4jVOlfOzk2+eRs7p8uj//u3CgC86NGVOrJaWDJhwdGv6iE//0T0X1uKC69/ZzBzptN0OFSTYuoiuI170 5Twxr81d u1BNWm389q9PtT3eWZJIWjtUD4vFiPrLk3qTGXQygbB07UKj8lqOguAvRjhQ+KuNLKPZzeI5vlXlnFhS8E5H7WXqVOzWKQcRwwW5ymozr0blyy2GW4zzweiLOiMusSo66R86/a7KN1E4DQ4twRHT97pwB3DHFuyFI1o4lJYqU0vnbZCThaeV5k6mqGy18AbRH5pubK/rcqapXtnLUDgeuyxDjtYNPKR+xFyilOWdZb93uAE3XrTmh4qexR/mzg4wC9baBtYIAFoA5Up+Vnhcv26eETEGQWpKh88iL 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 07:04:40PM +0100, Bernd Schubert wrote: > > > On 12/19/24 18:55, Joanne Koong wrote: > > On Thu, Dec 19, 2024 at 9:26 AM David Hildenbrand wrote: > >> > >> On 19.12.24 18:14, Shakeel Butt wrote: > >>> On Thu, Dec 19, 2024 at 05:41:36PM +0100, David Hildenbrand wrote: > >>>> On 19.12.24 17:40, Shakeel Butt wrote: > >>>>> On Thu, Dec 19, 2024 at 05:29:08PM +0100, David Hildenbrand wrote: > >>>>> [...] > >>>>>>> > >>>>>>> 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. > >>>>>> > >>>>>> But there, writeback is expected to be a temporary thing, not possibly: > >>>>>> "AS_WRITEBACK_INDETERMINATE", that is a BIG difference. > >>>>>> > >>>>>> I'll have to NACK anything that violates ZONE_MOVABLE / ALLOC_CMA > >>>>>> guarantees, and unfortunately, it sounds like this is the case here, unless > >>>>>> I am missing something important. > >>>>>> > >>>>> > >>>>> It might just be the name "AS_WRITEBACK_INDETERMINATE" is causing > >>>>> the confusion. The writeback state is not indefinite. A proper fuse fs, > >>>>> like anyother fs, should handle writeback pages appropriately. These > >>>>> additional checks and skips are for (I think) untrusted fuse servers. > >>>> > >>>> Can unprivileged user space provoke this case? > >>> > >>> Let's ask Joanne and other fuse folks about the above question. > >>> > >>> Let's say unprivileged user space can start a untrusted fuse server, > >>> mount fuse, allocate and dirty a lot of fuse folios (within its dirty > >>> and memcg limits) and trigger the writeback. To cause pain (through > >>> fragmentation), it is not clearing the writeback state. Is this the > >>> scenario you are envisioning? > >> > > > > This scenario can already happen with temp pages. An untrusted > > malicious fuse server may allocate and dirty a lot of fuse folios > > within its dirty/memcg limits and never clear writeback on any of them > > and tie up system resources. This certainly isn't the common case, but > > it is a possibility. However, request timeouts can be set by the > > system admin [1] to protect against malicious/buggy fuse servers that > > try to do this. If the request isn't replied to by a certain amount of > > time, then the connection will be aborted and writeback state and > > other resources will be cleared/freed. > > > > I think what Zi points out that that is a current implementation issue > and these temp pages should be in a continues range. > Obviously better to avoid a tmp copy at all. The current tmp pages are allocated from MIGRATE_UNMOVABLE. I don't see any additional benefit of reserving any continuous unmovable memory regions for tmp pages. It will just add complexity without any clear benefit.