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 EF919C64EC7 for ; Wed, 1 Mar 2023 05:42:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 253366B0071; Wed, 1 Mar 2023 00:42:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1DAC86B0072; Wed, 1 Mar 2023 00:42:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 07B716B0073; Wed, 1 Mar 2023 00:42:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id E75886B0071 for ; Wed, 1 Mar 2023 00:42:35 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id B5B3AAB98A for ; Wed, 1 Mar 2023 05:42:35 +0000 (UTC) X-FDA: 80519234670.27.7A259B8 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf06.hostedemail.com (Postfix) with ESMTP id 1A2B9180011 for ; Wed, 1 Mar 2023 05:42:32 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=DywQDkHU; dmarc=none; spf=none (imf06.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1677649353; 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=v2VBdt3kHKVqHXSdicN5o2cil7i5B6UknsXaVF5uIhU=; b=6sqtyn+g0uylLag1VVk8gboQsRau8B+E1t3CNHsiCjM0rYphV4HT+6lg7aUIBs/GeHH/xO GifdMUbZzLbxtsSEtiBoIOUk0Qu05Tu2p7WkFBb53qbUQUWKtDv51kD9MTQZXEjIzP3QkE E27dG/TvZN0JreZ7nhDXNHtpONK2XoE= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=DywQDkHU; dmarc=none; spf=none (imf06.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677649353; a=rsa-sha256; cv=none; b=u9zaPskwxoOzVWKs6d/rtAfvBg5dk1IVyqCd+udssWEnlEM+1Rdc7cdXllmei8YWV9CrLS UoIk6tZiDD8p2X7lhyH2v1e7pVT2NCyjvOyRxnNQpwkgFWBQ75hGMvp+aCMGBgTU1A76Zc UgZ0Sa3OXxKGNIzS4fgA4avQlkbLRW8= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=v2VBdt3kHKVqHXSdicN5o2cil7i5B6UknsXaVF5uIhU=; b=DywQDkHUM4ppZeg43fbbwjP2M2 /oZO+6xgBiP8hwhJbgWiTP69FQRD4/TRYreUdNCf3f3ItX6aQ6ooZyRGSKDJtl2hi5PQQX4aIklSg kkxhaosMgcf/f6Edwdrw1DDqkninZ/HzXgIXFhn/IsHGBU/TBcbzb2xHGu9Ge9dvTSbOdP41aX/Sh NIew+5py+V0Pp6iglRuW2MOGodiC7wk4PmF/ZPgOsEUOKjaPdnWOi84FNtU1EKrNdgUVc3JCRjj5s /u6r9TIoXEQj3dEuOpitvrS7BGqiK8TJuB/+BKvrrHw8PmEb8VEyY72snQpJ4SwUWiQcPA/Z8Hxe1 m4zgbPmg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pXFEK-001Ph8-Mb; Wed, 01 Mar 2023 05:42:20 +0000 Date: Wed, 1 Mar 2023 05:42:20 +0000 From: Matthew Wilcox To: Gao Xiang Cc: Theodore Ts'o , lsf-pc@lists.linux-foundation.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-block@vger.kernel.org Subject: Re: [LSF/MM/BPF TOPIC] Cloud storage optimizations Message-ID: References: <49b6d3de-e5c7-73fc-fa43-5c068426619b@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <49b6d3de-e5c7-73fc-fa43-5c068426619b@linux.alibaba.com> X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 1A2B9180011 X-Stat-Signature: xzuexfdzyy3jh84ygq473mqonoiureo9 X-HE-Tag: 1677649352-760898 X-HE-Meta: U2FsdGVkX1/GwZDl5Hyh6QOLpCPMC8/MRNt9oB6gk2ITOeAKSzuEQt4G79iz19gDA6ioHBMFNyzGWMOhpQYXZy5G2LKapevOUwojdFoe2x4lZdXtE+aJOtes2F7xOeG/hS7fH/1ZBBhX9LBsonQEiQtD3C/EIwsUHRDOQl0RhSBHqd+ZhOW5NzrOIOeSeb6NOLeT+Of8ZyUWd0q+dinq6+bQODKV1fHHZOHJq2/mAH6LBNuvQe+eNaMA7l0nT1gir9jQ3/hm12BnrDMXlP5sb7jQc+nRnTT30vp5jvUOTmBsIxzkiLYF6+JboBjn38Bfcb7n1qmE3kbJ/tnqdqiJBn31RtEQO6beLZ2ehDw/bvAQGdpWtPw9DsYsbE1aMgJ1vXEvgWW0TAUY1NKwOgISjAiWcPJQ7poz9lhzePiON6/mQapaZMagFU8ACmZsrYuZvwmusHvF1n+xw3SJJYThtYMP3uR/iiorNfXSastHwHP8IEQe2mOGPKDOcCIEbE3w7aQygkW1TqqLxcCg2EwYtv6/hxaQjkys6Ut70oaxpSYpoeKuH0ru3e9O0H0PoME0ao7FHY4uES5W5dmA5Yfq8bNHlOMFhcJrRoCPBRje/x4zrijvfq2FrsmaGDESm+C2qpEZ7dh78b3qejb4woGvrZdXZBWjl/mnGYzdfRB6RAKJI1TbnQtVUnNonv88vr0ZPUHNp4AgUk0Om3+eQrL6GoqA61YetJ9lPW/Eh85l78Y5aIfUW1RCSQ+oGe19WO3nTPUYKoI55cPMuIt67VeLINW+CKt4e8qlrL6LCrKeGCMSmL1uTKKUSHv6hs3uDutgkYa0ea6zIVVlw/NMKsPq+voDnAD4QfJMLBumaYVYNXft2gPQweOnqklZT6RsBdkAfuPRSXAbNISYzeHbQCsINnb1FG8Ae/0PZ29Fgx+Y8NkXkgGdxaf6YnXqbsFD3QOVxdER+jWLAsxMII9vTUa +PiZEnLe 7VqTqdblsyCxl410IZtac6WnWF9qnr23tD8H01TY1kYKIPTUNMmQIt3MznCbtdX8f9g4iMAk4YaR3KSimAM+u4E2McjD1xEkSn0+y6NVpLdSDLTAt2heYZuCc/wB3STpacA05/krDEeXb8eoku8TosOe0JQ== 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: On Wed, Mar 01, 2023 at 01:09:34PM +0800, Gao Xiang wrote: > On 2023/3/1 13:01, Matthew Wilcox wrote: > > On Wed, Mar 01, 2023 at 12:49:10PM +0800, Gao Xiang wrote: > > > > The only problem is that the readahead code doesn't tell the filesystem > > > > whether the request is sync or async. This should be a simple matter > > > > of adding a new 'bool async' to the readahead_control and then setting > > > > REQ_RAHEAD based on that, rather than on whether the request came in > > > > through readahead() or read_folio() (eg see mpage_readahead()). > > > > > > Great! In addition to that, just (somewhat) off topic, if we have a > > > "bool async" now, I think it will immediately have some users (such as > > > EROFS), since we'd like to do post-processing (such as decompression) > > > immediately in the same context with sync readahead (due to missing > > > pages) and leave it to another kworker for async readahead (I think > > > it's almost same for decryption and verification). > > > > > > So "bool async" is quite useful on my side if it could be possible > > > passed to fs side. I'd like to raise my hands to have it. > > > > That's a really interesting use-case; thanks for bringing it up. > > > > Ideally, we'd have the waiting task do the > > decompression/decryption/verification for proper accounting of CPU. > > Unfortunately, if the folio isn't uptodate, the task doesn't even hold > > a reference to the folio while it waits, so there's no way to wake the > > task and let it know that it has work to do. At least not at the moment > > ... let me think about that a bit (and if you see a way to do it, feel > > free to propose it) > > Honestly, I'd like to take the folio lock until all post-processing is > done and make it uptodate and unlock so that only we need is to pass > locked-folios requests to kworkers for async way or sync handling in > the original context. > > If we unlocked these folios in advance without uptodate, which means > we have to lock it again (which could have more lock contention) and > need to have a way to trace I/Oed but not post-processed stuff in > addition to no I/Oed stuff. Right, look at how it's handled right now ... sys_read() ends up in filemap_get_pages() which (assuming no folio in cache) calls page_cache_sync_readahead(). That creates locked, !uptodate folios and asks the filesystem to fill them. Unless that completes incredibly quickly, filemap_get_pages() ends up in filemap_update_page() which calls folio_put_wait_locked(). If the filesystem BIO completion routine could identify if there was a task waiting and select one of them, it could wake up the waiter and pass it a description of what work it needed to do (with the folio still locked), rather than do the postprocessing itself and unlock the folio. But that all seems _very_ hard to do with 100% reliability. Note the comment in folio_wait_bit_common() which points out that the waiters bit may be set even when there are no waiters. The wake_up code doesn't seem to support this kind of thing (all waiters are non-exclusive, but only wake up one of them).