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 88DE3D3B9A4 for ; Tue, 26 Nov 2024 15:28:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 173416B0085; Tue, 26 Nov 2024 10:28:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 123096B0088; Tue, 26 Nov 2024 10:28:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F04EA6B008C; Tue, 26 Nov 2024 10:28:10 -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 CEEE76B0085 for ; Tue, 26 Nov 2024 10:28:10 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 3CDC5C07F7 for ; Tue, 26 Nov 2024 15:28:10 +0000 (UTC) X-FDA: 82828626804.20.3F028D8 Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) by imf08.hostedemail.com (Postfix) with ESMTP id 00D9F160006 for ; Tue, 26 Nov 2024 15:28:04 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=mfLwtFGY; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf08.hostedemail.com: domain of anders.blomdell@gmail.com designates 209.85.208.176 as permitted sender) smtp.mailfrom=anders.blomdell@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1732634886; a=rsa-sha256; cv=none; b=ANv87i6uJRy5lJz9EykqbFAeElPFFl9BjdRjshAC2WZmtG9SXqUXFRPngIkhDS8jfWGyJu QwHuh4UXbyb5oHEtTPHwZH5ueGlg3NNvSdPQmiSTX/ZAAhwRyRQv1aoSsKf0y9zLihmdYU CpLXORObxc6EK/jdVud+g7Tji3qAJW8= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=mfLwtFGY; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf08.hostedemail.com: domain of anders.blomdell@gmail.com designates 209.85.208.176 as permitted sender) smtp.mailfrom=anders.blomdell@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1732634886; 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=hL92joE2utUXDrWBWHIFKxahnMA5d997Re4iaT4oJkY=; b=hz2mEVTeKSfHnIwpS8uHgpmJ/MFXHOWFrnkO7Y/Owhh44ZCLZA9KhLGr9/w9/NJ2i1MhF+ WrAre5TJiR3DQ9g5lAnC5xoALUL2K5j+vwAprzaOYn/r5Bs97AZoqVqDd0UdBLU61UFj2P 4/oEvqBHqgFIK/BeUIPclzEpteIfniE= Received: by mail-lj1-f176.google.com with SMTP id 38308e7fff4ca-2ffa49f623cso57044211fa.1 for ; Tue, 26 Nov 2024 07:28:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732634886; x=1733239686; darn=kvack.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=hL92joE2utUXDrWBWHIFKxahnMA5d997Re4iaT4oJkY=; b=mfLwtFGYVXWssuNfdo4rKvOYpJoQ837HulbJYrQYhPmM+dWb2mLcqUM6xjFzhwZKg1 Rh2AinVdP7A9Xb2khsPvwEskK5HpK/QEkYjwgBw56FSZxSVONPxCjwip4/BdUoYi32J6 18D0Df4sA1gH0qXiKgq3bBJk0IxueXnIMI7JVik5W4ghpQ9qqJaAHVnNNjnq6KsHKl/x GqLdkL6JzwM8F8qghMp2L0ZFH02G3jIOT6Baqzrflbj7LZOOYLNxnctLXYZmvV/kjNPP 6CrP9MvI9EaNdhQ/Q2JU8m5U3QcI8tB9pHu0zOzQPqR+9uhYOmCHyiX0GYYtGekeOUEL Ld4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732634886; x=1733239686; h=content-transfer-encoding:in-reply-to:from:content-language :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=hL92joE2utUXDrWBWHIFKxahnMA5d997Re4iaT4oJkY=; b=rqFqRf5HRdIGasIURS6z2cwODX2/zA0wJM+L1gwJQ34aD6AMcGPRlgIUn35ynOsDEt FY5p/84v88K2YC/VS9rKGPeVVxbOkWvzx4MPlb0CIrBEH4Ojv8X/SHq1q4S4jZezOUoH zM5ACjZWzf+4et455luGVqtAJOoLlGoyhvYZllPmv6Sp6NxoFJkFkTC+ZcfemqJy/V3u wMcZ31g8gTsgwCBTXXW0HV+GNel/YSe48OfX2VttPkz4p5Xkcdxx2c4wPHkB/O/fVh79 xG/mYOdwTsSHFgbiuzN6kYxKAyjJb9eDW2dSIKrNtnDD1W5/fXz/giTgS7XEFLBd8QPK IN5w== X-Forwarded-Encrypted: i=1; AJvYcCXyxc8jkNgDXZCJIOhXnPzfsTUyE9Z40Xv+zCHxB+mWK0mCWicFZ08z7B5ptLc1qXjZJDWddUASIA==@kvack.org X-Gm-Message-State: AOJu0Yw2pMrz6gJEdAs5zMJadkLwrL3iA3W+ZNg8WjqckDLlJzy9o8ys iD+aTvBZeNdpoYghtIaRsuMLF0g9icC5MPs6Dv3wnU0KlegfSId9 X-Gm-Gg: ASbGncuf04USyaptbtl2fVtf08sZuM4T3uFu0pLzGShEHuo+Zp8AxojSlnhR5C+20gN 3vhrBzVJFpoqh/6GvqIWzgu4VCzHcg2tjsRu6378+EKdzfZzP5YiqsmS+z9t2TyqTuJFSVJoAJv wZaIuY/CLVdAn/aJ63EVYbG4marjYKgych6BKBovXWzZitZ2j5BvIBnbydtlN/iyF6EaUzOOww3 UGv+/KSJS5z02OZxFtfX64HgE7I0JYA23N3Dov2uM2NigLLPDSD2KHjTqGpTLC926X20xZlTeNl G3mXWeiH X-Google-Smtp-Source: AGHT+IF3odjqvL+3f50N+hGfNnykpAnmeU9HNEIgrF/jthnjL150g9fKJV14VNDDx4LXOZ5E9j/TEg== X-Received: by 2002:a05:651c:199f:b0:2ff:d15d:649 with SMTP id 38308e7fff4ca-2ffd15d06ddmr12400911fa.31.1732634886074; Tue, 26 Nov 2024 07:28:06 -0800 (PST) Received: from [130.235.83.196] (nieman.control.lth.se. [130.235.83.196]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2ffa4d171absm18923671fa.15.2024.11.26.07.28.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 26 Nov 2024 07:28:04 -0800 (PST) Message-ID: Date: Tue, 26 Nov 2024 16:28:04 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Regression in NFS probably due to very large amounts of readahead To: Jan Kara Cc: Philippe Troin , "Matthew Wilcox (Oracle)" , Andrew Morton , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, NeilBrown References: <49648605-d800-4859-be49-624bbe60519d@gmail.com> <3b1d4265b384424688711a9259f98dec44c77848.camel@fifi.org> <4bb8bfe1-5de6-4b5d-af90-ab24848c772b@gmail.com> <20241126103719.bvd2umwarh26pmb3@quack3> <20241126150613.a4b57y2qmolapsuc@quack3> Content-Language: en-US From: Anders Blomdell In-Reply-To: <20241126150613.a4b57y2qmolapsuc@quack3> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X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pNxjFcmiQVpI4yGPlQ/d+7ANRnYN+w+ GPd/Fo4C eDu9aRmDl47IPHsEk14nXVYon9OJjB8YQh0jrRqG+KE+uNQa+CEzJauSyHTDkba8/WVxLhzxuwyjldgPcvckyYzuB7oYdKTxd36/dE3a+1eBoK8l8m/6/xM7oBAbjow+Thf8RmLIVG07wFoztSr+xgF/fmmzKca7y0MeE7ZhTvVCAPvDlQOlnqf4N4kQ7VZKRvaq+SruAJyoR1rm3DhYF/dqKzi7qbUqXO0WMNNvXrOR1gTJHDEif9fiDlLTWHeH1Asfvi8Cjgka8ggQm8eeg54YkYZbPhIDKRowhYXin4RjeACiPLABRJotnqREIv9ADylNdC4LX2CKQgfR2YM2b5vCO4omjUu//cFf8+DXQWM3jkZDuVmLiwNE0QM3neKCMAMF1vM1eBc6eYK3F6hBk3YX1vvQvTXkQYkyZUkxc9MXyJ49mrNKyryHkeQ== 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 2024-11-26 16:06, Jan Kara wrote: > On Tue 26-11-24 11:37:19, Jan Kara wrote: >> On Tue 26-11-24 09:01:35, Anders Blomdell wrote: >>> On 2024-11-26 02:48, Philippe Troin wrote: >>>> On Sat, 2024-11-23 at 23:32 +0100, Anders Blomdell wrote: >>>>> When we (re)started one of our servers with 6.11.3-200.fc40.x86_64, >>>>> we got terrible performance (lots of nfs: server x.x.x.x not >>>>> responding). >>>>> What triggered this problem was virtual machines with NFS-mounted >>>>> qcow2 disks >>>>> that often triggered large readaheads that generates long streaks of >>>>> disk I/O >>>>> of 150-600 MB/s (4 ordinary HDD's) that filled up the buffer/cache >>>>> area of the >>>>> machine. >>>>> >>>>> A git bisect gave the following suspect: >>>>> >>>>> git bisect start >>>> >>>> 8< snip >8 >>>> >>>>> # first bad commit: [7c877586da3178974a8a94577b6045a48377ff25] >>>>> readahead: properly shorten readahead when falling back to >>>>> do_page_cache_ra() >>>> >>>> Thank you for taking the time to bisect, this issue has been bugging >>>> me, but it's been non-deterministic, and hence hard to bisect. >>>> >>>> I'm seeing the same problem on 6.11.10 (and earlier 6.11.x kernels) in >>>> slightly different setups: >>>> >>>> (1) On machines mounting NFSv3 shared drives. The symptom here is a >>>> "nfs server XXX not responding, still trying" that never recovers >>>> (while the server remains pingable and other NFSv3 volumes from the >>>> hanging server can be mounted). >>>> >>>> (2) On VMs running over qemu-kvm, I see very long stalls (can be up to >>>> several minutes) on random I/O. These stalls eventually recover. >>>> >>>> I've built a 6.11.10 kernel with >>>> 7c877586da3178974a8a94577b6045a48377ff25 reverted and I'm back to >>>> normal (no more NFS hangs, no more VM stalls). >>>> >>> Some printk debugging, seems to indicate that the problem >>> is that the entity 'ra->size - (index - start)' goes >>> negative, which then gets cast to a very large unsigned >>> 'nr_to_read' when calling 'do_page_cache_ra'. Where the true >>> bug is still eludes me, though. >> >> Thanks for the report, bisection and debugging! I think I see what's going >> on. read_pages() can go and reduce ra->size when ->readahead() callback >> failed to read all folios prepared for reading and apparently that's what >> happens with NFS and what can lead to negative argument to >> do_page_cache_ra(). Now at this point I'm of the opinion that updating >> ra->size / ra->async_size does more harm than good (because those values >> show *desired* readahead to happen, not exact number of pages read), >> furthermore it is problematic because ra can be shared by multiple >> processes and so updates are inherently racy. If we indeed need to store >> number of read pages, we could do it through ractl which is call-site local >> and used for communication between readahead generic functions and callers. >> But I have to do some more history digging and code reading to understand >> what is using this logic in read_pages(). > > Hum, checking the history the update of ra->size has been added by Neil two > years ago in 9fd472af84ab ("mm: improve cleanup when ->readpages doesn't > process all pages"). Neil, the changelog seems as there was some real > motivation behind updating of ra->size in read_pages(). What was it? Now I > somewhat disagree with reducing ra->size in read_pages() because it seems > like a wrong place to do that and if we do need something like that, > readahead window sizing logic should rather be changed to take that into > account? But it all depends on what was the real rationale behind reducing > ra->size in read_pages()... > > Honza My (rather limited) understanding of the patch is that it was intended to read those pages that didn't get read because the allocation of a bigger folio failed, while not redoing what readpages already did; how it was actually going to accomplish that is still unclear to me, but I even don't even quite understand the comment... /* * If there were already pages in the page cache, then we may have * left some gaps. Let the regular readahead code take care of this * situation. */ the reason for an unchanged async_size is also beyond my understanding. /Anders