From patchwork Sun Nov 10 15:27:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13869945 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 E9333D12D44 for ; Sun, 10 Nov 2024 15:29:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 57FF46B00A6; Sun, 10 Nov 2024 10:29:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 52D7D6B00A8; Sun, 10 Nov 2024 10:29:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3A7C66B00AA; Sun, 10 Nov 2024 10:29:18 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 1BD9B6B00A6 for ; Sun, 10 Nov 2024 10:29:18 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id CE0BE1612F3 for ; Sun, 10 Nov 2024 15:29:17 +0000 (UTC) X-FDA: 82770567516.27.9FDE970 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) by imf19.hostedemail.com (Postfix) with ESMTP id B531A1A0012 for ; Sun, 10 Nov 2024 15:28:26 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=i8lWOvDm; dmarc=none; spf=pass (imf19.hostedemail.com: domain of axboe@kernel.dk designates 209.85.216.42 as permitted sender) smtp.mailfrom=axboe@kernel.dk ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731252470; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ATQlrsiKbF4ovWTP3SQYfEdawQE8siSIL4Gn+HYptZ0=; b=f9hAgkKDXq0+Irb7w5rSUhUscZFxlMGQJ2plIs4/ym5LjgN/VVINHSS3Goabu/F+9wDPqs t2QgPt1vfquKw7wVoGLneO5lBx5Rk2O4FGG1U4aZPDxTv+xvt5itYT2mZSPoA0nBToEyk8 Jw7CgDLh51sYLVgl80g+4istCBPE5O8= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=i8lWOvDm; dmarc=none; spf=pass (imf19.hostedemail.com: domain of axboe@kernel.dk designates 209.85.216.42 as permitted sender) smtp.mailfrom=axboe@kernel.dk ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731252470; a=rsa-sha256; cv=none; b=1Op7TdW4lmrCjVzUHYuf9GwjVGSVpdPE8EiHbO22acCbs5yujCUG+zO1O2hbOEto5G76nf FPeaak/bzKiJ+zc2vPTQvtpOgbiyTC48t9r/MEeT7kL6QMDYhkG/r8tGtvMqMZAwPN6Z1e 5g5lZaYIa0dTgw6ChNsx9UXrceQ2q5I= Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-2e9b4a4182dso1473329a91.0 for ; Sun, 10 Nov 2024 07:29:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1731252554; x=1731857354; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ATQlrsiKbF4ovWTP3SQYfEdawQE8siSIL4Gn+HYptZ0=; b=i8lWOvDmeJDyWbmxFn0i/dOiwKU/jDD5ELlGL+eV5qgWd9k4AZgBBhcJe9UBXqhkLD 7Gbpn/FlkbpVKoJ5hunLVTwrlKYpb9HY3ufGDaeegHoZ8RIi//jeqh/xhKxVmp5CGOcF dX/MJ1xYMLFizwISbvy1dG6JoPDk32OrUUyM1ozcttN1KMezBs+kZfFNcMiQ0d3s3eVD eTO/+oMxAL7ug0I0StECStKLiKiG+EUDv8coV3G8WyrT6UCC92jjsSZhGDGiVza7AXyP DlFEMeIr9MjxrG0Z4K9TISYlsp55kke/hmqhW5WgEyxhVH5ZrasnaGrhTmzju/WLreuI 7Kbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731252554; x=1731857354; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ATQlrsiKbF4ovWTP3SQYfEdawQE8siSIL4Gn+HYptZ0=; b=mIVTBi/hV+M3khgWjZ7DIfJ38ypdLd4aMbuyGE5Vo1sgRA0rRfYGJ5BYj8THYQp99/ b8l84uOjWyDsykeRM5U7sTJ5YnEraXdTRPTyeIAoWF/Qxl4K4duerOX9fBaXE5GwVPfm qtP1nUzM+zUQa6jiN8LIKedZBjAgaSp/1svFLjOnAYSFuexpR7S3VQCki3CXdyfyDTo9 oDYzHK+d41iYuP8b2sSAlSSo4F/y8w0GJ/+C8MeMgFjGuw7XmsYAJoFBY6UbVC0OFIEF VslCMoDxexFupPynZ2OILde5ca8jEcWgc+b+b5+begdN+5XN24zfG05KehLKaWnG60HV hu5A== X-Gm-Message-State: AOJu0YzTgKRcGdmfQ8znV48i/YMDyebRQjvKsUqCbGlv7qJBCO+KCzwq U82XgmqWxhlpMdnsCJK4b1yfEI5qqXyxQxWxfeE+fWSfxmhK9gO5LOfrEDLBtpVpo03CNVbAXWB Sk0o= X-Google-Smtp-Source: AGHT+IHudq5kHes2nSMTtH3m+uxQGkBDk1+1Ad9rVBdouFER/SNEbqW3PARIVnuSTIfSKRPsHGRgYA== X-Received: by 2002:a17:90b:388d:b0:2e2:b94c:d6a2 with SMTP id 98e67ed59e1d1-2e9b1e13166mr14624611a91.0.1731252554158; Sun, 10 Nov 2024 07:29:14 -0800 (PST) Received: from localhost.localdomain ([198.8.77.157]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e99a5f935dsm9940973a91.35.2024.11.10.07.29.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Nov 2024 07:29:13 -0800 (PST) From: Jens Axboe To: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Cc: hannes@cmpxchg.org, clm@meta.com, linux-kernel@vger.kernel.org, willy@infradead.org, Jens Axboe Subject: [PATCH 01/15] mm/filemap: change filemap_create_folio() to take a struct kiocb Date: Sun, 10 Nov 2024 08:27:53 -0700 Message-ID: <20241110152906.1747545-2-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241110152906.1747545-1-axboe@kernel.dk> References: <20241110152906.1747545-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: B531A1A0012 X-Stat-Signature: jfah9tksetmie9w3r168xbadwop3cyn3 X-HE-Tag: 1731252506-267903 X-HE-Meta: U2FsdGVkX1+phvItYeTNhzHspxI+eTWffMQhOhpZ87DqjXkcYgwsI51/W7cyl9rJIzv9MDfcJrJ9SqGuy9ts70HLxI8mXJPsZWYLh9a6za/WsIxECx38ODjcsVqYtmLXTXbjIwrz1sscBF0c4NYyJFXB1nkCh9FhIOSKKPCfKj6GPWtMn3IxBS4qcdPHuV+51f5tJJEHNjwHnfMTdZpszn2n2mU8a5WgImfZqreKPcd0CqGzoL6OymYg6qPVn8OTvdFnZkCIuY3vISSE1djfNZxE6kmd4unmtfdjDaBFz/nv8elsm8dJXwR6guCvwgBWo9dhZQVGcO5asr5nMTyNxjDnmLOVgIKK+t7YIjBMfs3sIcZhIhRoa3rh9tSLKj6fTsUw6v2nxTCMcNv8SB+DbrrA36D+5auqD9m/cIe//xxuG/FXbrIENZYQNNy/vgfPmNFJTm865eQar2/z6eqJSo+/S0Msm2NO0f8JKDfOG/4BYiUG8qEaIJXzwyhPK4+ikARJylBxaunjfO0wNBNGEDN9GLITSSkHDy73Q/PCKLyD8mfk3eCfsSpADegmkFXtnHtenhrGT3X4GRstPb7pKjs/1vuArsWBiiggndk0SxeR2gnUtFQsiLwh/vxRhSWEoZbXJEevMheRi/L7aMXSR1mldy2hYlLkyWWCCOiVbtLYiV2mkEwoSpS4wqOzIR4yU0uSyhilYkPNOrQ/X2fnQuWryYFfIG974HR/PhfHktAfnQ516TJaJ7+qDp0oNH7mgYFpJpUfS6qzHATjxHCxEJG0dlNmNyluCIzBdy41DZoi0B+I8VDbtZhA+73wi0SkcI9WF71EAsYI3krjeedd4Kk3gPRubdBvDoX/PuqHbUuoKygg7GoLbBII1fUUURKNNfshuM/kzWTCW2o3mER/tQYlBP7UU/jdNhivtc/x+R36Mlbq0aspoER1j2IVpX7tjyACyn4GfuZr0YS2MmF eUyk0egV 3a/kqfvzDkS4/kcX3Et50n5rHb/kOWHJaEBg9DkSGlr0jDC8xz58KV9puFxnD6qwwU75AqsO8cVhkTxYNbJ77Ud04B95xFtSkpHgARCguo1+RTOcioVYmsRCIlA6Bn9WVy3eoLO5v+2wX7LrLAnzl7LIFWtk3koBWKpc0Fvfmdp+ssCRtth/qxtJOrTltLm/WKTWxirjuuB1Y77c/gzqagd06jFwH8bkGJ2vGyt21sjhWNkze4nTa+yamG5hcSpw6Vwr8aoTAY2tafWdIIijkpjj6wS1rSY3Gbx6lecQVeusqThssbUN3EGWYmyY0xEyn0d5TEOTni1YZdlJORxrLce/Kc5VauhXVvbet 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: Rather than pass in both the file and position directly from the kiocb, just take a struct kiocb instead. While doing so, move the ki_flags checking into filemap_create_folio() as well. In preparation for actually needing the kiocb in the function. No functional changes in this patch. Signed-off-by: Jens Axboe --- mm/filemap.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 36d22968be9a..0b187938b999 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2460,15 +2460,17 @@ static int filemap_update_page(struct kiocb *iocb, return error; } -static int filemap_create_folio(struct file *file, - struct address_space *mapping, loff_t pos, - struct folio_batch *fbatch) +static int filemap_create_folio(struct kiocb *iocb, + struct address_space *mapping, struct folio_batch *fbatch) { struct folio *folio; int error; unsigned int min_order = mapping_min_folio_order(mapping); pgoff_t index; + if (iocb->ki_flags & (IOCB_NOWAIT | IOCB_WAITQ)) + return -EAGAIN; + folio = filemap_alloc_folio(mapping_gfp_mask(mapping), min_order); if (!folio) return -ENOMEM; @@ -2487,7 +2489,7 @@ static int filemap_create_folio(struct file *file, * well to keep locking rules simple. */ filemap_invalidate_lock_shared(mapping); - index = (pos >> (PAGE_SHIFT + min_order)) << min_order; + index = (iocb->ki_pos >> (PAGE_SHIFT + min_order)) << min_order; error = filemap_add_folio(mapping, folio, index, mapping_gfp_constraint(mapping, GFP_KERNEL)); if (error == -EEXIST) @@ -2495,7 +2497,8 @@ static int filemap_create_folio(struct file *file, if (error) goto error; - error = filemap_read_folio(file, mapping->a_ops->read_folio, folio); + error = filemap_read_folio(iocb->ki_filp, mapping->a_ops->read_folio, + folio); if (error) goto error; @@ -2551,9 +2554,7 @@ static int filemap_get_pages(struct kiocb *iocb, size_t count, filemap_get_read_batch(mapping, index, last_index - 1, fbatch); } if (!folio_batch_count(fbatch)) { - if (iocb->ki_flags & (IOCB_NOWAIT | IOCB_WAITQ)) - return -EAGAIN; - err = filemap_create_folio(filp, mapping, iocb->ki_pos, fbatch); + err = filemap_create_folio(iocb, mapping, fbatch); if (err == AOP_TRUNCATED_PAGE) goto retry; return err; From patchwork Sun Nov 10 15:27:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13869946 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 B7F47D12D46 for ; Sun, 10 Nov 2024 15:29:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BC1A76B00A8; Sun, 10 Nov 2024 10:29:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B6FDC6B00AA; Sun, 10 Nov 2024 10:29:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9EAEB6B00AD; Sun, 10 Nov 2024 10:29:19 -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 7687F6B00A8 for ; Sun, 10 Nov 2024 10:29:19 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 284491A06E8 for ; Sun, 10 Nov 2024 15:29:19 +0000 (UTC) X-FDA: 82770568062.24.B362CEC Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) by imf10.hostedemail.com (Postfix) with ESMTP id D103DC0007 for ; Sun, 10 Nov 2024 15:28:59 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=tlg6fRa+; dmarc=none; spf=pass (imf10.hostedemail.com: domain of axboe@kernel.dk designates 209.85.216.41 as permitted sender) smtp.mailfrom=axboe@kernel.dk ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731252384; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=G7YIma1TSdS4GVKncfhre22V8DGIHalzmKUoqzgwI0E=; b=cwcoquyhmC8hRcZ2MEDYvCcr077WktxPG6VjMIeiZz2jagh7Oi1MBwPtFyVVgmbmcj2AAw jlVnp8K6nV4Lsu1bHYsGCZK+LIbrZpJcQONDig2heVmA+pCwdJXI90CIKJXtFFnny+Hmr0 hZ0Z/zpMbcGafAMNpZ9TOmSXaIzZ7L8= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=tlg6fRa+; dmarc=none; spf=pass (imf10.hostedemail.com: domain of axboe@kernel.dk designates 209.85.216.41 as permitted sender) smtp.mailfrom=axboe@kernel.dk ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731252384; a=rsa-sha256; cv=none; b=u/BP0Hyz96nWPGoOQzST33uwrzS8PIN+IpFQjmwWgmDhbT5k/PublShnIQp4FY6dNIM4jO skXxmOUPMp5qDUkx5GTazgAzlDn7woZMCYD6ht/MHmAAeR1Ue9V1FMDpJTs90crrrXT/Rn QO1Ojc3mm+sWsJr+E0SJiESRdj8TfF8= Received: by mail-pj1-f41.google.com with SMTP id 98e67ed59e1d1-2e2eb9dde40so3037418a91.0 for ; Sun, 10 Nov 2024 07:29:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1731252556; x=1731857356; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=G7YIma1TSdS4GVKncfhre22V8DGIHalzmKUoqzgwI0E=; b=tlg6fRa+hyotEfuZLS3oHTJP+dtcdvMOJyzbCqXiposHH99LRCHgu0LNoAdHkhGd2c S/Rofx8iGPBzA/RH7G8blVjATUPi6AqLXSGmAZUyNJt0v24ncUMTg7HjVCxQUyo3pTv0 ThEAmNXwsrMHAv463a+NsZeg84xd/XxGe70YpoHLcspcABI/cuLvpMHt4QrEnzoiTsVJ EJ0cIldIojL3SLMLZ6qHXKugmcvnZmQGM0zChem5x/kMf+EtM41DKkFn7J3MHpxfkGhf 21mCTMTb2pFhpQ9GTLHbwKcfE+czhcBXAdPbUUTAFVJLOMhZZAy5jA/kmt/uoJxQ0mto 8sSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731252556; x=1731857356; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=G7YIma1TSdS4GVKncfhre22V8DGIHalzmKUoqzgwI0E=; b=b80SPF0sClWpO+gFAWMxys+ccTa1t0qNnNxcX8PBRtW/zEf9+v911c7AWCBnTUXFJ7 vgcjQPaMjYS9ZugDKyYVP6KadTpDFru3ebfQqpM3UV0S25cK352JnSGOLXqSpi+GKIte jVACQ1c2q0uRNDh5anQ8fyeqf/WL+J1kBfvorp9xDoGb/bWyhH/d9+ezU5hH8KdQntk+ Ll8cEkr1RauLU1kq5TIRma2ghjIHg62kNNNONpKTffl4fdx3tq0J7pUNWeaHCqS9+Tx5 WtGQiivx7GsEtS0kL8CyXkHocZaEnt7VRNZrj236rBCuURbJWZEDh8Scqzx6qiM/lr47 0Y6Q== X-Gm-Message-State: AOJu0Ywv54q7mA8V68MoxDfNuahE64ZJTGdQuInr3oIC/KCyR8Duov83 0Zm/pDTd77DWiriKs738hCCAVzHiBIO5hpxk0TH9iXmN9/fDia8zSyiW4memwXDA8UNeaI7AEGA IYQc= X-Google-Smtp-Source: AGHT+IGMsIWblwQtQWO8JcRHCLRTN0pIGof64EqqksTz4TFFvZ2UD/wQcBuuSf4CK9eKe+atZiR/kw== X-Received: by 2002:a17:90b:4acb:b0:2e2:be64:488f with SMTP id 98e67ed59e1d1-2e9b1655945mr13617134a91.6.1731252555726; Sun, 10 Nov 2024 07:29:15 -0800 (PST) Received: from localhost.localdomain ([198.8.77.157]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e99a5f935dsm9940973a91.35.2024.11.10.07.29.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Nov 2024 07:29:14 -0800 (PST) From: Jens Axboe To: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Cc: hannes@cmpxchg.org, clm@meta.com, linux-kernel@vger.kernel.org, willy@infradead.org, Jens Axboe Subject: [PATCH 02/15] mm/readahead: add folio allocation helper Date: Sun, 10 Nov 2024 08:27:54 -0700 Message-ID: <20241110152906.1747545-3-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241110152906.1747545-1-axboe@kernel.dk> References: <20241110152906.1747545-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: D103DC0007 X-Stat-Signature: wgtzufczwhpdhjgaezd3fxzcsrodgco9 X-Rspam-User: X-HE-Tag: 1731252539-790440 X-HE-Meta: U2FsdGVkX1+spjhJnOckx/PmG5izCeaHuvk2O/KXz2Z3tiPIlk5DL9sdLAwUYayN5SljQ64/ExRD4YgefZW6pbONCF+u9bh9Jabfdyc8CWakf3bFHiQfGe805JsKi7/++Dt92ZpHZHkXVocG3QhudB55qXecV6uOmMzuN4PA6gOPGGMv+1GKNtMM2ojAa6G4asCN+QF/A6MeJC2MaH9Jz0tvxONlLvvnZaMCRhjW87uu7rctD4nNNjiAeDxG40RD1vG2kovkPsthzKYwK+Vj4dVe+vjLS371oRKBk2SQPg/FBQXDTSlB+yLKRs0FDnf5J5xUWh7M0tzhRimVEu3Rm/cdGuSQt/dYjtUtk6//w1GOJFZGmr0UFwulUL0TFg5XMYhVMbmuqa0bRWt7GCW1WjqM3J34Yuf9IsGAlN4NuTQ2I611zVaqFuX8TfsX9CG/EXVk2jwSutH6k7QhUmASd20WpmywfyM/YGOLnWtHyg2ZKLM+0/iqTpu0QL/D+fbMHryZXqvN46lUK4zy7BjBIPUtIA++t04Tkd7USSLBAh8BSA2Cj+l29OGa7ZzlUhcuRuPqRytSpy6IzL+Fs6aJht8ygWtMpB2hUyQm7unQpCX++oErDXFIQhJugawyDmadZhRaaOaHbdLx3VDdKijmSoLb7tS5qqIFQ0vQgsc7iE0vv5qTRn2wmNR9Ie+8S+/DlavKZOO5B+F9pYZ3ofFarrCKtlPX+cgT7flr7pfHmiB+2DX5u0CZ7l84p+flxWsEC/tWmyrz4VqcmIBA14usT8jrwxQnkSQpmqfPzKFMk0PKUurbNDRntsEw2psgZmIo7RdJDXVR0jrnNAoBbLAPiHnDCS+IienPTbYHf34U7Rjf201nyG0eBvgk+Z4SSw1O0fC5SVV5J0ouxBwFF40LCE/VlQQ0euZ1oAcj7VFS7RqWntRDsk/dkFDuf/6TFEq5Z1yZIK5S2J7cIyMgb0s evlfOiKX uwf1pfJlWdilGgTmbv70DwNEn5+yJ3Z/oWpTeKLyG8U2M9R7hxZqMn1pm+Zi6tCbOO1UPcupQ7M+QbQq5jBZQBOx9C3hrVEtYtb0vAAoF1IkyCjKdGyjeOhMcblcSMrw7N1+60IzhrBPbEEx56gv2MUirac1JOE201E5FvxK07kziMbqsMKm2KkK344nKm9T3W1oWw5IVMN2Fvr7rGXGGxCY/ZeT5YO9VrdDzEJqFR1WzLP54zkg4EQgzif16cdP9GfBTB2U6MUoWIzBI4oKfHJ67iDTHWccYHh0A2MUrn5Pqvbg= 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: Just a wrapper around filemap_alloc_folio() for now, but add it in preparation for modifying the folio based on the 'ractl' being passed in. No functional changes in this patch. Signed-off-by: Jens Axboe --- mm/readahead.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/mm/readahead.c b/mm/readahead.c index 3dc6c7a128dd..003cfe79880d 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -188,6 +188,12 @@ static void read_pages(struct readahead_control *rac) BUG_ON(readahead_count(rac)); } +static struct folio *ractl_alloc_folio(struct readahead_control *ractl, + gfp_t gfp_mask, unsigned int order) +{ + return filemap_alloc_folio(gfp_mask, order); +} + /** * page_cache_ra_unbounded - Start unchecked readahead. * @ractl: Readahead control. @@ -260,8 +266,8 @@ void page_cache_ra_unbounded(struct readahead_control *ractl, continue; } - folio = filemap_alloc_folio(gfp_mask, - mapping_min_folio_order(mapping)); + folio = ractl_alloc_folio(ractl, gfp_mask, + mapping_min_folio_order(mapping)); if (!folio) break; @@ -431,7 +437,7 @@ static inline int ra_alloc_folio(struct readahead_control *ractl, pgoff_t index, pgoff_t mark, unsigned int order, gfp_t gfp) { int err; - struct folio *folio = filemap_alloc_folio(gfp, order); + struct folio *folio = ractl_alloc_folio(ractl, gfp, order); if (!folio) return -ENOMEM; @@ -753,7 +759,7 @@ void readahead_expand(struct readahead_control *ractl, if (folio && !xa_is_value(folio)) return; /* Folio apparently present */ - folio = filemap_alloc_folio(gfp_mask, min_order); + folio = ractl_alloc_folio(ractl, gfp_mask, min_order); if (!folio) return; @@ -782,7 +788,7 @@ void readahead_expand(struct readahead_control *ractl, if (folio && !xa_is_value(folio)) return; /* Folio apparently present */ - folio = filemap_alloc_folio(gfp_mask, min_order); + folio = ractl_alloc_folio(ractl, gfp_mask, min_order); if (!folio) return; From patchwork Sun Nov 10 15:27:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13869947 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 4E0D0D12D44 for ; Sun, 10 Nov 2024 15:29:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ECD7F6B00AD; Sun, 10 Nov 2024 10:29:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E55376B00AF; Sun, 10 Nov 2024 10:29:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D201A6B00B1; Sun, 10 Nov 2024 10:29:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id ABDE66B00AD for ; Sun, 10 Nov 2024 10:29:21 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 3E548120E1C for ; Sun, 10 Nov 2024 15:29:21 +0000 (UTC) X-FDA: 82770568524.16.BE1375F Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) by imf19.hostedemail.com (Postfix) with ESMTP id 18F4E1A0009 for ; Sun, 10 Nov 2024 15:28:29 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b="M//905Wp"; dmarc=none; spf=pass (imf19.hostedemail.com: domain of axboe@kernel.dk designates 209.85.216.45 as permitted sender) smtp.mailfrom=axboe@kernel.dk ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731252432; a=rsa-sha256; cv=none; b=Mr5IFTIR7i9U1OEJeclnED6BsDFTzP5rNZnXQLRFzyKYj0HZawFDwCjhn/+y8rZbkNZ1Og yNBooBeADC2LlfUr8cgzg23jdmwzWqYEtxhbzfe3rVS3ihWpTaT9vhFT7w7+Yej7IIG+0A hDuXppyJMfW/h4SXVWlylPcAKZBHPgE= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b="M//905Wp"; dmarc=none; spf=pass (imf19.hostedemail.com: domain of axboe@kernel.dk designates 209.85.216.45 as permitted sender) smtp.mailfrom=axboe@kernel.dk ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731252432; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=9QDQ8u+XOjRX6rdX1KxWEpFxXqQ9HPCp5iTXnKjwIis=; b=mdTZl0ylC1l3+vHodDfgeKcu3te+R1dYbdHIXpEo8b7V/hbQvbpp6WGTj7u00vVH7/yP59 9W1OMztg+9iyRVZmwWvUOYGbTgR8YIbpAp03yj8P7365D/CkeGfspag/6WlnrCrccFq45U sD1BjdTu+5IRHQCd/hRX5lQ1QTC7E6E= Received: by mail-pj1-f45.google.com with SMTP id 98e67ed59e1d1-2e2ad9825a7so2840089a91.0 for ; Sun, 10 Nov 2024 07:29:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1731252558; x=1731857358; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9QDQ8u+XOjRX6rdX1KxWEpFxXqQ9HPCp5iTXnKjwIis=; b=M//905WpMXS9pXY71xZpvYJVnn4dIHuxdp7gYZCmuQqTP1DpxfowHLl7pgXd0orQoI PMFVIdZxxOygVw4XIyygouoHWXTb3gAImv+aF2ehykwJYoHwynFB668Z/HGSYOJJEAZc deCcxWBYLPTSo1n3ovSQjGDlO4+nBcwtEqEj53VEyEdiRAwFL0cQAzdxbRNkdt22B6+V 4Tx3v1mVMPZGXdWva8S3YprD+RAI3FHYOKFxNN2mmCjVYfrVpMpX9KTeYUI8EK/dvgUJ 4mtZoS0rSJy3eTzWIBvMwCz+gdLs+TBn9qu6A9UdJrrMQFei/2hf6sidXYAPdlazua1G GEWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731252558; x=1731857358; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9QDQ8u+XOjRX6rdX1KxWEpFxXqQ9HPCp5iTXnKjwIis=; b=apbK9Tn1TloGoJ1a1USpgfId9h+A8K969izpJ/l8Lf4p6g6J0WTdBq0zjd5VMIgPN2 k2ewZmOB90qgVLoP7uV3ulgNfEz99pStfmUF6/6jMAOxJq2DIFTpmREg+GLMsWEyEwi5 FAxPlEtJ9L69maQMxkhdj28Ulru6D3HXoRx1En3QODEfqNBGGcSFuLAdZC8vSrPBigQ8 RdRZZmbOl/v7XdmvDBdjgZlK0og+3LlktnlIUIQBQtEzg3/+rljLi5u3p/AqWuWDFYNx xhjaOxAUOfcmYtEIVZDcolmRP89LBid47X4BBPf69HuzYU0KHp5RhdrUc8yQYnZnoIli LNhw== X-Gm-Message-State: AOJu0YyR9soMlpB9MzzKt+d2oTyRM8FeZ3VwhIVN1gyERE8iVhBsYL+g 65F8VEYW4oXxk3UyaTk4Vhjs6IMeoGiYPZ1AXGIP++Uphy4c/rPb1CjL2IGzsQGK+oN5fI/3+vp LX8M= X-Google-Smtp-Source: AGHT+IEK+RdpBHKlpp5v8yHzxXuRsIFP9YbjrZgEGVdARDnq+2H6kYv6T3B7kfQSRNLPJFM3Uvu8sw== X-Received: by 2002:a17:90b:35cf:b0:2e9:48d0:3b59 with SMTP id 98e67ed59e1d1-2e9b16eb007mr12818842a91.8.1731252557781; Sun, 10 Nov 2024 07:29:17 -0800 (PST) Received: from localhost.localdomain ([198.8.77.157]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e99a5f935dsm9940973a91.35.2024.11.10.07.29.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Nov 2024 07:29:16 -0800 (PST) From: Jens Axboe To: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Cc: hannes@cmpxchg.org, clm@meta.com, linux-kernel@vger.kernel.org, willy@infradead.org, Jens Axboe Subject: [PATCH 03/15] mm: add PG_uncached page flag Date: Sun, 10 Nov 2024 08:27:55 -0700 Message-ID: <20241110152906.1747545-4-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241110152906.1747545-1-axboe@kernel.dk> References: <20241110152906.1747545-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspamd-Queue-Id: 18F4E1A0009 X-Stat-Signature: 9pq4e5froa85s9gtoxey6uqsj8heztns X-Rspam-User: X-Rspamd-Server: rspam05 X-HE-Tag: 1731252509-165674 X-HE-Meta: U2FsdGVkX18zLuE4PeeGVMmscyIjM3c0tIjS2iS8tA4/Y4Kk8FcGh1ayxt4XC4OF7emjElDodvZgKloI3o7cNhbIotMIPUcI1cIj0m/6JnkudvocQXyBQCDDQqIWp6sS8oNGTavYAIlZpapp8OoM35ZYy0HRlHmgagCNZNlTAyIOMSmaziv4svSX+EfL9U7PXqaV0t2gr20pZZc8B342yFN4X9jQdayKTK1q8D7pR9vNV2MEcMF3ywgJ9BpSRsBc8djKjqR1MY1+3rhSBU3QLcuor4CmhpIgnhAMIykHgQz51m85f0ci4xaQeo0iAremgIU3KotHHc+KAbap9Vg9qkJ8WXqqAw5sDFahRwVaoupx+Ca5zO0LHK9oedwmXKDzEK3GGSOKxYfZqjldd6W0gL0LoQkhH5oXoM4IxeR/rmhdbxeBBHdOoc64rwFleTl5+3V8jjDxGrguESulRuIYubZPU7T5Xq0hej/2TC1vZl07jQfY6mammnezb7JxnNQNrvuX5uxB4/6EF1X3/E8UIwfGjXIWTyBV9ZrkyI5EUj0tUJU7QroFBx3C7k0/2w+Fa9NwRkxbGgS6Y00pGihCr3jai3GHz9RBQpHRFXHTs62B9UUX0w0IQPvOGXYCfUBanfk+DxQ0GskZSNjSUggufGavBxWmYyvWwGRfFhgJ9MXsxIcCoS/XTn2qeSINaiuQRRzuK7yUOBPV8HwB7DW/xzsX8lHIiZ9GjlZm8Ug24vczftNJqw2MT18rOryrLT36Qs8hH0Q+b7svr4KNnGvhDvn6SHSrByzDhImQD/d/n/bA+3lJMFUQXIRMbzjtpVMU7ppeCZLVVdFqaWxF7lShUL34jUTODNPZgRs0qi0uFWsK3etTvMtRIwgnPI35SjcPO5L6e1z5AcBSD8rw1j/G3SDMfdKbaXrQNEbvJb9CNYpjCCIUiN1QvWojqsBJxtU94a8gfnTey4TIs+m4IkU 9Q6aut3/ S4p3iJxvOvy8prFZVowuapWw6oUMyyKzcGp90K/hk9QIKEm7D37Hf1B7XRzWOWSwX1C8FfLRS95q34iuuNn0iLIFHfjLr9JtOtt5BIDInDVSTOeyh6Hmza6V8MtZB4Xa4QJ3z3KzY/xmWrIg9ST9M+HDtRtDJ7VAbfksCs0sfUsoQY6mm98+MvOihcTm0MjNjXT1Wwd2GoT8/lCyqxlKdMOMq9dbm7T0Sra/0UJS9QX7vOOxpO7o+IxnTWxVJYAUKxv2hrZazaZNlEWry1QHax2BYO74w9YRwfBWhWq09scaA0yMEFvAdWVtne36vpKL15c1D7YdUMvuK0vzTrWmAm8iwJBbvl1qHqWBY 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: Add a page flag that file IO can use to indicate that the IO being done is uncached, as in it should not persist in the page cache after the IO has been completed. Signed-off-by: Jens Axboe --- include/linux/page-flags.h | 5 +++++ include/trace/events/mmflags.h | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index cc839e4365c1..3c4003495929 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -110,6 +110,7 @@ enum pageflags { PG_reclaim, /* To be reclaimed asap */ PG_swapbacked, /* Page is backed by RAM/swap */ PG_unevictable, /* Page is "unevictable" */ + PG_uncached, /* uncached read/write IO */ #ifdef CONFIG_MMU PG_mlocked, /* Page is vma mlocked */ #endif @@ -562,6 +563,10 @@ PAGEFLAG(Reclaim, reclaim, PF_NO_TAIL) FOLIO_FLAG(readahead, FOLIO_HEAD_PAGE) FOLIO_TEST_CLEAR_FLAG(readahead, FOLIO_HEAD_PAGE) +FOLIO_FLAG(uncached, FOLIO_HEAD_PAGE) + FOLIO_TEST_CLEAR_FLAG(uncached, FOLIO_HEAD_PAGE) + __FOLIO_SET_FLAG(uncached, FOLIO_HEAD_PAGE) + #ifdef CONFIG_HIGHMEM /* * Must use a macro here due to header dependency issues. page_zone() is not diff --git a/include/trace/events/mmflags.h b/include/trace/events/mmflags.h index bb8a59c6caa2..b60057284102 100644 --- a/include/trace/events/mmflags.h +++ b/include/trace/events/mmflags.h @@ -116,7 +116,8 @@ DEF_PAGEFLAG_NAME(head), \ DEF_PAGEFLAG_NAME(reclaim), \ DEF_PAGEFLAG_NAME(swapbacked), \ - DEF_PAGEFLAG_NAME(unevictable) \ + DEF_PAGEFLAG_NAME(unevictable), \ + DEF_PAGEFLAG_NAME(uncached) \ IF_HAVE_PG_MLOCK(mlocked) \ IF_HAVE_PG_HWPOISON(hwpoison) \ IF_HAVE_PG_IDLE(idle) \ From patchwork Sun Nov 10 15:27:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13869948 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 129BBD12D44 for ; Sun, 10 Nov 2024 15:29:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4E2636B00AF; Sun, 10 Nov 2024 10:29:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 493DA6B00B2; Sun, 10 Nov 2024 10:29:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2E5396B00B3; Sun, 10 Nov 2024 10:29:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 0B4056B00AF for ; Sun, 10 Nov 2024 10:29:23 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id B6BD1C0426 for ; Sun, 10 Nov 2024 15:29:22 +0000 (UTC) X-FDA: 82770568608.04.94C7047 Received: from mail-pg1-f179.google.com (mail-pg1-f179.google.com [209.85.215.179]) by imf28.hostedemail.com (Postfix) with ESMTP id C309FC0006 for ; Sun, 10 Nov 2024 15:28:40 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b="Sh/jkn19"; spf=pass (imf28.hostedemail.com: domain of axboe@kernel.dk designates 209.85.215.179 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731252420; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=jvfAlDie45/dO/q2Oa4nMUlSYRbUQddnQckYeJvFoiA=; b=8TKhBEozykjd5XmlwYr9i65jd4Shwg3isDOnZadSS+BfCqPbUxtmFholHsQ9ycmfLxdnqW sb03fLnQ3+yF+KyfR7ToaRO7/vjmDyhvo8l8S9OtHHgB0QcrdKk534zzq3edloVKpK7foN 17LSPKFsPV7GuQwQe+8l1QVdHzVf1xY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731252420; a=rsa-sha256; cv=none; b=tk53o1+FhiVfzgKBOvZEZW/st7qZvkkpXRKic2rc0U8KSm8VVtuwCkJHK2HUFl6OfEpnTt efXjSvcq7j2Xiz3QJ+POasql+cVqHYubfLH59lSIylp47luRu3sBrZgf+QbUDMYmRYx2GF zAzCkZewXVMK2oNRtgRpzheJJ1OVgrw= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b="Sh/jkn19"; spf=pass (imf28.hostedemail.com: domain of axboe@kernel.dk designates 209.85.215.179 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none Received: by mail-pg1-f179.google.com with SMTP id 41be03b00d2f7-7ea9739647bso2613479a12.0 for ; Sun, 10 Nov 2024 07:29:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1731252559; x=1731857359; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jvfAlDie45/dO/q2Oa4nMUlSYRbUQddnQckYeJvFoiA=; b=Sh/jkn19XHD9Jog3WwLAosYywGUw5yL2sShIEEsA6c9j+XxbqTk+3mwwB+cO3F92QI 60gUutz7T/Wx41A2eafzgpfDw3nmf/0qzSwH4YZxXpnHlwyYvlsrqN4ePCwlDqY06427 1iBz9V/Rx+H5xn5HjcWBy+jUytQ578QEw6q6xkv3QaDvGzL/JDHctz+zoppElQZounAK 6X+QAg1iYfdXvVSMdYHFnFkzJwZS7nZI9P7fYXamJrSvRHgkEejSngVeiDYSZ7LMKWqe F8syLrfm+4SGS/yYkCTpsVBOgSSCIrGK+sUGQIcE1VpCXiT3fu0rlQv9e2bo25vANqHe 9i7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731252559; x=1731857359; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jvfAlDie45/dO/q2Oa4nMUlSYRbUQddnQckYeJvFoiA=; b=YlLqc+lCWznJN9Q3RpTEKgfJTLOF0U4jfa1KZR8Na+qOd78zzIBCurj8UTzSifnEs5 WeSY+uSEBZu+Fx6MHSbNnIqU8ZkaX8dL080cJTcAJffZaNi5KNUQpCv7s7IsX0BwXLhi QCPZQv5ZObSa+MKuh9Mc3tLVvEcjN+t09CaGhdu6ZoCMxhL1pQcQw+RSOlBBmsn+/sLl Emsc7OBkV9NGIvyLB4NPr/L5u3byxEZeOaPW3+F4IzZn0DEqqPn+2Q3pXo7hi95RcOPA 9F4UTKhWMzvfAAWazYOmPNGJ49nhKjfeW4f0Qu9zlpdZmbZaw3j6I2JFMOX4aZKoOo2d YMRQ== X-Gm-Message-State: AOJu0YxZDBGaTVNJBEW6sgaxO2eIXnILpe3dn4Pe3kS5zC/WRYNrwQbU B7hSRoAJ/WWdCXFQB+7qIJuNI04zMACU/8gDk0Xt4njMB1sGHDzIOULILnhVSeJLruaBksIDDPQ ZFUI= X-Google-Smtp-Source: AGHT+IGu/u+FhGsz3wBr1Zsic2L7vJ+0uwzRrgnEJRvL3npe1QZdpxBowle6ldDc43UF6F8F8hYjFQ== X-Received: by 2002:a17:90b:2ecb:b0:2e5:5ab5:ba52 with SMTP id 98e67ed59e1d1-2e9b173f1ddmr13558707a91.20.1731252559257; Sun, 10 Nov 2024 07:29:19 -0800 (PST) Received: from localhost.localdomain ([198.8.77.157]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e99a5f935dsm9940973a91.35.2024.11.10.07.29.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Nov 2024 07:29:18 -0800 (PST) From: Jens Axboe To: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Cc: hannes@cmpxchg.org, clm@meta.com, linux-kernel@vger.kernel.org, willy@infradead.org, Jens Axboe Subject: [PATCH 04/15] mm/readahead: add readahead_control->uncached member Date: Sun, 10 Nov 2024 08:27:56 -0700 Message-ID: <20241110152906.1747545-5-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241110152906.1747545-1-axboe@kernel.dk> References: <20241110152906.1747545-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: C309FC0006 X-Stat-Signature: 49iqiaon96tnjhg8k6u9m8o1y86csdtf X-HE-Tag: 1731252520-405578 X-HE-Meta: U2FsdGVkX1+jP0p4T33qgCrYWYRNx4ZdDy9wowwG3KEw9UCWxnnOYNSHEFv+Ulpq2l5ryWzQWspv4DoFIAFZF4luOf8sVEmw+kAnoorAxqrEBXFmE8gc1JfU8dH4ei3woKoM/4y32EHpjXMkdujoUU6l26hUIwSSHhnAR30ee/LDKz9aUKFvGpB2uM+oyTApf7HqVEmWKJWXMaUDBuy2wYPcmyEpnLTeq9zqu5sUdMhqkvE4Cq3X773YUh+WSyTJdYPhV2cRA3YYqOyipnTEbP+UmnK/oaLVXkgdYnR5GmGobbD7uHMOiEbjD+Qk1H3okuwxYPnhGXG/TWPzKP2pglMSx4Cm4D6tppJlZ/RS+1XBLP2wgczo9tAAO7tEUJIU4b9ptRZPTJ+LAzjRA7/KkbM+GEVmO3N3EFBJ0ZH1jbwZwIQuNsoh5RDNCH/Ggufo4mIkakxlig8meI26gHfq39e4scN+uIqp+cc6cWPKXeX0dLfjI8xvKGNvsu7fAf+czmYNkzy2wkr82/9QJ+0fyl8TBsvqyr+uPKfxDhd/++UuDL/GJ37Ao+p3L3qED1BaM5HPKFKFYQYNk7o/qzOT3vFsHvaVsW7W/v35BizqOXhdHToUJskBZiclQexL2j0KulrzpYAFkzKOe7cOCa5yT47zrPeygJvqNrXXWMVXHYPgI2R2Q55jNqp6FM5K4kNThZdK0p5yAe5H6iCWecU/vvR4rO1IQ0jjjFFA3lF/mc3faKjYcmreIprSQEpum/oc69p3gpEkVPqJM9WaJrC6iyCiziF77YBcFF1PqQ4fggtwNAhydh15aA7nc0jUjh1YxnRE/+HzNo/L/wx8jBYHHo0Q9yOnHOOGBdJ+iZ2lmiglRQka9svzvoMcr+dMBJKGqZYCtf7141JSApHxx/k8VJnVN75ZgMgNpv/h8VXCulwba+fvGVgSyc2+JlThX0AhFR2HePRw/fcGBTJVQHR hXjEvjwy 70EBvPtcLsjMsBSmu/E55ic61Qg16BDz78eMB2AAR6NA5pFteD0Dct+3/RYUeQMiI2wLr9FkPYWwGypZZit4YYNgER9Xuq+RNWY56tkYQ/amOOZZzyhKw4633bIrvA7a6SmWCWByTNji4pj0k2ygWhll5YSjwmMVlI85tDU5JDgza48F4o1EtiHCz+8fI4WOR5+akNA/zcYpqCsjPPAX/0hEjITi0gYK+NvzatbfD4eZ93M08Xi281GPHgSAuXt1OIZfLlAw8FZP2m527yl2iaSDmfiAI8M41qWdUP/+oi/BNg49XOJAgBunxQQU0Q5xhRNg6VQOYApXOi1CEAFZoq57ktikaInF+96Ja 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: If ractl->uncached is set to true, then folios created are marked as uncached as well. Signed-off-by: Jens Axboe --- include/linux/pagemap.h | 1 + mm/readahead.c | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 68a5f1ff3301..8afacb7520d4 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -1350,6 +1350,7 @@ struct readahead_control { pgoff_t _index; unsigned int _nr_pages; unsigned int _batch_count; + bool uncached; bool _workingset; unsigned long _pflags; }; diff --git a/mm/readahead.c b/mm/readahead.c index 003cfe79880d..8dbeab9bc1f0 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -191,7 +191,13 @@ static void read_pages(struct readahead_control *rac) static struct folio *ractl_alloc_folio(struct readahead_control *ractl, gfp_t gfp_mask, unsigned int order) { - return filemap_alloc_folio(gfp_mask, order); + struct folio *folio; + + folio = filemap_alloc_folio(gfp_mask, order); + if (folio && ractl->uncached) + __folio_set_uncached(folio); + + return folio; } /** From patchwork Sun Nov 10 15:27:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13869949 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 9D0F6D12D44 for ; Sun, 10 Nov 2024 15:29:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B9CDD6B00B2; Sun, 10 Nov 2024 10:29:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B4ACB6B00B3; Sun, 10 Nov 2024 10:29:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9C34F6B00B4; Sun, 10 Nov 2024 10:29:24 -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 741FD6B00B2 for ; Sun, 10 Nov 2024 10:29:24 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 25841ACC2D for ; Sun, 10 Nov 2024 15:29:24 +0000 (UTC) X-FDA: 82770567264.09.23FF9BD Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) by imf14.hostedemail.com (Postfix) with ESMTP id 8A592100010 for ; Sun, 10 Nov 2024 15:28:38 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=o6D1cfUl; spf=pass (imf14.hostedemail.com: domain of axboe@kernel.dk designates 209.85.214.177 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731252332; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=uN7tjL2s/tmxM6CJqz4ta5HuqLPCPNJgi5Uvj68apZw=; b=eZsbIkiMvYsxJqJEP+pbHHY80pPktq6WrEEETPxsq2PwDerycUyjH8Dxp22iFA+YNUEung ErPlyJsYQDIc4j1TXn20rxEB23/u3qaOz5DtAxe3dKTNlmw3E7wu4j6NE2ksKyqLLk7oan kkXPNp6BAfrdES7xO6UrPFJgge/3UV8= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=o6D1cfUl; spf=pass (imf14.hostedemail.com: domain of axboe@kernel.dk designates 209.85.214.177 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731252332; a=rsa-sha256; cv=none; b=Tf9dFdSmS67OwoHSGiS+cnm1Rpba3zUojLtdy9vILTmqH6x+lBPmBg/0ao7kBwtthpmb2G 4QseLdfR5REwwcdhuOdThmevsXur0I9t13t/dTjUjRqBj6F4pYf/8zolrnTLZ1XMiYO9Z5 unWhi7uTuoF8pPIAIPn5NqUDvxyU/po= Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-20cceb8d8b4so24320035ad.1 for ; Sun, 10 Nov 2024 07:29:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1731252560; x=1731857360; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uN7tjL2s/tmxM6CJqz4ta5HuqLPCPNJgi5Uvj68apZw=; b=o6D1cfUl5NeoQBgYrIqzJBLvDWL2ILpeI72o3/vDASBiE6ina7KL9mxGGwlJwAcAbd H1w5xNP8QmSadTa+pKRoQ4zDhEJK0ncEdhX8v7f0iBjqGSHw2B3WVYAR2gp86TBoeGF/ Nt96cJEkuK9GjxNrxGzHYtWS5SLcHTJUv1CTKoX3n1v+LhEwUGEKme9lG/SeFll3Dq0M ozvX2Wfc11lFNn0Mr/0YTpR5U+8zSm+58HDXZfVs8w83gLrE224OYcVpEgPYKEUIEbRa x/q4OoMsst66SGE1wkMnCLgUMJoMbF1p7Rbjq0BLChuYmwA6asmHFXTNMWukGAA3e0Or R8Sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731252560; x=1731857360; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uN7tjL2s/tmxM6CJqz4ta5HuqLPCPNJgi5Uvj68apZw=; b=lSJ2dOyS/l0bsWXfh5mXZDKaZ+TMrA6BSca92NhXEwywh6CO0nIAyjsl1wwW04P6Jz Spxrm9ZISOUJ94BI21OHoxFflNl7+xUnfdY5OZ2JGo6iX2xR6yz3ld7lVxoUWzYFyDSm dAE+sAwG4q1wV0jJFGyykhTZiFnAbWDUvAECAT3e0Sxs4EQ+BLRPBzEe7SILn5Hyup+M jO2XrjDmUGp0K8C8kH1KGxPpvmcHLG7oaXNPEpm9zaAGoD/Vu2Tm4cBZdhbwQllG/WV5 yLl/BFTZBol7QLv2bsqtkihVL3ds3Dq7SNt03CjtwY5CraFgYr0APCJ70Wn9dyZN57Kw SOwg== X-Gm-Message-State: AOJu0Yx/E7ovX4EkoB0ymDkaQyJfKJiBw/LgEGb2/IKlPflZtdbeJqhX AGKhIFbXLYGq5QKJOsP57T2qeW0ET943JYKZWHed4IEXKRvuR7pHN10jnrsyTW5oqxZDaDcs1Ls VlPQ= X-Google-Smtp-Source: AGHT+IEPVPrIsvzVKM9BRnKywqUBY+49ysTGl3h3gnVcSq9byO4UW1dwGcp/l7t7WWnOfvV7vMqjdA== X-Received: by 2002:a17:902:e812:b0:20c:f6c5:7f6c with SMTP id d9443c01a7336-211821c4546mr156324045ad.16.1731252560665; Sun, 10 Nov 2024 07:29:20 -0800 (PST) Received: from localhost.localdomain ([198.8.77.157]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e99a5f935dsm9940973a91.35.2024.11.10.07.29.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Nov 2024 07:29:19 -0800 (PST) From: Jens Axboe To: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Cc: hannes@cmpxchg.org, clm@meta.com, linux-kernel@vger.kernel.org, willy@infradead.org, Jens Axboe Subject: [PATCH 05/15] mm/filemap: use page_cache_sync_ra() to kick off read-ahead Date: Sun, 10 Nov 2024 08:27:57 -0700 Message-ID: <20241110152906.1747545-6-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241110152906.1747545-1-axboe@kernel.dk> References: <20241110152906.1747545-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 8A592100010 X-Stat-Signature: hgumuoipzef79irwqrhxar6hiats4jgy X-Rspam-User: X-HE-Tag: 1731252518-656182 X-HE-Meta: U2FsdGVkX19JLyKBa69zh6gs/vRT8ZXvDtmk4h8pf7rhNFFfD+bo2Ecfr3B5qcrysDlzQ/53D1NAlt0fNRu5/7u14U3xZxI35nQNm2IqkTqsSg8WKe/glN7Yj0hfRpbelznhCvv4TXYW/G4x7Zx11n5xaSlDpn1n9XFkH7Fz8n9JWG7AYv9ioW1YxQwy/KOemZ1OknBmg02dFgktkG2jdu8DWSLZj2W6cbYoIQldcVCvEh9c8u6HvpgivqVWkunifGVrbobk7GrSs3KvJ/2xiOM1KfcQw7GW1A7fY3ZM581aPLCc/zYa2FPMcpG0WjsP3FthnoCmtweFfzmthaKw4k4kiH9HkXT4hEgUOPXD04rTAXHGYNHTn2GmXk9938xHfILJQnafXqeaxiTv+/IPf32FfkjL33Km1vqc4CqLrn2kFbZVN+lOKpk9AFgdK6X+VQa8u75rOtu3rVFlbWMc4n9U85VdWendl/KqIk2kW4I2H0PV5uT0FHIcp10a57OzpQ2El9ND0kh/IX+yEZWrM7//0DKuRQSMYG2aK+WAquX6zJRiGbRQbr36C89LW+8gbBJzkGuHiQoAmH/zIoKWY4hjGC+Sw+JUVvadgddQqWX+6vkFn1xeOUwg+UcJbebp+LIu9qcbLPRJQUYx1IL/jEWXSMPZYwV5+bTDYB0XwOlCbH9fTTJIGElc6YlVMBjof+srewZ29vzHGzGaTOA80WFK3uvPvrzy9RrCOXjWcsVnjBmCGUUk2EbT1NOaYSJVCz51F1wlPVsu8GNQi9mkvDuuWc4nDtX100EDWf6NC5X1meg7osnwfNKUTBSwi/A27ZkN78NjB/yrtGxm9e24hcH1gzEKqTo9qmvLUgRG1RvmvH8hQP7+lS9HJOJPgf7atVO43O9ycYu64PJTSVi0H5cjx8ssxtvREGHrf70mFKIDlJdvulF5Kf02Aq8aZXRbWDvi3cAT7fsF/3Jgcko Ai36qWEV evqor7qdEGoVCpM8Ez4gUE0MXmSD1NjbpBWMDBgQaOGl+xtHC7ccYaewWgHIIFDYRd/7n2BRhCnNFDXumhXlDcGZ1rQA4PCzxTSPpKPiQEbSEw6voMP30MfBBsv5hXqnsFew8l9oz7pSxQLm7JaVbFdmISOkyR5ZwdJQN0JoANMCKlX7+sueQ1X/Seg6bXrF8LZ4KPsZRwi4KeNPn7G2Wt4rRnRMXDF7fKpb8hsIMO8DKWBXQv6pJcxne2HwAXhWDmGJVAkfVLTV5PUOZz8mBoWSopcR7bAwi5cogJGhNGiEFfqzt5MhrqivnciHLknkVHzuhcSibWzX0oSbXlwEPFM1hKs2sj968caQx 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: Rather than use the page_cache_sync_readahead() helper, define our own ractl and use page_cache_sync_ra() directly. In preparation for needing to modify ractl inside filemap_get_pages(). No functional changes in this patch. Signed-off-by: Jens Axboe --- mm/filemap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 0b187938b999..38dc94b761b7 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2528,7 +2528,6 @@ static int filemap_get_pages(struct kiocb *iocb, size_t count, { struct file *filp = iocb->ki_filp; struct address_space *mapping = filp->f_mapping; - struct file_ra_state *ra = &filp->f_ra; pgoff_t index = iocb->ki_pos >> PAGE_SHIFT; pgoff_t last_index; struct folio *folio; @@ -2543,12 +2542,13 @@ static int filemap_get_pages(struct kiocb *iocb, size_t count, filemap_get_read_batch(mapping, index, last_index - 1, fbatch); if (!folio_batch_count(fbatch)) { + DEFINE_READAHEAD(ractl, filp, &filp->f_ra, mapping, index); + if (iocb->ki_flags & IOCB_NOIO) return -EAGAIN; if (iocb->ki_flags & IOCB_NOWAIT) flags = memalloc_noio_save(); - page_cache_sync_readahead(mapping, ra, filp, index, - last_index - index); + page_cache_sync_ra(&ractl, last_index - index); if (iocb->ki_flags & IOCB_NOWAIT) memalloc_noio_restore(flags); filemap_get_read_batch(mapping, index, last_index - 1, fbatch); From patchwork Sun Nov 10 15:27:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13869950 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 1578BD12D43 for ; Sun, 10 Nov 2024 15:29:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 35DA86B00B4; Sun, 10 Nov 2024 10:29:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 30C8D6B00B5; Sun, 10 Nov 2024 10:29:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 185A86B00B6; Sun, 10 Nov 2024 10:29:26 -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 EDC1F6B00B4 for ; Sun, 10 Nov 2024 10:29:25 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id AE187A1478 for ; Sun, 10 Nov 2024 15:29:25 +0000 (UTC) X-FDA: 82770569112.14.F4866D3 Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) by imf21.hostedemail.com (Postfix) with ESMTP id 48F051C000F for ; Sun, 10 Nov 2024 15:28:09 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b="1/+GE2Wl"; spf=pass (imf21.hostedemail.com: domain of axboe@kernel.dk designates 209.85.215.173 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731252423; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=SJBisbj/rGvidSFxNEf05dxDvPbQrKvqbgVXmZ2uTrI=; b=ashXA1kUsC2zP1vE+UN5x8i/HRY99wbfHR94pBYkOb3h1Uw2Z2qiZ2CmDPSh5YtReju0ev dFJJQ5jcfCa6lAgdARX2bmD1xuACbvfq4byCMZzjP8gRK3XLmjQXqPqjboju+1aWs70APG xEsjxK+y4B7DGC2B3+aBS1Euq8vtQ24= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731252423; a=rsa-sha256; cv=none; b=c1OfBvf5ZfvTz5x/SueHKnUVD67uwys0GSAzcflJjR0Aq1LC85aH8tpo/DOUdI8x2nCUfe 3lKGh9L3WD6tFktrYgddhiL+4nL4LlRCY88UJkdRWJmkqrrLEZfWmba1Ob1Z0aGaOrrY0U wR8ZmxpsFGcl3E9XC2y3i9pk+3aoS5Y= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b="1/+GE2Wl"; spf=pass (imf21.hostedemail.com: domain of axboe@kernel.dk designates 209.85.215.173 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none Received: by mail-pg1-f173.google.com with SMTP id 41be03b00d2f7-7ea9739647bso2613488a12.0 for ; Sun, 10 Nov 2024 07:29:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1731252562; x=1731857362; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SJBisbj/rGvidSFxNEf05dxDvPbQrKvqbgVXmZ2uTrI=; b=1/+GE2WlwCRtDqXq8epwOtkwl+PwKbKK90OMe4y2M2kB6PxPzI1TNFUMcn1lMHNkU7 Kxp9faNOkt+d2/L9+VidA+0QCN0PUHr08ez6cvVOwYopmrNSnadlkmpgB1p+CchHM6xV YlUDvi1WvYIg+3YtoZJqEwmAkNMe7UzWjqPbSGP3eZMRHaQs+Nh4GqdvcAgD7c5usN/j ND09Qwu5Hq/rgyW0RPFgyuFa0GmlDN4FfNdMPvMuxrXub/tRqpgyaTru0GQ7GET0t77e 0/0rMYp2GFTvSr1p+oksgo2sJOMtifPKdkNNWaKIPlynSbKQL1fp2couCvYjGJ9Cbutt 1haA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731252562; x=1731857362; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SJBisbj/rGvidSFxNEf05dxDvPbQrKvqbgVXmZ2uTrI=; b=UmzK6NTOYqzls0H2veErh3Ijuvu907peGtgHqbvPj0TVUo8BbMHomBXXjjSLd3+x5l PU/d9b/SmknNy8UCCmgA/BToqzv4hwlKmepoZ+c7MfZgO9nNMrgSoRqff4UGiWrNPsT9 GwFfAxEsstyazUqMPIX9plK888siir5UQXGulXAcYMtnXbf1s1zeJN/npu6LUqHAvdan dJ5pwpZ22TGyPDyWyM0Yc1AXCfjs5dD7OwgpVb/4gaVpFHSq3g8i7ih9ZDF/gTBh1e4o TRKNgsw+DQDMGbzbhCW+GRhXYwYysyJW4dfs4f9954M+9fAiakSNutSxtIrXhv4f2LUZ UGnQ== X-Gm-Message-State: AOJu0Yx2SBw0ZFIBrLu6R9KMeX7MIjCnra+Ef3MYrXMqsxyFxle+7xN8 Q8NuNqai8pu6iv5qVBJvejZfyOwY21hhQdyiipSCK2Ca4pWgtIzl+Shv76N3qHvXSKs4wuFagI7 5lnA= X-Google-Smtp-Source: AGHT+IEztLXy7pfG6RYnicaB5W8MU9mXcvU3VePtiJO2A6vGFaDJWmS6lrttgNl/g5B6W7Nsuo57hw== X-Received: by 2002:a17:90b:224f:b0:2e2:da6e:8807 with SMTP id 98e67ed59e1d1-2e9b177fc52mr13814904a91.26.1731252562169; Sun, 10 Nov 2024 07:29:22 -0800 (PST) Received: from localhost.localdomain ([198.8.77.157]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e99a5f935dsm9940973a91.35.2024.11.10.07.29.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Nov 2024 07:29:21 -0800 (PST) From: Jens Axboe To: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Cc: hannes@cmpxchg.org, clm@meta.com, linux-kernel@vger.kernel.org, willy@infradead.org, Jens Axboe Subject: [PATCH 06/15] mm/truncate: make invalidate_complete_folio2() public Date: Sun, 10 Nov 2024 08:27:58 -0700 Message-ID: <20241110152906.1747545-7-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241110152906.1747545-1-axboe@kernel.dk> References: <20241110152906.1747545-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 48F051C000F X-Stat-Signature: 85i8x4o47o8x4gaqfrmk9pbaum447pah X-HE-Tag: 1731252489-887341 X-HE-Meta: U2FsdGVkX1/yBGrCjyYplJlgI+myY8fq5KQMO6UxIb0MQsbSRsij2ApGkzhJj+cY2E4ECdYxJoZ5EfahAzq0lS4zjRYoGVDYCiLKpIQU2nJn6yjeKSUJVaUsJ8qcf39Zhb9/OEm4jwP/ONRDtA5Q8654/O9NGU7Z+bcw4YpY/dprTS6oTX9NGFM0kfumUAInWYquMXlEW/CH/3vYKRl/FatWJ7GnAy+p/IXDzg8nEB2oHKA8Gi+312p3aL4jHzo/b6wcu48WkNBCgQcQ6mSOzo0xbcXBaShkVDJ3Gs7z/LIYRb06uFaYMtgMsW+o6tcjqJ2S5l0MV4ui3QB5bxNGx980XwSd/qxvi893saNGdkRZMRB3ZSG1cOyVXaUjpKsBBNpxsflj9qctoYM2fwN6WOe8LI3dg3gTnRvosbiWtPrw8kFvOUVAgEZgu0W1XUEJxd7v0knJ7g6bsLwyT8e6iKc5ugwqAw+1wwbhKVfQ36UIpusd8Jv6OHJRaAnmaTgwsLs8t0ge/LKyMLagDnyDLujzT+bMwn1J0nfKmQVXGxLsZ5ocjdKDjGO5C8GdfzICS7LBOotWllQxOWphDbGcs03Epr5Du/8DyZjDQOIO2DUBzv1P/+KYG3Sbp0lAWFykPmqFf9rBLN/4Ifhie7iyr+MdS67ic+8jTQcGfokncQ/4PxXJTEZAehMkFGHUfdh+BQkU8RjkD2ipCXl/mctpkBvHJB35kZDbWwO0NDu71woRMWDoBEXjYaaA0VmDfAu/+zRssGB1xAabXw4Lyt4u06dlvp7MYLobSf1aM+773C6FPKIQ+dOXyhFLJzf7Sgcjio1y3UDFT+63sLavoClt6LSkJwOApKa7lYjqa/ZjQZiHzIbOG03bnDz4H7/xjuFiPsa2IJs27/1uWMBccF7/QE89tWCE3Dwq2vCo35zbPgPePonI6QtnFXdIiJD+PcmoIRJkgeS6yHFA8vvxidV rtqK0Tgd wPCnp6oZKM6u5IjH+3VVqeH0h40kdEBooVhKfCNGskIHmQ2sBEWDtyc8Tpy+/CmkNZCQpOsd0XhB2BkxYH+VGXOpYz9eHNHaXgTwNn/IzyGLnziOovK9TyUI6dgGalUosnjYIW4pSxfI6BhPsUsOMTeVn9dbaigIkeus981vSzkvUSXrx1fm/h47fciIk3RUJO2MpxD5IjlOBMFaoWpY7f2Voyp16ysPTEgoT7x5u0dPNdtTP0vhyHEe2tV5U2F3qbfgbv9hdKZWiG0dnXyw2LC/zqGu616mWGdMhRH6hayJ10g02t0j/QQEjwo6ew1CM+JpHuWdKth0C4G3NOLpl3HO/5Zn572wfVX1W 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: Make invalidate_complete_folio2() be publicly available, and have it take a gfp_t mask as well rather than hardcode GFP_KERNEL. The only caller just passes in GFP_KERNEL, no functional changes in this patch. Signed-off-by: Jens Axboe --- include/linux/pagemap.h | 2 ++ mm/truncate.c | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 8afacb7520d4..0122b3fbe2ac 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -34,6 +34,8 @@ int kiocb_invalidate_pages(struct kiocb *iocb, size_t count); void kiocb_invalidate_post_direct_write(struct kiocb *iocb, size_t count); int filemap_invalidate_pages(struct address_space *mapping, loff_t pos, loff_t end, bool nowait); +int invalidate_complete_folio2(struct address_space *mapping, + struct folio *folio, gfp_t gfp_mask); int write_inode_now(struct inode *, int sync); int filemap_fdatawrite(struct address_space *); diff --git a/mm/truncate.c b/mm/truncate.c index 0668cd340a46..e084f7aa9370 100644 --- a/mm/truncate.c +++ b/mm/truncate.c @@ -546,13 +546,13 @@ EXPORT_SYMBOL(invalidate_mapping_pages); * shrink_folio_list() has a temp ref on them, or because they're transiently * sitting in the folio_add_lru() caches. */ -static int invalidate_complete_folio2(struct address_space *mapping, - struct folio *folio) +int invalidate_complete_folio2(struct address_space *mapping, + struct folio *folio, gfp_t gfp_mask) { if (folio->mapping != mapping) return 0; - if (!filemap_release_folio(folio, GFP_KERNEL)) + if (!filemap_release_folio(folio, gfp_mask)) return 0; spin_lock(&mapping->host->i_lock); @@ -650,7 +650,8 @@ int invalidate_inode_pages2_range(struct address_space *mapping, ret2 = folio_launder(mapping, folio); if (ret2 == 0) { - if (!invalidate_complete_folio2(mapping, folio)) + if (!invalidate_complete_folio2(mapping, folio, + GFP_KERNEL)) ret2 = -EBUSY; } if (ret2 < 0) From patchwork Sun Nov 10 15:27:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13869951 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 66DD3D12D46 for ; Sun, 10 Nov 2024 15:29:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 978D36B00B6; Sun, 10 Nov 2024 10:29:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9270B6B00B7; Sun, 10 Nov 2024 10:29:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7A27F6B00B8; Sun, 10 Nov 2024 10:29:27 -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 5A18C6B00B6 for ; Sun, 10 Nov 2024 10:29:27 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 226F2ACC8A for ; Sun, 10 Nov 2024 15:29:27 +0000 (UTC) X-FDA: 82770566802.17.357DA31 Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) by imf25.hostedemail.com (Postfix) with ESMTP id DF3FEA0003 for ; Sun, 10 Nov 2024 15:28:56 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=0eUB1Hxp; dmarc=none; spf=pass (imf25.hostedemail.com: domain of axboe@kernel.dk designates 209.85.216.43 as permitted sender) smtp.mailfrom=axboe@kernel.dk ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731252504; a=rsa-sha256; cv=none; b=xSoMa/Gug5bNNVhaQTiSRm7ZA0lVU+EmUyFWmAGIWEaG6c6GJT7ZpovDo4LSe0BzMQW6/M OWS+XVvjfVPxx6r/Tza4pOgmvhxjU4tNxEU9ihgbcM8aYP8uDQHv7gqvCww0qlfeoADjgA X3BuN3KO3wBA4VEYb4BYWszygvA46YI= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=0eUB1Hxp; dmarc=none; spf=pass (imf25.hostedemail.com: domain of axboe@kernel.dk designates 209.85.216.43 as permitted sender) smtp.mailfrom=axboe@kernel.dk ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731252504; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=BpaeGG8sCxZf4JRh/p7NGjZl2gbHvBRPjf0TUvSvRrE=; b=yx2S6AypbN0bDCEBAIIEzI1EYW5WgNzg1p8IJJ8wYTRhJariRd3VrTWMSuRNmeFIELbZbj QSMd1C/kHzjzMSqaw3l117Ai4eTjPHcHhzUOipxKFTK0+9xdwW6Bf4SUJ9rNgfTB+eA9Hq 6ax+ItkOdK22Jn/VqhFowTCt6zskVbQ= Received: by mail-pj1-f43.google.com with SMTP id 98e67ed59e1d1-2e2ad9825a7so2840109a91.0 for ; Sun, 10 Nov 2024 07:29:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1731252564; x=1731857364; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BpaeGG8sCxZf4JRh/p7NGjZl2gbHvBRPjf0TUvSvRrE=; b=0eUB1Hxp1NEBj58pU47ypngPEvk/5vS/T0jhKFdKKFy0Z5tOAm+cjePcrGjooN/Bxw szvZEIrhs+JIS5OYSefVvlAxrnxiq/HO/nGojeUkMD+CG/TScuRda9NrsS2HMoI4ylGA gbnG3kllkjJLtju027GjB4AGOEgvyS5dUnG45sSGG5BJvouZ9Fi3KFbbKwsOTblP8PZa 3gZU5JuYtQB7n1A9+5j0bs3bJpS4iUQnySjmRxUDr94qX7TcgxZaGWQgu+m830x2DzZD Tpb5BBKyuLG6e4PZqXDpUnt5yyND58M87H1aiKlUSO/L4c6JXYTaWdxtBQWVOOPkb17o vNIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731252564; x=1731857364; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BpaeGG8sCxZf4JRh/p7NGjZl2gbHvBRPjf0TUvSvRrE=; b=kXSHp5pcR8SXHLfn7O+CkAEXDIVGBeCEFpQAyx3eS/vXBYBsGXFN7PepuQOLVkDjY3 g2Pty6JFFb6fMMokqCzFKT6fwzwxulWRFtdXmXIT/Wq8hfn8LagEg7ffKqbW/hCQUprf 5sdrqJj7A2CDk1PLtd00pdwzDrn5EsJT0/wXrS4KRKPg/m1kqUBgahaYtOR5eDfMqm2U evjtB9eCMsYmVBWE9m8E/68/NiF4lddp12bdzy6KCv9INT5CGTNofKNcvShxO6WdBQWa lAoJqPNPVEkGy7vCJySwoKBDc3mTkJnLHHwadG2LZHPWReHOU5vbsXX+SdYYJdw1T+qj bBDQ== X-Gm-Message-State: AOJu0YzIPIWiGrMri+29MyQRnMmc1+BCZUhDgCL5oa2bKGvrJxMz5nRT TW9kV8rXt+yD76OR8EsY6wMJ5+dOipDGsYizF1ovoXNFcrXe1oIVgaIu99esg/ejeMBJqUah4JJ YNVE= X-Google-Smtp-Source: AGHT+IGs3z/1IuRBhhgcQrQmIVWwPr43n/jctzILt+apLswhddJAGBym568yRqijFSP667Ww7gbDZA== X-Received: by 2002:a17:90b:1f8e:b0:2e0:d957:1b9d with SMTP id 98e67ed59e1d1-2e9b17163cbmr13877494a91.13.1731252563753; Sun, 10 Nov 2024 07:29:23 -0800 (PST) Received: from localhost.localdomain ([198.8.77.157]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e99a5f935dsm9940973a91.35.2024.11.10.07.29.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Nov 2024 07:29:23 -0800 (PST) From: Jens Axboe To: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Cc: hannes@cmpxchg.org, clm@meta.com, linux-kernel@vger.kernel.org, willy@infradead.org, Jens Axboe Subject: [PATCH 07/15] fs: add RWF_UNCACHED iocb and FOP_UNCACHED file_operations flag Date: Sun, 10 Nov 2024 08:27:59 -0700 Message-ID: <20241110152906.1747545-8-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241110152906.1747545-1-axboe@kernel.dk> References: <20241110152906.1747545-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: DF3FEA0003 X-Rspamd-Server: rspam01 X-Stat-Signature: f67zme1i3sw9o9ahfco5gft6hz3gp5uz X-HE-Tag: 1731252536-513637 X-HE-Meta: U2FsdGVkX1+i15g7Ink2jlWd85Xj0syBQPqfOPm6w8OgAmJm0ogVXtxWcAqpEVl1nmATo5/59x71ICZ8nmk84Goy1WbsjGKLRApnG4eTIMgTlmJZkFx6qaowm6O67mODVQ3UhJuuApuWWLiSUL2a1w1Rg0Yrq6FezUDVA3OtcRJ42hiFUcY5sk1MZkI6Dv8PPGFYgQNB9RYaYwY33GFvGmXcWLydR9XWHkwWuhVQ/R9OyhP9S00XQFJ681f2zc6kIY2nAh6TkRuThzXw/hodcf5p/kbLlxUJx3KYpPEEkBRZEgaxrfieF597KK4nee2JjEle1lOrb6AIcmA7dF0OCb5urIfnQWdx+fW9b1NbWXPOBWAtpHraoME5B21VkgOmDqZcjHoyuP7vLmrSwTxjP8bMGqZeDbjgY5uZZc28iQpJ0hvtMgDmnUImW+Zlcn+By5WCK3qaMzBBn34OP24fDwjZnXgIaBgpSGeM7DFrn1JntI7y7mzQknwKN9acUzEHFW9WMo0kr4Iqupq3oR7VlKSUdgEU4S4+zo7DwEDnKpKsl+9/VCi/B49TO/CxqIaqpDaU8E9inzXQrY5KomrUC0fm9rOIZwsA/UpZJsR22Uk9pcJFHU4qQ5HKdKuH7KGwVGvHcqQivrWuSbmzmWSUv8f94X7Zpm3OOrOi7b64WkWGS4S/2BTgfZVj0lGAF2hsrEZlnEwob0rREDqmLaj5WdHsh9PwO/RtBRgrsAmLse6L+IJskG1Vso8m2oZUOu3ap7cyloeu9XHvGnwZoyBQQyoWDpS6eEnneeP40Vs+vVyQ3Ct35Il/nOuXphELexlkYoVLD3CaMjh2Zi4HM3Toc21xTMNLBwBCLlrehfh+DsxK5faasYR365iOnFF4XAjmyzxX6x4iKywNqXhr+BrZlVs5lDXRFhKMveGmtCjXChP5IU5aGwlawDkn9gJ+uVydxsb5C2VjITdDSZ6yL3k wetjaBsx VZQvproBAqeVglHHDrHGCCv5MO0zNa8lYDWg17Xxb2C6z2GH7dXNO1ZKD7ZLNuNQxevjqH+XuIdxZOdiiG1CFTVdYKhLi0PHapQ250r/mju8hef2qVroJgddYF4if5ssWrvoI2eulbgVyqzYYbpI01Tde20HPQDUTX0p1dzvQx0NMBwUZXj9mdGGJENE/DE5h+W6wMSxJ1cacDzW7n7VuWLOorJKdYWGfwX0I5nAchjxTKOJnfTuHYZHrNbNVzUklcLap4rRg5VDW88dSKui5RwjdUUSOtpooVqZjN4wDTvG8MGw/rewqTH8oEkgR9N/QDnNyRg4vCB+hotLgXzo+HGS3ccfMXcn6xWsK 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: If a file system supports uncached buffered IO, it may set FOP_UNCACHED and enable RWF_UNCACHED. If RWF_UNCACHED is attempted without the file system supporting it, it'll get errored with -EOPNOTSUPP. Signed-off-by: Jens Axboe --- include/linux/fs.h | 10 +++++++++- include/uapi/linux/fs.h | 6 +++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/include/linux/fs.h b/include/linux/fs.h index 3559446279c1..5abc53991cd0 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -320,6 +320,7 @@ struct readahead_control; #define IOCB_NOWAIT (__force int) RWF_NOWAIT #define IOCB_APPEND (__force int) RWF_APPEND #define IOCB_ATOMIC (__force int) RWF_ATOMIC +#define IOCB_UNCACHED (__force int) RWF_UNCACHED /* non-RWF related bits - start at 16 */ #define IOCB_EVENTFD (1 << 16) @@ -354,7 +355,8 @@ struct readahead_control; { IOCB_SYNC, "SYNC" }, \ { IOCB_NOWAIT, "NOWAIT" }, \ { IOCB_APPEND, "APPEND" }, \ - { IOCB_ATOMIC, "ATOMIC"}, \ + { IOCB_ATOMIC, "ATOMIC" }, \ + { IOCB_UNCACHED, "UNCACHED" }, \ { IOCB_EVENTFD, "EVENTFD"}, \ { IOCB_DIRECT, "DIRECT" }, \ { IOCB_WRITE, "WRITE" }, \ @@ -2116,6 +2118,8 @@ struct file_operations { #define FOP_HUGE_PAGES ((__force fop_flags_t)(1 << 4)) /* Treat loff_t as unsigned (e.g., /dev/mem) */ #define FOP_UNSIGNED_OFFSET ((__force fop_flags_t)(1 << 5)) +/* File system supports uncached read/write buffered IO */ +#define FOP_UNCACHED ((__force fop_flags_t)(1 << 6)) /* Wrap a directory iterator that needs exclusive inode access */ int wrap_directory_iterator(struct file *, struct dir_context *, @@ -3532,6 +3536,10 @@ static inline int kiocb_set_rw_flags(struct kiocb *ki, rwf_t flags, if (!(ki->ki_filp->f_mode & FMODE_CAN_ATOMIC_WRITE)) return -EOPNOTSUPP; } + if (flags & RWF_UNCACHED) { + if (!(ki->ki_filp->f_op->fop_flags & FOP_UNCACHED)) + return -EOPNOTSUPP; + } kiocb_flags |= (__force int) (flags & RWF_SUPPORTED); if (flags & RWF_SYNC) kiocb_flags |= IOCB_DSYNC; diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h index 753971770733..dc77cd8ae1a3 100644 --- a/include/uapi/linux/fs.h +++ b/include/uapi/linux/fs.h @@ -332,9 +332,13 @@ typedef int __bitwise __kernel_rwf_t; /* Atomic Write */ #define RWF_ATOMIC ((__force __kernel_rwf_t)0x00000040) +/* buffered IO that drops the cache after reading or writing data */ +#define RWF_UNCACHED ((__force __kernel_rwf_t)0x00000080) + /* mask of flags supported by the kernel */ #define RWF_SUPPORTED (RWF_HIPRI | RWF_DSYNC | RWF_SYNC | RWF_NOWAIT |\ - RWF_APPEND | RWF_NOAPPEND | RWF_ATOMIC) + RWF_APPEND | RWF_NOAPPEND | RWF_ATOMIC |\ + RWF_UNCACHED) #define PROCFS_IOCTL_MAGIC 'f' From patchwork Sun Nov 10 15:28:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13869952 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 DA92FD12D44 for ; Sun, 10 Nov 2024 15:29:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A67016B00B8; Sun, 10 Nov 2024 10:29:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 900016B00B9; Sun, 10 Nov 2024 10:29:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 77BA76B00BA; Sun, 10 Nov 2024 10:29:30 -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 4C8476B00B8 for ; Sun, 10 Nov 2024 10:29:30 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id F185B120E1C for ; Sun, 10 Nov 2024 15:29:29 +0000 (UTC) X-FDA: 82770568482.30.AABD959 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by imf22.hostedemail.com (Postfix) with ESMTP id 35432C001F for ; Sun, 10 Nov 2024 15:28:39 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=uxtVz91c; dmarc=none; spf=pass (imf22.hostedemail.com: domain of axboe@kernel.dk designates 209.85.214.173 as permitted sender) smtp.mailfrom=axboe@kernel.dk ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731252506; a=rsa-sha256; cv=none; b=W/Dxku8nw99dO3clJpcsTA3RvA6VnQYrf07lEL1qQWHus+5Kv8Zo0DDdxVPeu5n1lUbSXM heWTY4NmJOl0aNlYUUrMEDX5Qiwqlz+1vOPRfyeUYWcCOvcnI2EBMGEOwgiVNBHyZHFQhz hJoEnrSxiHJb4zO5aW9YsVdzkZua7a8= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=uxtVz91c; dmarc=none; spf=pass (imf22.hostedemail.com: domain of axboe@kernel.dk designates 209.85.214.173 as permitted sender) smtp.mailfrom=axboe@kernel.dk ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731252506; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=xtqsp3FpRWE9h3nra5m9D1cpUkXI8hkSCKuFCrWSblw=; b=13FXyrmnOI+XxG+IFmgad/oH6/+oxT5w9Qe3OP71df24hLDc6pTxzPD7LFZRVSXJNMCFNf 2TIzYk4HAdYzpy/6U5oLEaVrwDnNPt56ZYTBQUfNgsGnQuLCvQPrXPZ6HSmekb1sKU6l1E gie9Dxr6rzovKj3GZlnGp6BR9Lld61A= Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-20c8b557f91so40229285ad.2 for ; Sun, 10 Nov 2024 07:29:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1731252566; x=1731857366; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xtqsp3FpRWE9h3nra5m9D1cpUkXI8hkSCKuFCrWSblw=; b=uxtVz91cVsc2WyOKcUH7fr8ENmAXGh2U3QYmPYEE9Ry9VgcCUGmKHnkdHZtKRG1YiP wk5dWR8j7HX9VLpWTkQ47Ddb8B0CnfO3yuXH0SLU9puMkZLLyIpZ7HycyNr6GpdqA7/z kXhnyZPDMT7EZYIEcTn2C9CLZP0mfVkiswUSLGoVM22bk938l+ASsvR97EVsqrCCi/7f 83/RMBeYnl5hfiCDeFRRLYA43w3Ril39sTO4MT615D/RXEjs4VIQ9+auvYN/rg5OAyRk h5Z0qYSwoKGNXeSmKUEZwVcK58qmTekWRkPmvARZpkYSgQNayOHXlUqU+cXmxb6aHi4B xS5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731252566; x=1731857366; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xtqsp3FpRWE9h3nra5m9D1cpUkXI8hkSCKuFCrWSblw=; b=p02aVTUcO4mh/TqZIDHUCJjRQEmFmB/DfSYk4jpRsuwd/jI4j9jciwOHWt0OT4Gmnv tZ4yPoKlKsIZIzB2kmuQf6F4A1mU1j2cE8Gb0NWTMNQ5fEiVnjzIjJcmNkXG/9IgEMAL yNV4Ol63bOjVHNKC4PUiZys205sywZV1bsOFqTVVOVphCk21OGSNCOa87YA39uYBpVgd Wd9hKf1VL2v2ZvKvk/uLqbNBOEX4pmtLdoJD5EuYlfggGd421kudRQliwgOp186NgPZo XmnH/q+jc5DzBmfh5QyCqqcwYLMqLmd6+Ik8VrfkmXCzB1NMjVkHGmC0H1SDY3Awh79B bJnA== X-Gm-Message-State: AOJu0YykisvVkmBnhgHRJV9/UjKqiMgBmDYJh1gbSNXpOY78iY0rdxpo HiDX2MobnFl3bY6+MDy9z2u9TwzPTR0P7N59ioZ1LAnwu0puBe2yldForjqv1+Q/TBJHwpBzsm5 kTKU= X-Google-Smtp-Source: AGHT+IF5qTNuztLawL22nFdoWM3hBa8g+iEMn3AucUKZX2m0zot7CflQJgWfjjOvLTZBT0mpwh+/bA== X-Received: by 2002:a17:902:cf02:b0:20c:af07:a816 with SMTP id d9443c01a7336-21183d087c7mr129753345ad.31.1731252566678; Sun, 10 Nov 2024 07:29:26 -0800 (PST) Received: from localhost.localdomain ([198.8.77.157]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e99a5f935dsm9940973a91.35.2024.11.10.07.29.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Nov 2024 07:29:25 -0800 (PST) From: Jens Axboe To: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Cc: hannes@cmpxchg.org, clm@meta.com, linux-kernel@vger.kernel.org, willy@infradead.org, Jens Axboe Subject: [PATCH 09/15] mm/filemap: drop uncached pages when writeback completes Date: Sun, 10 Nov 2024 08:28:01 -0700 Message-ID: <20241110152906.1747545-10-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241110152906.1747545-1-axboe@kernel.dk> References: <20241110152906.1747545-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 35432C001F X-Rspamd-Server: rspam01 X-Stat-Signature: xkuq3tk53ypne1yy8o34u16a817btgbz X-HE-Tag: 1731252518-812574 X-HE-Meta: U2FsdGVkX18+Ak+3eVaUvFNYkokCdwjiCRZTIhHYww4QxLhwaspUA8LOA4tmZ1NHtlMQQptBlIBOKdT6a+F0RFJFnFEaf4RrFIj8ZV8+reJBLF5V5gp9q4x1skZP+lEH+eRGu1f/87Gn67GNxjRa3h4UI2pyARRKsX0qIj6qDTLzyoKC4WPxDrvT/G9oRUSrugUeHSmc5Rk3YKkaPro7VW2s6xEfYigF73sJgEHIOKuaPgDJuTTkFDsy8R2paWl8u7bh0/sQkmy39pHP1uMZdfNKBhH8fnqO/YYjtVwd5Ez/e/gMzqgeHBePE+L3yRG4qjmm/wttIJjnFa5Z2hbkoBkLQKqiOMv3Aj0TSxxDRQQR3acEFo+Uc1B5knmJRoejEF7syuybjTEysMYJcqHv0mf17V+fhDKNSsQ9ES1OZgXDb3oR03R9gs9dCKYddS+bv1pQhAu2ZbpWC4k07MZKEyl7EMvyiu9X6izzSJb66osOi+4tqOEMBCXr3zOaDX92tKZMXlKwW3UZvqje03iPDgq/6MQt5I6eQbtb+m0dDSO6yoem+XUycpBDfMXPJrH8YBMzjnRXBcujzXbtKapKH+VpFM8CYtG3XcZHIadGrAYpWlCXaIghDHklsdJyWWhczC4KbsvGEUPb447/3VhYVr77zZM8jaNruicFUXJj9Ry2/xxJbzpbN+gdiADX1Wy2RSyMjID6VGJOAjgd6kxwFmiMtflKkatyCLrc841fbK0DofzXNWNiYD/sW8rDZUOklZscyklx4dlmygdwsjTp8s/HtZWi3XC7jnMGhZJLYrXen+ZEYNPAXWyuQJjE1ycclpD2S5kN4OufdQX44WnQQQY2QPePrxVc6d1lU9UzFo7kDDkSZ/V0OkpboVh3QMe9M4BixLZcJy7A6jIJsJOblozcTKtrpE1MFU2Ha0op8oryRvOTqSbAruhMxPsYfJW81DjWv5kW29UeIf02AW4 iLBbPUEO zbWIZNbXkk6DmH9oSRDuehrM0zW/2RZHeHHsn9Mu+bKuMhlsbopUn3yaX8ZgON1GUvYQBQ6SFXflTHc9U8GPVi27JddxWh4OsaUUCg/An/hdtFWr/+r2RXo4DYxNsySnwBFg+bmLyAwKDhDBITIjGCzmBaI4xa8UB802j5xUr1EtL6R3/jeD6ccfyEmttCY/IeZxbe51foYzUiHyw+PiSTK+1erR+Bw3sez+1/4NPFpX0/laK16MchUp6Cb0Kg5WzAytobhSD6Z6UcRQYhy+POCn0FYnqLdAjCCTirHpOplzcIHyTzJ8pURn39Q== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000334, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: If the folio is marked as uncached, drop pages when writeback completes. Intended to be used with RWF_UNCACHED, to avoid needing sync writes for uncached IO. Signed-off-by: Jens Axboe --- mm/filemap.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/mm/filemap.c b/mm/filemap.c index bd698340ef24..efd02b047541 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1600,6 +1600,23 @@ int folio_wait_private_2_killable(struct folio *folio) } EXPORT_SYMBOL(folio_wait_private_2_killable); +/* + * If folio was marked as uncached, then pages should be dropped when writeback + * completes. Do that now. If we fail, it's likely because of a big folio - + * just reset uncached for that case and latter completions should invalidate. + */ +static void folio_end_uncached(struct folio *folio) +{ + bool reset = true; + + if (folio_trylock(folio)) { + reset = !invalidate_complete_folio2(folio->mapping, folio, 0); + folio_unlock(folio); + } + if (reset) + folio_set_uncached(folio); +} + /** * folio_end_writeback - End writeback against a folio. * @folio: The folio. @@ -1610,6 +1627,8 @@ EXPORT_SYMBOL(folio_wait_private_2_killable); */ void folio_end_writeback(struct folio *folio) { + bool folio_uncached; + VM_BUG_ON_FOLIO(!folio_test_writeback(folio), folio); /* @@ -1631,9 +1650,13 @@ void folio_end_writeback(struct folio *folio) * reused before the folio_wake_bit(). */ folio_get(folio); + folio_uncached = folio_test_clear_uncached(folio); if (__folio_end_writeback(folio)) folio_wake_bit(folio, PG_writeback); acct_reclaim_writeback(folio); + + if (folio_uncached) + folio_end_uncached(folio); folio_put(folio); } EXPORT_SYMBOL(folio_end_writeback); From patchwork Sun Nov 10 15:28:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13869953 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 7B840D12D43 for ; Sun, 10 Nov 2024 15:29:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4E38B6B00BA; Sun, 10 Nov 2024 10:29:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4707F6B00BB; Sun, 10 Nov 2024 10:29:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2E7E26B00BC; Sun, 10 Nov 2024 10:29:32 -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 0C2226B00BA for ; Sun, 10 Nov 2024 10:29:32 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id C055DC0C68 for ; Sun, 10 Nov 2024 15:29:31 +0000 (UTC) X-FDA: 82770567726.07.38209CC Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) by imf17.hostedemail.com (Postfix) with ESMTP id 9CEF640012 for ; Sun, 10 Nov 2024 15:28:59 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=pgOEkR5f; spf=pass (imf17.hostedemail.com: domain of axboe@kernel.dk designates 209.85.214.169 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731252517; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=c6ru6+H4oQlmjhy4ZS59TJ0rgrpyxDTaEbRj/Vr+gBQ=; b=2nhwsnSKw4WicCbyIaBFwV/mTw9C7pl0VBGFmxPzoSIr0P+zD5EdLkY+eJ/s0IDX6UFbNI rALAJ2io/wTxjjixBPeXxc9JgqShmKeSa2G1RUrGfH0cTE++ZZovfsEHYpOWuWTjmzRN1A qxYVknNaHeYPImlUz9GN1tgk+Uu9oKI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731252517; a=rsa-sha256; cv=none; b=jMQetVNC7GnR8GoAoG+pasw0FTOFIxMHfeR5wcwY35SAUVcUUf4EzKK7RCZH3d/2zKRLRd moUaYTXX8H4yQTImvsvnwAYP/0s5IXEYs94/LOntkTmqOYXl4iLCRv/BV46T9+af2koPTg LLX/81Uv7zV5A/5gXwJg89yikob3E6s= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=pgOEkR5f; spf=pass (imf17.hostedemail.com: domain of axboe@kernel.dk designates 209.85.214.169 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-20cf3e36a76so38486215ad.0 for ; Sun, 10 Nov 2024 07:29:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1731252568; x=1731857368; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=c6ru6+H4oQlmjhy4ZS59TJ0rgrpyxDTaEbRj/Vr+gBQ=; b=pgOEkR5fqRNuWXzrqEmF81jtywUxQ5tRzLou94rZV590KY30OafYUwHNGgVlFwS+QJ Cms2byr9Bs5UxQ/+ONIDBNUeGfQDKNyQypA/Xn+O6TxZuyZl80uwLGHA7i+U7oBq0SG6 eKBYEyAlsexehPgP6Cf4eiQmlTGYL37PEloqvNHKC8KmU1Ou6LlVuabWYz5uNdZWoeO+ U3Ec0WEq0V1SBCY7Kwh7TUsBhYjWAJVjPGUPyr66YJtiol1ux98HH2eani4fiI8KX8q1 fbA/KYR1YqQ9e19PdRv8S4wyW2dyew4ryn728uGxnd72oqj8Sm5YAT2x/uXwzPmb8Gxa XWLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731252568; x=1731857368; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=c6ru6+H4oQlmjhy4ZS59TJ0rgrpyxDTaEbRj/Vr+gBQ=; b=IIyHYH0ATi6Hr/VGw1nSszqJvq0TyDRBTAqB36S4cVqlR1VyR+H1sn84XMorxQfVy6 wVsNRsmBTDZIYsvCm7TRYgQesm03xPZ3J4O15AvhmonMUiy//clRt2qynqmWNh6eJEx+ yhmIBoBKpKHW2XtKc67zsjZXMuJz7Uy8SpQCkjbRPGmBAPhX7EMdpjLrW8q+oFprU+c0 wrXr+1+jpFc6JkmAI3rRsO2Ac3g9O8Fzi5srIDT0SvwuDhZUe4gWZ2jX/emurZwgs0hX K/YZEcOv6ozkw4mWNmNjI6DC03Cq9jkLLV5ZrMyP4Uo2+sRDdkiZIndF9M4rKePMH7kK 89zQ== X-Gm-Message-State: AOJu0Yy+W9+OLl1os4qG54Vcu2ZbqtZefix4N/RXPVFViXlBRiPJuLWd qZJtY34cLTBRwtS1XmrruRYSGNSQIJIf8v0G1nbtA5dLfdlZDWpEP5HDoBfNEZMw2AdlWfbkSSW YhtI= X-Google-Smtp-Source: AGHT+IEOVFhFei02kQq1ltQWyF+j1C3XIjJZGZV1LAM2AT1TQ/js4+EAJqEYuNTXGh31ae8isAOkHA== X-Received: by 2002:a17:903:2391:b0:20c:b274:34d0 with SMTP id d9443c01a7336-211835d19e6mr136506735ad.46.1731252568109; Sun, 10 Nov 2024 07:29:28 -0800 (PST) Received: from localhost.localdomain ([198.8.77.157]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e99a5f935dsm9940973a91.35.2024.11.10.07.29.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Nov 2024 07:29:27 -0800 (PST) From: Jens Axboe To: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Cc: hannes@cmpxchg.org, clm@meta.com, linux-kernel@vger.kernel.org, willy@infradead.org, Jens Axboe Subject: [PATCH 10/15] mm/filemap: make buffered writes work with RWF_UNCACHED Date: Sun, 10 Nov 2024 08:28:02 -0700 Message-ID: <20241110152906.1747545-11-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241110152906.1747545-1-axboe@kernel.dk> References: <20241110152906.1747545-1-axboe@kernel.dk> MIME-Version: 1.0 X-Stat-Signature: c7s79xwnqmj3gizcsshhsz7megabu971 X-Rspam-User: X-Rspamd-Queue-Id: 9CEF640012 X-Rspamd-Server: rspam02 X-HE-Tag: 1731252539-107284 X-HE-Meta: U2FsdGVkX1+xd8ZcVGHW9Cl6q/4m9egKgukbiHJfJ8ex7ElTGSPF0NpcyaO6ZUgdLTR7lRVCQ7aQfUqZcW2JyOikBWQ2dPLxe7yE/0ghk1ZiJhDVu8BVQcSY9E/zx38hVdF6Xb2Sq0OYidxGdRmN/l0zXbZ5WObv+BCB+gSsYZH5JlUUdeQwaMIbU8LxN45DEiXm9gbY99yA/Ruo5yPyEh0RKvDFpAqXWJM/GV3GwK42tQjr2HAsUrnbW8tMWKx1oeOJECeFeOPKjniDihbSBQ9IP4m/efhoYF+PvX7+j1Lr3sE2crzwkDeoF8s9/13zrmdf+2vn4AqH8BYiZrPiEYEzIBqB/vMPbd7Hp1EWyQHDmNrRc5mexQVMBfoCdyWt0UVWsuhoNVWG8GR0vVg6gNaR1Mu4Sdi1uw6lci1rwjD1Cgow9Ifw61zxZnlmZcfzyIKDb0pwUAPMlGBnvin7wHqnvoqfm4gj6pAQZUgcBM52tvjAZF6HZevwKEnWiM15GQCva26hUqk1cFv8JdUbj9K59JlGgaKJbWZQilzvR3Q7JkxksTOCsx0SDnOkx4l9k8NFLNW8Pmt8eZc9CeWPUjgDevRGyCglA0qctxdSN+XI7HBwilzQLofe/jz2vC5SvEF6RJ9D1C4NeFNPhfy5zkR1bUKZitd2d7as3qFERujSdlhGet1dk4OxdL8/1Mpxnn5YlKSIWdrUPWua1F3GBlz19S3w42JaRDSscCYTRFpg3hM7MmxHc2yySY2HnlBXUv5q+d6SUvRB176DvyfF2fA2Yl3a9JAwA88kxIWRzlr3E/N9zml/mIkg3Rsh82DSe1pHn1QbKkuOq7DF+GkNurEy4V3YjuqbBfbqhJjnFtZVapZG0WSXuTbGkRbIVql/aK37A7oWAReX/VmckCPqEVCW0oLVMLLTli/KepJXTN/XTvc9eCsOj2W52KmgV03bc6Uv7uzv+aAhXOwSnuy 0+H1AByl onNntQG5VXRwmjALgsdOfNvDSAzdEdS9RXmp9Dkl/CSReF77X4W9Tt/5ZTfw4ixFb4lg5TtnsD/FL8NLOhI3i+OabmarxSVZbNXAEQNajtSuJJ6TLKzaKabDBPSHKmu5h81GKxLR2IUCi6w/GR2v2vn3t8ZjgF51LaUGgNrDGzxsVKBHSHU49gElnimiN+OYGLHBGay3Fqh+RjBGob7sjHoYeKzaHWhv+10hyaRsAIFcWaHTqJ+ViYTPwKe/3dYMdpJuFXDBjkYxHYEu7Zou6Vgf6+nD5A98TQhYzpGpYatCXz/j93qHKUwHtr2I8TU/oZBanS1WnJIsyC843DrlQFTDXuVZc2lbORp+k 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: If RWF_UNCACHED is set for a write, mark new folios being written with uncached. This is done by passing in the fact that it's an uncached write through the folio pointer. We can only get there when IOCB_UNCACHED was allowed, which can only happen if the file system opts in. Opting in means they need to check for the LSB in the folio pointer to know if it's an uncached write or not. If it is, then FGP_UNCACHED should be used if creating new folios is necessary. Uncached writes will drop any folios they create upon writeback completion, but leave folios that may exist in that range alone. Since ->write_begin() doesn't currently take any flags, and to avoid needing to change the callback kernel wide, use the foliop being passed in to ->write_begin() to signal if this is an uncached write or not. File systems can then use that to mark newly created folios as uncached. Add a helper, generic_uncached_write(), that generic_file_write_iter() calls upon successful completion of an uncached write. This provides similar benefits to using RWF_UNCACHED with reads. Testing buffered writes on 32 files: writing bs 65536, uncached 0 1s: 196035MB/sec, MB=196035 2s: 132308MB/sec, MB=328147 3s: 132438MB/sec, MB=460586 4s: 116528MB/sec, MB=577115 5s: 103898MB/sec, MB=681014 6s: 108893MB/sec, MB=789907 7s: 99678MB/sec, MB=889586 8s: 106545MB/sec, MB=996132 9s: 106826MB/sec, MB=1102958 10s: 101544MB/sec, MB=1204503 11s: 111044MB/sec, MB=1315548 12s: 124257MB/sec, MB=1441121 13s: 116031MB/sec, MB=1557153 14s: 114540MB/sec, MB=1671694 15s: 115011MB/sec, MB=1786705 16s: 115260MB/sec, MB=1901966 17s: 116068MB/sec, MB=2018034 18s: 116096MB/sec, MB=2134131 where it's quite obvious where the page cache filled, and performance dropped from to about half of where it started, settling in at around 115GB/sec. Meanwhile, 32 kswapds were running full steam trying to reclaim pages. Running the same test with uncached buffered writes: writing bs 65536, uncached 1 1s: 198974MB/sec 2s: 189618MB/sec 3s: 193601MB/sec 4s: 188582MB/sec 5s: 193487MB/sec 6s: 188341MB/sec 7s: 194325MB/sec 8s: 188114MB/sec 9s: 192740MB/sec 10s: 189206MB/sec 11s: 193442MB/sec 12s: 189659MB/sec 13s: 191732MB/sec 14s: 190701MB/sec 15s: 191789MB/sec 16s: 191259MB/sec 17s: 190613MB/sec 18s: 191951MB/sec and the behavior is fully predictable, performing the same throughout even after the page cache would otherwise have fully filled with dirty data. It's also about 65% faster, and using half the CPU of the system compared to the normal buffered write. Signed-off-by: Jens Axboe --- include/linux/pagemap.h | 29 +++++++++++++++++++++++++++++ mm/filemap.c | 26 +++++++++++++++++++++++--- 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 0122b3fbe2ac..5469664f66c3 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -14,6 +14,7 @@ #include #include #include /* for in_interrupt() */ +#include #include struct folio_batch; @@ -70,6 +71,34 @@ static inline int filemap_write_and_wait(struct address_space *mapping) return filemap_write_and_wait_range(mapping, 0, LLONG_MAX); } +/* + * generic_uncached_write - start uncached writeback + * @iocb: the iocb that was written + * @written: the amount of bytes written + * + * When writeback has been handled by write_iter, this helper should be called + * if the file system supports uncached writes. If %IOCB_UNCACHED is set, it + * will kick off writeback for the specified range. + */ +static inline void generic_uncached_write(struct kiocb *iocb, ssize_t written) +{ + if (iocb->ki_flags & IOCB_UNCACHED) { + struct address_space *mapping = iocb->ki_filp->f_mapping; + + /* kick off uncached writeback */ + __filemap_fdatawrite_range(mapping, iocb->ki_pos, + iocb->ki_pos + written, WB_SYNC_NONE); + } +} + +/* + * Value passed in to ->write_begin() if IOCB_UNCACHED is set for the write, + * and the ->write_begin() handler on a file system supporting FOP_UNCACHED + * must check for this and pass FGP_UNCACHED for folio creation. + */ +#define foliop_uncached ((struct folio *) 0xfee1c001) +#define foliop_is_uncached(foliop) (*(foliop) == foliop_uncached) + /** * filemap_set_wb_err - set a writeback error on an address_space * @mapping: mapping in which to set writeback error diff --git a/mm/filemap.c b/mm/filemap.c index efd02b047541..cfbfc8b14b1f 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -430,6 +430,7 @@ int __filemap_fdatawrite_range(struct address_space *mapping, loff_t start, return filemap_fdatawrite_wbc(mapping, &wbc); } +EXPORT_SYMBOL_GPL(__filemap_fdatawrite_range); static inline int __filemap_fdatawrite(struct address_space *mapping, int sync_mode) @@ -1609,7 +1610,14 @@ static void folio_end_uncached(struct folio *folio) { bool reset = true; - if (folio_trylock(folio)) { + /* + * Hitting !in_task() should not happen off RWF_UNCACHED writeback, but + * can happen if normal writeback just happens to find dirty folios + * that were created as part of uncached writeback, and that writeback + * would otherwise not need non-IRQ handling. Just skip the + * invalidation in that case. + */ + if (in_task() && folio_trylock(folio)) { reset = !invalidate_complete_folio2(folio->mapping, folio, 0); folio_unlock(folio); } @@ -4061,7 +4069,7 @@ ssize_t generic_perform_write(struct kiocb *iocb, struct iov_iter *i) ssize_t written = 0; do { - struct folio *folio; + struct folio *folio = NULL; size_t offset; /* Offset into folio */ size_t bytes; /* Bytes to write to folio */ size_t copied; /* Bytes copied from user */ @@ -4089,6 +4097,16 @@ ssize_t generic_perform_write(struct kiocb *iocb, struct iov_iter *i) break; } + /* + * If IOCB_UNCACHED is set here, we now the file system + * supports it. And hence it'll know to check folip for being + * set to this magic value. If so, it's an uncached write. + * Whenever ->write_begin() changes prototypes again, this + * can go away and just pass iocb or iocb flags. + */ + if (iocb->ki_flags & IOCB_UNCACHED) + folio = foliop_uncached; + status = a_ops->write_begin(file, mapping, pos, bytes, &folio, &fsdata); if (unlikely(status < 0)) @@ -4219,8 +4237,10 @@ ssize_t generic_file_write_iter(struct kiocb *iocb, struct iov_iter *from) ret = __generic_file_write_iter(iocb, from); inode_unlock(inode); - if (ret > 0) + if (ret > 0) { + generic_uncached_write(iocb, ret); ret = generic_write_sync(iocb, ret); + } return ret; } EXPORT_SYMBOL(generic_file_write_iter); From patchwork Sun Nov 10 15:28:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13869954 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 4E355D12D43 for ; Sun, 10 Nov 2024 15:29:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 867956B00BB; Sun, 10 Nov 2024 10:29:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 817CB6B00BC; Sun, 10 Nov 2024 10:29:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5F25A6B00BD; Sun, 10 Nov 2024 10:29:33 -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 347E36B00BB for ; Sun, 10 Nov 2024 10:29:33 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id E6C2012081E for ; Sun, 10 Nov 2024 15:29:32 +0000 (UTC) X-FDA: 82770568608.23.0BC0AA7 Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) by imf18.hostedemail.com (Postfix) with ESMTP id B7D911C0014 for ; Sun, 10 Nov 2024 15:29:13 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=ZTwkxnCW; dmarc=none; spf=pass (imf18.hostedemail.com: domain of axboe@kernel.dk designates 209.85.215.172 as permitted sender) smtp.mailfrom=axboe@kernel.dk ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731252509; a=rsa-sha256; cv=none; b=P8ZqhsoSCBFLfz5ESlceAkR/eEyYaOsH1ad8nmG68Ttlg1uEHrDnhu4R6waIteHRTUYCFN dRiHcpTjrQs8aS8AyffHOxpDJQLp20YIG9mpR1AfhcSsJnZvKLgNDDfeJb/DWerV2Ds7BY lmN0Gf7FWEOB+J9xqxcPqG59EDjzsbs= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=ZTwkxnCW; dmarc=none; spf=pass (imf18.hostedemail.com: domain of axboe@kernel.dk designates 209.85.215.172 as permitted sender) smtp.mailfrom=axboe@kernel.dk ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731252509; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=2Ft1nD1O8TW6ajHAbmpyRJ7eqllXRgDsj9KVxLudGNI=; b=0JQtPgZqG/svYm56EerWUtC8i4HmpY2z7i6ceZIFWrniLNHoCcv1mHLybkm12QCPrgZ4F9 o5FHwnMsdp+1xW+Yhuet9a/wzJUK3KkmZ8wPinCVfGGiN4wD5s3qDcouM61tEsZVyUO0Ls zmFIuBBEB5/gtW0eFdftJIif1VE5JMc= Received: by mail-pg1-f172.google.com with SMTP id 41be03b00d2f7-7e6d04f74faso2601701a12.1 for ; Sun, 10 Nov 2024 07:29:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1731252569; x=1731857369; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2Ft1nD1O8TW6ajHAbmpyRJ7eqllXRgDsj9KVxLudGNI=; b=ZTwkxnCWWQXadgOi0Zd7ymv1hgIwnIPaFEqG4A7AH1ANtP7iJORUHorloLpouFlHFi 08dFExld5dGcnLz5ldXY9nbaBh0XFuV6R5eMS1gkXyh9+izk+pqy4QPP9dGZ7xsrHX9l 3HEebp2gJmsPogSMWfAfwZRgP+qfsORSiiYqbp+zYY2H9w2beUTUMEr50dziN9t+s+jz IAmwAub6ubmlZ6XgXfdEJ9NZk+6QDcMrJ3kvDar9fq1mcq+9lDhfZce5RaMYlvIpPHiG pJ1052zn3xmUA+CffRlPujq1OSsGvmu3pYynxMSrmyxxQD+xbvWMel4AEmvl4+1v3Npc Wsdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731252569; x=1731857369; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2Ft1nD1O8TW6ajHAbmpyRJ7eqllXRgDsj9KVxLudGNI=; b=lVK+QswUyP+2Hj730tpGi3keGtzDCF8iXgDeJKsdfExpXr4DjLKm0etbIriTb70t2W TbXZP4bWPVhrT4EqSkt4zes2cC7q03GFL9tQiCelnVI5B8bx6yX+ZrjH6j+H+3pxP8Cf k9Nb++DJ+z72qzUjAIKohCOCX35HtpsuqbfVYqau6lt4T8Oxb9RKGYT9LMO9QVf1CBpI gIo/GOh9uLu8S0Pwb46Qi8guzxYgAtkakZjlMaf8HD/ywn9XGEPWt3Qw1/FkrLFvCHAV h8X0P7ZIiUn/K6o8O2Ryi5E9uBAVLGfyKfTkFS9F8nJEEcTy3NAhwdhrS/Ye12PzZH1K 0UpA== X-Gm-Message-State: AOJu0YxD2YWDtzFQDfasZmeDK84AuhtVx5/tJQNUVu1iaYC0zgS+U3zh VrRMbeFYOlsMFjePges1pDRHxzZr5c7nWtBTKBOx9PctAc4hIjCJifuATI9kip9FOTpenZjaedu 6LIc= X-Google-Smtp-Source: AGHT+IGnzg2hDaZ2lVFGocJncR7soOdtnLL/Yc809zXi6ImqKmn+BDcRSWipzylZxh/jlIYcFDHDiw== X-Received: by 2002:a17:90b:1bc3:b0:2e0:7b03:1908 with SMTP id 98e67ed59e1d1-2e9b0a57d33mr14506762a91.10.1731252569648; Sun, 10 Nov 2024 07:29:29 -0800 (PST) Received: from localhost.localdomain ([198.8.77.157]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e99a5f935dsm9940973a91.35.2024.11.10.07.29.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Nov 2024 07:29:28 -0800 (PST) From: Jens Axboe To: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Cc: hannes@cmpxchg.org, clm@meta.com, linux-kernel@vger.kernel.org, willy@infradead.org, Jens Axboe Subject: [PATCH 11/15] mm: add FGP_UNCACHED folio creation flag Date: Sun, 10 Nov 2024 08:28:03 -0700 Message-ID: <20241110152906.1747545-12-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241110152906.1747545-1-axboe@kernel.dk> References: <20241110152906.1747545-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: B7D911C0014 X-Rspamd-Server: rspam11 X-Stat-Signature: erjjbgqwome6m5wifjxjawd3169m3np1 X-HE-Tag: 1731252553-108428 X-HE-Meta: U2FsdGVkX1+WBKvrwD4MUMZROEIGm2qCdu6SOv12UGPoNr6Lyb0+VRT4VPQrNxQv4O+jRAJ+BZ8X/WqyW+qoDhZ6YjPqTSmpGjNVToe2p859szGHikf1hX1N1WuI9Uizo66SwrWj0TWaRX0spKxoHIFfmmn+z5mDesSTExzVZxKfb3glfrNc2nccnrDMo5E1Q5iBb1yqzYC8V0k9uk/phNFPjuapcyGyKtspnrP89GOqGBjV4+R6NRVaUsDeLFxRMJV/GI9C9zzGdioXkeA2nmgMzeoBaSCeZPtoy3hRUspM1IQchfTO60RhnR8idtGXuY1ERgxpYTGTacHcgl5+KwcYztFuOF3sUiNk3zCrvkN0K04AEC6ouPX51/Grq04CCEiW5TX9dNDThBjfBYRPehoBuWQ2C8OMVYSSPqu6G5abFDl8JJ8sGqH1nzpwCN3VQkNIf6CPGFjMKxGovNtEi05jKBcmjLKhCw1ifji/fGgusjK1gb2GydA7Eeup1VqTUWiH5w2Sdew6vbwPeciL2vavWZzC76BzSCHM7VzISki25T5jTzsBIU3jOsOlWRAnFunMSkIr5mSc/FVdYUMxl2y2xoNhWD60rG1k2Bjn4TFEfMK3XXGPzWMaCCG3pfqmNZDnd5e4xNRva4+HyCsRR2RZdbF4dv7sdufRavfQ3q8/oabNOE2t370l+scsbPcibV9EXyVRqmejyhTYRO/Bedv+/dLYMEXLs7ZkL9+g1cS/QJV3AVsyqfLZ0O0JuWd2qianhYn3rn3s1bn/GL4V3akdhdlpTDSl9sRw49KcbE9ZijdxOhx293bJVhJ61iratWzY143h+DP9a4memLQKdAiBIAqDbseHTESpSc5oy9vY8N94toVi03Ww9dsZ5sAVdAYZOMTJdNlOmX/Ftib4iNhSY12rmVaAO3jjAD/uyG8sr/zDrcYZG+sRderOdznYU3Ey4/a/4a+okCiqbev h3rYOFww XS8TluMpFFnEUtfJf42p/13EwYjsALxUE/HKx+bCguvyyCffVQ/uSspsmLAMytme3he6r2MVtuMAXhna+O2QV/UdaMnbpkSkt1M5Adrn2p/l7N3JiAOuWSjrIpOSUHzPHFxl3YwE8Nsq3FCIEPqEe588BQIqn9+wmLORXzzJkVlRz6p5HlozHewp0jNtH6cEgi4AhlwTCMyoL4eeykEZ108Nnjjev2UL2UyKrNf5rMkQNiyroD/0EDIKgmitUy/bjHBAt+MU4so65qo7ueMNo4BJ21zCr173oViHCqukiJ1nTLyZpazM1x1L+UyW0H+4B8+5ED+eeFAoEphVe3+KMOKkHzDD1AJF8wVlz 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: Callers can pass this in for uncached folio creation, in which case if a folio is newly created it gets marked as uncached. If a folio exists for this index and lookup succeeds, then it will not get marked as uncached. Signed-off-by: Jens Axboe --- include/linux/pagemap.h | 2 ++ mm/filemap.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 5469664f66c3..de0ed906cd2d 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -741,6 +741,7 @@ pgoff_t page_cache_prev_miss(struct address_space *mapping, * * %FGP_NOFS - __GFP_FS will get cleared in gfp. * * %FGP_NOWAIT - Don't block on the folio lock. * * %FGP_STABLE - Wait for the folio to be stable (finished writeback) + * * %FGP_UNCACHED - Uncached buffered IO * * %FGP_WRITEBEGIN - The flags to use in a filesystem write_begin() * implementation. */ @@ -754,6 +755,7 @@ typedef unsigned int __bitwise fgf_t; #define FGP_NOWAIT ((__force fgf_t)0x00000020) #define FGP_FOR_MMAP ((__force fgf_t)0x00000040) #define FGP_STABLE ((__force fgf_t)0x00000080) +#define FGP_UNCACHED ((__force fgf_t)0x00000100) #define FGF_GET_ORDER(fgf) (((__force unsigned)fgf) >> 26) /* top 6 bits */ #define FGP_WRITEBEGIN (FGP_LOCK | FGP_WRITE | FGP_CREAT | FGP_STABLE) diff --git a/mm/filemap.c b/mm/filemap.c index cfbfc8b14b1f..4fdf3c4ae00f 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1987,6 +1987,8 @@ struct folio *__filemap_get_folio(struct address_space *mapping, pgoff_t index, /* Init accessed so avoid atomic mark_page_accessed later */ if (fgp_flags & FGP_ACCESSED) __folio_set_referenced(folio); + if (fgp_flags & FGP_UNCACHED) + __folio_set_uncached(folio); err = filemap_add_folio(mapping, folio, index, gfp); if (!err) From patchwork Sun Nov 10 15:28:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13869955 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 13F04D12D43 for ; Sun, 10 Nov 2024 15:29:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3838B6B00BD; Sun, 10 Nov 2024 10:29:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2E3056B00BE; Sun, 10 Nov 2024 10:29:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 137CD6B00BF; Sun, 10 Nov 2024 10:29:35 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id E1E5B6B00BD for ; Sun, 10 Nov 2024 10:29:34 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id AD533ACC8A for ; Sun, 10 Nov 2024 15:29:34 +0000 (UTC) X-FDA: 82770568398.25.B44DC56 Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) by imf09.hostedemail.com (Postfix) with ESMTP id 8FB85140007 for ; Sun, 10 Nov 2024 15:29:05 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=VQITK2h1; dmarc=none; spf=pass (imf09.hostedemail.com: domain of axboe@kernel.dk designates 209.85.216.41 as permitted sender) smtp.mailfrom=axboe@kernel.dk ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731252511; a=rsa-sha256; cv=none; b=pzNEWof75JKgtSMPfb6lDgtqJ1VoSKAbI/9quLVwrZFlTFikV6/uXS7ddUmLr2F5fevcVm Bp6/3IwfCfMgVidl1j0yvGdYG39+sfSpu4JqOlrNaKSqsH2+9e82az2mY9OWrEmVE42X2E pEXIkj/ST8i+bQq5JJeQZCA0+DmMs/M= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=VQITK2h1; dmarc=none; spf=pass (imf09.hostedemail.com: domain of axboe@kernel.dk designates 209.85.216.41 as permitted sender) smtp.mailfrom=axboe@kernel.dk ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731252511; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=TkS4Adcluut9E9TBSf0Q5Dr6BdVnPYdslAPkTGEhwiY=; b=w4nSLwvk6cEByHUmBNigWOVux0kr0v3WPty+3m0yuV4ojx/4Q9NAK/s8b2ueiLIeTWnS/O ZDvgcsK2x0WKlXFJkabYKwk+BgmTmMneYMkvL0OMqD8a9fH0Ffpnat0Pqdvrlg0rhp/eLj wC27zvUBaymzFZRWxRThyfnxoMvkhBQ= Received: by mail-pj1-f41.google.com with SMTP id 98e67ed59e1d1-2e2ed2230d8so3011832a91.0 for ; Sun, 10 Nov 2024 07:29:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1731252571; x=1731857371; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TkS4Adcluut9E9TBSf0Q5Dr6BdVnPYdslAPkTGEhwiY=; b=VQITK2h1zYEw2E/f39nYicyeA7rrcDBF2yb6qV4dIXTV17OhJcfLSq4P8thGYm4W/W QdnqBcIueSeZP6+owvB6efRKbnmdohurk4GIE0kzt+ZIhjYHzp8xuBefC2CYS7fLWSaC pBrJIpeC0SwcH86jagC9GFKpa2wzTgTU0zejQ/8knUe8mB4+yNK7wLsjfOJOIXsvuxnT Ie00EmNCOU2JveKNn5Q/m5v0Frdn3U57s4kMLM4WgbugKWn4kr8L8oH7P+e+/7/ndhq5 5/sCwgI4ZsWqePRuHRi2Vun6alMbNxgxi2aKzRHHQPDBetw6kVBwhsQHnYL5ZsuTfF6N gGQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731252571; x=1731857371; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TkS4Adcluut9E9TBSf0Q5Dr6BdVnPYdslAPkTGEhwiY=; b=YUPWv7syFv/Shl03XPwhJ/lAyNF76xKTMYn0WLq11RIkusO4hb/8qjCU2hDYaIquxb Cy57vRGrml5dAPs7w+l7rtAtnEgR16T5DMshtw8nV2U6vxv6GE79JKq3pSHuj5ktF1Zt TSCkbs4pr9HTNCzhcwB4KFzZNvUn+lTMLovRJnk0VFDhwJusDyldZv8PyjhZjPdegRdv 0ugz0SaYXZcDf9pFdjunMmkI+rSh7T4wpdVN4OOmqXZTmuL+tQSijmarzAMbhbzfAQN+ Iz7gst9JtoRf7RtDZ4RIG8OfvDCSKPSs8rTmDp34QUxyaeqS+Xzl0AyA1U0CGPtyKGp2 2Ecg== X-Gm-Message-State: AOJu0YwA+JRhmmX4iHsiuYM+t6CH8TH7pQi2ACCFDloKLn++lJZVzjsZ sa8RuzEfrbWOlHlWCaXB2FWrS0Y9qE6wgOYsKHS/BbZUxTwKmDx++2nbHRmTD1EPbGYsmvGLjnt 9DOo= X-Google-Smtp-Source: AGHT+IHRHbLBUb09CwGoIXN66uipNoc+nR4rS0OGfJWtMF1GUwRkiOluIK+uk59p6smvN8SFsh8EQg== X-Received: by 2002:a17:90b:2b8e:b0:2e2:b69c:2a9 with SMTP id 98e67ed59e1d1-2e9b1770362mr13736497a91.26.1731252571252; Sun, 10 Nov 2024 07:29:31 -0800 (PST) Received: from localhost.localdomain ([198.8.77.157]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e99a5f935dsm9940973a91.35.2024.11.10.07.29.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Nov 2024 07:29:30 -0800 (PST) From: Jens Axboe To: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Cc: hannes@cmpxchg.org, clm@meta.com, linux-kernel@vger.kernel.org, willy@infradead.org, Jens Axboe Subject: [PATCH 12/15] ext4: add RWF_UNCACHED write support Date: Sun, 10 Nov 2024 08:28:04 -0700 Message-ID: <20241110152906.1747545-13-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241110152906.1747545-1-axboe@kernel.dk> References: <20241110152906.1747545-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 8FB85140007 X-Rspamd-Server: rspam01 X-Stat-Signature: f1cfgaxj1tdwikxiqu15o4nc6xw68g8e X-HE-Tag: 1731252545-2805 X-HE-Meta: U2FsdGVkX1+kYk5o12FWpLuKWBCrMB7OBvJ4HPjmfvuVrIA1XnHtexe/cheaGTjFFCg0gOwKtSk92aMjT+vO6TCrrRVIyaykpcgtHrqG4eR/1YharS2pXtg033Hm0Bf30778YjVOeMyxEkLCHNBjYV5Uuo9gwo1kwKDf2AJ8d8O1i9mRlqRamJ1XCl3jfGH9MvR6Fg7txLyMxKdqIkReLYrcDTu5Vtj6QUJAkEhDuIDtIWUZ3dXI1lBbWoPbpzTHk0b2piu11fz2HoRY69tR80DquCzZOyH2zbegMLjV4ZNmZXUOPvo4v8B68CKFV0jgHFjvzgPf4VNAmdmA32tpgSexwZoE1u6Equ5uOX9EGk5a752Oo6fYwxcH6wm3sLVUNzh7tonavW1fZ3SCsK0aI8JinyTVUVh/FiYSCFSpRKJsCXN85FivJeNhZQzm4ojLcLUiUj3VRvXdQNAQkOOliHKrZG38Y+/KcUSTipSs30O+dDiT81tTlwTQy0N5Si/QNGbCWq9AAUG+cOZwMG730qBm/1wEZcs24PkkfQZvwjn4w3rH2F0SpGSvFFQmMLPc8DZ3bRQ/FBSi88/15q5AFcOFzCFDy7qaz9sBTWYTjIkuewRiNEwJFlYEbjDmWVtnKRhQNN3oPE1SH3ACr8wCAySASnO/QdAqxAyJRW4ZdQjROPlHdczXhAP/Eha3PsJo5MvSJx4PqYCYgHpR4BsmYtnGxc82KwzS2WVy+Xny2N/zs9Uebgvz8TNGHDe6vdyxik9SEyJ6XMqWSZygGFRCIQ1ktE3oLuZNfa8KeTUafo7689LH98wvqP7CxIwlLGMhPCL2ZMpWsPCMH+zx7DG+5PStkLJHdI9cRnv+yy4nESZBRcUgJMguHlWiEMbBznEbNB/kwDMMHpCYDxYkzf/Dm5dpUilYikMfua/9EnyPLsl8oDjPuVe4aU9NamRUEp7LQMWqLk4vrTCAlRp8ApB aAtw4dWa 0AKuPL0NnHfFwfmgMhnpMyV66SNWvZjkcFTiTJXzv/0olwWmQK9CFh5Tzb8HJRuTnViV9moizZP4e3SaIfb6zWtuNd9KEDf7EVoD2KpNl9F9rsHcxtpt7/NymECn8ujGhzw3YEsBYvE3PRT/qos5Vex7FbbVJKRkQ8KQi/rbrkeAdbcJzHNtEDdIe1IUML9ciT5IJML2YZQ8kE+4n20rrIThIV6K+sASIlFfX+a0o+BBU5z6Nd51t+pSnHf0IhOWrjTSwi0+TsRv1B44sxSyzmo3xOmz4ufX65hSjCv122RgzhYihH//mkctTWWrtUVht80Z0fjAmYmt0P7WYvFqZWhLqKI7LdWNMCydW 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: IOCB_UNCACHED IO needs to prune writeback regions on IO completion, and hence need the worker punt that ext4 also does for unwritten extents. Add an io_end flag to manage that. If foliop is set to foliop_uncached in ext4_write_begin(), then set FGP_UNCACHED so that __filemap_get_folio() will mark newly created folios as uncached. That in turn will make writeback completion drop these ranges from the page cache. Now that ext4 supports both uncached reads and writes, add the fop_flag FOP_UNCACHED to enable it. Signed-off-by: Jens Axboe --- fs/ext4/ext4.h | 1 + fs/ext4/file.c | 2 +- fs/ext4/inline.c | 7 ++++++- fs/ext4/inode.c | 18 ++++++++++++++++-- fs/ext4/page-io.c | 28 ++++++++++++++++------------ 5 files changed, 40 insertions(+), 16 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 44b0d418143c..60dc9ffae076 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -279,6 +279,7 @@ struct ext4_system_blocks { * Flags for ext4_io_end->flags */ #define EXT4_IO_END_UNWRITTEN 0x0001 +#define EXT4_IO_UNCACHED 0x0002 struct ext4_io_end_vec { struct list_head list; /* list of io_end_vec */ diff --git a/fs/ext4/file.c b/fs/ext4/file.c index f14aed14b9cf..0ef39d738598 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -944,7 +944,7 @@ const struct file_operations ext4_file_operations = { .splice_write = iter_file_splice_write, .fallocate = ext4_fallocate, .fop_flags = FOP_MMAP_SYNC | FOP_BUFFER_RASYNC | - FOP_DIO_PARALLEL_WRITE, + FOP_DIO_PARALLEL_WRITE | FOP_UNCACHED, }; const struct inode_operations ext4_file_inode_operations = { diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c index 3536ca7e4fcc..4089d0744164 100644 --- a/fs/ext4/inline.c +++ b/fs/ext4/inline.c @@ -667,6 +667,7 @@ int ext4_try_to_write_inline_data(struct address_space *mapping, handle_t *handle; struct folio *folio; struct ext4_iloc iloc; + fgf_t fgp_flags; if (pos + len > ext4_get_max_inline_size(inode)) goto convert; @@ -702,7 +703,11 @@ int ext4_try_to_write_inline_data(struct address_space *mapping, if (ret) goto out; - folio = __filemap_get_folio(mapping, 0, FGP_WRITEBEGIN | FGP_NOFS, + fgp_flags = FGP_WRITEBEGIN | FGP_NOFS; + if (*foliop == foliop_uncached) + fgp_flags |= FGP_UNCACHED; + + folio = __filemap_get_folio(mapping, 0, fgp_flags, mapping_gfp_mask(mapping)); if (IS_ERR(folio)) { ret = PTR_ERR(folio); diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 54bdd4884fe6..afae3ab64c9e 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -1138,6 +1138,7 @@ static int ext4_write_begin(struct file *file, struct address_space *mapping, int ret, needed_blocks; handle_t *handle; int retries = 0; + fgf_t fgp_flags; struct folio *folio; pgoff_t index; unsigned from, to; @@ -1164,6 +1165,15 @@ static int ext4_write_begin(struct file *file, struct address_space *mapping, return 0; } + /* + * Set FGP_WRITEBEGIN, and FGP_UNCACHED if foliop contains + * foliop_uncached. That's how generic_perform_write() informs us + * that this is an uncached write. + */ + fgp_flags = FGP_WRITEBEGIN; + if (*foliop == foliop_uncached) + fgp_flags |= FGP_UNCACHED; + /* * __filemap_get_folio() can take a long time if the * system is thrashing due to memory pressure, or if the folio @@ -1172,7 +1182,7 @@ static int ext4_write_begin(struct file *file, struct address_space *mapping, * the folio (if needed) without using GFP_NOFS. */ retry_grab: - folio = __filemap_get_folio(mapping, index, FGP_WRITEBEGIN, + folio = __filemap_get_folio(mapping, index, fgp_flags, mapping_gfp_mask(mapping)); if (IS_ERR(folio)) return PTR_ERR(folio); @@ -2903,6 +2913,7 @@ static int ext4_da_write_begin(struct file *file, struct address_space *mapping, struct folio *folio; pgoff_t index; struct inode *inode = mapping->host; + fgf_t fgp_flags; if (unlikely(ext4_forced_shutdown(inode->i_sb))) return -EIO; @@ -2926,8 +2937,11 @@ static int ext4_da_write_begin(struct file *file, struct address_space *mapping, return 0; } + fgp_flags = FGP_WRITEBEGIN; + if (*foliop == foliop_uncached) + fgp_flags |= FGP_UNCACHED; retry: - folio = __filemap_get_folio(mapping, index, FGP_WRITEBEGIN, + folio = __filemap_get_folio(mapping, index, fgp_flags, mapping_gfp_mask(mapping)); if (IS_ERR(folio)) return PTR_ERR(folio); diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c index ad5543866d21..10447c3c4ff1 100644 --- a/fs/ext4/page-io.c +++ b/fs/ext4/page-io.c @@ -226,8 +226,6 @@ static void ext4_add_complete_io(ext4_io_end_t *io_end) unsigned long flags; /* Only reserved conversions from writeback should enter here */ - WARN_ON(!(io_end->flag & EXT4_IO_END_UNWRITTEN)); - WARN_ON(!io_end->handle && sbi->s_journal); spin_lock_irqsave(&ei->i_completed_io_lock, flags); wq = sbi->rsv_conversion_wq; if (list_empty(&ei->i_rsv_conversion_list)) @@ -252,7 +250,7 @@ static int ext4_do_flush_completed_IO(struct inode *inode, while (!list_empty(&unwritten)) { io_end = list_entry(unwritten.next, ext4_io_end_t, list); - BUG_ON(!(io_end->flag & EXT4_IO_END_UNWRITTEN)); + BUG_ON(!(io_end->flag & (EXT4_IO_END_UNWRITTEN|EXT4_IO_UNCACHED))); list_del_init(&io_end->list); err = ext4_end_io_end(io_end); @@ -287,14 +285,15 @@ ext4_io_end_t *ext4_init_io_end(struct inode *inode, gfp_t flags) void ext4_put_io_end_defer(ext4_io_end_t *io_end) { - if (refcount_dec_and_test(&io_end->count)) { - if (!(io_end->flag & EXT4_IO_END_UNWRITTEN) || - list_empty(&io_end->list_vec)) { - ext4_release_io_end(io_end); - return; - } - ext4_add_complete_io(io_end); + if (!refcount_dec_and_test(&io_end->count)) + return; + if ((!(io_end->flag & EXT4_IO_END_UNWRITTEN) || + list_empty(&io_end->list_vec)) && + !(io_end->flag & EXT4_IO_UNCACHED)) { + ext4_release_io_end(io_end); + return; } + ext4_add_complete_io(io_end); } int ext4_put_io_end(ext4_io_end_t *io_end) @@ -348,7 +347,7 @@ static void ext4_end_bio(struct bio *bio) blk_status_to_errno(bio->bi_status)); } - if (io_end->flag & EXT4_IO_END_UNWRITTEN) { + if (io_end->flag & (EXT4_IO_END_UNWRITTEN|EXT4_IO_UNCACHED)) { /* * Link bio into list hanging from io_end. We have to do it * atomically as bio completions can be racing against each @@ -417,8 +416,13 @@ static void io_submit_add_bh(struct ext4_io_submit *io, submit_and_retry: ext4_io_submit(io); } - if (io->io_bio == NULL) + if (io->io_bio == NULL) { io_submit_init_bio(io, bh); + if (folio_test_uncached(folio)) { + ext4_io_end_t *io_end = io->io_bio->bi_private; + io_end->flag |= EXT4_IO_UNCACHED; + } + } if (!bio_add_folio(io->io_bio, io_folio, bh->b_size, bh_offset(bh))) goto submit_and_retry; wbc_account_cgroup_owner(io->io_wbc, &folio->page, bh->b_size); From patchwork Sun Nov 10 15:28:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13869956 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 2BE2AD12D43 for ; Sun, 10 Nov 2024 15:29:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A88146B00BE; Sun, 10 Nov 2024 10:29:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9EC0F6B00BF; Sun, 10 Nov 2024 10:29:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 83B286B00C0; Sun, 10 Nov 2024 10:29:36 -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 609036B00BE for ; Sun, 10 Nov 2024 10:29:36 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 139DE413D7 for ; Sun, 10 Nov 2024 15:29:36 +0000 (UTC) X-FDA: 82770569112.18.BABC0E3 Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) by imf12.hostedemail.com (Postfix) with ESMTP id 6729840008 for ; Sun, 10 Nov 2024 15:29:16 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=zy+fsDul; spf=pass (imf12.hostedemail.com: domain of axboe@kernel.dk designates 209.85.210.173 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731252344; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=QHHnA1NsQjr1van9cnJ+PQRWRXhY+a6ETIPA3kXFfjk=; b=naCIA3pJVSTUZiTP3aV901E0vLAYBym6oHyoOAlFcR6+sSBJTJNWu6WcRsYUfJrRo1FY8b I7M+zJynQMgf9S8op2sMC4xQlBxNGHWTw0hZ5CsZoJIgRLizrbaa0VH8qN1pY4lmXnn68g 8dGtuLtyaBtoYqd6lhpE3Eie6iBVbQA= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=zy+fsDul; spf=pass (imf12.hostedemail.com: domain of axboe@kernel.dk designates 209.85.210.173 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731252344; a=rsa-sha256; cv=none; b=yOlrqvLaFsoefhBH8mJxFz0+ix9sCjVTL3W/TNlR0G+pBfv+s9ODsb0HKwjqmnhUgt6Mx3 CHKL/E4yBUdXEtNECLrrNKC3WSGNH2inlTpOomHw9w5qnYwIZnCSnSitv5iYlNCwJ/6Vx1 5imsGEUPBW7KH5OOXKhM4kuc9AXmtC4= Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-720aa3dbda5so2658078b3a.1 for ; Sun, 10 Nov 2024 07:29:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1731252572; x=1731857372; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QHHnA1NsQjr1van9cnJ+PQRWRXhY+a6ETIPA3kXFfjk=; b=zy+fsDulDDNNSuO0+XDG7cy99Bf3eUs3kBi/uab5+p4p+VI7lceYoVgFetfHQCvBuO gp+BOHH+UHEQ1eqjIZAJWH3RqvII94ss6hwqC5GorG7aREH6/aLsygrSF0wR4DPfoNpd tcP4kyG6i/YSM3qKWRowtW3XRb1Vg0b6i7kwAU+Phd1Ic2owOEB6l6XOzcb3C30N2TU3 HxaiIqlC/ZkwccaoXFZ06vaBJMR1bf4Q8qPh4Nl0pqIYBw1mt1MSZ1587lQ4mHW26uLt ADNwCfDcaO1myupT6egho/jLWoqJQ7Ukb6vxTq2hePauuZMx3eqHuL0zmW1SRhRC/PBB troQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731252572; x=1731857372; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QHHnA1NsQjr1van9cnJ+PQRWRXhY+a6ETIPA3kXFfjk=; b=vYNZzygM1239/jSSbYFB9GtqbnovO6rN0BmayPZjOrT4BinM0+7nbXJsJP/rvslstf zlRtWIkMTyYFzrIVsRr0zQqBBLPji2moO+rPb5/2zNTcLoArQvMIfHmMvY3PKrK50Jgn Xfxu6/Mhi3lvoSGL40r6kjRQA5bAQF8FYcRsR9C6wAAgx1mx+MMdgQQvp8oAN8JTadxP BIfZFe6imzexHYj+jCUb80Y50n4qGPuXRWJkm9IlYw8gadpABs9gPwOKzbkdv2VQbgyg cqX59HdOZYKyw+KFMHCeh7RbIVhvnSxJmFlaZAOLlLB0soU9wbEGnLgwvTWDQYDw2J3y /WXQ== X-Gm-Message-State: AOJu0Yz5e7YAkcdEF58lYPqK/9fHF9PYF9G4lmiDAeEiv/X6WtqNXlZa uo21uDnZ/HH6mYCxhaV5nPfP3LUwIe5kgRXkqdA5RXdL9uIl0z5GCUcScPBWVMKTuVGpYt15ds1 cklc= X-Google-Smtp-Source: AGHT+IHV0wAiD3bQchKcabbTvXh2pU9AbMQUOshna304t+XB0bKs6GgV7ufQgRJwzKJwVoPNWeBA0A== X-Received: by 2002:a17:90a:e7c1:b0:2da:9115:15ce with SMTP id 98e67ed59e1d1-2e9b1682714mr12810753a91.15.1731252572603; Sun, 10 Nov 2024 07:29:32 -0800 (PST) Received: from localhost.localdomain ([198.8.77.157]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e99a5f935dsm9940973a91.35.2024.11.10.07.29.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Nov 2024 07:29:31 -0800 (PST) From: Jens Axboe To: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Cc: hannes@cmpxchg.org, clm@meta.com, linux-kernel@vger.kernel.org, willy@infradead.org, Jens Axboe Subject: [PATCH 13/15] iomap: make buffered writes work with RWF_UNCACHED Date: Sun, 10 Nov 2024 08:28:05 -0700 Message-ID: <20241110152906.1747545-14-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241110152906.1747545-1-axboe@kernel.dk> References: <20241110152906.1747545-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 6729840008 X-Stat-Signature: ngbf5wt7gjx7fcx9pwoo9ogm1bmenmkg X-Rspam-User: X-HE-Tag: 1731252556-19039 X-HE-Meta: U2FsdGVkX1/j2VoO6hltxc5XMWdHgE1f99qmqGQneXXPlOynkBpIXI2SszHTwZJU2RSjfq9k9CNvBjzTBky93M8Vf4CHbB70wD4FNey7AZfMURL95CQY7+YQ4cURSH9JU3eOtIAfxbCdfonLARcCeZ2b9ku2EnQ0hDfu8uLwOh64bQ46XbzzsetFX0ESYlb+cxkDehmKGCQqXlhBNJH1M2RgX7TLg9YRWqTW+cRlP2bRI3GHInXfJbFTX6ctUBz81QMW8hZhlzhEG5+NKjJkuRTPSIDWveY+eTfywJSLZe1NS4qXZzCFw1mgwidRSaHPfFSuMOZijqEVcC3GgyaO74CypdxBXfZyWXEIhbwYPsCKMgaeYG2wSpHs9pPU29WObJlVzLsWNm00xPsgyKC5qK9fd0muVh2Xwe/QtjrPFU4mZQixbW//IgBOYgszJzlLERM22c2UCp6VW1a0Bft6CEnz2ulYC5UNCj9SWlrHKG2qzuSkcG8xKUbZFYcOUt3grvIosFdvN1lh/ZavmcqQpa/G3j6fhPmDNtuVBM6L6AyWnr1SaU0M6AgqKdLRYtUlV3RXVM9ocFfKZ2JWhK48k3CAMiVqf9MYl5T+5D7Zr4xQRndCIozHO29WA8kiGEozulzd+OwPAxaLeBXLDO6bPcgzFivy6H6F3niPmFfxenu0PoTLF99h/wSPxAXhliP7Vm9HxD5ROQ5/RSc/H1A08oarR/c2JhBaNHCeWZ+B9HJy7+OtfpFqb+a9tZEelD9R08z1mciOUXwbmLjAIEFA/y4oiRpufifDRb23fpMu1yrN/3h2dA60wx33zaMd/ebkyFpLuvkjSTYn4c1bypojcQR9BdxPkZS7vjQA8tXHpXrCkpORl4Nq2YyKYsyB2Jxct6WXGjLbDt4wpSCnW5IAweItgtCQJOP6uCyL09Gz5lzai26aDc6hsVWWNOVqS0I5fT/qUCsBEnlBal17PND /J+2BUkR Xh6l6FQwTnj2ynfvy9I1NlIwNoj7d5P/x9Ow1sg00SYXUN9bQ8G5SL2oaOljSZWw1aWCwnEHSZmhcxdGTp1FWHCPqMIi69B/L/ZJABHErH2Yap9L3FUTjQjKagNaOaqP4HxjOPc7tOTi6LF6bK0FeVh9RLA79Keqh35XZ80gEAY2K/2EqN1F1w8BGQdfvlEZkIyoN/okkRpir+xHd4Q45bkMmuF975aKg8Ronsta2IADVowrCW/Haq5bbNqPmXmJJVjG91pv4/3JxDpndhNpvvCTkXFgFWifhYs/tnyjF57gCx7FuvskkT7Y3EyjOBTMf2DSZQg/G5B9Rk+DOkAqbi5JSEZCPRUdxzbYt 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: Add iomap buffered write support for RWF_UNCACHED. If RWF_UNCACHED is set for a write, mark the folios being written with drop_writeback. Then writeback completion will drop the pages. The write_iter handler simply kicks off writeback for the pages, and writeback completion will take care of the rest. This still needs the user of the iomap buffered write helpers to call iocb_uncached_write() upon successful issue of the writes. Signed-off-by: Jens Axboe --- fs/iomap/buffered-io.c | 15 +++++++++++++-- include/linux/iomap.h | 4 +++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index ef0b68bccbb6..2f2a5db04a68 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -603,6 +603,8 @@ struct folio *iomap_get_folio(struct iomap_iter *iter, loff_t pos, size_t len) if (iter->flags & IOMAP_NOWAIT) fgp |= FGP_NOWAIT; + if (iter->flags & IOMAP_UNCACHED) + fgp |= FGP_UNCACHED; fgp |= fgf_set_order(len); return __filemap_get_folio(iter->inode->i_mapping, pos >> PAGE_SHIFT, @@ -1023,8 +1025,9 @@ ssize_t iomap_file_buffered_write(struct kiocb *iocb, struct iov_iter *i, const struct iomap_ops *ops, void *private) { + struct address_space *mapping = iocb->ki_filp->f_mapping; struct iomap_iter iter = { - .inode = iocb->ki_filp->f_mapping->host, + .inode = mapping->host, .pos = iocb->ki_pos, .len = iov_iter_count(i), .flags = IOMAP_WRITE, @@ -1034,9 +1037,14 @@ iomap_file_buffered_write(struct kiocb *iocb, struct iov_iter *i, if (iocb->ki_flags & IOCB_NOWAIT) iter.flags |= IOMAP_NOWAIT; + if (iocb->ki_flags & IOCB_UNCACHED) + iter.flags |= IOMAP_UNCACHED; - while ((ret = iomap_iter(&iter, ops)) > 0) + while ((ret = iomap_iter(&iter, ops)) > 0) { + if (iocb->ki_flags & IOCB_UNCACHED) + iter.iomap.flags |= IOMAP_F_UNCACHED; iter.processed = iomap_write_iter(&iter, i); + } if (unlikely(iter.pos == iocb->ki_pos)) return ret; @@ -1770,6 +1778,9 @@ static int iomap_add_to_ioend(struct iomap_writepage_ctx *wpc, size_t poff = offset_in_folio(folio, pos); int error; + if (folio_test_uncached(folio)) + wpc->iomap.flags |= IOMAP_F_UNCACHED; + if (!wpc->ioend || !iomap_can_add_to_ioend(wpc, pos)) { new_ioend: error = iomap_submit_ioend(wpc, 0); diff --git a/include/linux/iomap.h b/include/linux/iomap.h index f61407e3b121..2efc72df19a2 100644 --- a/include/linux/iomap.h +++ b/include/linux/iomap.h @@ -64,6 +64,7 @@ struct vm_fault; #define IOMAP_F_BUFFER_HEAD 0 #endif /* CONFIG_BUFFER_HEAD */ #define IOMAP_F_XATTR (1U << 5) +#define IOMAP_F_UNCACHED (1U << 6) /* * Flags set by the core iomap code during operations: @@ -173,8 +174,9 @@ struct iomap_folio_ops { #define IOMAP_NOWAIT (1 << 5) /* do not block */ #define IOMAP_OVERWRITE_ONLY (1 << 6) /* only pure overwrites allowed */ #define IOMAP_UNSHARE (1 << 7) /* unshare_file_range */ +#define IOMAP_UNCACHED (1 << 8) /* uncached IO */ #ifdef CONFIG_FS_DAX -#define IOMAP_DAX (1 << 8) /* DAX mapping */ +#define IOMAP_DAX (1 << 9) /* DAX mapping */ #else #define IOMAP_DAX 0 #endif /* CONFIG_FS_DAX */ From patchwork Sun Nov 10 15:28:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13869957 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 449ADD12D43 for ; Sun, 10 Nov 2024 15:29:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 61BEB6B00C0; Sun, 10 Nov 2024 10:29:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5CBE36B00C1; Sun, 10 Nov 2024 10:29:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 444A06B00C2; Sun, 10 Nov 2024 10:29:38 -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 1F3B66B00C0 for ; Sun, 10 Nov 2024 10:29:38 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id CAA43807EE for ; Sun, 10 Nov 2024 15:29:37 +0000 (UTC) X-FDA: 82770569070.15.8E23A28 Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) by imf07.hostedemail.com (Postfix) with ESMTP id A3F4A40005 for ; Sun, 10 Nov 2024 15:28:40 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=1fYMogBX; spf=pass (imf07.hostedemail.com: domain of axboe@kernel.dk designates 209.85.215.177 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731252404; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=LL88Qd2tMlsmBvcuEyGfQPoq7EBSjG4mmD1oB3CTmL4=; b=H4KVtCs8jc025ohUs8z9nvnc+7yIjmEAKacqhavuQbKnF3u+P8pqDVVg75EhAzCBwqrb1N WRXOakOJ4Dp9AekCls0FPky6uGg3Z7FffJ1dHHbIzn99SWYvtQeQEDh4Ik9NdvCA+fWvYc 3OOx2tLS6KjsVCdFrt5fp0XRAIpul8w= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=1fYMogBX; spf=pass (imf07.hostedemail.com: domain of axboe@kernel.dk designates 209.85.215.177 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731252405; a=rsa-sha256; cv=none; b=5BKNvh7oxqcsM95gQbRQIBu6bChmD2/xwcmZaOPjINfTQKdgJ36QbF4yzrZ7jhNcoIr7v3 MlvGfMtVPVAcyz9/ZL+kU6XG3ZDqDbkv4zHgMRcjwhE7YVpsVpsTm/6W+gizR3XhtmCbp/ toR84Wx2UYWZbE1SV4JpKkthdrsKz08= Received: by mail-pg1-f177.google.com with SMTP id 41be03b00d2f7-7eb0bc007edso1952400a12.3 for ; Sun, 10 Nov 2024 07:29:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1731252574; x=1731857374; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LL88Qd2tMlsmBvcuEyGfQPoq7EBSjG4mmD1oB3CTmL4=; b=1fYMogBXVAxHN3slM9IWZefFoHG+T6LDYbFl/nRiQtp0nc0yOAcaS61CZ+j0zg+uTG DF7FDy7V1Fi3gYw/g67v3cDXd/G7S7NX8zP9xaZT4qC9xpUXXOjrjBYXqakuxKoF5k51 Ix+0eY/NWIJMSp/deJ2baO3o8Z8BYNbfqhsz6vWGkiWZLUpY/hktfN2Nt938e6Gpc9uw S+7deCWAfj4S2ERqgrpBEohz+kjqR8JVG9Mgl82mfZuiLUd+FkdSm+SuyGnhduceoec0 2kiaOYIvKR7EKs+yD2lpqNAHpnHvGmzeWn141zsQh6bVZm/s7oBslDAgYGtPBFg1FRFt lyNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731252574; x=1731857374; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LL88Qd2tMlsmBvcuEyGfQPoq7EBSjG4mmD1oB3CTmL4=; b=kwLkaJOul7SigOAke9gyiWkUlHOJ2XUGYsRF/ruQlc5bmv/Qx84F2jv93oKcdb+sui bgexXWpbi0lv/14Ip8tGi3xfFonpoPSvKBlakvWrZKMN3N6C2/jXZXERygfMXFZRvnsd poVNobzfFYEke4K3yi2zqE6hlFwL3f01kuR5ty69L6vkfJ7LcMGeUkwPWc8n+twSTH8E NmwVc4bu9uQDp2dDxlraPnSBEj3jMjWXF1N/kw6DYIUydNrxPYWaM2WRmbpaLtPuN2dV 9XVLJWup0iA66J1nj6HaEBaajDfafI2J21X9sFZxq/hw98j7NMT9epHFUynOdSeKsudk Zv+Q== X-Gm-Message-State: AOJu0YzgyzCNzEHzIFWI/O+SIWLA41Ny2C8J5AtIe3goxTn2BpLCEKoY dK6s+DbpQI6GhGuECRnuGOgO9i23kN5Ej82SPF57Vc6AJC2oNGyuRVyfCEx7djcM/nQBRQwsOlJ 8Aok= X-Google-Smtp-Source: AGHT+IGDHhrWZvwz3+S2z66PgLKGWEEUzZeIBjMPJzYATyn0eBE8Y9PpfOEANie1fvuwvTvVxNqbng== X-Received: by 2002:a17:90b:38ce:b0:2e2:d15c:1a24 with SMTP id 98e67ed59e1d1-2e9b174113cmr12568464a91.23.1731252574323; Sun, 10 Nov 2024 07:29:34 -0800 (PST) Received: from localhost.localdomain ([198.8.77.157]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e99a5f935dsm9940973a91.35.2024.11.10.07.29.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Nov 2024 07:29:33 -0800 (PST) From: Jens Axboe To: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Cc: hannes@cmpxchg.org, clm@meta.com, linux-kernel@vger.kernel.org, willy@infradead.org, Jens Axboe Subject: [PATCH 14/15] xfs: punt uncached write completions to the completion wq Date: Sun, 10 Nov 2024 08:28:06 -0700 Message-ID: <20241110152906.1747545-15-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241110152906.1747545-1-axboe@kernel.dk> References: <20241110152906.1747545-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: A3F4A40005 X-Stat-Signature: cfyhkajz8pdcup8dueghqp8n3g3zjnh7 X-Rspam-User: X-HE-Tag: 1731252520-794031 X-HE-Meta: U2FsdGVkX1/oLxwbkQQ2JdOZDH74bbEsg/odeJ3mar9T+ymmI6w6yfCYl5FHAuLMGViV09qXx+MHp6M4+ST2rSNmziLltrnj54hf88KgK08FcT4ogDUrudWSffzV+NE+OyfuO9Y6ZZy9fMbQpPWb5lOwMR6Kb+rgZY8WePAE33BGo0bB6U5OnVQv3C3jDJ42kzAugXUMwJ4gpmpBzAxSLAon+o8X/SWdduh2hN2nbGu83sAo1tuhKIt/DnCrH7RTS2X3LOnwqNJNt6QpehvGv2M1YasFclGKZIpOeUn1TZRtR0gcvNJIKPfS1xFUPIJxb0bm0T58fFDuSvP1mgSRnNkBa90inHbWSOy1/tkM7SHO+HWK6yJbfxy+om+6lNTo8qCdkS+RU2HeNt9mYhbbkWDevbViHIYgHsx2T4X/jCKRLD1MHPgkO0E0DwLOaYyf0g6X1sz8FP4LOrgS6lxN2PZQkEQuiHf3YhNbnmEukQ/WM1tHdA4klWjaPffIl7aV+kKxWj/4h9tgeLs/JrTT/FafxL7S3H71f+Xx5NsM2rpbID4cly3GfiUZELtMPyDZnsl/bqKv6Er86t+efKSiA1ezhkKzztRr0rZhTpwnaOmcwIF8eTTOVRuv6Ic2cTn4CzxWOLENgt/7abp7i4XYMA9koDkw+A+X56YXNKH1uFIrtHfxMTS4WpBumFC1lnNCueOtKZR6Bpe01QBHbKVNfr11Z48us/0DDR2fO4rmpHHBtJ5xSz7RA1yGOEL0BxMMYq3NsMq0lOuWvtexTfVYDW0tQurLEaONz8Ym8S4z0ar9oby7ruJE5lDqQ+HnVxH0qY9iDh+MX1AI/lKJc5UmYUFLivisSqP6gfW5QwHOEM3mYejBWCBT0SwcYR2SIA0O9CIzyscXgxX0ruLifSEEWAlKSDkal4sXN+5frT+v7i/lGsvXiAmYjMH1vmMm21/Hrv4yExSiTmW733ihz8i R/hp9+2i hI4a4kxCwnV/ELIV8sz8D36oj/+oehReZ5434OZ4C0ZxMFBWWXb0WJuXF2J76dUPrR5AqsW2VkHAXmWwTRKyU5m0VooD3Qha499f1ryZ78mSXpDhat178pfm97H8MvrqBFTZdXTTdwHNOseV42gg1m2QpT0Yl8f+A2pH25EpBUemvEzFHqgTADXmgVwGu5QplCfidp8qWI7rbKnSocWbyylMhz6B2Eu+RUYzrKMgB98AERUUTHwzY3eCmuv/tau+0jAunI2gARMj/EvHHdGuBUhJSZanCfhdfMv/uf9s+Lpv3GYenmW9RrJdYKe3xcaflA26UARSerS68K8g= X-Bogosity: Ham, tests=bogofilter, spamicity=0.016598, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: They need non-irq context guaranteed, to be able to prune ranges from the page cache. Treat them like unwritten extents and punt them to the completion workqueue. Signed-off-by: Jens Axboe --- fs/xfs/xfs_aops.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c index 559a3a577097..c86fc2b8f344 100644 --- a/fs/xfs/xfs_aops.c +++ b/fs/xfs/xfs_aops.c @@ -416,9 +416,12 @@ xfs_prepare_ioend( memalloc_nofs_restore(nofs_flag); - /* send ioends that might require a transaction to the completion wq */ + /* + * Send ioends that might require a transaction or need blocking + * context to the completion wq + */ if (xfs_ioend_is_append(ioend) || ioend->io_type == IOMAP_UNWRITTEN || - (ioend->io_flags & IOMAP_F_SHARED)) + (ioend->io_flags & (IOMAP_F_SHARED|IOMAP_F_UNCACHED))) ioend->io_bio.bi_end_io = xfs_end_bio; return status; } From patchwork Sun Nov 10 15:28:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13869958 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 745DED12D43 for ; Sun, 10 Nov 2024 15:29:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B73A36B00C2; Sun, 10 Nov 2024 10:29:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AD62C6B00C3; Sun, 10 Nov 2024 10:29:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 958F46B00C4; Sun, 10 Nov 2024 10:29:39 -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 6C1D36B00C2 for ; Sun, 10 Nov 2024 10:29:39 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 2FE351A0CF9 for ; Sun, 10 Nov 2024 15:29:39 +0000 (UTC) X-FDA: 82770568062.03.8F6CB08 Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) by imf17.hostedemail.com (Postfix) with ESMTP id 1352A4000D for ; Sun, 10 Nov 2024 15:29:06 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=E65yYVCn; spf=pass (imf17.hostedemail.com: domain of axboe@kernel.dk designates 209.85.216.51 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731252406; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ieWCO7ZvnQOESu0rOvKqnHS1oC/GZ0fSczrbrfzlBys=; b=UOFPioBMfFwiULfX2CgCROzzq0T9+46LQQmjqPU1X3SA0jqRFnUtmT1NG+j12V0xvwNQ9W UFmvyJDcIlnaEXWp8q6OwFeOke5dZ/EmWTx3GFb+GXt6n2nsYSA2L6hCOECKlWUzZJny3G Rv00TY0U+uzmduxfqxNckcvbzJe/9f0= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=E65yYVCn; spf=pass (imf17.hostedemail.com: domain of axboe@kernel.dk designates 209.85.216.51 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731252406; a=rsa-sha256; cv=none; b=mpN4AoOERER7kkD5rGbs8ahMZBaxKz+vDaLVVupqw1HI5bgrR8InPbkMFJMMtS6TN24Y36 BtIoYTDZc4QtI5wLk14ElnZjXRw01q4YMpAPwgiz52/o15e6qEFx1D972qW/+xJOMbkoP7 VtJb2qZF/pDGZHjeDeAUXELXnRoQGSk= Received: by mail-pj1-f51.google.com with SMTP id 98e67ed59e1d1-2e2eb9dde40so3037535a91.0 for ; Sun, 10 Nov 2024 07:29:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1731252576; x=1731857376; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ieWCO7ZvnQOESu0rOvKqnHS1oC/GZ0fSczrbrfzlBys=; b=E65yYVCnPHaYjYncZnOvxSZUd1iJBf4fE/JmpdjLnHQJ42JwM5/Ojxnv0yCV2TsqLy NE7g8QV7VBKvbFYSGBdgILHgh/u/+mX6hjRtr9RiEJy8gaxtbEq76OD3GpnmerdMGocS 9OmapmmGXH1D/Vaz18UkbtdlQcDcCjScCkJlD7YjN1SV6L6neun2puU5Gy3hvYf+uBrf B6fxTXYCMCpI59tnoM+RDgf7n57IEfDYx58QVMczeECNFdjp/xwLlOMVH77pXomBYziM owDfbB9hQg5yaN32wLuWOJ+PIcA0grRAwxzz+KQQFYnxSM2PiLVHPIKP9NBsYQIDGL6n g4sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731252576; x=1731857376; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ieWCO7ZvnQOESu0rOvKqnHS1oC/GZ0fSczrbrfzlBys=; b=bjh/GeNp9VL5fPICkKHSpvVl4p0maDR4rx4l7UtkAGGtw2yywu85QyIwEpTrVCCNnq tlvksqZpVlB/kmBetAerinnx0utVD3Q43ny+rBba5AzUdB3rsMcWDIu47DyWY5qIJ5Gs ri+KypwxkwZY3+usrON7FAVx8LOsGeWHoElJciOAvwou6E2Mcu/CNI/f6B2ZS00os5II AhSIbln6NbkOuUYbiqNwck8yusjvWHXts5yuwDoyXjCVZ2lGSkfNXVfdbjAm4QslK9ig 9MqhWEXK0srkXM2WN5/iZQ7zRMlGPoMGWprYUnOA5oiSCd6AXG5ONs/OFYJZqOXrV+5t Hyfg== X-Gm-Message-State: AOJu0Yx/mohtholbrUmm1n8fiufyVnOvIJssEqYRNQL92xswKmqKz9oP 2uo6LRfwjwdvIRjQqvaHSFvELIfYBFkXld1GORUSl0wHeYQ5xu7hdgXmpaBeYS0JKbhPUCMKLtr Cm7M= X-Google-Smtp-Source: AGHT+IHHwm5ckcwW6tzDCyvD/cFUv8RX7EzbVytEaqdSin9tImlfNCqPLYYgjj9DyXwqjBBAmsxOog== X-Received: by 2002:a17:90b:180a:b0:2e2:d434:854c with SMTP id 98e67ed59e1d1-2e9b1655951mr13339967a91.2.1731252575687; Sun, 10 Nov 2024 07:29:35 -0800 (PST) Received: from localhost.localdomain ([198.8.77.157]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e99a5f935dsm9940973a91.35.2024.11.10.07.29.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Nov 2024 07:29:35 -0800 (PST) From: Jens Axboe To: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Cc: hannes@cmpxchg.org, clm@meta.com, linux-kernel@vger.kernel.org, willy@infradead.org, Jens Axboe Subject: [PATCH 15/15] xfs: flag as supporting FOP_UNCACHED Date: Sun, 10 Nov 2024 08:28:07 -0700 Message-ID: <20241110152906.1747545-16-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241110152906.1747545-1-axboe@kernel.dk> References: <20241110152906.1747545-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 1352A4000D X-Stat-Signature: f1d5ywujbbe76fqi5uenkokmq8b9wfuu X-Rspam-User: X-HE-Tag: 1731252546-218481 X-HE-Meta: U2FsdGVkX1/9DXeqluoovzSj8NdOkNQtC1YCnq3soktzgo65FCQ3Jlfln2nnGkfBP1J2vwkPlEEWcA8aud8tgypiczzIzwWOdcxUE3tI0i+5MAylBku3f1VVDmCEKjGATRG8KSxGPYiaVBMq9sos3nHsKjNO1+3tPUHbE5VTXUC9DXDJIrFU3SivSUAemg8WxvVqiPw2rvD+sG+tRwWlxo3SUhx+D1DkbAm5mkOtLNpn9/0aWib4FknqT1Jg9dPWgnvrZ3ynzP/LkYrgtB4nI7wItnJ+PCb28mVw7hz4CdXMdBsE6LuRbR9SyzIw4BH9rvhrWih16NsR7dgnou1RhWhzzeJZdj05pJYHCsSF2/ISYMlHkR1JjCqq73bFvdeV/KZdi5SzFY96OHR26kXt4pBx9CuMsBrZm3O1RPDXLlB2PORFXwiPSrJoWAW5gK/BrmePIFuAoJBxGaPMBaLeDFZEj3D2y/0rTBqsZIFga0S2J+7kw1z31StOmPjRFWiBrbN1jpaYiubXY0Mo/n+s+LpMkMpUYY9oG/6kQOyzoGvreUVNf5btLxjzwD80ucCzVznBonHsJkeAZlD9mrOHl5rRPWyKODFLLVIRb1rkVQYu4b1JU1EEif59wF6/+p0odKwTc+nvUZrWqrRONlxd9Z742R3xmuZPpF7tmIbgIH6hMcsoCHAfoQOLoc9rSpZsmQ6HwN9ywxf7sFPRlLR2wMKEeZXkGwcvtcGVbd5lqKLuFlr0sgzVG6BevCNF2EmRneDYYegXs39ewK5Y+bHM9wxxQIlhRPxOzao5v7npRJ7ZU94/yYeXL+avLcg4TyxIh+XW0sjq2m8p40HI4clcV/xJjwbogdZXIfkNyyutX0PIgbVhgwGr665SgHkZ4IymvJ1XSUOnIaTPPCLZBIQh6iHRQClweyZqeYV3ApeZgCmcfQX9J+lYZG6AVt8rgF13DVxOD5SvioxrqkDridn zHl6u5ZX vucysdrAEJUrRQ/M55v2iN0JOgsPhrIOpaEUtQjzbCwzSgeeoXdRfO2YH4MjUqE00WJ0mEdKGmMz26C3s49w+NOu8MUYYANNC3MyBTLMaaVQMQB8aQpm1JWnIk6kLg8Vdj88eLVsEAx0bcCsIEGRIYXqRKBl/BliyT3laNL4dbD1KZg5/e3lrTYazlO2H2gyvNHVoXRRIQCc80Pn3AjNpPvd1/0y10OKyhgL4+ncK//EIgkbB//4LjXOt7Vnwvf38pWAEwgI/JBayh/HuMOsM7Pofto2+2GoPtsJRhHhtqSBEWrYrPtKGsi6rhir+vVGY77mHyRFoGcIz2sXQFLIZIbiVbargnX9k65lu 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: Read side was already fully supported, for the write side all that's needed now is calling generic_uncached_write() when uncached writes have been submitted. With that, enable the use of RWF_UNCACHED with XFS by flagging support with FOP_UNCACHED. Signed-off-by: Jens Axboe --- fs/xfs/xfs_file.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index b19916b11fd5..1a7f46e13464 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -825,6 +825,7 @@ xfs_file_buffered_write( if (ret > 0) { XFS_STATS_ADD(ip->i_mount, xs_write_bytes, ret); + generic_uncached_write(iocb, ret); /* Handle various SYNC-type writes */ ret = generic_write_sync(iocb, ret); } @@ -1595,7 +1596,8 @@ const struct file_operations xfs_file_operations = { .fadvise = xfs_file_fadvise, .remap_file_range = xfs_file_remap_range, .fop_flags = FOP_MMAP_SYNC | FOP_BUFFER_RASYNC | - FOP_BUFFER_WASYNC | FOP_DIO_PARALLEL_WRITE, + FOP_BUFFER_WASYNC | FOP_DIO_PARALLEL_WRITE | + FOP_UNCACHED, }; const struct file_operations xfs_dir_file_operations = {