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 80D93E77188 for ; Mon, 30 Dec 2024 10:16:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DF5F76B0098; Mon, 30 Dec 2024 05:16:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DA3EE6B00AC; Mon, 30 Dec 2024 05:16:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BD05C6B00AD; Mon, 30 Dec 2024 05:16:27 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 9C8366B0098 for ; Mon, 30 Dec 2024 05:16:27 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 3327A1419EC for ; Mon, 30 Dec 2024 10:16:27 +0000 (UTC) X-FDA: 82951217538.17.0F7AD9E Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf09.hostedemail.com (Postfix) with ESMTP id E2E69140008 for ; Mon, 30 Dec 2024 10:15:52 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=f7OoLQX4; spf=pass (imf09.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1735553736; 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=wfPhj+GsTVBoLadkr2oEBzb5MpKJh5g9F2hLfDLIhAE=; b=UJQtsObvXI0jO1lT1WkuJLsoMW/D/wunUdF3PQr0J6Jh2sdjUQBaJt20XG3YFJ2IA43Y4G SSpUWk5fZW7TLPVSeQFaN0xpHGTp+HTc5GABArLqsShkIm4b8NWJdvhtWMHFikzopyMM6s +d+j8gGRMZoVUhs/tvZGJwzdf4sdXYE= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=f7OoLQX4; spf=pass (imf09.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1735553736; a=rsa-sha256; cv=none; b=xCM2ghhpuGFYT2Lqkr2ac1CjUM5lDLH8BBmu5er4dXq19QLzrt0rxUNaUq+zq6ey3SiPjZ O4xFrXbHbXMsZvJZkmU3zZ3GHg9wRCwCoKWkeEfTB781uZbexlnD5PbpkYlJnw1w+w6C20 iKHi9EERKx69X3aq3plVW6eHpKiWxXY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1735553784; 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:autocrypt:autocrypt; bh=wfPhj+GsTVBoLadkr2oEBzb5MpKJh5g9F2hLfDLIhAE=; b=f7OoLQX4EA9PFqKlFQJ2pPho1KwHWKfMiUu4AcaeXy/RgoVs9MlQhkZSm+B5QBARE9vfi8 ON2UhZyeOYH9PlX7AC2RK8A+swbfrp4Jx3XG2xpJFVgx3KjGxuCYrsoG0W1XYXe6YmRy+y /nHdv8kpDONcujLxgU4aLOdbPXrU1p4= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-410-j3ri08ChPn-_d4Y-ORDHDg-1; Mon, 30 Dec 2024 05:16:22 -0500 X-MC-Unique: j3ri08ChPn-_d4Y-ORDHDg-1 X-Mimecast-MFC-AGG-ID: j3ri08ChPn-_d4Y-ORDHDg Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-385f0829430so5606730f8f.1 for ; Mon, 30 Dec 2024 02:16:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735553781; x=1736158581; h=content-transfer-encoding:in-reply-to:organization:autocrypt :content-language:from:references:cc:to:subject:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=wfPhj+GsTVBoLadkr2oEBzb5MpKJh5g9F2hLfDLIhAE=; b=hkdEMg6zXhlo7r1F1dR/OyR9lYjTYPFf8fQlRKvrO7yPtuQovzmFK7udul6CpUugGd l2GLKdCOAt3w6LR6ksSLV2jznXOz14fmoZdnPLSoV5P1GUgRbZnwA62jQxsnv6DMIB20 /ZjgayoK7HTqqZUiZzfn2wpZGwl/akn680u2hL6fxJwSkXECezN1uUPMJvbCqSCE/8RX dwyjPHUViYVYzkpsBF5ZiJ2aBESzzO3FCMUnoiwb6A+UNNzrJtiCiP7ZkKD9XYVY6i0b fh8sRVCNrnD3VXuX2kbaa9DP/z3clZnbJzkknv98vuLy/putnjbXNL9AVcARvCwQFgYw 2BdQ== X-Forwarded-Encrypted: i=1; AJvYcCV21Lw6n3hWbVCMtXBM8gR3oCRxCjNJp5RnGaBwMnvoZveO13KKHdjSaxYkOr0KZaoU+x8SoHbIKQ==@kvack.org X-Gm-Message-State: AOJu0Yxe/cTlPZhCFf6ngRYy6ke8k8Fp+MhYcqIh0L2pW9XB70xg+Cz7 a0bxoEXzwZ5dR0Fof09itO//vQ6xZohChmkFg6cPfh9HC3RIRD/h5cbObhle4DYHpthLGpLP0WJ tR6lQfrIfo0icANjkh6I2ojbJtKRlj9Ux3MNlbkAaiUMDMzzT X-Gm-Gg: ASbGncvGpjbf3Wu8p1kr1P0zmks9dTSIig14pIsaBq5ZIhPhm+f4TansxQZdMrTtzaA ZvW4py1l9fON0dvhtjibymcNqsE/txe9B7pQoeqs3W6yJRYFUXunbINsiA2DJi8xHPEwXI0vFpz dQ96cDRqhdgqvCPnC9vZQBx2H2nlT1qqrgNI3TeIJCwwoPDmKLlrF1vvB7JRL+Cgeqiivko9fhZ Hnd1Tp/91do3Jv5pAjXAZOqxchs7RQ1qKzB2GFooHcbtQ9RcyTsmvtFeJTAoR5ZT8NgZVqVFtZZ y6OSnxRcy4yNh8rOZCwM50PaB6Rcft1lTryZCpJMuoL0Tiqx4E/w5Zq031EK71vgSUofd7VFJR4 NYghJA1PR X-Received: by 2002:a5d:47ab:0:b0:386:1ab5:f0e1 with SMTP id ffacd0b85a97d-38a221ea67fmr33687863f8f.14.1735553781493; Mon, 30 Dec 2024 02:16:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IF0iVyi3Ka5o1ghQOFECyWau7dB/SLiwvV5HEpWiwGLxJiUR3UMPbGjgX5SGFe1rWyUA2+Pbw== X-Received: by 2002:a5d:47ab:0:b0:386:1ab5:f0e1 with SMTP id ffacd0b85a97d-38a221ea67fmr33687833f8f.14.1735553781038; Mon, 30 Dec 2024 02:16:21 -0800 (PST) Received: from ?IPV6:2003:cb:c718:5800:c745:7e74:aa59:8dbe? (p200300cbc7185800c7457e74aa598dbe.dip0.t-ipconnect.de. [2003:cb:c718:5800:c745:7e74:aa59:8dbe]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c89e2d2sm30149795f8f.71.2024.12.30.02.16.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Dec 2024 02:16:19 -0800 (PST) Message-ID: <0ed5241e-10af-43ee-baaf-87a5b4dc9694@redhat.com> Date: Mon, 30 Dec 2024 11:16:17 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v6 4/5] mm/migrate: skip migrating folios under writeback with AS_WRITEBACK_INDETERMINATE mappings To: Shakeel Butt Cc: Bernd Schubert , Joanne Koong , 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 References: <2bph7jx4hvhxpgp77shq2j7mo4xssobhqndw5v7hdvbn43jo2w@scqly5zby7bm> <71d7ac34-a5e5-4e59-802b-33d8a4256040@redhat.com> <9404aaa2-4fc2-4b8b-8f95-5604c54c162a@redhat.com> <3f3c7254-7171-4987-bb1b-24c323e22a0f@redhat.com> From: David Hildenbrand Autocrypt: addr=david@redhat.com; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou6478faXE6o2AhmebqT4KiQoUQFV4R7y1KMEKoSyy8hQaK1umALTdL QZLQMzNE74ap+GDK0wnacPQFpcG1AE9RMq3aeErY5tujekBS32jfC/7AnH7I0v1v1TbbK3Gp XNeiN4QroO+5qaSr0ID2sz5jtBLRb15RMre27E1ImpaIv2Jw8NJgW0k/D1RyKCwaTsgRdwuK Kx/Y91XuSBdz0uOyU/S8kM1+ag0wvsGlpBVxRR/xw/E8M7TEwuCZQArqqTCmkG6HGcXFT0V9 PXFNNgV5jXMQRwU0O/ztJIQqsE5LsUomE//bLwzj9IVsaQpKDqW6TAPjcdBDPLHvriq7kGjt WhVhdl0qEYB8lkBEU7V2Yb+SYhmhpDrti9Fq1EsmhiHSkxJcGREoMK/63r9WLZYI3+4W2rAc UucZa4OT27U5ZISjNg3Ev0rxU5UH2/pT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3kq Er5KTrJz3++B6SH9pum9PuoE/k+nntJkNMmQpR4MCBaV/J9gIOPGodDKnjdng+mXliF3Ptu6 3oxc2RCyGzTlxyMwuc2U5Q7KtUNTdDe8T0uE+9b8BLMVQDDfJjqY0VVqSUwImzTDLX9S4g/8 kC4HRcclk8hpyhY2jKGluZO0awwTIMgVEzmTyBphDg/Gx7dZU1Xf8HFuE+UZ5UDHDTnwgv7E th6RC9+WrhDNspZ9fJjKWRbveQgUFCpe1sa77LAw+XFrKmBHXp9ZVIe90RMe2tRL06BGiRZr jPrnvUsUUsjRoRNJjKKA/REq+sAnhkNPPZ/NNMjaZ5b8Tovi8C0tmxiCHaQYqj7G2rgnT0kt WNyWQQ== Organization: Red Hat In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 8lcxTD3VlM6bVm18srZMW20c4QQWvu2OqqEtdgHaNS8_1735553782 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: E2E69140008 X-Rspam-User: X-Stat-Signature: k9gdmkgr1rj7e5i6f69snk57xotsp3em X-HE-Tag: 1735553752-117291 X-HE-Meta: U2FsdGVkX19C0hUWffmnNxGOlFXTOIAMzHmYuqSkP7ap25AyCC5IS3mGaeaCwNNI9UHF96xp6FQEf2l5P+ZNfBQMhinWiVKSVJQq8i9kNUkc2grg87WIG2jEk7xv/0ywnTVsc8981X6ivOVMSGkIBivja+Ad0fJv+TYb+Ey4b6yNQElkh2c5wLgsmSKbCdVfvrmjiESC1Yv9yuZQQJvtshNn1hoysY6LeVs2gQ7oDmSFHHrdQzbEH8AgBFJLMiEYwfK/rUn9Wj818IVuyKVxLqxTqt/mp21Kd6Ba8vkJnXgG52wxxT+m13fW7DWWGZxb/1JuALRtrFhXoKN7PSnAaJzY3vkyuJoFMHzyNIbdOJlPGifuc4VtbY0cz/c8doQeICM7GyoiydNFBgRCw6p3THxgbV/apujtAlqqecMODH9Wf0t2EJcIuoIqQw2jQMvY2NcGNGVYpEUl2Rx34b+GDxQZ6idULt5ABAC0EuDgGF9AP17DMXqfYJfPVENP+MwFBS3sJyyMTOcyBd5vn978haCX/rUeWwRNU2BQt1ecjG/UOS4utr+rX48gJjf44s7+VcF12f0nr2AihORWPuEIi9sAcQKjqyhbjyllkCUljNo8N0Y/C/5BJupGqi8jbMtcL5qjLPAFDNvJ7KTiGfHwd2y+Q+JToqWS/c1XJkJdWk64mclWzYRhh0RlRg+ehiXhxA/+/ePdPQo7yE0QYFfRhHNdoX4PkG3l3/iPxJolqpHNAN/i4FPodRB/7q0ecZm3Xh60EGclop1AUWEVFhgPdli6Y6XXwry2FfolHNGjq+Wa6nUxYGS5sVLwyrFzgBSVJpR1OZHfowiwZPntfic1F9G9a6nZpgFZoypG4wKOpNAJA9R9yFZ9P/bJtoiUJG4RXpkGHumvOfI/8TdWlYNPCAtgRG8s/pSvnbOxFA5d7Sh9T5NsykRs77L4sGPusOoxFJhh4AC9VlEQqpkYrpr KYGa+13m OeERZR5OYGXsxlnSlXzBE9eCjaIz/CThA/5KVfsmRyo87I16warrMCYqUQ2UT1GgAsrogKmOpXPjVvzwECnETOq97+mVTkjg9GOKuztQv3kPFFlCeC8vZU36HoT1ScgWkk7eEMzxPEWgV+9pZHyodLZIxAvXUibZgPOoYNHmclL1L03Jm64t+tkWjNlqSKdnCTeqXqApgOZEciDn7l/nKZXVbnkWcyiKW4SiIJKKo/cTqgNdlPDINbsZLTu5Y8AnEF71e8EBhqwRSqU2mAslg6PIOiLPjFP7LmrytPqCAdzxaSc76tcLSTo5apaKVmUBqNEkodv7dHHd2UHEHb4zekMp5cS+cojZetKlevTugny7fs5CZ6D4xoQmLOF0SzVAeaN2mCcYXmgwo0Fecw0Kyz1xE2L8pSglWardo/1TBdzZ/4IYbotCrtlPS4etySNmlI41q 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: >> BTW, I just looked at NFS out of interest, in particular >> nfs_page_async_flush(), and I spot some logic about re-dirtying pages + >> canceling writeback. IIUC, there are default timeouts for UDP and TCP, >> whereby the TCP default one seems to be around 60s (* retrans?), and the >> privileged user that mounts it can set higher ones. I guess one could run >> into similar writeback issues? > Hi, sorry for the late reply. > Yes, I think so. > >> >> So I wonder why we never required AS_WRITEBACK_INDETERMINATE for nfs? > > I feel like INDETERMINATE in the name is the main cause of confusion. We are adding logic that says "unconditionally, never wait on writeback for these folios, not even any sync migration". That's the main problem I have. Your explanation below is helpful. Because ... > So, let me explain why it is required (but later I will tell you how it > can be avoided). The FUSE thread which is actively handling writeback of > a given folio can cause memory allocation either through syscall or page > fault. That memory allocation can trigger global reclaim synchronously > and in cgroup-v1, that FUSE thread can wait on the writeback on the same > folio whose writeback it is supposed to end and cauing a deadlock. So, > AS_WRITEBACK_INDETERMINATE is used to just avoid this deadlock. > > The in-kernel fs avoid this situation through the use of GFP_NOFS > allocations. The userspace fs can also use a similar approach which is > prctl(PR_SET_IO_FLUSHER, 1) to avoid this situation. However I have been > told that it is hard to use as it is per-thread flag and has to be set > for all the threads handling writeback which can be error prone if the > threadpool is dynamic. Second it is very coarse such that all the > allocations from those threads (e.g. page faults) become NOFS which > makes userspace very unreliable on highly utilized machine as NOFS can > not reclaim potentially a lot of memory and can not trigger oom-kill. > ... now I understand that we want to prevent a deadlock in one specific scenario only? What sounds plausible for me is: a) Make this only affect the actual deadlock path: sync migration during compaction. Communicate it either using some "context" information or with a new MIGRATE_SYNC_COMPACTION. b) Call it sth. like AS_WRITEBACK_MIGHT_DEADLOCK_ON_RECLAIM to express that very deadlock problem. c) Leave all others sync migration users alone for now Would that prevent the deadlock? Even *better* would be to to be able to ask the fs if starting writeback on a specific folio could deadlock. Because in most cases, as I understand, we'll not actually run into the deadlock and would just want to wait for writeback to just complete (esp. compaction). (I still think having folios under writeback for a long time might be a problem, but that's indeed something to sort out separately in the future, because I suspect NFS has similar issues. We'd want to "wait with timeout" and e.g., cancel writeback during memory offlining/alloc_cma ...) >> Not >> sure if I grasped all details about NFS and writeback and when it would >> redirty+end writeback, and if there is some other handling in there. >> > [...] >>> >>> Please note that such filesystems are mostly used in environments like >>> data center or hyperscalar and usually have more advanced mechanisms to >>> handle and avoid situations like long delays. For such environment >>> network unavailability is a larger issue than some cma allocation >>> failure. My point is: let's not assume the disastrous situaion is normal >>> and overcomplicate the solution. >> >> Let me summarize my main point: ZONE_MOVABLE/MIGRATE_CMA must only be used >> for movable allocations. >> >> Mechanisms that possible turn these folios unmovable for a >> long/indeterminate time must either fail or migrate these folios out of >> these regions, otherwise we start violating the very semantics why >> ZONE_MOVABLE/MIGRATE_CMA was added in the first place. >> >> Yes, there are corner cases where we cannot guarantee movability (e.g., OOM >> when allocating a migration destination), but these are not cases that can >> be triggered by (unprivileged) user space easily. >> >> That's why FOLL_LONGTERM pinning does exactly that: even if user space would >> promise that this is really only "short-term", we will treat it as "possibly >> forever", because it's under user-space control. >> >> >> Instead of having more subsystems violate these semantics because >> "performance" ... I would hope we would do better. Maybe it's an issue for >> NFS as well ("at least" only for privileged user space)? In which case, >> again, I would hope we would do better. >> >> >> Anyhow, I'm hoping there will be more feedback from other MM folks, but >> likely right now a lot of people are out (just like I should ;) ). >> >> If I end up being the only one with these concerns, then likely people can >> feel free to ignore them. ;) > > I agree we should do better but IMHO it should be an iterative process. > I think your concerns are valid, so let's push the discussion towards> resolving those concerns. I think the concerns can be resolved by better > handling of lifetime of folios under writeback. The amount of such > folios is already handled through existing dirty throttling mechanism. > > We should start with a baseline i.e. distribution of lifetime of folios > under writeback for traditional storage devices (spinning disk and SSDs) > as we don't want an unrealistic goal for ourself. I think this data will > drive the appropriate timeout values (if we decide timeout based > approach is the right one). > > At the moment we have timeout based approach to limit the lifetime of > folios under writeback. Any other ideas? See above, maybe we could limit the deadlock avoidance to the actual deadlock path and sort out the "infinite writeback in some corner cases" problem separately. -- Cheers, David / dhildenb