From patchwork Fri Nov 8 17:43:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13868794 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 CD0E0D64075 for ; Fri, 8 Nov 2024 17:45:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 95FA66B009E; Fri, 8 Nov 2024 12:45:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8ED196B00D6; Fri, 8 Nov 2024 12:45:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7613B6B00D7; Fri, 8 Nov 2024 12:45: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 4C6546B009E for ; Fri, 8 Nov 2024 12:45:18 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 11E6440E8B for ; Fri, 8 Nov 2024 17:45:18 +0000 (UTC) X-FDA: 82763653938.28.40C1349 Received: from mail-oi1-f173.google.com (mail-oi1-f173.google.com [209.85.167.173]) by imf29.hostedemail.com (Postfix) with ESMTP id 17D93120025 for ; Fri, 8 Nov 2024 17:44:25 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=BR9Jenhh; spf=pass (imf29.hostedemail.com: domain of axboe@kernel.dk designates 209.85.167.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=1731087830; 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=fZxELLVFDjwUYsFIGQEeVxILEzmt3BirwJxOvJB40G4=; b=xtBLA8Y1iEIOiv1sBgUnkPkUvRjrWkH3L8H3HtGMUN4CT7Wpi9cnjcAkPMCjg+tsGaCwkk pFAIOGthc/qatYt+rNBV1zfQK0JXYebK9GUkiSVRR9NlXArwMQKnYJlnnO6akAXox8XHEX pj4Rro2Ut4DGg8QN77qL7TSzuEYd50c= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731087830; a=rsa-sha256; cv=none; b=dhrn29d5aqd0yh0sWqWWeYMrAJGGkBCquzly5C4Pus6U2g3eCcF+gE8gShqTNMPMs6vWGT Gqty5W9s3qfFaTd/WygnqAf2Zyk5MlKtM7ErszT8dqsi10VZ2CcwAs4FN867zYf4fBXMLB RyttiRoxI3T4bt/mxB4DX+1dJjwhQc4= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=BR9Jenhh; spf=pass (imf29.hostedemail.com: domain of axboe@kernel.dk designates 209.85.167.173 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none Received: by mail-oi1-f173.google.com with SMTP id 5614622812f47-3e5f86e59f1so1484788b6e.1 for ; Fri, 08 Nov 2024 09:45:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1731087915; x=1731692715; 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=fZxELLVFDjwUYsFIGQEeVxILEzmt3BirwJxOvJB40G4=; b=BR9JenhhvHb0OU1BwQZa7KIubk6tPhhPUTreqPQcchZsrRcuUS38Qurjd84o49FHF5 F161Ofg3eFWWuiebvP/UoqcoTKuKOtWPeGqYTzx2Gxs6IrmkZopaFQsXeFU9EwcHcctv 6+wNdwG4nly5ccdHZ47DeAdQOp4ClY+cKt9QG+pF3lXIO1z+1vXjVJKIuGLxlGEIjxFS d8D6mAqKjvRA3r3iZ/2TLaLO5pVRKHR9DnmLPaUGoyFj8f9MnR/KJaj84ZklscLiP6XL W/GfnZ7pioHXE/h54LHSXipJqZt4J/1cqnLO56JrMExXErjyAQRBwfX23j5+0huhuIGE VlNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731087915; x=1731692715; 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=fZxELLVFDjwUYsFIGQEeVxILEzmt3BirwJxOvJB40G4=; b=E4nIB4BowCEowq6I70YE26EIlrIvzYV69JTw13wOT0iLCf2Ga8lsdoR/hwLaxovJw7 I8dbcWCD7cpgU812ZeXOaz0FU1WdYghliWg3lxnZNBSlO412duDMYi7bkImhmZUQMWMS ecMKc4XP6nOz7RgOYboHpHlIw6yfuDY1v4aSViCXtizFW6xu4LLkxiaBiPDr8jEUmLOg LrNOvWi08WWLajb1+wH/DvH/LsEIt/G+uz/j1IbUJxsRK+i6H4fxGPSfh/SbBLaNfl+7 B3lDtzEHzr4jbtto0+LsAw8dt7wUyXO0AGD7laHsrxzi8gB2ufa9xTvY04bfRCiUk/XZ TrNw== X-Gm-Message-State: AOJu0YxMhQeCPaWzo7FWufa/fZe+SLdHODdP1yeq7whWU4AidbL4pfgb 9kvJ9cK7+Cl5LoWSWqRNdjL0v0nurAvAZjZRO+EtKrD3fwo+ZwzTNSavo9Qs6oqH5cYbkQq8T6X mVr8= X-Google-Smtp-Source: AGHT+IES+vxslMkWIJ9Qt53dufEtarFT3S5DaOvldgjpcVbvhQDjZUhL8AdkSUoXq58a5ka/shhJOA== X-Received: by 2002:a05:6808:1524:b0:3e0:7005:3f86 with SMTP id 5614622812f47-3e7946c80d6mr4180469b6e.28.1731087914910; Fri, 08 Nov 2024 09:45:14 -0800 (PST) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 5614622812f47-3e78cd28f80sm780969b6e.39.2024.11.08.09.45.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2024 09:45: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, Jens Axboe Subject: [PATCH 01/13] mm/filemap: change filemap_create_folio() to take a struct kiocb Date: Fri, 8 Nov 2024 10:43:24 -0700 Message-ID: <20241108174505.1214230-2-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241108174505.1214230-1-axboe@kernel.dk> References: <20241108174505.1214230-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspamd-Server: rspam10 X-Stat-Signature: yiz91iede3ga9mm4tnzoy4qnetmrey1j X-Rspamd-Queue-Id: 17D93120025 X-Rspam-User: X-HE-Tag: 1731087865-213287 X-HE-Meta: U2FsdGVkX19xIrLuECIf0qjuD9CJ6yP1IHStbOsEm14EMB7WwWhegWrPpRo5+cjkphCjpPgk+Ks3IG9F95sdIRRCHL7gjcxEa78kJiHAWOXYTEQEjsrSjUc/2QWZJsDY0mHxarK00/9A08QT5GinwptBRGsNFO73j238awSlzmMDx9d1o0n9H21QbDlDWb8EHL/p1MncSyUObLdGdYgq3GgaZ0l+46TaMhmqItjVpV8vKupam3r+c51f3C1nHOqqhgoVLiXCFml54XAlhENIivxtDajCLNU0A54smtED0jfvacQKiOt/kvfUF3C9owxDP7l01Ter2eK0fzefa/S6p92nq9d36JMIAzA5r8iDOszs5e0OJC92XrUZE6o3jZ64SX/DLRUuV4aAWaetIc9kCoLODCIaZWB7TmvPk3s2M5Lq87OrR00gh20nyjN0e+/46iOwcYLesWpQu8po1U6DSHVjJIAj1GrJ9CqSE7eon5H7VwkTM8rDklZvyMfqlrFku6rYLexh8XGHAsfR8esDeuitG0/h2txbN+04qHKH0rg5+5wvhLeY0DiOwtomIXT3PTfkgn4A7C3gfT14VeqbMtlTkqbgI7uJuRYmPqMqbk3/NJ4O3Q3UcU1WhFqWMYK5mA5nzw7s9cqs5yYy1tHIxSnewsFoJ7NJGNGyPsC2Hmxt5NlqZE7jQ89JKTxrlnfMJ5flAMJAi8tCb+WVCeh1TCfMUqKU34N7/p89ljMjS9dfi+Brj976imDwIDQMhFeSsS2PE0s6losk3Li97twyLNn3VRBK198TIkZt3Xrvvuu63Y7lx7OXv75+6GH/fTGrSir9dWg/gba3cFquDRlPcbu8Q1S9vXKgFD1wS+9hfwzlcylKcu50WfqiB7hrJIL0V1lyMKPeAlCcewub4A4hDV8wS0P+6ARTj1RZTHL2qwOrEd+8LwJx9Jnhl99M5anLEbtukPA9+XhrIWs0V0Z MshGH3PE Ynj/Klg90cCHF4Y5nm8xOMNOXv6nWpxLsv7yJWe+p7fd8Hp6PVn68CEAscpihqSTWQSMthx8EWKczQO2cK0Z5cz+GJeRwG2MHpca5TuVvSJ1BMO/w3qdUEwFFVq3AG9tH6dnOsz+K1mzMC8kJgkJkBKWyUHK5GqUE68P4W10+Ta62XD4KrO94m7QmKrasQ/xAPr9YpG1YQYY57dEd8pqgGjc63tZa9KtBA0QhQ6F3uB9AIf6ewvhIlnMs58WUNs+gixOZWmS6ik7UKRSche10dVIKudg6VYg+3BCysosH3aGTW8zH9ZZar3wq//N88gbqC4pkqddTs4QXT9d4dAcpLyfAu17nam3DH0+p 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. In preparation for actually needing the kiocb in the function. No functional changes in this patch. Signed-off-by: Jens Axboe --- mm/filemap.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 36d22968be9a..2ae26a0f961b 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2460,9 +2460,8 @@ 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; @@ -2487,7 +2486,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 +2494,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; @@ -2553,7 +2553,7 @@ static int filemap_get_pages(struct kiocb *iocb, size_t count, 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 Fri Nov 8 17:43:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13868795 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 ED6D7D64072 for ; Fri, 8 Nov 2024 17:45:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D7EA96B00AB; Fri, 8 Nov 2024 12:45:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D08696B00AE; Fri, 8 Nov 2024 12:45:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BA87D6B00D6; Fri, 8 Nov 2024 12:45:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 932476B00AB for ; Fri, 8 Nov 2024 12:45:19 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 4AE2B80EA4 for ; Fri, 8 Nov 2024 17:45:19 +0000 (UTC) X-FDA: 82763652468.01.C549FF4 Received: from mail-oi1-f179.google.com (mail-oi1-f179.google.com [209.85.167.179]) by imf19.hostedemail.com (Postfix) with ESMTP id 2070E1A0009 for ; Fri, 8 Nov 2024 17:44:30 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=h5wSqiFA; dmarc=none; spf=pass (imf19.hostedemail.com: domain of axboe@kernel.dk designates 209.85.167.179 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=1731087832; 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=br8jgxnQmgT2WwT5MKI14vCxulhwnuEXuJqbR3APlapGNNz3O+6WjTw5J/OBfihyw8hAZv Hvhlx5SSPzzqjMkKGsIQ3V9/L2MbiCrHh202UeOBJnO+lF0DyjSYy0H2fBFwLX+WDOePoc Y6uO3F2Yq3M2dKtT8eK26zpYP7OKQ50= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=h5wSqiFA; dmarc=none; spf=pass (imf19.hostedemail.com: domain of axboe@kernel.dk designates 209.85.167.179 as permitted sender) smtp.mailfrom=axboe@kernel.dk ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731087832; a=rsa-sha256; cv=none; b=Ft5DCzWPt9xjBhF+vf6z2tglwfjTjPLhw5iYJDtX49g6Zt4mRBGRIFUmZH6K6JMRv04wlc r3wfDz7kVkz/edZQ7WfGJqm7p7HGihHJBTY4A4T4wagyIZPsyiHUWpvHpU4Do6kASzXda8 ngRIDVgSOSVQETBvyDUE7N2oTBoZfY8= Received: by mail-oi1-f179.google.com with SMTP id 5614622812f47-3e6105886dfso1775814b6e.0 for ; Fri, 08 Nov 2024 09:45:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1731087916; x=1731692716; 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=h5wSqiFAb6hCta567snjsCpCzBVM3Lm+3UgbzSi4xuz8xp36TgA4pnKBQogi8b3kkm yMa2fk7ZfP4UVW8Va5kZJEofcyrnBozyVtOcbxQ6oiwMdE062bE8SHw3+jWwQN2DWusa C0jc7SZvC7IXIbIX2JDLQHbhASiiOzhiOuZ+s5EwIN5Pfppx/qYef13nBPRp+ay/0fE8 /KuFhwJSm0hbOokJ/J3Cb2H0WC8AgHqRWt6e1X51TjWDQVxHLdeT4Y0sKzYcKMyNOBHR z5EgNXIe5eeZZ3pebgsYUUxkbPzKVdQsrBK4b7Mhyq2vtEbMZuhu0PfT3+FrnRjb2rp4 KRmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731087916; x=1731692716; 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=XW743CRzAs/oA7br+RO7ItlsH5M+LgXR9W/I4AECXKYWW43aa2L0GDImBs+NzYBAG6 9iwDp/1VwcYJCd4QDa/RHGcN8Of58EyFLNJRBzUpMvW7PtDfmHfXaOjARc1DwDQ3uyXq nPyCotw1EJrX+17pjBZ2WPMUjGP/OE3W7B+yOv23iiVA264sexSbWLXn9necop7hoBVJ AjVj6YSRHMVXITsOQWfo0PQqtS/FnozVk6meXrUERYsVb3ahUVrVwGqf9jOzMl7rq/kk x2iQBRBPHoGJjM5Bcsr5Wi75eKLwIhZ72s2PQhd3GBQIXi1voEq2GqTwtt/lIOu6iI8n YMtA== X-Gm-Message-State: AOJu0Yyv4lqL7EGD/byWkBBUZgZZB4HGV7kOgQEr8CywHuHVGc1PLUe4 CbDY+2Dyj0/vjrJ/v0+LudcVZB1Wj32uNzKE6LMXFdulO5Nidgd/Ys/fvzMWzz3mCM9DRogER2l op/g= X-Google-Smtp-Source: AGHT+IE9yyGg7trloxg8/sxB/5Qab0oFpLsLqTwz8oiFcGSIzzHT5q20m9z/5W6tquS0Nz/aDzjCkA== X-Received: by 2002:a05:6808:148f:b0:3e5:f9e9:43c4 with SMTP id 5614622812f47-3e794dc5b57mr2378031b6e.18.1731087916223; Fri, 08 Nov 2024 09:45:16 -0800 (PST) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 5614622812f47-3e78cd28f80sm780969b6e.39.2024.11.08.09.45.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2024 09:45:15 -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, Jens Axboe Subject: [PATCH 02/13] mm/readahead: add folio allocation helper Date: Fri, 8 Nov 2024 10:43:25 -0700 Message-ID: <20241108174505.1214230-3-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241108174505.1214230-1-axboe@kernel.dk> References: <20241108174505.1214230-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 2070E1A0009 X-Stat-Signature: yry36g1nisyqu7tzswfgt778kupikij5 X-HE-Tag: 1731087870-448471 X-HE-Meta: U2FsdGVkX1+HwrDDmS4IviAcz1XZeXldXrhlB6sbND2xegm8wZuYp42cukJVC1XzV4kDpCRIZGTEZzouitvVEYx0rQ65B8+TorYvQyfAQQlZ5Qyvg+J99m7ya1TUxUMs/E3OYfnyplD0fMU5WqvK2sXjUzBKX+q5nbVXpTrBmNyiKoU3qQvgvb+5s164O0t9zXjdPI7lljG0DLcUi3R9siJj0RIGs92MTYL8wUBrGkN7QeCq+7ya738X/ZHc5QKYr3l6Cs0AZh+wHng58CspZMv79U7RwcKAGyiJ9/vY3f88LwXG0vpbgU8R05W0RrkWWM+y+lt8ODwUW8O53ra+8GTmLGCOcDeuOOa/oF9uSD6AT/KV0t7AxGXp2h8yOB0fnxOLln/xv5gJ/Sr2iv6t6LS1UlI41Ax1fazFnqo/7bvjt13PpJCs3QTDmM7A0oSyj0AuX5Ug6XtPEEED75mEIdppVGekXCzx3EanMumZvgvVAGOEjP5nCCI97se166QaAuy/gX4485XFvtZGu4cefoA59KU/d2A3uj1a4Z+qMO1p6fD64IbQFQaX8CMN+jOq4Jo8CuPRgM8KRbBmCrsBEjE26qI7mlP7QvZOQBE8exVvPH6tg80CCoV+BUCKocL0lJ8DKkd6B9CUtKf+eSXkXa6LjzYef2xLTN198+NzNftqU7xgUEBiSAhkDeI+fE98d8hUyI5LP1YWN2IJSCjSTY/YYsF412gKi8wMbx4VN/9F3DKuXueamHGeCH52fK/I3eTXIgcuei760m3eHEB3MJ9kvdYZ2XiZrPByFmkvNwfKzJJLOqKJutnFhOJ5RZPniJls1rAP31S1VaRHi1DJT+efWn/EeGfPsCYvATlVez4mrccP6c9hhSjERuJNh7xGdUpLKSzFeISsCwj4aCVLYv7RRtaMOGEQARaxSz5eYRSalFeqFxD3lL6n/ij8H8C5fVCHdbHmvCVm2fY/wli QfduXMt0 eNRRlUIvXigm+J9uhSCJDfUOTkg2ijsmeIgulhm35culgXIwX09PzHxwrTsQuAItmljQH2HbngJLS/sk+3TsA+FLlxWvvJqMCRyK8t3JT/P/UTyRLQrUcZwxBLPsVfGwkOAXuDMWOvVVodyyFvmSBgSW9Xe+8BgCfzTXQaxW8qTx6+u1K1dLP2Me8Flqyzpr4MwzCyq04hskbUVIKWbLlKPwcIhopabrnSFLLwSMncEh0NzgW/stHxuNIRaXEGA/hua00rC2gHBvRWvzmimC7ogLxZRdJLYcczxfjIUtjQotP+IU= 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 Fri Nov 8 17:43:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13868796 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 9DD96D64072 for ; Fri, 8 Nov 2024 17:45:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6A3B76B00D8; Fri, 8 Nov 2024 12:45:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 651286B00D9; Fri, 8 Nov 2024 12:45:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4F2636B00DA; Fri, 8 Nov 2024 12:45: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 2C8836B00D8 for ; Fri, 8 Nov 2024 12:45:21 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id DA343C09A8 for ; Fri, 8 Nov 2024 17:45:20 +0000 (UTC) X-FDA: 82763653686.16.04A009A Received: from mail-oi1-f180.google.com (mail-oi1-f180.google.com [209.85.167.180]) by imf28.hostedemail.com (Postfix) with ESMTP id 4E996C002A for ; Fri, 8 Nov 2024 17:44:41 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=zozP61g0; spf=pass (imf28.hostedemail.com: domain of axboe@kernel.dk designates 209.85.167.180 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=1731087867; 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=eb3J4ACDa/QxAyq2unbnJHaKnDMFxbMjGmPZoVCHw0tDQGci7wSqMNCqxJrb82JqMzJjKp dr2hF8zP3cgLOuSO5zEo6NkPmJEaZ2UU7viIE0s4N2Qh8+zrdi0mf1r6+nw2ruPEfxsqtQ d2WZEblygTqf+MBO946+kc/rP90w1QI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731087867; a=rsa-sha256; cv=none; b=WlLngFJYxq4k63/OdzGbv97dR3y90ilzLoqGbxt+2Ttt+qBHzBQWq1FqKIYUJNH9uNpmYI SbQN4PPXWDEDOvvGguXQwLHCHtRcgtwJU9wgTrYfTPsRRzS0cD55BzMsIi4jY3oS/WIpU7 rWjWECXWZhuGGvWUr6uIi5MKRVNi6ig= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=zozP61g0; spf=pass (imf28.hostedemail.com: domain of axboe@kernel.dk designates 209.85.167.180 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none Received: by mail-oi1-f180.google.com with SMTP id 5614622812f47-3e6010a3bbfso1610411b6e.2 for ; Fri, 08 Nov 2024 09:45:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1731087917; x=1731692717; 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=zozP61g0voQ37QalKGhleDLAYffn2UYZwqSsmrfQVKwinisf4EYgjZ3Mv1lSSpyZ+e 4A+egjM1+VJmgjzlUB6L2QEcOIxv72vK3w9eobBoT9ZuOYtjeayElTJtgSJcmsNUYgWD L2uX4oqUtiiwHw2mPH/x1t/BlQ/6tqyjszlvvacvzGMauKkbT+ZLb/zUxJmd2HGaKhEj /dWwuUt9ksJEXzNWo/SVQhZg4MN6m21toDpZE1A5pPDuT4NWxGAuwn1nC+e1I4PEgW3W l/PR9EZdMFUlCn66jNvpHPIanGpCP4G9Or7whATL6lthHKdjjrtTDWcQMp3TBYtwPK5l YanA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731087917; x=1731692717; 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=CQqVt3fsy1riqQ57PCQDORoZADBz8fJSlQUVxvpIvzYbDGGyQhiWEFTQb491jqkMdu +mkDsyc5oAtL/wKSL/JUfGG+wa8azZPMigXs1XGnBtQX4oBDf3CmhWamLR+FGsTczaYo Ckdr/fL2mFoMC7vDJPpEKVkJ+TUNssAAVyHE3xuSKKsrPUeq62a0dfe9LDQMIugntAWl iiOS1D5+IIQU69XKyEyhh8NcNZhAWxJrZ86STT24zOL3V1lnaCRmfL35iBnwpN9UrhsQ lpqOhCey/t9d3fxNIWrUwkvOyvm3AYI0jnbFZZvl7OPbzC7bgC0plQxC6BrVAhQk0ged xnKg== X-Gm-Message-State: AOJu0YzMMllT9oxV3xNIm7k38Vr0dKo5/pxconLgeKnqsvFWN+RnwfN8 2Wg6x/dAIP8TNLp9BpnBstPHCWcIJz/8Hz7kHLb6i85jy4J96rIpKiT9/MmdG/LZhtZkWcLi7dJ h1oo= X-Google-Smtp-Source: AGHT+IEFLKzY9PDxLtI3q9tzu1PwOWnBFTiZM//bYtu3vxzi/sNq0OsnpZ8TGg2ZJ4XyTsEPnsyfQw== X-Received: by 2002:a05:6808:1789:b0:3e0:7d53:251 with SMTP id 5614622812f47-3e794675decmr4661644b6e.15.1731087917560; Fri, 08 Nov 2024 09:45:17 -0800 (PST) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 5614622812f47-3e78cd28f80sm780969b6e.39.2024.11.08.09.45.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2024 09:45: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, Jens Axboe Subject: [PATCH 03/13] mm: add PG_uncached page flag Date: Fri, 8 Nov 2024 10:43:26 -0700 Message-ID: <20241108174505.1214230-4-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241108174505.1214230-1-axboe@kernel.dk> References: <20241108174505.1214230-1-axboe@kernel.dk> MIME-Version: 1.0 X-Stat-Signature: aqdg73obihk8g3xz14yfymq9659j5kp6 X-Rspam-User: X-Rspamd-Queue-Id: 4E996C002A X-Rspamd-Server: rspam02 X-HE-Tag: 1731087881-666032 X-HE-Meta: U2FsdGVkX1+0RgWdef0TXplmVO/DQMwyJ80CH+AGssSTYJS2BXSfaKb5Q9/JEw1WLr1wv1Sr/ENF57IgQjuB+OhkNtLSUzzCb1o8FVFbdsg/itZRTCwMfYR38WcONg03m5OZ8GRD1JBvf4S9Pb8a2wREwX4SghFEgAhjTkxN9BLR5qdtxVUfY8/PDkOXUVAOrs2hll4kEUmuZjangaUQJrDJ5/pGhTreDRi03JPyiyt2JFX8keldIPsaqcn6ShtCMy+4woKNL7TiWRum4yuIv2Uf1ZCkfZHn+/5gdFq2u4EtQz0PLwXwyDb9ivjojVwjdZnpoVCV56exTQ1BzGssulXytNI05LKQ629CmVCpcW07/5hR5IRHQ/9/2zMcWl2yf5XS++bZtx4qXQy0EDgffZSwBSkBB6uN8M375Mz8kmwQvtN3miaZ8FF+UzR9R1olUN2Pxm+X0pZr+2pCuLZCSFgr8AWT2e1NzA8HIhknNVNN7S5mQYP/FdKluuG48l4UWXdimPu9XMtN65e67AfBhF34oqxIt7cF7cp3uce7opO7W6fIKsbjmZxKRQiNq5OZqDlPCAGwm04UcA/Og55JG5hrauNUdIMk7kZum4j29AL0nZqBIdQO7SJTWm/VvrI9qSfIVonMFiMcguaaz19r4hqyL49ISgzlXIe55oDG2cHRlBSqEIziLqHr/Z7rW+61yv2+525HvVTUx5V/HtSzs3sI5llQavaI5cvGf8p5QFWqmqzuLIIYTl4nbMcjvDMnwJMH5TWxu/s4wTLsJncHeZ4ziLQLueYRHpsTRuKjOq6YGFSssO8QFtXDa4/hSGAPE1livmEl3/G9ewF748R9UTfqL5qNbxBwlhCHy1buufAUuN+sueNThv3ZZvt9oXjG7L4SRIjkaAkNnVvsQsooTlTyVu4KmcHfBzZcEwc5t5ywgmL2phTFzq7T9M3bWyrLolahOWPom74HATIpGSH WiN2E2Mi inFdh4JuB98mnVyeG6l4mwlwGVvQbsFYE+BCGQhhB/CwzfyU74KrF71uEXSoS8fRQ4sZjyxlM2bHu2+vGwvoDifTa/w5hexcKz/r7ID6olseXtbSOIlGdPTQWS4tDhuwLZVKt2TvIxBlskGivH3iEHjRMbvzH3gomAer1xpAgZu+bpg85D+9aYIKVjZ9KToppWoSkVz7ZHG8xVVL6S3xHn55HyGxkCttOw9in9KZJh2fH0KtKNufiAmJqlMTUBEfEReBvqazVq6OT3iBV09v3jFtPJNWN4kv0BKJVS1UxxYPJ3Zmg8oV14Mhp/AlZ1I33RappMwaoVbPKPHke1Zvg79FcAm6wvV39lqsb 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 Fri Nov 8 17:43:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13868797 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 50030D64072 for ; Fri, 8 Nov 2024 17:45:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 20D066B00DB; Fri, 8 Nov 2024 12:45:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 197FD6B00DC; Fri, 8 Nov 2024 12:45:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 011CB6B00DD; Fri, 8 Nov 2024 12:45:22 -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 CE0636B00DB for ; Fri, 8 Nov 2024 12:45:22 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 7D3ED40E38 for ; Fri, 8 Nov 2024 17:45:22 +0000 (UTC) X-FDA: 82763653728.18.DA20D9D Received: from mail-oi1-f180.google.com (mail-oi1-f180.google.com [209.85.167.180]) by imf15.hostedemail.com (Postfix) with ESMTP id CFF19A001C for ; Fri, 8 Nov 2024 17:44:42 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=elTKsb5Y; spf=pass (imf15.hostedemail.com: domain of axboe@kernel.dk designates 209.85.167.180 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=1731087869; 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=nPkGwSldMNFXF3cURXd1feXLkclwp0ZCxyEpzT1cPW4=; b=f5OTZGt1SqFyEfuTPOyvzgJE+SHf+OA8WxoidN9SzNcKIqCKtW1Iqk6SRyrwmxcbyJfRRB HHyYCLTy6KvnGenlxQNNJfHbYQtHjGcbDu2BlIxKpSdne/h2eEQIYwCunsPg3/NrHQM0VS mOKeeeLodLIjhjBUC6iA6DzpBIpi1vw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731087869; a=rsa-sha256; cv=none; b=f/O13NWfTqD24VXHNMjgeecq/3OoRgNsejPhCpIip6Y6/AQICwsfRFuR8aTj8uzTebCTxA CJCroNk9ptH4/DdjhhR+/UP54ehs7JU0ns9534GavHr5AYn+KbQZW1fQZI0y8Jhy91n0Iv A7K7HDy11avEcF/CSNcRvsdStPzGn+w= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=elTKsb5Y; spf=pass (imf15.hostedemail.com: domain of axboe@kernel.dk designates 209.85.167.180 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none Received: by mail-oi1-f180.google.com with SMTP id 5614622812f47-3e6104701ffso1630400b6e.0 for ; Fri, 08 Nov 2024 09:45:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1731087919; x=1731692719; 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=nPkGwSldMNFXF3cURXd1feXLkclwp0ZCxyEpzT1cPW4=; b=elTKsb5Yp3N4qJw9uvQu773MrTba0z5+4rw7YCA8SecIIr0niVd98DMO8uvhIpVZJK FtYfYn1HCr8nbAn/AZqYcgyCVr0sqZ2C8QLzHeJN8nvX1jIm2lDcDIRv7Oj4GDMtIVuu KSdrNjY/BIMlZiUIoPFLO71K18VEUcQo1Hmyc4OPeNSYDqB1sEwWKCdgXhvHdefSMVom UNRSzKc+GHIpn/v1Z2WkV9KakAg9I9YFpP83p2OpfEY/oSwfxdsXDqz/9Klz55Pr/pym v6Atp/2SOVPXHL7JDFNg/lmgvfOSVe56/g6oKK34nq4M6mVFSphQ+uFpgBcT6QYx19t6 Zlpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731087919; x=1731692719; 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=nPkGwSldMNFXF3cURXd1feXLkclwp0ZCxyEpzT1cPW4=; b=WCHCuK7uEEnOX+ixJKH/ZvNv6NHIYG5FX1LFSo04X3296bcryE0U5dPTNTFRhB+G7M HGoWZ0tEU0HhgAJcelOwV7DDy3NKWg8VcNy2/P3hCrx/bVadJu3uc8z73BnFeFYR1o+/ U07H8OHZfoyK2VhklMCRX/1pfg8Jv/CCbOJYayP5lDdF/KQVonxpWF/tmPinGohMfzDn e6xf+SjI6jUNhFV//7yik3XFGN5Dkm1s1EQ+0iVEpWQQB2z0yLWoKX/lPwOE7VjeDPyf OzhY01c6LJDC7B57Z5aiq+S7PwwBipMdwWITOzUE6DeZ4CFGHlnseKthOSO3FjJaQsFP E/ig== X-Gm-Message-State: AOJu0YxHnOkI+b0cB7F3KhzN6N85MTt4XaxfOV4pVi5XosRD4hFicTeC +MRqxKp4euM2Sef+UwF6lj+yGMkBWAtl0dkGk11QF3YgZjRoIzEId8p/Obr4i8rKx/hiHfLFzAP pqbU= X-Google-Smtp-Source: AGHT+IF9qnEH6iAmuqzMOZRDZm41rR73Vxyg2vpcvzcsSJsHVKcaTPsimGzR6K5FioRiJT7HzzWlGw== X-Received: by 2002:a05:6808:2119:b0:3e6:134e:3b90 with SMTP id 5614622812f47-3e79470a347mr4589807b6e.30.1731087919330; Fri, 08 Nov 2024 09:45:19 -0800 (PST) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 5614622812f47-3e78cd28f80sm780969b6e.39.2024.11.08.09.45.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2024 09:45: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, Jens Axboe Subject: [PATCH 04/13] mm/readahead: add readahead_control->uncached member Date: Fri, 8 Nov 2024 10:43:27 -0700 Message-ID: <20241108174505.1214230-5-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241108174505.1214230-1-axboe@kernel.dk> References: <20241108174505.1214230-1-axboe@kernel.dk> MIME-Version: 1.0 X-Stat-Signature: wizidmqh9q3n9ycoi9t3rgyqij9ttb6g X-Rspam-User: X-Rspamd-Queue-Id: CFF19A001C X-Rspamd-Server: rspam02 X-HE-Tag: 1731087882-354017 X-HE-Meta: U2FsdGVkX1+1V1U/1C+uQBjEFnITwJJjBZ3swOjB6FB3tnquSh7pq8gCh0BzmTJp7d7Xm7iIYZnd0G0WH+CxWIbI/BnPx8l9Kj1RgyslKhRghNtKrNlKjIbaeAD2RLx6pGUtO1DXAXTQ1N+ZHfKXvNZ3IjllXLNcT3rzjHa2HPy+jJLWbmBfLD+FZ210hpcw4p1Q9v5ryPXs+rUpYH222dkA4vM8ke+VQQfsWEfC/s5uP7tC/7tHlBSrEzuws5JSKv6fEneRgnEIIVOTw5luc2aT0X0AVybJ/ZWEVjwDNVawfNwqcEMeB8VIaoK+UyQVKUaUeg1ydutJ/NEV5iUoXgjuMpcFizHxn0t1tCwm5YjuEqFvijg3Ifd0xF/XUgV80nU9shrhG8R6X65O00VcHO7zjVy6E8WXnH+yg6V73jjaiQUvXczw9JfSRtz9Ljhki5XQRZ+gwUej2XBSG2wlbQQYLd2xz15NCmdcajFwx+s4OA3XhJF4QyDUjFDnojHRSocGikLNPeq0oPz4Q3FgpC/djI0gLvtwBWiGFNhpzX0YW5Z0HiI7E9dSSDVa370VpZ2aVPQ+z52xshzAH40vNp1bLY5zpupm6a+5gWJDofYBo9XbYlV9ejyZPs131YU63aiQ78qarHsSIFXA366LCr9cCUDJyCnB8vDh/R8i3jrI9U83UrknevWY8f2I5kMgyn4sD39Z2YsWO/PEFhf8//8XVQn9MEL0CVmQvbipaSBWaJ0rxvFiWjPlh1hRr/wctaPTSEQ1rS/a7k6lopZjwJXlaYIT/VBt6bSy/B/rlGxWXOQI4xFL8RtrVlOhumbZAGV/rzwnDqizjWjDSwDwkt8IdpSS1NVl9K77CGApnaTJYbzlmnFnMXG2++CcWPKWqD7QEhI1IVgpAbEAkZvPwLMt0GlO0C4IubMmPXgPayGAsHG34Sqb3SotbWB8XQiCgjbEO30Zi9Hs/gffkNY ddojdOQI GlEmL0ZM4hOCnmQSCf/Jx6f3mK+wqah+VosRGuj1lsnRCghYt+qMZVNK+DH3OzJn9715xZMWi2o3zSVshOJzrqJfoJ/W7tFB8fsys5EZdnQnG5k9FRb/zdkLYECrPDWAAoUUSfZCCBjbjkPIgGgjBIrBpMG/j8O69U5T0rJ8JbtDZmAmRe5XvmWuiWfpW5ATrewxnoJWOPwMgEGamETA+eSwkOIyAatahpW2EsqS/1x0zrTsdJbXBnpY+cvDu0vZF8K6ro7PKaYBlh4Mv27xPi+DJ/wc5WZkGShvNrSAvceUeBT7aohilOimat4h7Wy33p23qP7vXQtZXsLukDUmVQOgI5Pn1hvgzH/7S 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..09cddbbfe28f 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 Fri Nov 8 17:43:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13868798 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 2D5B7D64074 for ; Fri, 8 Nov 2024 17:45:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AA32E6B00DC; Fri, 8 Nov 2024 12:45:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A55356B00DE; Fri, 8 Nov 2024 12:45:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 89BD06B00DF; Fri, 8 Nov 2024 12:45:24 -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 61B186B00DC for ; Fri, 8 Nov 2024 12:45:24 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 0410FC0F53 for ; Fri, 8 Nov 2024 17:45:23 +0000 (UTC) X-FDA: 82763653140.25.42957C4 Received: from mail-oi1-f180.google.com (mail-oi1-f180.google.com [209.85.167.180]) by imf08.hostedemail.com (Postfix) with ESMTP id 4663C160023 for ; Fri, 8 Nov 2024 17:44:57 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=hlhYSMzg; spf=pass (imf08.hostedemail.com: domain of axboe@kernel.dk designates 209.85.167.180 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=1731087783; 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=c9RgbH65zDtdD1C8SyJhiChYXVIUYPb7qWGKr+fnitI=; b=deFfVMhh7RvQcN7FJNZ5DFFnFzLrTTZyZxCOWhVOmlGxf8xu452L2YWne+m0hQ0GV6DwnM VDpRIY0dLL24Uq2x+G+2Q92kIC9oDf2GlG+G45QNd6ElDrJbMf3zx1NvB4BPJx8zRj5GPB S/CnGfkMcmy+rTAhKdpmwMZ+w9dhSns= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731087783; a=rsa-sha256; cv=none; b=B0lWKLVwy7FgS05t6i47KShQ0CgY34Gnfcw3x563nApnkH20u0pWcZrB8lkGtVet+wUd5n fQHPxbwIZkyCzOznMWokE+ATdWDEjT3v16ZXGi/PffMWPrKEaJ+kIhuhCVpi2hCYZkvHKP ZdXfLpns0/DYSIdB5ULx69DEL8ezC7s= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=hlhYSMzg; spf=pass (imf08.hostedemail.com: domain of axboe@kernel.dk designates 209.85.167.180 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none Received: by mail-oi1-f180.google.com with SMTP id 5614622812f47-3e6359ab118so1155271b6e.1 for ; Fri, 08 Nov 2024 09:45:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1731087921; x=1731692721; 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=c9RgbH65zDtdD1C8SyJhiChYXVIUYPb7qWGKr+fnitI=; b=hlhYSMzgwc0K652I8lKOgMsvfl3sk7anYie4cI/UIcGPJrARpZ9ZVKvV9akddyg00A cl5deaDvtRuMiTVztJqWMwspzeba4ARcTlO5gR3zirvUrNU17wBY8w+okjgBncQcUall PopPqzeHevZIcQw2yVVQpWvnXp0q6BqKKubts4DDD6J9RKPToUV7igtiovR5jYXgRs4y JvgLqNsu/VCmBb0x8kHfwVe97KiuWeCzRJsqQV96s+0pZRrCG7DhnxRwSlf21zfruojR PDEZta/IhfGqeylSykW0pSMG31m7YVbPcGgeJ4q2yaeFNstUsKkBSjsosxrerr6OjIhc 4nOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731087921; x=1731692721; 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=c9RgbH65zDtdD1C8SyJhiChYXVIUYPb7qWGKr+fnitI=; b=S8LKExvduMiIcgPg4LFmWP6tM5x7ORIMYI1g5lZPRwQXfzxOy5fCw1NdUU0+CH2ara KFaiaTgbhSZSU0oGnHvPdq3ZAqxLN+Co/EH+RlACbiAmE0gELM2NQmthzOwEor7cVjAH nyYjtQMohttKIjTUxQHjVP0leEcnyDw/iLK2Qa5Ag3U4OqRMi0yo/a4dI/wbhAXVx50P lHn1NFvm6VMrmlDHWUHjq6pBM1g9NXqP8p3CJcOdW72dp9Qcz8xpKsjfFF3cJJmRnrJG qbv+U9yVEc9e6GBj5TOxw+fIDDDxYCOrrcATGEt8+Exq9bmbO+aZHd1mgufLUavqd7In lMtA== X-Gm-Message-State: AOJu0YwfAe0HFz011zaJE+YUt5lXed56pK/Ixdh0Fgq3NAKQZRKO6i77 XqEWGEw5pTdHdUTcmw0sut+mPjxarRl6in83DEY5yIvoyc9I15PyXg021FZSnNQSPr5CmKuKBLx AYuI= X-Google-Smtp-Source: AGHT+IEdm8GyqJXGR6xkfsMSAWw5HHFtOAoa8M2cW5v0Mo0ooZH016xwV9QTHy9Q50Vx5kixVOJjvw== X-Received: by 2002:a05:6808:1391:b0:3dc:1afd:6688 with SMTP id 5614622812f47-3e793f74377mr2161727b6e.20.1731087920676; Fri, 08 Nov 2024 09:45:20 -0800 (PST) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 5614622812f47-3e78cd28f80sm780969b6e.39.2024.11.08.09.45.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2024 09:45: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, Jens Axboe Subject: [PATCH 05/13] mm/filemap: use page_cache_sync_ra() to kick off read-ahead Date: Fri, 8 Nov 2024 10:43:28 -0700 Message-ID: <20241108174505.1214230-6-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241108174505.1214230-1-axboe@kernel.dk> References: <20241108174505.1214230-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 4663C160023 X-Stat-Signature: 66y51w7mu1er7jsxs5fsrgejc4bc64fq X-HE-Tag: 1731087897-842469 X-HE-Meta: U2FsdGVkX19oJ0EUrV0bqMI95+1CiAl/zokWApiqxzkHn8C4JYnPb+MToWxrV9YsVrnEeW9esouRQ/WSieNhUqKcyShEvm8HkvJZVwjSsgj2xOxy5L4GEaA3i+FTmUoJHtodYhMs9PP9xqw6FF+dMptzsiTRaiXz9bH2jyxGoCEu7ebdDHrv9pFBVKzZ709HHE/MW0E3j2TWSWGZWaaYxwxS962cOElYi+MUKEk/fHV0Zmv831x7SFrhVpF6YhYxdHjyiu7B79Ll2W4kg2FWGJYFGiH3G+XRolcy68nMWjbW1OFAPnhCuELT+kpfyJlDE8379PHm4wci86ZzORlMcQ95lhk0rm5MXxJQNZA77hSDOdbwFDTJVTwF28/JrW5VVwIcIq4D+Nj3PKk96D9dgUFDHtSeRF7GWaP2auSKrgcpbn6yvYoxY+rQC/tveMhywEQO5KAG88UNv1+d+lFCpRJudk/4syrApZPd7RU1WIpLAe0xiMxSD7YMgIc1sY7TTokqwwYBMwMqSOarc1BYq+Wqv7YvVxOsUNclFdtL5wKZyyLaAVId9vi283zWY2EMXPMN8u6jpOkc6jZkEuyNViWU7/LXcHx4Tjquv6g6A9y6PIPUJejy0YVndWNQ0kZr5vnMLKu+zOlbmV1k0jERnFpTf7TQoDXuvCnEquMZdBqU/o0FZmzd9DrGeLYzBcMg1xR1ljwQP/hU95C58ZGeefMwmVkkr+60pYgMI2D7NIjQnYq16kU9E92c88hOLXwjGguX/pwITiTMEolnMhyo6AF/YuL8CDPkHpAXRnqFvFKJx+pe5PJIQyjyCHqVckkUXLBOYF4SeX60dPbE8GrBbuxKsWeiD25v3QOrQT9iUUR1dCMCF4ne9WEmCM+0nmwrBS2s61Hmyg/uq3a+K/g7CAVMJt5/KO/KV+c9wFtvtIGthHJpRxmt50cg2qBAmilN6eAWM4C1zC5ZMKQC5iD d+mwXTWt OBG6Z9mKJc5EuW1cWnkCtU0bSqJbxoglF6fKVNML9juzx1bUirWieX5DkjPR/HTHgG0GatUidgod4tQseZGOdj34eHSCLzCdAl5ee3kycB4fFsyyYdV48taVJc3mf+joLsrvSNHR0ALsZY/Z+rUDs5eNyjOOCrrnmfBi8vn5CMMFOuwFCFijiUsh3foGSqLiBgxtZd9k3qZHeEmANFH0Vkjs6o8nXG/f9VxlP+kxoh9ZFFZrGfbnFEGvRPqHNjJA3qpkqCX6zwAWG6JECDqReAFOe6h39zJhJweH5cuiCx7u98XwbabDpRbVXbCKGB2cNilf2fDb+w1rcPvM+X6Np9UNovl7fAb+F6EZY 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 2ae26a0f961b..7f8d13f06c04 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2525,7 +2525,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; @@ -2540,12 +2539,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 Fri Nov 8 17:43:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13868799 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 C9771D64074 for ; Fri, 8 Nov 2024 17:45:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9D6666B00DE; Fri, 8 Nov 2024 12:45:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 985556B00E0; Fri, 8 Nov 2024 12:45:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 788776B00E1; Fri, 8 Nov 2024 12:45:25 -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 565646B00DE for ; Fri, 8 Nov 2024 12:45:25 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 049C2120E4B for ; Fri, 8 Nov 2024 17:45:24 +0000 (UTC) X-FDA: 82763653812.18.25E78C6 Received: from mail-oi1-f173.google.com (mail-oi1-f173.google.com [209.85.167.173]) by imf26.hostedemail.com (Postfix) with ESMTP id 264D614001B for ; Fri, 8 Nov 2024 17:44:54 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=BPJ39qPe; spf=pass (imf26.hostedemail.com: domain of axboe@kernel.dk designates 209.85.167.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=1731087837; 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=1vjdP3nlPrwhEhT0XuCs2kWKTL+yve8/Zr4EKKF24iPwZTuunPVZq99FU4KNTqp9lnuTug /G9omVnMVKSQIhDXYLJtfN92gCQHHdcMONb0h4VzAVwz4xLZb7zey+OaFilL+j3jTSs882 w25XyixVfizDddr/I7PBA5BsFGSPuPE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731087837; a=rsa-sha256; cv=none; b=jyj42Dp51yUl3fUHGSWiUM5ediO55VeUPLOHoZNYKN2E+viay0jAy0V0uNV0T6/8lwuaVK aNaA8gLbcCadf4aLGRJcTV8m010a1MzD6NOlnLwZ5J3ShGBNc5ibbNW4DLJlvPyfpozyHf Cx132etieaAq1DySOTH3GgCiIuY+a3U= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=BPJ39qPe; spf=pass (imf26.hostedemail.com: domain of axboe@kernel.dk designates 209.85.167.173 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none Received: by mail-oi1-f173.google.com with SMTP id 5614622812f47-3e5f968230bso1270848b6e.3 for ; Fri, 08 Nov 2024 09:45:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1731087922; x=1731692722; 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=BPJ39qPeWAyi0QNo1R5wi208IRfUo5we5Bq1JQgYkbEpwIQsIYTwcVclz64/4a3WIh kT0zFGjp9nYMBpCcApFHKP6AbBhtYALwiR0iipvsGs58wxOG7ySaIrJmhs4d5SH7M3Yd bDj/hfZybkG/XVemtm+U6kOwxQ4aGbfsCjZdSxTIeG4HdHFXm7rC6hf/VGUUQKpa+u1p iFad+iHH/GUapCQAs3bcwxa2pRDzulR5RANzi1IkWrxn9N5gSpu6euX0wjYjhXolSvkS 5RWMWt5FUN1pdQWjoO1J7QVJKrDHCdLeaSoM+DzakViA5SAQXmLxTJKPvKEPse1IuRJ7 2Lyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731087922; x=1731692722; 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=r0rhQodXER4vDz9+jdb2FfHHcoJPaUN7e6nkyFfMUjRiDKlJ3P4XRukMVCphmHgT6M Qeunj3eTp4YS3U+etGtsrgbvUkf2HIP526YXZ1QyU0un8Dk/R6p4Ua5Awn5Q+7AsZLl4 jkoxquuz1FLt/13Kdd1G6yNFb6Vxxs56h3kfoPOp6W/+UAZBpll3J686bvGUUYYdjqsS 4WD1HY4k7WrE9wUYqVqv1YXM4dNjWOLIs0/Qm/tW8R6wzNftTr8v85gY2pSmbVH/IW0r vae6uTkNybBo+6L9rwx9m1P6jbiNbsT9OfXfMlL4rVvgeqJNmRtC3J1RLHIr+4r8W1TL yj+w== X-Gm-Message-State: AOJu0YxmxFL9/c581X2kMON6Ad5WnzdGClH8sMCwO/Mo6xngLeE3kzlX d8TjyNUyFksd3ShTmEnsFokP6rn3BMVAhmk5cWfs8H0l7fsFc3HhtQkyViwnx5MupT+4Q1Z54Hz Sc5o= X-Google-Smtp-Source: AGHT+IHAnYXln3VhbkemWI+8mH1zeQAS07vGHF77rvkzzA3Evd8Py7SGOWt6/hgQMWEBNANFNnt9yQ== X-Received: by 2002:a05:6808:1987:b0:3e6:1057:21af with SMTP id 5614622812f47-3e794772f73mr3805781b6e.41.1731087921963; Fri, 08 Nov 2024 09:45:21 -0800 (PST) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 5614622812f47-3e78cd28f80sm780969b6e.39.2024.11.08.09.45.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2024 09:45: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, Jens Axboe Subject: [PATCH 06/13] mm/truncate: make invalidate_complete_folio2() public Date: Fri, 8 Nov 2024 10:43:29 -0700 Message-ID: <20241108174505.1214230-7-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241108174505.1214230-1-axboe@kernel.dk> References: <20241108174505.1214230-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspamd-Server: rspam10 X-Stat-Signature: nd3i3noktg5u41hzmj3bwnsrdeu3qt77 X-Rspamd-Queue-Id: 264D614001B X-Rspam-User: X-HE-Tag: 1731087894-340313 X-HE-Meta: U2FsdGVkX19GcY0QMoXIz+pxDRB2zHtxF54YtipbFX3AZvwstcTYCdFNMDECIM79vgaJm2o2AJX8H+bhduwMquZz8yzv4zd42wI78QYQK3ZXp+DfpCXkMUeZH6/ekbkEly97Iio1G/Edstf6KyK68+EYsVRb5uLMZXaNRJbANzx3c3vpnP5v32DHcQJRImuovSMqHxELkY4bdcOESSzv4pNfqIBRFj2950+dDj0W/baxbWyL8Mudt2ilI8Yx0hSIxUAlLhSxEVuNvCGAdXyZZ9fy68/O8dvTHTxUwspvNJUlxd2H5l3noH+3q8tk0F5Ddepx8KXs6rJVTpKy6EHEMmozkfq8Z5AJTU8Ql/mynga8zqL3u1Eu3lvxTOyD4f09rc7sfP5TMmP14Z0O15vF28wCygH0J0Xl2l3TKsWBrjTgWRx5ADgom3T59ZHCcT3mjaD+M0H8rhIo6KrIiuB+NQYsh66V+M33926kvUwrOdAVAEBkTtKFnrE5nZJTnYFfdeN/0F2CxTHLAWmUy1yDic75cSeUjqh+m7Q3Y/dI6n5DueOv7cvODg8wQpBPtAp7JrEVRtbBEM6kZ8L6ciH63HOuffnVfH/bD/FnsyuwKbkMKq2/ZzL6dErbI5yFwVQcFLuLfmGW6aNX58rjwfFM/ZDgZJiZjx/WfGfzShHN8rJiqJcww21yZDuy6uj8fkFXyOxzI+dEsf5mN8cYjH4CwkJAtiOEBUiUWTv/EA/BoAjuXMCenknGOhrIMQzpwiMqEm9a3fNpGHChfWE5BVvUf4QEzQVEZIFDidMMF753SmHVHwF+gbXatV0AtLE4SyW9QnL/Zjr5maJD/z25+xGb100XSgveuoDuF0G5iOOxhuF5Z/QorQ4nmdlkW5TsrTz3xCTu8/zneTEs/mRQIEu61oGvRBLdlyqtNMOyI0rifn0IIKhCRext9SZ94T6jfo7SxbxwOdxizaapT1Fb0Nr WKrODKhN 3tMQW4NLKTgNjg1Tx7CEC2fdADWwgbBXSZpN+Ro2HP17+cX1PB0busTTStIzX8ROYpdv6xWaRkAhrr0IiwRB/NGPkTnVEFTWCkax++iSUxfgfnj3/n1NR4Hn8gp4Gh5kZQjlZraQ0yXl3c+olfmlQyMuqRSow7CHhYiUL1ULl4lNygZ+CRfwHLWnGneQo0k0bDF49h6ucSItyvLYw80Xz1VHKpEMV3tw0xiaDHyUwYHdqCtIveQb28HotW2WsaiIZy91WkpxBjPaDT/1HRyg/Cc5aHM+fv6x4sEbRKApemSFhynyvqnnoX2ZMxuKwcO+wuoTG0ZtytpgtgpzqV9R25uJ4OhRrgKkpeNrw 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 Fri Nov 8 17:43:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13868800 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 45B79D64075 for ; Fri, 8 Nov 2024 17:45:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 14C716B00B6; Fri, 8 Nov 2024 12:45:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0F9846B00E0; Fri, 8 Nov 2024 12:45:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EDCC56B00E2; Fri, 8 Nov 2024 12:45:26 -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 C64B66B00B6 for ; Fri, 8 Nov 2024 12:45:26 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 80D6C40E7E for ; Fri, 8 Nov 2024 17:45:26 +0000 (UTC) X-FDA: 82763653896.16.77DA39A Received: from mail-oi1-f178.google.com (mail-oi1-f178.google.com [209.85.167.178]) by imf02.hostedemail.com (Postfix) with ESMTP id 9599980022 for ; Fri, 8 Nov 2024 17:44:14 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=DOyAI5iW; spf=pass (imf02.hostedemail.com: domain of axboe@kernel.dk designates 209.85.167.178 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=1731087838; 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=wWDNTRuAGEC8P1PkMAQXcWfNP3UvXVPT3pXPdqP7CT4=; b=8pJAWKhPxRnOFVBtwUrQFjQWAwW03P+spO2xF+nh7OO78VhOxLizLWWvHHNBPDdMk6p0ol n+Xa0ykAX58lSWnxIWEPg4BjCAsN+Ruu4mDw56suS1kh7h9RIJS9ernwObtaGwcO1F/oJJ 72BaqLyf7zPcEeUrLIIPFXl1vMO3jSk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731087838; a=rsa-sha256; cv=none; b=7i3JK1T9YX+sjVWTWVDLrLmpkop4t3ZrpPiOfi7ybRvE+Nj8A/exWbu5WjXLBaPNsDJ3oO eVrAwBVepUAomgQjaRnzasXWjTcKMzA+Ewi+gYBl1g0AQ0wzS+QRYtsw7EiA/tfZ1MyHu5 KWVnzBVi+raEAICS8LWQCJ1cFOgjEGI= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=DOyAI5iW; spf=pass (imf02.hostedemail.com: domain of axboe@kernel.dk designates 209.85.167.178 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none Received: by mail-oi1-f178.google.com with SMTP id 5614622812f47-3e607556c83so1581617b6e.1 for ; Fri, 08 Nov 2024 09:45:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1731087923; x=1731692723; 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=wWDNTRuAGEC8P1PkMAQXcWfNP3UvXVPT3pXPdqP7CT4=; b=DOyAI5iW9njSI/n+52sK5n9g5WrANMKGAD1+s3lwc1ATuzL8A+OMn+JaOBZPLuMCco +vWm8qzPzlXU0InsRuG4TT3gmPwkIojEVmgDgypWJIZMonpSegDFAL+zFA+CJOb0PNDP j6FHToWdank5fl3fYJZ9UK7jUzyRuJYdMcJ9JUzJx2zueIUgJbHDrvoZPP/Thm+ceQx1 rVaxaJCCYpgnteSjUK/LcAEdAt5RefajX2gRPKbL1JjHmOF3JOCeACWfhdHldiZBDg+Q 5OiHzY9JNJBek4vIpd5NIyyja4UmJySqjK46e++Ie4kO8UjkRYKOW3u4K6VIODuj5vHm +t7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731087923; x=1731692723; 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=wWDNTRuAGEC8P1PkMAQXcWfNP3UvXVPT3pXPdqP7CT4=; b=qbcldQGqS6fkbb4KXJxzxrelNtXuSStF8oSKVlMt35vPVIGLLlVY/tOvnVLz/Fe57H opVPylQkeVACsaKmXnVmqzoR/SFJVNcGaQmhVUhkvS5wXAff1g6AgDOVyosLlq+p7RDL ia6gABNEslQiaX8MBxybPcm4nypHYILPr+IXSPnyUJeDFw/N3eV6P8nsuSc772oYcokZ FvgVgh7Mi7OrQal14wf2aCzQ2WY2VagjT+QzXUBjWFNtdCFTfUXFNs202b4LnTt+kWWT +OjUP2foTBWJPqZWm8wHouDFdyhp8LA0dSY3Cm8gyHUMuJ30hsNQsP3SwhNnZbnn970V /WIA== X-Gm-Message-State: AOJu0YxvkrwMyhw2M7pZEkUU2cK8iM0nl5fgIKtqP0WYWR0kUoIGDQM3 P2l2czkeZ3ni2mi/fGXHMraflWha6cP34oKr8G1Mc4MR84aNWI+sh5NUiOh4mRXqfkiFuZt7TFt CvzE= X-Google-Smtp-Source: AGHT+IEpy29b6bGe+h/CboagPQRbeA16vn/em+bpmlLLfLOrXhNW+1oHUaJS7mfyo/74o97NJpvLFQ== X-Received: by 2002:a05:6808:1525:b0:3e5:f141:1331 with SMTP id 5614622812f47-3e794733f1fmr4465090b6e.37.1731087923389; Fri, 08 Nov 2024 09:45:23 -0800 (PST) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 5614622812f47-3e78cd28f80sm780969b6e.39.2024.11.08.09.45.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2024 09:45:22 -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, Jens Axboe Subject: [PATCH 07/13] fs: add FOP_UNCACHED flag Date: Fri, 8 Nov 2024 10:43:30 -0700 Message-ID: <20241108174505.1214230-8-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241108174505.1214230-1-axboe@kernel.dk> References: <20241108174505.1214230-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspamd-Server: rspam10 X-Stat-Signature: uqu7srk733h53x5w5e9wgexbrk5buhcy X-Rspamd-Queue-Id: 9599980022 X-Rspam-User: X-HE-Tag: 1731087854-594509 X-HE-Meta: U2FsdGVkX1/YRAno5TFiMbb7TrLhBG6Nw8Bu6csgZBkh0Y1WbW36XCU8ecRGlrMA+ZriEkh1cNjAxCjgGsp5PhaQkiyNgdK1/lJtojt/IRBRAKWM4+oVLYsmLQKI9RLyrb89jY1xgIAKNBz/kH32ph2eaMGvc8YzOMOiqQA8oKfN62v3W3TFi0oVK/klfZcgcfkdsF0coeOFagPqJ3Z79N2cMgrhPeXFII6nRw4oYz4P/o/V7o5YxdxLxE1nvJbMpIMpCnNGwWMdudsnuzc95NpjJm23oX+zSzugJKDBzez50VkiCsBLEomUGeKhzF7sDGM/FUw2lxLqz/plfSnJ38QagwGrZi6kjhJG/h20HwE8+jUBI3v+q/FT3KLP65Cz333rEHBgwwGptgS6Xz35rPAHC0oChq3sl1FnesxUCuWI/VyTHPMWx2JukM8RuE1NYB4tWN2NJ6mvEdCSoQQOsUgfeQ6HBMsA4RQQC+1V0lFxs8jX29TfhJAa8mqg18pGFjzHlwOhNgffUeItRpX8sVDyXYvoosFe64dBhQWov7RV2EZv4XlAkObtzhMdPsceyQf9HV9eKKvSLeppzbQx1fO0uX3wnku/gv+68HQeAFTcrOfVs61t9g35m3HQ5dfpAB4uuFRyztBCmEuphDRhHy9N3Qz+GaZm5oIHueZRTbBG9d8hwsRoggFahJdG9KVE4W/iky8pu/pYiCP8tC/TwVK8qAbi8OafHxXxfSs/gRBQJmPDMGayv2eOr1pg22UEI39aZX6NjjIJICNUrN3oLnniJhAHCr6Cev06u2vaS9w2Gspkhe2Sk+zsU1u3j26Mhwzexaih0D6JOKan9xEgXYB6EGdvuuhyi9w+CQH2Tqc4nkrBjfyk3AsNTWjMNJHLq9BMaTY+CA1LoDgPAoTjWV67jm3n638m3i6zxubbvK67pEe9j2/VUj7echd4fWt+K1FTn8IVKPCUA5Il0eD PHEfl07i TaVQxmeL7Pkza7x2Hrhi72WJHW3Mm381OZUc/9JbbSVpybHSLbRfKLdXE9WN3ttDLafRamYo8WycLKIRFu0yYa8uuGBnLI4NHk7JbttsN9cP1NsZWOnXDs9ZcHMHpy5PoucyVCrxqCNNRwfX4nXazFqJxsZ96XKGHMpEQHuOOMBYi41JKV8kHdKTMX6qiIQc7kSNdJNk4Cs4ykvuD/bkK9ZFBtbXPhfFQWKAEcisQOrTWCqsfpvwRzhmilrvCXXwiSU9+D78VQ+gMREo8fqnHIM+4WpOfshnriEzbc4Rog9YXvgB2bF+N6J3W8Z2HyY54bjrOPZWM9BV63l9o8q1Jw5JZKTBwZKYD78B5 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 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/fs.h b/include/linux/fs.h index 3559446279c1..491eeb73e725 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2116,6 +2116,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 +3534,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; From patchwork Fri Nov 8 17:43:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13868801 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 2C5D1D64078 for ; Fri, 8 Nov 2024 17:45:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9AF256B00E0; Fri, 8 Nov 2024 12:45:28 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 961266B00E3; Fri, 8 Nov 2024 12:45:28 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 73ABA6B00E4; Fri, 8 Nov 2024 12:45:28 -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 544E76B00E0 for ; Fri, 8 Nov 2024 12:45:28 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 0219E160231 for ; Fri, 8 Nov 2024 17:45:27 +0000 (UTC) X-FDA: 82763653056.19.FD10C40 Received: from mail-oi1-f172.google.com (mail-oi1-f172.google.com [209.85.167.172]) by imf17.hostedemail.com (Postfix) with ESMTP id 8293840026 for ; Fri, 8 Nov 2024 17:44:57 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=TsvjZw8E; dmarc=none; spf=pass (imf17.hostedemail.com: domain of axboe@kernel.dk designates 209.85.167.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=1731087755; 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=Tq+ywqpEyPaYsCraC6z/Wa/2p0SbC90MEdwC8hVGLhU=; b=6reP76dFMGtQ0rDqvNg3CJ2AAdLjaqZYJEczPK5YSq3dBr6emjlId+vkO3kVrOcmBzsVZL zARL3KzhkgyPD9GWeroMyT3CXG1pYWGbj72jyobDv3cJZPKJpu5baCw8ER18qHMNPwEtWp 5WhRvB4zezy9O4/csxtig+aS8UCyidY= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=TsvjZw8E; dmarc=none; spf=pass (imf17.hostedemail.com: domain of axboe@kernel.dk designates 209.85.167.172 as permitted sender) smtp.mailfrom=axboe@kernel.dk ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731087755; a=rsa-sha256; cv=none; b=sB0Bjp9QQn1IIBHFs7bkABFGVlUH9RqNiwwmE9LF4wOF1Vm6W8DZ2r9n0tt9jJXDCRAYGX g0WW0BChsYf8lMeDmOMyVwk6KLVNI70TBeDGYYmnWKl4iTQLWyt6L3LO1ZQTLeh3Jdaft3 AhVLIrNNZcoNFN46Nk4IyrfBdtjO3ec= Received: by mail-oi1-f172.google.com with SMTP id 5614622812f47-3e607556c83so1581624b6e.1 for ; Fri, 08 Nov 2024 09:45:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1731087925; x=1731692725; 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=Tq+ywqpEyPaYsCraC6z/Wa/2p0SbC90MEdwC8hVGLhU=; b=TsvjZw8E/RVPtPCjNuHmBndQjfyOd78dkkfVtsAcQEr8Xvi8Nk0xjUy6M4LZJShJTg +8dfjWFTWU8nTpdMb1stdYKMcAOfFbTsDN1DzMl0S31NGB8Oo5I8tdYnLQ9Bv5oF4h00 zVNUr5Sm63JvgD1LD1THF6a2ZSoGhrX2BYNQ0afCCK4sBrmbklWtiFpO9y9InswymFK2 b5sZcPmteTPv9BkMg+SslJhdHkbM2X4m4mtHcEJvcD0kVx9MQbxk/nRqZfKGuGlznjhv lddjF6Q69pnSlZuev698gKxjuj+FQa75r3v9xP8cyyf/RYHR8E1tF54TBYrJsjprnXsV ea0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731087925; x=1731692725; 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=Tq+ywqpEyPaYsCraC6z/Wa/2p0SbC90MEdwC8hVGLhU=; b=QVUEE0dQwgtToi9nUkS7aRmE2KYplGwEoPiWj36YOLDEa+7pkvpcRAtqVrwmGt9NkS 0hK8u3feJygJbpDA3jVIiQP6EC4j8gb5bakz0LF+oWjcBZ+2SgFvNCxrxre6+bLgBkYN LAaj9zlKfFxqXySPgnVi/vhDiClhJLunF3v/+zyFC/jhs66dP8OgYUBLg79xOt44K9CL VhguY0zj6eCtBs43fRadz1DeaMEmxi7vtwifLIp1ylnhl3V/PD1FJnusEIXvsspb460U nY+ERISO+aXpiHrUQGH13AE4/LeYXPA4ohMohXsniFGuHe6sqAgtPkTP3molIYUttPDA dD+g== X-Gm-Message-State: AOJu0YwDN8hGQsQS8UfTfAZ2Zjq5DxPOo/D4eP3Hp0qk9yT/KTfVf9iD eYd+o7T00giDI+PmObBcOiXo1B9bG34v6WnTzs6vl73IkSQeJbpB84hqKMhYhn1WMUc4T9KHTvQ t4n4= X-Google-Smtp-Source: AGHT+IHYb37IuRL+rD3E4bWkVAGE9ioVB03ZuysIUbDHqe4Odg9KTg4FuyvIzrjyhDZyIdkBKG8ezw== X-Received: by 2002:a05:6808:1819:b0:3e6:3205:1a71 with SMTP id 5614622812f47-3e794699f41mr4284876b6e.15.1731087924649; Fri, 08 Nov 2024 09:45:24 -0800 (PST) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 5614622812f47-3e78cd28f80sm780969b6e.39.2024.11.08.09.45.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2024 09:45:24 -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, Jens Axboe Subject: [PATCH 08/13] fs: add read support for RWF_UNCACHED Date: Fri, 8 Nov 2024 10:43:31 -0700 Message-ID: <20241108174505.1214230-9-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241108174505.1214230-1-axboe@kernel.dk> References: <20241108174505.1214230-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 8293840026 X-Stat-Signature: r4sqnbr7rkdswszjwz6ihdajty34ju71 X-Rspam-User: X-HE-Tag: 1731087897-754227 X-HE-Meta: U2FsdGVkX18mEu9LbJQ3RTcpbcLea7Gm6gxOAj59WPYE/nst/h8U7K8wZ8cNjOVVSkWvVstmPgrDEZfIbgrAuSgBcLGz5uS43dnMIjs1S3uoRkmSmG+p/OT869EKayCPutCCSUM2WhvDg/pMdn7+ID6kRS3VMrNU6/l/sSimF6vmuL4it4FQnWz6rzgvemNR1c8inz0clutAdypsV9w89yfHlb3moUKwdc4pNmRJoUFB3Nj3bhek+ZXm5mBAPq2YT1eF+sg+zQBmWvVqp4b119PgY0U4RgcseYgVb8QsxQTg8QfTfQV69UOIZ/CJYAGSaHpBvMwuUFfzOFmsx1p76vv6RqmlhahTYpZymTqp38cIpHKzy2eEP8AaNYe0kMxg4w/k4mcBqGG73z1d/zkfQn/nE39E2mCgykktMKFEIfS6dS5emkdidEF9qTmHdVsEGIFVzCc9XjKYurorr38gBZiCBlSyzsH+xF40SzqGtdrnQUB1uUHIBnksjHxaEPlxgoLjllftl20RHjqe/hQ21qFHXqpBH2TxtUT6RWQAIzBAYGPNrSMRXipHWiQGPc2BlMsPDpAEZ63XDxZREGZ99AAJj8NNe6p5CoHWeN3vz38w5bT7pGZHJGc1Vb8jJr2954b8vyrZNyJKnuIAIzP1ZijpesBi2VqTU0/kQDS6IaHhfAH0GIihV6xFqZoyAfwhTsNS69DRUYHWk9W+H/iR0nqcnnClP7iUcjtfztjW2sDJV6PFDjvuwofvXMt+j0bvz7ZnaTYpyYtIYfMxe4oR2zkoM9Hp7lD8c2xfuM/ptt235yBpfAKM0GmghVoo7LeztaIJq6IxiMqeg10UJ5L1Cu9TvyaC3OQ0D8cD4193YqjDjvXuaGonbJf9MrTz/JpgEGTDMv1VHOWqyLHSc+k4VvHc/T9toIQzj1Iu3W1SJK9kcurTuGfB3HqWzuKWk16097ycWHPSSopSqlTSkux h9lKGnoY Kgl/2+UE7yKkDN0DhAcOC4TETLmPYDdPWEo6HTQrfaQyiOF0DebqbR/R5jwqkz/cuHm9LbV3Tbra7leeANVjBUhNE1h51gnhMFIGiBUxkPQ20UbH0GA3xPeXgiiaWAHy3eqc48iLg2JbXjeW7288Ic6uGDuGpT3rQpj3d8c3OaUphXqJ6E0xnnGx+izsWTkDIF7nPH+AhC6mrod4z0v6GHURahG27l6jULhnRLNnNX834/X+5ipz3qkUAVge3nhb+v85t9KJOIPXaBpp2HrnevczbmwvkNFl8oU6v7qme2Rj1a2luYVBFs9SkNQhqmMH/WDTO2XMS0xN+sPs6+BrTQx/r1d6pgKX4cEDy 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 RWF_UNCACHED as a read operation flag, which means that any data read wil be removed from the page cache upon completion. Uses the page cache to synchronize, and simply prunes folios that were instantiated when the operation completes. While it would be possible to use private pages for this, using the page cache as synchronization is handy for a variety of reasons: 1) No special truncate magic is needed 2) Async buffered reads need some place to serialize, using the page cache is a lot easier than writing extra code for this 3) The pruning cost is pretty reasonable and the code to support this is much simpler as a result. You can think of uncached buffered IO as being the much more attractive cousing of O_DIRECT - it has none of the restrictions of O_DIRECT. Yes, it will copy the data, but unlike regular buffered IO, it doesn't run into the unpredictability of the page cache in terms of reclaim. As an example, on a test box with 32 drives, reading them with buffered IO looks as follows: Reading bs 65536, uncached 0 1s: 145945MB/sec 2s: 158067MB/sec 3s: 157007MB/sec 4s: 148622MB/sec 5s: 118824MB/sec 6s: 70494MB/sec 7s: 41754MB/sec 8s: 90811MB/sec 9s: 92204MB/sec 10s: 95178MB/sec 11s: 95488MB/sec 12s: 95552MB/sec 13s: 96275MB/sec where it's quite easy to see where the page cache filled up, and performance went from good to erratic, and finally settles at a much lower rate. Looking at top while this is ongoing, we see: PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 7535 root 20 0 267004 0 0 S 3199 0.0 8:40.65 uncached 3326 root 20 0 0 0 0 R 100.0 0.0 0:16.40 kswapd4 3327 root 20 0 0 0 0 R 100.0 0.0 0:17.22 kswapd5 3328 root 20 0 0 0 0 R 100.0 0.0 0:13.29 kswapd6 3332 root 20 0 0 0 0 R 100.0 0.0 0:11.11 kswapd10 3339 root 20 0 0 0 0 R 100.0 0.0 0:16.25 kswapd17 3348 root 20 0 0 0 0 R 100.0 0.0 0:16.40 kswapd26 3343 root 20 0 0 0 0 R 100.0 0.0 0:16.30 kswapd21 3344 root 20 0 0 0 0 R 100.0 0.0 0:11.92 kswapd22 3349 root 20 0 0 0 0 R 100.0 0.0 0:16.28 kswapd27 3352 root 20 0 0 0 0 R 99.7 0.0 0:11.89 kswapd30 3353 root 20 0 0 0 0 R 96.7 0.0 0:16.04 kswapd31 3329 root 20 0 0 0 0 R 96.4 0.0 0:11.41 kswapd7 3345 root 20 0 0 0 0 R 96.4 0.0 0:13.40 kswapd23 3330 root 20 0 0 0 0 S 91.1 0.0 0:08.28 kswapd8 3350 root 20 0 0 0 0 S 86.8 0.0 0:11.13 kswapd28 3325 root 20 0 0 0 0 S 76.3 0.0 0:07.43 kswapd3 3341 root 20 0 0 0 0 S 74.7 0.0 0:08.85 kswapd19 3334 root 20 0 0 0 0 S 71.7 0.0 0:10.04 kswapd12 3351 root 20 0 0 0 0 R 60.5 0.0 0:09.59 kswapd29 3323 root 20 0 0 0 0 R 57.6 0.0 0:11.50 kswapd1 [...] which is just showing a partial list of the 32 kswapd threads that are running mostly full tilt, burning ~28 full CPU cores. If the same test case is run with RWF_UNCACHED set for the buffered read, the output looks as follows: Reading bs 65536, uncached 0 1s: 153144MB/sec 2s: 156760MB/sec 3s: 158110MB/sec 4s: 158009MB/sec 5s: 158043MB/sec 6s: 157638MB/sec 7s: 157999MB/sec 8s: 158024MB/sec 9s: 157764MB/sec 10s: 157477MB/sec 11s: 157417MB/sec 12s: 157455MB/sec 13s: 157233MB/sec 14s: 156692MB/sec which is just chugging along at ~155GB/sec of read performance. Looking at top, we see: PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 7961 root 20 0 267004 0 0 S 3180 0.0 5:37.95 uncached 8024 axboe 20 0 14292 4096 0 R 1.0 0.0 0:00.13 top where just the test app is using CPU, no reclaim is taking place outside of the main thread. Not only is performance 65% better, it's also using half the CPU to do it. Signed-off-by: Jens Axboe --- include/linux/fs.h | 4 +++- include/uapi/linux/fs.h | 6 +++++- mm/filemap.c | 18 ++++++++++++++++-- mm/swap.c | 2 ++ 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/include/linux/fs.h b/include/linux/fs.h index 491eeb73e725..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" }, \ 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' diff --git a/mm/filemap.c b/mm/filemap.c index 7f8d13f06c04..6f65025782bb 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2471,6 +2471,8 @@ static int filemap_create_folio(struct kiocb *iocb, folio = filemap_alloc_folio(mapping_gfp_mask(mapping), min_order); if (!folio) return -ENOMEM; + if (iocb->ki_flags & IOCB_UNCACHED) + folio_set_uncached(folio); /* * Protect against truncate / hole punch. Grabbing invalidate_lock @@ -2516,6 +2518,8 @@ static int filemap_readahead(struct kiocb *iocb, struct file *file, if (iocb->ki_flags & IOCB_NOIO) return -EAGAIN; + if (iocb->ki_flags & IOCB_UNCACHED) + ractl.uncached = 1; page_cache_async_ra(&ractl, folio, last_index - folio->index); return 0; } @@ -2545,6 +2549,8 @@ static int filemap_get_pages(struct kiocb *iocb, size_t count, return -EAGAIN; if (iocb->ki_flags & IOCB_NOWAIT) flags = memalloc_noio_save(); + if (iocb->ki_flags & IOCB_UNCACHED) + ractl.uncached = 1; page_cache_sync_ra(&ractl, last_index - index); if (iocb->ki_flags & IOCB_NOWAIT) memalloc_noio_restore(flags); @@ -2705,8 +2711,16 @@ ssize_t filemap_read(struct kiocb *iocb, struct iov_iter *iter, } } put_folios: - for (i = 0; i < folio_batch_count(&fbatch); i++) - folio_put(fbatch.folios[i]); + for (i = 0; i < folio_batch_count(&fbatch); i++) { + struct folio *folio = fbatch.folios[i]; + + if (folio_test_uncached(folio)) { + folio_lock(folio); + invalidate_complete_folio2(mapping, folio, 0); + folio_unlock(folio); + } + folio_put(folio); + } folio_batch_init(&fbatch); } while (iov_iter_count(iter) && iocb->ki_pos < isize && !error); diff --git a/mm/swap.c b/mm/swap.c index 835bdf324b76..f2457acae383 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -472,6 +472,8 @@ static void folio_inc_refs(struct folio *folio) */ void folio_mark_accessed(struct folio *folio) { + if (folio_test_uncached(folio)) + return; if (lru_gen_enabled()) { folio_inc_refs(folio); return; From patchwork Fri Nov 8 17:43:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13868802 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 DFE9AD64075 for ; Fri, 8 Nov 2024 17:45:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A27A26B00E3; Fri, 8 Nov 2024 12:45:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9DBDD6B00E5; Fri, 8 Nov 2024 12:45:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 84F136B00E6; Fri, 8 Nov 2024 12:45:29 -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 5E5186B00E3 for ; Fri, 8 Nov 2024 12:45:29 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 1AA071C3BA5 for ; Fri, 8 Nov 2024 17:45:29 +0000 (UTC) X-FDA: 82763652888.07.566874C Received: from mail-oi1-f181.google.com (mail-oi1-f181.google.com [209.85.167.181]) by imf01.hostedemail.com (Postfix) with ESMTP id 5F0B740002 for ; Fri, 8 Nov 2024 17:44:58 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=0pGqEBHl; dmarc=none; spf=pass (imf01.hostedemail.com: domain of axboe@kernel.dk designates 209.85.167.181 as permitted sender) smtp.mailfrom=axboe@kernel.dk ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731087867; a=rsa-sha256; cv=none; b=pulVld9bgbEj+7sTfE6/0zzqIbE51uRmhxsmw+sECGfBFdupabmQ1phvpkUMqMw/XcPR2z 1BCc80Ugd3F2IalfEXdJ4mF5RMDqUvLa4N251g+AXh4yj/YAP3ZcFHZBwMsdeW7qs/EbDp HymesXpZCvp/seElWW8qKP9b68ZkWuA= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=0pGqEBHl; dmarc=none; spf=pass (imf01.hostedemail.com: domain of axboe@kernel.dk designates 209.85.167.181 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=1731087866; 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=8Os07YYPQ7kZ+kUIdYmg3svY/CQbT8cCz0FxxTNIj/Y=; b=Ujt11bCnppcbs6PPFijgn1cKnT35hvi5LBtpbvN6EbA8b1Zc/vUjhukNwpi6TB37VGKGV4 D18HpsaviCwsxlRlLD3PPWy9RLu4TMQeEfiWobuIPv6/S8+d54FcfK2D6E/3sMmuarJUcV Qa1C13Ngqo07rkVcfRW44ISycw5uinw= Received: by mail-oi1-f181.google.com with SMTP id 5614622812f47-3e5f9712991so1354975b6e.2 for ; Fri, 08 Nov 2024 09:45:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1731087926; x=1731692726; 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=8Os07YYPQ7kZ+kUIdYmg3svY/CQbT8cCz0FxxTNIj/Y=; b=0pGqEBHlj6HmTXxFltByEXY2LvAK8bqJh96kaRYyTlIrpNguZ6iucuT1ZvoVeoWFyO BnIckhAjIiTOamohc8niO2HqwPzoRsfbtG691yXMvlRsry7ynNUeDpaOzMb7pX5GNIT0 p/zUYyaB/xFzRySoTLokteXn/Z3G2Jl2pIJZQZo3gqruV2Te+9sGlJuqI+zgVMLY1rcU FFyujmFfoDU8gJ4zEwEG2eo3PRHbCQf1ZKvax7nkloMR9C3j4h72Tj5UXQmbTk0mJDM+ 0056G9COt7ZSt5XuMr3TuzCqNE9cqRD6pTfeOI8HL6p9SvKj0mowhTCa7EHTxbi3wsOx QQJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731087926; x=1731692726; 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=8Os07YYPQ7kZ+kUIdYmg3svY/CQbT8cCz0FxxTNIj/Y=; b=aP1ZkoQEcJjJ+VW1EWx9RZgMfmP7zt5ue3NCaCi5hZlWFuNLQT0qmXrkXbsRc/hRjx r50zXe9nnUWeLaNYgaERoAdlGKdfHtO0clt9ixEOpPriOsVrcyqNDgl33oUuTyjGUvZl 7PioR+0TR+F36DI57oiX5ksQI5eQuF+fT62F43hdnwussHLdx8Fl1CBBc2cGqG6/ByeM Wbq8MoemBqJ2pJfxAlF8P5sMbiGIIfxXXBi3jruBL3FxeJy7E0+ZcuEsSsQk54xkLkXD GYc7GDgD1EWHrBvR1QTQxMommFX8G4RDePvpV6KF9fMtZQ/X5i8lkStDTcfq9aVuQwHT 48yQ== X-Gm-Message-State: AOJu0YzCnjnydzX6nWpmb2mQUwpkN8XdIbyddp8vcCbQ22U5QhRejKoA AIKMIyugQdh54eiigDuPnaZtQBDkLR+WGhJWAQJJIo1ZCGatXyW2nU3B4ST7V5EHTyqpaK8uMBQ H7vE= X-Google-Smtp-Source: AGHT+IEK3I8pTmLVAcP1tiUKABdaXPcTEUhdzcwYlEN/XSWu4cE0qIXfxmg72hsMc3+DTSEsR4vUEg== X-Received: by 2002:a05:6808:120e:b0:3e0:4db9:8c44 with SMTP id 5614622812f47-3e79470a35bmr4931161b6e.27.1731087926068; Fri, 08 Nov 2024 09:45:26 -0800 (PST) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 5614622812f47-3e78cd28f80sm780969b6e.39.2024.11.08.09.45.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2024 09:45: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, Jens Axboe Subject: [PATCH 09/13] mm: drop uncached pages when writeback completes Date: Fri, 8 Nov 2024 10:43:32 -0700 Message-ID: <20241108174505.1214230-10-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241108174505.1214230-1-axboe@kernel.dk> References: <20241108174505.1214230-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 5F0B740002 X-Rspamd-Server: rspam11 X-Stat-Signature: metxok9ksrbpxq9hydrw3nhbdaw6f5ud X-HE-Tag: 1731087898-15758 X-HE-Meta: U2FsdGVkX1/LrOGr4wT40G9EscYRpROsguzI+aF8vgq4pIOkYQc3DtURTF2BK0vnm70ubP4m+4fFTuN7muaBNgEoX83ZjPDVwHFeLbEAuGm9nzno/NhP1QoGcTNWFK1YDzb0IQ4X9e3VZYOLzvgET6ND9SPfm4CqmFMLxeYdUXNndifssFvKAdBJy3GQh5shV26XkRY+dPha+rQ5PlPoQjlPursc0UI0sj6pc+bV91FvgXDO2mIW4dknwhktUo7uyP7zq5savFfwfAceTynJeWsGleF7SNw3wW1SxK5a/CVBNj2nH/FrK6kS0PYKMmfzdIs9RJskR3+IS7aJKdgRl9KZMsJIAJ8vuhzFt8o5KyQGmP5rTeObbidtBd3LXN3A+qsISRQzDqLd38PiDcy6+hZ7wS3e+5iRxmWwlfPuKgMbH3rnQ1sM/LFEMnY+B1KQrIWXdaKB/NlD3axG9mtXmDEBeBJwIkf3VxhqoSe3du4J/ETgGtVIkVhMwuHBRhU9fhcMmR5FNNOERNfJ4Kkggo0svLC5IG27NBG84VIwZ++AD+FG2NS65b/5cxdE9Psnwtm8pFoNM+qsnEHJqYlM36e/hjKYirsm9a0dpCPy5lQaReSq11ZqQiC9g0Gf3ofugiLF8QQ8cw29GMCD62DfnDt0d4xy0Tdcr7UYK5nnn0qWh1KHMt0lF/hXmuj/QSJ8wrQ1mTzGG/mLgLey81m42POu2gpukbMpOL6BqIX/f8hOSBSiX9CQMlT4y5jROB6WpodKM4C8QzqDF+TbH3AnnhMMD2DjcAZxzV6xG+eg9WInajHGvwJn2JdJFlqcMMrH/pOHqVDgG/AaBQwGm5Fy9tzHTiZ2nJPbjNpMZOg/nv8UDvLiscGEK3NSrNQMSPwadhNaNxrwdjUCZdP26kKNvmrVqpj7sFYvznEAf6Ytf29i1AZymLytaTfc/WcD6KRSaW6AUd/WhpVsPWZp6Qf wfYHP65Z pBUqwHETSLW78Kk2KoFJ/7HoJLG3k5asxILotq6NxBs8ND+xgfbaZkchvnMeOs/vG5MvoiwZT1N4o28gQcd7fO+Ji6RqQYhTlGLAzoi0BM117Q3dhhLpwn/V3njFsKBB0cS3/KmMsbj19Lef0n7ILWoerqK4p6nb18W1j9rx1OyyS4WnMnUSFfHaaQDWU2otZCIoQrsIYQioZgjvMFtQHV7yO6lR9wIkmKp80ZyOxN7bm9yT44YnH8bU/EqMjYF6gQLjTlBIBst+mpwjE1rAp0z6JSUMyVcVcz+G1idhhKrAYGMRWCKSTVWcZf0Dyu73em/N9l8Hbj8pAzhM= 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 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 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/mm/filemap.c b/mm/filemap.c index 6f65025782bb..1e455ca872b5 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1634,6 +1634,18 @@ void folio_end_writeback(struct folio *folio) if (__folio_end_writeback(folio)) folio_wake_bit(folio, PG_writeback); acct_reclaim_writeback(folio); + + /* + * If folio is marked as uncached, then pages should be dropped when + * writeback completes. Do that now. + */ + if (folio_test_uncached(folio)) { + folio_lock(folio); + if (invalidate_complete_folio2(folio->mapping, folio, 0)) + folio_clear_uncached(folio); + folio_unlock(folio); + + } folio_put(folio); } EXPORT_SYMBOL(folio_end_writeback); From patchwork Fri Nov 8 17:43:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13868803 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 66766D64072 for ; Fri, 8 Nov 2024 17:45:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0D6C06B00E7; Fri, 8 Nov 2024 12:45:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 084EA6B00E9; Fri, 8 Nov 2024 12:45:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DF3B86B00E8; Fri, 8 Nov 2024 12:45:31 -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 BAA026B00E5 for ; Fri, 8 Nov 2024 12:45:31 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id D2EAA1A0EB5 for ; Fri, 8 Nov 2024 17:45:30 +0000 (UTC) X-FDA: 82763652804.09.263473E Received: from mail-oi1-f178.google.com (mail-oi1-f178.google.com [209.85.167.178]) by imf24.hostedemail.com (Postfix) with ESMTP id CF5E7180020 for ; Fri, 8 Nov 2024 17:45:23 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=17eBT1gp; spf=pass (imf24.hostedemail.com: domain of axboe@kernel.dk designates 209.85.167.178 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=1731087701; 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=UUX+L5JwxoRfm7kNG+SFpzZJbOBH//rHSLdNBno0i1Q=; b=hP/Qn5AAnvj0gfE0kaaBZSZv+GUZqz0lwfhutge40Z4zm1J+FB1Iww8pRF9R4WDhn6dEq9 vuN06BPlQ0azJQlE1Yv/Knnd2Pti8CkfwOMdZRNYt4QYxdrsReAeI7uzS4etyfl6yWIh1/ 1Lp7rwonAUexHf51zIEnt7RQX14Pt/Y= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=17eBT1gp; spf=pass (imf24.hostedemail.com: domain of axboe@kernel.dk designates 209.85.167.178 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731087701; a=rsa-sha256; cv=none; b=Ui1/sntzfocx537Z3QyKi5WfvCh3KBNzoM8SENdFLV/tV3Rsyxsqr08d7bnXb91t1Hv0HG mHyAc55gHzU2ZSBDfrprss5QCm/Jn+znIlaVxfZ6qQ843CNIgHxP6a75B7EK+u07U/8H8t ZOFEYm6NeW69ATXz0lBbhXJAuxa6WcM= Received: by mail-oi1-f178.google.com with SMTP id 5614622812f47-3e60966297fso1316671b6e.1 for ; Fri, 08 Nov 2024 09:45:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1731087927; x=1731692727; 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=UUX+L5JwxoRfm7kNG+SFpzZJbOBH//rHSLdNBno0i1Q=; b=17eBT1gp1GuQErem6BJ5e1aRfkrMZ+N6rFD2MAFy5B0SQHcqN3aIWsyl0pIGGp+p1O jXsbWdPLOhyTny2ffdM0HwqwKXIfaWf1l0Y7ImeoCE3TY7KkAmfY/Mz/z8zyeZrqhUEP gPQdifcThJe8ZyWzJ0A7Eh8RWQZX5+03JvcMuxeG90sdF1K6occ2pqdWDV23nMlaICOy bmReoghjRRO8xRuvHZGl0Sp1pm+xwxBK0tTewnsJ8g2WFtn4snWqkvKwTyKnuiIlOHfo mipCNojMLXcUl4vwDUbht4AWWZusCbHt2N8E3D7MAyE8RvXBgID0//HmGch+dxYjAhYn Gy2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731087927; x=1731692727; 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=UUX+L5JwxoRfm7kNG+SFpzZJbOBH//rHSLdNBno0i1Q=; b=Wj6Qfl/PmkZWnUs2L1pQdyneUZ0iC0b2Pa/UoMGmRoiINrgUFBTr0rFrbLz+sa68Wb kVVPiUNDWMAVch3cYmkDeJFfQB0fObugVmpmkCUoZ6m7DuGO0IZpAp+rOs20YmJcd+7x hGGWhF0BqtdWklH495tUglCfzEHzQ03SIZYmE8AI26VnNa1qggnYAQPnUUpEBOILdk1w G3gZYWRddys8OmywIizm/jxGPXZBeoAzsCW+Dluc2u6VgIkC/hfx7KSKYw78ryFb5J2J HgJ+grP5ySm5FyHfKjQ6Q+4wX5e7zxgmy5aOdL6YBtiVr/YPdXS0HYw96X7CyfKIcd6i Tr7w== X-Gm-Message-State: AOJu0Yz0PX8iq1hDkpfuH5eAq4Pji1026/f73r/6M1pZkus8gWQj1jgF ET2iveAzYUaO2VUMvVIMnNge+YXk/zKBq+50Q7+pHEsqpxCUX86IGw8uNWyUGAlrrESUZyaJdKY fyqQ= X-Google-Smtp-Source: AGHT+IEeKABK38xxsKod0vZKixk/J7Qylyl5MmSX7mHW/jyfME5Ez4w2eu08IqUOJbkoLHt8qw1oZw== X-Received: by 2002:a05:6808:16a1:b0:3e7:63ce:1f26 with SMTP id 5614622812f47-3e7946a678fmr4543740b6e.24.1731087927472; Fri, 08 Nov 2024 09:45:27 -0800 (PST) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 5614622812f47-3e78cd28f80sm780969b6e.39.2024.11.08.09.45.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2024 09:45:26 -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, Jens Axboe Subject: [PATCH 10/13] mm/filemap: make buffered writes work with RWF_UNCACHED Date: Fri, 8 Nov 2024 10:43:33 -0700 Message-ID: <20241108174505.1214230-11-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241108174505.1214230-1-axboe@kernel.dk> References: <20241108174505.1214230-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: CF5E7180020 X-Stat-Signature: p9q95sstwhxyre6gkw6tfeaip1mw6gpt X-Rspam-User: X-HE-Tag: 1731087923-560208 X-HE-Meta: U2FsdGVkX19tDmtdgRyDm8EF3JCfIcG4vPZCM8iz5Nxj3W9WWftPvVYLPhMSv3D7ixvLlPcS7NgYArygpWiW85JTDR2Apn6yMjFqn1/T79aKmOshP66opB9mDlnCMMeyAnx7w60mf6IWLCGaXlZ25kzi3d087PaymSKTQ2N6bP9fB39u6hX9NbhLS9BKBqLjyLeHBQGFDPfCJEInl7EBC4n39EvN3vYo60JQtZscyk/0Wu0XqTVV5z+m6mluTskmcarWioFKaJbjIYidEREtylFX2bLNi246oKgHfZKJV4LO6mBIx13BtzYftIm6qMr6P/GKl/iUIivYm3t0Ez8R6W3n0vqVL7RmUBLsvE3s5NkNbvn25xACZaCamLfeC3wDlJk2zPX34Nr0FhrRpAqdmhrQIeWnSorNmut+nIx+tK81CWY9zWWesQBV+lz0cu3gdGtZJgJCaYGPtY+H1THZXGRRRe10J8OFbkHUNa5JiwsV6Ohz4N7SATzsrju89+6rkRmw9hDYUZK3PNgdftvYw6KEmCIwpJpSWPYnN+X65FFZbnwpUaX/QuIAW/3OOTsT31rkpprXssJLnw9o9EUkWN0iUGy8mkeGqriwn8V/A52haxxfe7yryvXVGMrcKzIN5jOfPchf488pudVKsZyk0fO7zzYlnuRRBNHNvZ1ZLYoVcGFJr1m9x8wCapqib39G+ex3wG63680Q4pTlyX7iScwCuto5/x2FIlNf7vJuyUwo6RP2TarvPgy551wemeEe8C+7Y+fOM6zGNoYUv8jUzFt+jZ/vY+REu721rJ2HdJFA3zzS8p8HTaAgqKfyNxrZjqLWkGmc1L3gYftIYeUaB4XZQZt3rHXsXKUaMRDYZGALxQW7bReB/nYUY29av/lrRmaFKtKPxuRGmeyVYP0Y3VMW27dm+rwC4iRpmkTa+Wt1lRhkDRVNYp0VErLEhfpdtuKDaUD0/4LvTwctzHU nrgjswj4 vkx/iIFZfITb39f5uST22cT6qciSY42PZnfVOTZUFs4nYd49MYazOaMWIfd8Pwcc0yErm0knUjRHrF8QdIef9I/KvMfZbkbowqq3i7mzKH0h+s59D+W/X09uOCZ4XYAouYSYihAeRpp6Au188IKOM4Lwg8qPzsxEl0gVlurCBCkAVMRNWsw1AVM55zPzASqn77zJKR/1053VgreF3EbyOs5u2H3soX8gHbsAlrwo5bG/+KVVqweZkhiSSufd5GpUNjrgA5gulhqbjHmWZnZCmPnCdd9ICwwHTHB7iJfUIDlHxaZ+Ny8Mc/JqiFPp7OgERcJcUVSbNxBFDgl3Fn7DcstXpbFUCagrt4iKq 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 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 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 --- mm/filemap.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 1e455ca872b5..d4c5928c5e2a 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1610,6 +1610,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,6 +1633,7 @@ 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); @@ -1639,12 +1642,10 @@ void folio_end_writeback(struct folio *folio) * If folio is marked as uncached, then pages should be dropped when * writeback completes. Do that now. */ - if (folio_test_uncached(folio)) { - folio_lock(folio); - if (invalidate_complete_folio2(folio->mapping, folio, 0)) - folio_clear_uncached(folio); + if (folio_uncached && folio_trylock(folio)) { + if (folio->mapping) + invalidate_complete_folio2(folio->mapping, folio, 0); folio_unlock(folio); - } folio_put(folio); } @@ -4082,6 +4083,9 @@ ssize_t generic_perform_write(struct kiocb *iocb, struct iov_iter *i) if (unlikely(status < 0)) break; + if (iocb->ki_flags & IOCB_UNCACHED) + folio_set_uncached(folio); + offset = offset_in_folio(folio, pos); if (bytes > folio_size(folio) - offset) bytes = folio_size(folio) - offset; @@ -4122,6 +4126,12 @@ ssize_t generic_perform_write(struct kiocb *iocb, struct iov_iter *i) if (!written) return status; + if (iocb->ki_flags & IOCB_UNCACHED) { + /* kick off uncached writeback, completion will drop it */ + __filemap_fdatawrite_range(mapping, iocb->ki_pos, + iocb->ki_pos + written, + WB_SYNC_NONE); + } iocb->ki_pos += written; return written; } From patchwork Fri Nov 8 17:43:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13868804 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 F3A02D64074 for ; Fri, 8 Nov 2024 17:45:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8C4156B00E8; Fri, 8 Nov 2024 12:45:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 872B96B00E9; Fri, 8 Nov 2024 12:45:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6EFAB6B00EB; Fri, 8 Nov 2024 12:45:32 -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 138BC6B00E8 for ; Fri, 8 Nov 2024 12:45:32 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id BDBE81C693D for ; Fri, 8 Nov 2024 17:45:31 +0000 (UTC) X-FDA: 82763653434.06.A816E11 Received: from mail-oi1-f171.google.com (mail-oi1-f171.google.com [209.85.167.171]) by imf30.hostedemail.com (Postfix) with ESMTP id 198AE8001D for ; Fri, 8 Nov 2024 17:44:19 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=vmnLOpy4; spf=pass (imf30.hostedemail.com: domain of axboe@kernel.dk designates 209.85.167.171 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=1731087878; 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=2fb9FZGyCFOFnaRiTxheAGhz9Js7yp85PwlVOXqpxuQ=; b=a+bPgL+sxHuPXdrERkt5rf+rpDNdzIZZYIbtzyzj+5K3dGFa31Ln1PxKUdPum6hu4w+jeA uNGvXzZ5BT6BYj6UmvLlqRfck6p6Kx813ldRYjigGpx34O9eudbA7RYuuyW6uRycM9cjU2 zxxRxNPmm/JKefSfqN00TzVJBmKD+BU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731087878; a=rsa-sha256; cv=none; b=jyFq1lw0UjrRCOOGDUb5XBc+Di1POkuOLcqH3JtbdKEAZosAPi9oG5//4hYjYrKR+xOUj6 MsyeVJTOKeQg39bmLYUqF3Vr6mzuXdl/bBHP0z/8p9qGxtB3hI/4h8zFtZ1haSWNOWgDm8 N7Fs80tCPI/zfHo2fNRXZnUqj8ilc50= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=vmnLOpy4; spf=pass (imf30.hostedemail.com: domain of axboe@kernel.dk designates 209.85.167.171 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none Received: by mail-oi1-f171.google.com with SMTP id 5614622812f47-3e6048bc23cso1497177b6e.3 for ; Fri, 08 Nov 2024 09:45:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1731087929; x=1731692729; 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=2fb9FZGyCFOFnaRiTxheAGhz9Js7yp85PwlVOXqpxuQ=; b=vmnLOpy4ER9mma0FxFCVZazuh9B3r9duraQGmwqfecBAdvlaJF8556oacc1Qr0KPsX MxAssnWeEULn7cIy5R1R1i9qUQLrWUGE6/L0GyX81wmDpSI4eK2jZrXRov8XgJs5LHae Q+MKhLopUhQqxJx+l1G2DMCSIywib0hmnz2tF4y9XfArdVKcu7EG5Uk1Zz3hbVQVhalB gyuwPVgC9PuCAZxhzpyNoTP/2fBTt9w6Nbi+9PZLoGIAsWwI0gFJgNRFqjgc+sibiYV7 DwsM5a6FVO+AE+erJ49YzP6fECACaCMJ0p28lr4qLVQbhodqFne2g1eozWjVmS/95WXE jxWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731087929; x=1731692729; 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=2fb9FZGyCFOFnaRiTxheAGhz9Js7yp85PwlVOXqpxuQ=; b=tpPPCOhMuM+6m0l+61MnjFgRW7sXtKWb0kJ+h5e3xNq+jbydMAkVlAeJrtDm5x6vJO jm6CGrJbi8BbdwsURfGsnzJCwxBF4wo7bKUKD/rlIPauk57oQQlRaZAB9RyAPC4pqvoM QDJIseMflazcALYOLK1pJOhrO/CEwqz0gzqFkmN8Jd2GBrsVr7Cl2mUNwpk6l7eaqpse U/ak3kDHKoXk5aIJzAW4kqBgrEKu+5iiE0LRd51LfyICfHvJalEimnyk3zEVvbJjjlvZ C5getV2uAAIJV4N+nvRWqRUhVoc6Uv67VUw50kEBvtEf/f2IGeTCkobQsCKcNAJ0721d XWnA== X-Gm-Message-State: AOJu0YxpLwesmQmLyTMqTajspzXB4dQxaAXvfV5A3HpwxRnkxdfBkHlG 4R9Y8ARCJlcNIuFXiHxzrCeOkqtqOF3cM0id6IazD0rlLVSCKoTmw/tdzmBrev6uBbh/TAWlCHf qK2M= X-Google-Smtp-Source: AGHT+IH8lOHs5F7JgjBYwdnat/pkPGU3i89izTiRydGTFEpVaYP+S65Vq9chKUX3hmqFUZHNf6tOPg== X-Received: by 2002:a05:6808:1922:b0:3e6:61f0:4797 with SMTP id 5614622812f47-3e79477095cmr3867819b6e.40.1731087928735; Fri, 08 Nov 2024 09:45:28 -0800 (PST) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 5614622812f47-3e78cd28f80sm780969b6e.39.2024.11.08.09.45.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2024 09:45: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, Jens Axboe Subject: [PATCH 11/13] iomap: make buffered writes work with RWF_UNCACHED Date: Fri, 8 Nov 2024 10:43:34 -0700 Message-ID: <20241108174505.1214230-12-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241108174505.1214230-1-axboe@kernel.dk> References: <20241108174505.1214230-1-axboe@kernel.dk> MIME-Version: 1.0 X-Stat-Signature: ry6bceimmb3r5br6wgang9pf5gfddc7d X-Rspam-User: X-Rspamd-Queue-Id: 198AE8001D X-Rspamd-Server: rspam02 X-HE-Tag: 1731087859-463646 X-HE-Meta: U2FsdGVkX1/0LOY32oSsWN7DDJ5+6OA86D+OfVZerAkLK5MyKuT/XY07fZ9QYhAfxo42tK2ZwIB21sFKjUdiZdhIen9IXkzY1UD9C+NNJSVNBI7PIOra71vl6p29GTIZjT52pyjq6GYBXoSGGqBSP3z5cTpcWmZhpKzHnH0UbYjulP3L0i3QzWTCPVOcmFtNz2aj+mKsCsqaed0bvAviFFqC96H4prESC3I/3W4V//t0j/wBo35Oo1JKgYyH5XeSSkiv8bxH9+ELoXnRi+OJ8xAKo3mVG2aOrb4XxmOSyeCSUDkdq1RzVXGsRHyXY36Q+DovlALV8pvXri6/ItY+0Nf+njWzK69TRLpn5/6TMTCw4iwmNVtRiaAgdfIrgK7bD3A9Iv4pZf6kiMGlq0XrJLWY71cfPLBphk6+8ZhdvqrQJi11TU3DnAEiQZA5bOtaHfeDmss9Y5EjLrguvfSY0ZPvCrRC0m15S7IeS4wh5widV0ZZRBlcAhkQLZpAzHgoPWeGQILsXxmKethTgKq7AI93HzIBHFLl226PbPz82YQAZ5KNjWcq2EItWVMZS8z+ARi/wGK+Dtz2SMFGvo5D8CLvEknijfGFpo8ky/mP9y4oi1GZcH4Ew0IhU00kk7IlabGUj66qhEaKjMwDAxLYzTJmaknRYrTVuVmkrDIkDB3SKuv9dMY4xEnejxNQK3OJNd2V5Nx3GKqjbIy3bjxaDqF2Q7lfrTyGcunem4rsbIrFyRy/s/fRrl2sKkHzPaiCi/LtPx576io6iLWfR89E0hh43Xc8aopMo+l5rp9fYxkSH0zKTHmZSOJDizjMBAt2l813ZGYG8grwcrahWRlNA9N/wPYV205Q/fxwHh7JSAl1cNWufkKqI3BSgNUbgTp2ZDzZRNv60V7t+slyFmaPwrJwZrtYn3s8XQeDHNJ2BgHXEAyQpc2pevETNzD2tkrPNOaGKz9nutZgcyCGS+4 ia5HHSsX veramc80+8tO/IUWSst71SRIv19n7t/ML/VmCFipg9w4CX7CTFRfuaIZjLGGs6v7F4UFb37fDKtpDgMusc7ju6ffKXSygTfWsUwSPP6+okZ/ipAoAhtj3NojiXmFqqUw/4ZCc4MpAKlJulCS40kEWphOQDZY3Wu2M2vulmw+NBoTq7F8QYhfxwfLIOcXiS7bnx/1EhfqKM+R5HaZohvRgfGGbPWsyZO53ytWVFYhDHVntnuqbaAsTO2u42vOcLvqSgVieMwW6NC7Kd59pqz660MKfa5lO91VBMYW4gZ8y8l+m/QNGJ2Bsn2mLTvcVM2ijzf7/wbcufb/G3jxlAW9KheY0PY4A2OOCrjOM 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. See the similar patch for the generic filemap handling for performance results, those were in fact done on XFS using this patch. Signed-off-by: Jens Axboe --- fs/iomap/buffered-io.c | 12 +++++++++++- include/linux/iomap.h | 3 ++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index ef0b68bccbb6..609256885094 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -959,6 +959,8 @@ static loff_t iomap_write_iter(struct iomap_iter *iter, struct iov_iter *i) } if (iter->iomap.flags & IOMAP_F_STALE) break; + if (iter->flags & IOMAP_UNCACHED) + folio_set_uncached(folio); offset = offset_in_folio(folio, pos); if (bytes > folio_size(folio) - offset) @@ -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,12 +1037,19 @@ 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) iter.processed = iomap_write_iter(&iter, i); if (unlikely(iter.pos == iocb->ki_pos)) return ret; + if (iocb->ki_flags & IOCB_UNCACHED) { + /* kick off uncached writeback, completion will drop it */ + __filemap_fdatawrite_range(mapping, iocb->ki_pos, iter.pos, + WB_SYNC_NONE); + } ret = iter.pos - iocb->ki_pos; iocb->ki_pos = iter.pos; return ret; diff --git a/include/linux/iomap.h b/include/linux/iomap.h index f61407e3b121..89b24fbb1399 100644 --- a/include/linux/iomap.h +++ b/include/linux/iomap.h @@ -173,8 +173,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 Fri Nov 8 17:43:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13868805 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 87BA3D64075 for ; Fri, 8 Nov 2024 17:45:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C957C6B00BB; Fri, 8 Nov 2024 12:45:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BF6D66B00E9; Fri, 8 Nov 2024 12:45:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A6F1A6B00EC; Fri, 8 Nov 2024 12:45:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 7FB396B00BB for ; Fri, 8 Nov 2024 12:45:33 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 3C2561A0E6F for ; Fri, 8 Nov 2024 17:45:33 +0000 (UTC) X-FDA: 82763654274.11.F56C444 Received: from mail-oi1-f178.google.com (mail-oi1-f178.google.com [209.85.167.178]) by imf30.hostedemail.com (Postfix) with ESMTP id 9041580004 for ; Fri, 8 Nov 2024 17:44:21 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b="I37hv0/b"; dmarc=none; spf=pass (imf30.hostedemail.com: domain of axboe@kernel.dk designates 209.85.167.178 as permitted sender) smtp.mailfrom=axboe@kernel.dk ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731087871; a=rsa-sha256; cv=none; b=UNqvVm5enzTGOHVePlXkNFULfWTmSk1I8aH1vjVjZDIBqS5ELQitJMwagFoJBtaFO01AQU X08wwIqtG3pGQkQiz2VFdD+6k1QaGmK1ODRsbXsu+PsHY/FR9mls0ylVDnuSEE62G/FGSq 9NTjJHZJqatZsuNjMYiaohBJwXrWl78= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b="I37hv0/b"; dmarc=none; spf=pass (imf30.hostedemail.com: domain of axboe@kernel.dk designates 209.85.167.178 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=1731087871; 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=VQL0Yvui1/uihQbO1amlpE3hTYTghb1QS2rKG5UGAbk=; b=V2SU9DZuTP78Eitm20Vt1gxx7Nn3RJiEjSKluDQBeTxBNY9ia+5U78UDGyPQ9JTQaXJljC rlGRhQl6HtK5e5Z2auGWFsnlwSlgfAqQbyTUzBlBWdu2HE8g9ZrqGnRNhOtz2BCE5UfuCM 52pfELyiUwxhSsFzp52HbXqfkM5/7Cs= Received: by mail-oi1-f178.google.com with SMTP id 5614622812f47-3e6089a1d39so1296209b6e.0 for ; Fri, 08 Nov 2024 09:45:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1731087930; x=1731692730; 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=VQL0Yvui1/uihQbO1amlpE3hTYTghb1QS2rKG5UGAbk=; b=I37hv0/bjcTr+F9YBxP1/BzTAtjKU3dMzIdnTXT0GthsyCiLmXKXo0YJ7vxXbMlPCh Qx2cdXNadXkTGceiEVHDN4Xqmh826b1qV20nTfhaJMDXLzPFf5Y8NEYfF0cLTzMRWVG2 iXhiAm4FDTQHsOvArQXk4MNTaEiNiqqvOE0MfOpHhnH2s6zrMUm6O8LzUmy1VhMuZqyO 3csSoJHPi4m5lqdds0Mc+ZrKPUG1Gy1z7RgZCWD+r9gZju2rMuDq2BeDqTGzB4YEhjIA lcXwwIZXouEAKEfx8txwTUxTNxs9aqF1iMITL08RxXt7yCn4VIoK+wlvc6x0Tzl5C5Is GF1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731087930; x=1731692730; 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=VQL0Yvui1/uihQbO1amlpE3hTYTghb1QS2rKG5UGAbk=; b=XevSONiQipVKkUOUJ9TfTNbskJvUmxWEw1tzZKCSZtPISFlQ9crShxdVUk29pIvSxY +yJshfmG/7JHB+qTlb+y/rXbJrnS5xpqc5MAh0boQHwb9ZiYgDPnH5rDDpqXwK14zs36 d4LyLBt8OcVm+tE3KvzMwmgfztOIPUcJ1gBQUEbLQKHaAnimjDL+9b/5CblDx1GWa6wg InQHUE8/zPnto7Pt1JPL2VAs/FQAltGKEAFcMPHI4GutqpT/rKhRWOWX83ShCBicCWgh qemos8cdGcrm0XlQdjodwvD0XlcvIWTCnJlTLlU9nz2HfcbZYgkk2eJaGKDfI8ldA23f l18Q== X-Gm-Message-State: AOJu0Yw59TXNzhVNIaku2uJvZwwvoLeSMMyositMUM7stVu5eVWXGt/c jKcaSFLNWSpnwRxpISe8Vw0wPofs/6mtuUwUtGVszWqty9s1SF2m44ByBFQgKaK8CYJLmDnUDCZ UXTs= X-Google-Smtp-Source: AGHT+IF8148kIy+GR70FdSYcCZ0fiyujzQfL1vs9+4lT648aDmaAqJC/hHYFUZhM+2GwXQZ5gTEvug== X-Received: by 2002:a05:6808:f89:b0:3e6:62fa:6b04 with SMTP id 5614622812f47-3e794720349mr5084554b6e.32.1731087929940; Fri, 08 Nov 2024 09:45:29 -0800 (PST) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 5614622812f47-3e78cd28f80sm780969b6e.39.2024.11.08.09.45.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2024 09:45:29 -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, Jens Axboe Subject: [PATCH 12/13] ext4: flag as supporting FOP_UNCACHED Date: Fri, 8 Nov 2024 10:43:35 -0700 Message-ID: <20241108174505.1214230-13-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241108174505.1214230-1-axboe@kernel.dk> References: <20241108174505.1214230-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 9041580004 X-Rspamd-Server: rspam11 X-Stat-Signature: 8rixpecb8h61uu1txxsn4un7uyzwzqju X-HE-Tag: 1731087861-887661 X-HE-Meta: U2FsdGVkX19G45D6YpBy9nhBjcHoVKBCl9RPXr4fzO66HYd7xiYnF6jXTGDSgzYa2jHJYLO+nwltSemdpVThGvHaoSM1A4+/sSl6BScgYJriKmXe0Y/RfhIGiAzKt/k8uF2/rLsRJLxBLKI0tS1vnuYnckpNNDniGBUI45FFZGk3nj0yWkuC9HjaMkdJHMdfQS9Ka9gPoTlYHjNLQPs0D25dHcZGU1bHMcDuO5pwMp97vVGRW6TOGk9d0OlYsw2NWzp9eelx549tsdbOeLPLHlYGXcZRdNowj8TNDwqBtGn0DKYQB4BKpPj/xWwQO7zWKXbK/xv1ttOEu4SfF41ut0xFTncg4TVNyjEGwsUa6Jn4J8XOM4/Pk/D6dyQl5HP8Ly1V4WkyaJXwvVvsuAB2UDj5QyjUlZ5GYyjUY4XbulRI4sH9DG7aiQIIB3J/DfE8FvN5n9BGSVc+BjpWQ5igcXfjUQCGjVihDyqG6+pBrpt7Vey8Z0V3/ODN2uToLL+8/TY0HXzy9zs/D017HF3xjCqm9BpkbOliZiaDPHDT1+hZw6yX6SxMHV2SYYzh1TefudgC6A3IYF11K2SpCigIoDiabp0JqV5XhtSPLFzBoWEt/YKkGnQ8e7so6bzjBGZEuwiCpN4dVZYKBZgRJnAb0POn6WKKF7+J/Y4uxqTa4QJ0FRBfTqM7uxxTHRo8tNUhidyH/vRnYI1rELN+qPr1latZHePXxhU/k5Hk3E4oSNwfuLgjZMA/1lBw9/1yfwpiJBTYHETONCB4tst3d6HhLyix+b/reOrzAM1UoRZVoNhkGKNaDpR4fOF+CCP8qO7rRqqBTUxnTr8K4ocM9mS1v5KrVceEJhqC30t4aPY8YhtiqlEJEml1JwM9/GUi8EjCe16ZWj6gvoydaZLcTeRs340acSyJE5nNvk2XRhVxQQ9nZSnGdLFF3VErKetS2pZEF75yrDWSIkV1sEhhAHI YOrcmLRf lW8gwsWAYPO6C+6vQdhkOb6ZbfEOUdoWVz9yDpFXIBsdh2LsjZrp4j5XZ5jOZBZSOaST+0TJuFOhlxRGbwuAm12gTfjhI1RaQzDUdlcQfibUnXJcHe/QWzbuGB+hbneAf5xYWtYD7WI2XWLt+gXyolrvQXjnUMSM+c2pE5Yx4RIKgp+Vaqbh2+ymiCZae56emtMUzjRbI/SQu2omLjf6YGn+xu9j2A9IVPLiSKaV1fS+aslXz6LAjpY0D1VVxkahdaQh9IFwVCsoiwbTMUpvZTkmtkZBKr3JYxojVtMpinpTa9k4dBoKmYKzLD4KKWwkapfOqBgV7CJAYF4L7xPcPb9/g8YKEUJXS/vAc 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: ext4 uses the generic read/write paths, and can fully support FOP_UNCACHED. Set the flag to indicate support, enabling use of RWF_UNCACHED. Signed-off-by: Jens Axboe --- fs/ext4/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 = { From patchwork Fri Nov 8 17:43:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13868806 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 021D6D64072 for ; Fri, 8 Nov 2024 17:45:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 82A526B00ED; Fri, 8 Nov 2024 12:45:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 765956B00EE; Fri, 8 Nov 2024 12:45:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 603DE6B00EF; Fri, 8 Nov 2024 12:45:35 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 3B6096B00ED for ; Fri, 8 Nov 2024 12:45:35 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 6FF3EC0F20 for ; Fri, 8 Nov 2024 17:45:34 +0000 (UTC) X-FDA: 82763653812.10.31BA1E8 Received: from mail-oi1-f175.google.com (mail-oi1-f175.google.com [209.85.167.175]) by imf04.hostedemail.com (Postfix) with ESMTP id 9A5364001D for ; Fri, 8 Nov 2024 17:44:45 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=mBDJFrny; dmarc=none; spf=pass (imf04.hostedemail.com: domain of axboe@kernel.dk designates 209.85.167.175 as permitted sender) smtp.mailfrom=axboe@kernel.dk ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731087872; a=rsa-sha256; cv=none; b=tZ/x6AxqLhpRtf+0T4Wmktoaa7YYz4Im/+TVhZchp/MZlm+rC3ijLGrbRHIf4N2c+sRCD7 BrJf6N3bbCdeQ7ioaC4Eqwx73uO4pmqtNQacylrDv7Elp8ApFguZJyhGOkUIhxRFEZMTd+ dpUiw+WGP3gSDT7TgL+PcbLzDti34ys= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=mBDJFrny; dmarc=none; spf=pass (imf04.hostedemail.com: domain of axboe@kernel.dk designates 209.85.167.175 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=1731087872; 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=6OLsZMH/yTrwPfT+lkkEOmz1bcJxf1X+T+9jhpWMtjM=; b=GjV/4AkonCYf0d9I6HZFbCpSaC9O/c0iEFx1DkjEYydVsvk0JkeyCgka53Uo3M1BixnLKM NNfTf31KTqFNNZKzg3RTOJWD4dtSxOSJdR/t2AvbWEJDm0TXk5Ie5l4p69al9KsfwZehAN EisNSShRz/GlsSxig9x6GDnPzPByPrI= Received: by mail-oi1-f175.google.com with SMTP id 5614622812f47-3e60966297fso1316717b6e.1 for ; Fri, 08 Nov 2024 09:45:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1731087931; x=1731692731; 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=6OLsZMH/yTrwPfT+lkkEOmz1bcJxf1X+T+9jhpWMtjM=; b=mBDJFrnyvYAe5vjlsTERPNP7vKHIxUio7kXgTjgXKuwefuhBmyVfxs70eCCw3/TDIt aKA+7y+IKWYvFahOhRbG5K36jEElMkDkQScJltXu5Y8OGNde2YiZwH93rli2iqyrC4Hy rYLIaXYrxyILmowNUl42TvxbnIx/JbseKiFv6iK85KRMI7FbjoOIk8ly/M1PAZmha7Jd nRhv0z1KVgNo/S+82tPZpzIwRqkfyo73tgWFKbifszOWwKWR2MQs9wmSDQzOjBuQfyDx xgRWFi1fMB/LJ3kZLPenN1RMYpuW0A0+D2ifiLP1drbAhvRA1KUcxy5Uk+hFIhAE/xmw nmlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731087931; x=1731692731; 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=6OLsZMH/yTrwPfT+lkkEOmz1bcJxf1X+T+9jhpWMtjM=; b=afouW4viZyR/OWsIryrea/MaD/8xv9LOVOqAn76wkRfB2QE+xlLzNYAVVHsyT4NzRp kDCmkoHTCpaOBTMKvgNJVUL9fmS3nqYK7axUNQlO755UqljySSDC6YCGIT2F2LaOy93X PSVDEi08EY0droUi4Hnwei9HpiLXihb/HkMghJ4JW5qwKTSzfEnR/y4Fu964+N4PJU4r qrS4VQyC+LJwghT8KNeIhFsYuNzmg/yO7LdXVxkX3FaOdRBAzTnsjyb7lmzxpPOqqlkM G+1wzgz8m7snL3XfFpNSJ6jnrwiTARHGrE2QL7vqaz675cAoZBpRrtoMBsYEfDyNcsLD 6E/A== X-Gm-Message-State: AOJu0YxRGRAO6C8PtRieiGkf8V3QwFjUAk5uEubwtRwk4aTK8hTQsqcL Qyj8/Mlkyl1V+zgUHqxy/upY3TeHDxmVBe1DDhjb9h5xdyWfZKa0cqVRGqgU1+4Cd8B9SL83+S5 /sQE= X-Google-Smtp-Source: AGHT+IHwGGg69OZHlPE1gXTTmbyei/EPohHpGXOl/6pBBWBH6HgFHFaQI6UOOM7LN2ifcEJcud5MBQ== X-Received: by 2002:a05:6808:219f:b0:3e6:366f:8e3b with SMTP id 5614622812f47-3e79475a747mr4137297b6e.39.1731087931319; Fri, 08 Nov 2024 09:45:31 -0800 (PST) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 5614622812f47-3e78cd28f80sm780969b6e.39.2024.11.08.09.45.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2024 09:45: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, Jens Axboe Subject: [PATCH 13/13] xfs: flag as supporting FOP_UNCACHED Date: Fri, 8 Nov 2024 10:43:36 -0700 Message-ID: <20241108174505.1214230-14-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241108174505.1214230-1-axboe@kernel.dk> References: <20241108174505.1214230-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 9A5364001D X-Rspamd-Server: rspam11 X-Stat-Signature: drz3q66ydnuo1sxob6wyh9u3ip87pnfd X-HE-Tag: 1731087885-208148 X-HE-Meta: U2FsdGVkX19wJNRuD6WJpupR8b0GyrUG/0XTkVBb/zJa9afUcyU8/sOlG1pvrG831nAaq6NzXmXDzczKDEe9QvENXLDd0c2gHJeP9CAcf9PVwKKhUgja8n+/mPvUQoCcC27rIKEGrMCkTyIWHf/dsVYOjoYD/IWQJUOHvPy+UOabNwbfTsUHafiOhwe5qIjBfWJndjVWQtiVC/FahHIqC2sdR7qbOTOFJiszH5y1d1rYK5v6K/Oe0OzYlZgNgdbejQYFWymplYjfeA7Neri+swsCFLiQevBmIxBTwun1tQCB11G8950+aCezJPQfwdkrB1dzVXGKfI9q6huNJvcU+R6IWMDpPoxmhucX7yLthoriZ5Ek1KaEW2Auav8WDfumKN1FzPHew+rMsUKqTLJuwsMcq26T9hjhG4t9jzopfhJdPolbLqhIE8QWIc3mZouWKuB3FgTd0DIGXSoEoXXdYHNF4Q2zZEXLfNlejEKb1B8r5EjODe3tt3HkUos5426nnsmO/4u/OTN6ZxblFCsJTqjHfj8liQSFxrUnHpcZ1hXMSU3FH60ookKsjTrXkLhOEfItpKwmCTeH2o5gLngEJlO/ehChYvkMn+JSgNab/QHKDn5IGZFmMu53gFZl+bYx0q/Uk8WnxV77YBMN7IKLgE3TD5pZqKX6eaRi1JoGiYpNWAxdhnjC+OGR02fI7JuIeQpk94fAo454aOYYR0dsaI2W1Pr6cU53P589glU8KmW3Wt6vSgRdwNwDVRrbqY1KbDY61QDa0h5lgQPHieCqTbNoUiZD+hbQ7IcEsY+FY6IksBwpjDDAZeFy/UUscUgxdysKGGzkT0U3fHD+yaJsyDLr5e2Gden/1wrgLDQMzmjw+Xht9Zfb94DW6DwpTrcOV5TLGYmG8NPJn1LqFmDmRkztpR9oCnhM5i9K0tKXaO8LbD0EYb9Db+/MCZoqjUwVSweLDA6y9hAeYtHHHKz 3bwrfpgx zzTkMr4Nn/Ebu7JnO2YPwtn0TbE0w+6pq9WWuyQ91/hQEqztyAhpHP3R186TIr8zg5ycZ5MTj0ZChhvI3J7uwEtbLro+zffZkYfDWjwBZbdZUYwHrXT7J4rlPhwLVUo78YfFznJbiSAkcEVAwjEjTDGMkhrzN7XGMLc8fKU4r3VmQylZMe55dE1vvz97bgp9a9R1nY//FXULt0XVbk1AzAqRCTBiKeFgwtIkzG6fe1B8zzSOZq86WjnKzk3E6s0VodAqO+c8ew709uvR8UlL5e30/1YEnEQyFSd15z2BhtR0jXrWXTWZoiFZ0YzsF81qKlxoqsRaCqSq6xIv7As9i6AcubbWWXddW9Fby 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: iomap supports uncached IO, enable the use of RWF_UNCACHED with XFS by flagging support with FOP_UNCACHED. Signed-off-by: Jens Axboe --- fs/xfs/xfs_file.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index b19916b11fd5..4fe593896bc5 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -1595,7 +1595,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 = {