From patchwork Fri Dec 13 15:55:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13907398 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 6BFF3E7717F for ; Fri, 13 Dec 2024 15:56:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DB3C36B0082; Fri, 13 Dec 2024 10:56:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D89D86B0085; Fri, 13 Dec 2024 10:56:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C2B1F6B0088; Fri, 13 Dec 2024 10:56:08 -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 9EFA26B0082 for ; Fri, 13 Dec 2024 10:56:08 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 53722AF643 for ; Fri, 13 Dec 2024 15:56:08 +0000 (UTC) X-FDA: 82890386208.13.B837EED Received: from mail-il1-f171.google.com (mail-il1-f171.google.com [209.85.166.171]) by imf28.hostedemail.com (Postfix) with ESMTP id 6C8A2C000B for ; Fri, 13 Dec 2024 15:55:37 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=nAxIGxvL; spf=pass (imf28.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.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=1734105348; 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=aJTsU8FOCztsZChrgynI/se4Hg526H6WFOVyatkHjPA=; b=5a66RRRoqy2ake808EgmrhKjnCx9yaJUpHiuTfG15cjOcOJd1zMts4irPo+WGKdpxvOhok abUaTKxzw/rOM3rMYgCizE/7zC3gwZMWYvUGL444+qktJETf0ptKwZ1lXH16LBPvtAPgv8 z71GM6OpPPKQh5fObDwXN0ywEfRBNP0= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=nAxIGxvL; spf=pass (imf28.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.171 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734105349; a=rsa-sha256; cv=none; b=kD1aIF3lbYQFi0tr5Q6zC4yED6j1JvohtvDhk1Kn6Sx3YW5OYaOa4cOQ1dDEuU4dCcsj1o vUNvVP9ePSgVpr+JXmw82//bsf0j6wFYIExh0GaUFPGVqj3/DNVG/IpgOdS2CFhhw8pKGF h2Zf10jJpspK32YPuNAJKgZQWE25q7I= Received: by mail-il1-f171.google.com with SMTP id e9e14a558f8ab-3a8aed87a0dso6517965ab.3 for ; Fri, 13 Dec 2024 07:56:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1734105365; x=1734710165; 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=aJTsU8FOCztsZChrgynI/se4Hg526H6WFOVyatkHjPA=; b=nAxIGxvLjxdiCQw4yemK3+BNf6RzIeeoWizFR0Gwk5YP+t373+2puaGKpsupQUtT/9 kFbXjSGOsiu9SGMFQVVTtIW8RieJezVckNjm3KxTy9hqqqH3CC6fx9Hu4rg/aHF5mBGk D7/wtusbEgvvyZejN3Ngs5TJsnOv5D1UH5RQCGGWxvXigzC2EiW5S++15O644u8rP2Ph oW8GtygWRwbWwy9pKP1x/WLZWyhXjiocVogvAvR+dUZP11TGIphwmqJpZCt4GguO8rYJ AqsIM2hHNcUPTkB4R7OAmlfWnopuijjhLoupx6IubsxUtyt9nl1ESL8NYuL0rY7FmIb9 2s5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734105365; x=1734710165; 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=aJTsU8FOCztsZChrgynI/se4Hg526H6WFOVyatkHjPA=; b=gBE9qo1NhQ0TTs4A1yjH4PXN4vzVXk9egin3BYCMtdtmACe22oro9LFk7YJZ/mD3cU sVp64cb6cRU7WDOT8l8uWy6aMtuaOZmWQ8mWPkBW2M2YZuNCdMwrtjKHhRK0ElPU2Bb3 cNsARbQbFWaGf1QLwOb5G53gwPj83DqnOqa3nX/RegkRLLpCUMB0viLz+G6K/psgEsL/ +Ee5z00oulx67pqtUrxJ881irHsqztaBjmDlnz8z7sCB/DY3iyU0iTiFfyUWdf+ONKLx CR2O688xBnVLMXwdnVxK79luCE7UwCNj0ZmdaSczK/SrNWni3MeqKqfKdkqDRQiHNoSc mwjA== X-Gm-Message-State: AOJu0YzR6dwaaK898j4R0n0X0GOFZ22f99N42JRhWIcQugO+moZi/bpC Kgkc4KSEJq2p55Y4ZT348Vt+QTjjQz9YidACmTbWaAuM+mZCXJgRO0YOAotNOpm7uV7Lt5HqUH7 I X-Gm-Gg: ASbGncvoiblV7OHLoFS1ibwexHhIbb4aDns0dtf8iQtFLp9qUFF5U3PJkNFbfJcGUfe //h5KTz9EvugMKipP5XEacTIJmvd49h/zAifwXCxhNxC5iD4UUEq4U46Y1HliRbeWS6C4qGqmrU OefAaxi4jWz7eb46T4Onid8L2C8YQeKL6X+HppmU6JOyEYdLBRhcM2FO32f9yx0yqejamsLdmGP oTl4vPMf4NVPVGLQyopyOI7Lw1ZmCWyc4VcfQ3LSJUHkifiOEUaLefm1UrV X-Google-Smtp-Source: AGHT+IHzvgK4Rw98UmNxw7TWkyvAABSCjKuo4ks1FFrTwghvSS0Ll84bbCaOcol8J/RzXzpmHkduIA== X-Received: by 2002:a05:6e02:1a8b:b0:3a7:7124:bd2c with SMTP id e9e14a558f8ab-3affab62206mr35203095ab.19.1734105365052; Fri, 13 Dec 2024 07:56:05 -0800 (PST) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-3a9ca03ae11sm35258405ab.41.2024.12.13.07.56.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2024 07:56:03 -0800 (PST) From: Jens Axboe To: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Cc: hannes@cmpxchg.org, clm@meta.com, linux-kernel@vger.kernel.org, willy@infradead.org, kirill@shutemov.name, bfoster@redhat.com, Jens Axboe Subject: [PATCH 01/11] mm/filemap: change filemap_create_folio() to take a struct kiocb Date: Fri, 13 Dec 2024 08:55:15 -0700 Message-ID: <20241213155557.105419-2-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241213155557.105419-1-axboe@kernel.dk> References: <20241213155557.105419-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Stat-Signature: 7e87zn3zbe9mmwb7dwtsqhbay7rmga8n X-Rspamd-Queue-Id: 6C8A2C000B X-Rspam-User: X-HE-Tag: 1734105337-928784 X-HE-Meta: U2FsdGVkX1/msCR+xDeE5zF9VVLbOhUI/uEs3OudI9MKPxjyoRCoTPD9At/4W/XtVucPcXy4epv2k3BsuDmUOba3kTKKfq3Y645URxbtQ4mcXD3S7IZPwGAjPVeTCg1oswBNLCIL7iUJGNUiGVZosNuxSjnGizQBvoAGrmj3gA/H32m4JAc2I7nE5n/uwoyHXuz5k5gvUqPaCP4rfC0Ohxgl38tcwSoEibADmW5ePd5CAol1ZIwodlv9Djmuo3m0HOZARRDXJLo5l7EK6j+YIqmsRKanZrq8wCRUY2tM6E1UGx906FCY/G+YxlJM5NxonoI6AoaPCgLrfp3I/8LHaSGAWPbEivu2SDlzSSV7NVVfM7OrqKc36Ye+qcNDhblpZm7T2pDSK0viUzTmJJSJ6iXiMH6GuvQOZER6bdwm/T3n9fgjgE++ocgAnI0wkQS33ZtcAOX24qvlorA6+4lTEHZtxM71YaC7e9v6ku26xc0dDjSnaTm4dsPRBIBSyEEzENwm1nB+CJ6scur/RZqbitbC7LYnToDTsqr7IPywHbL7WEleO4pZabpEi3L5DeY2AQbxNXwtnPR786yscqjhbLNaqZavq4HD05lD6PHGCNQB8uMjcSPM3nyl/cguySiWpMLpCxtWXW2fp9wSWDrnYjVSleNzcnS+OgZhQGmk8HkCNzFHHsrljuL4fIwY8kYNIwRiLVhE2D5FXWAkKmx+IKefM9E3X++7Q1nccs4idHrs9tnXX8gmoqNADlng2gI5/d+FbE5ICV1DcAmEI8FE18fR3XkwLmub9OThn1wfjUTBkMKvfc/QHlOCofAHFXqbjMsy9KY8IXWOOqvRRGO0nNx3uXKOuTRtrwvmv7Bz97+8zGcgVBAWoC5G+aTCSHlyt/K15NAKpwVNJToGDWXXAAiLnCdAF0ETAjUGNDgo/wdxl2kVVIyislYMRF4zpF9LEP2x6JEHIncluRAptGQ hF/T4uif 6H72sxKYX5pfXTnragy9WTuheh22rITk+No/g/N29bwqEo7Sd7BuiqDj9pKARDiV4o6y/aOCvQYzYWgY19ueaECRvDO3FjDt2FZAK4aTzZJqRJuEFvHS1A4BOTbtNBWrua8PvnYusqUxJDBFkWhCZll/keei/S57wWnzBhxy5c+3DB7uCMI4waXLGTlkAOr/4jvsJQHyBYb/EtZIf2oQaG1FtJ8Fx9URONlvb7C1K+9mvCY4Kb+en4pEWZtRIFQPz6HFVjb0hBOU4uRSLkKA5uz9Ngx+m1XYvRBgegEpFlQKuEclHO9yE/DqTK4Y7Vy/7aHn8l7Uw3yaK2R5Fd5V8HA+7oLgDQshgpOrJ X-Bogosity: Ham, tests=bogofilter, spamicity=0.000120, 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. With the kiocb being passed in, skip passing in the address_space separately as well. While doing so, move the ki_flags checking into filemap_create_folio() as well. In preparation for actually needing the kiocb in the function. No functional changes in this patch. Signed-off-by: Jens Axboe Reviewed-by: Kirill A. Shutemov --- mm/filemap.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index f61cf51c2238..8b29323b15d7 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2459,15 +2459,17 @@ static int filemap_update_page(struct kiocb *iocb, return error; } -static int filemap_create_folio(struct file *file, - struct address_space *mapping, loff_t pos, - struct folio_batch *fbatch) +static int filemap_create_folio(struct kiocb *iocb, struct folio_batch *fbatch) { + struct address_space *mapping = iocb->ki_filp->f_mapping; struct folio *folio; int error; unsigned int min_order = mapping_min_folio_order(mapping); pgoff_t index; + if (iocb->ki_flags & (IOCB_NOWAIT | IOCB_WAITQ)) + return -EAGAIN; + folio = filemap_alloc_folio(mapping_gfp_mask(mapping), min_order); if (!folio) return -ENOMEM; @@ -2486,7 +2488,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) @@ -2494,7 +2496,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; @@ -2550,9 +2553,7 @@ static int filemap_get_pages(struct kiocb *iocb, size_t count, filemap_get_read_batch(mapping, index, last_index - 1, fbatch); } if (!folio_batch_count(fbatch)) { - if (iocb->ki_flags & (IOCB_NOWAIT | IOCB_WAITQ)) - return -EAGAIN; - err = filemap_create_folio(filp, mapping, iocb->ki_pos, fbatch); + err = filemap_create_folio(iocb, fbatch); if (err == AOP_TRUNCATED_PAGE) goto retry; return err; From patchwork Fri Dec 13 15:55:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13907399 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 C552DE7717D for ; Fri, 13 Dec 2024 15:56:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 723A16B0085; Fri, 13 Dec 2024 10:56:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6ACEE6B0088; Fri, 13 Dec 2024 10:56:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 59D746B0089; Fri, 13 Dec 2024 10:56:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 2E30E6B0085 for ; Fri, 13 Dec 2024 10:56:10 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id CE6E0C0353 for ; Fri, 13 Dec 2024 15:56:09 +0000 (UTC) X-FDA: 82890386250.06.C7B0663 Received: from mail-io1-f45.google.com (mail-io1-f45.google.com [209.85.166.45]) by imf28.hostedemail.com (Postfix) with ESMTP id E616DC0022 for ; Fri, 13 Dec 2024 15:55:38 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=FBnYR459; spf=pass (imf28.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.45 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734105343; a=rsa-sha256; cv=none; b=Fb4tmz5eHMGS+CWpijq++RWCoMo8WUJA3lyo0JrhGYcZx3THXyPK2lxvlI5zUD80OlMTnC nS2WAfhRjCe20acbJmTYMflvDaj9p5NBCZMer2Cmhg/IzUFmvjPfbEIZHLGQLhhzdOZ83A wRT8oTdrVR/iHj51Q5d+YBEHyney8YA= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=FBnYR459; spf=pass (imf28.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.45 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=1734105343; 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=hANs0KTrn4AbTh3ILmowq5bBaAQVBAkU7MnXkJd6Hic=; b=THxx0UT78QVOrrC6bunmu9tCjVuivZ3ngpKApfhjMSAwRCAK9y3R+FbujGBCT+sci/fHSd Rqvp5NRqRLJhuQt/D8r2jGcddWRVn7lW6sqCVV5GOhRwFLeGYVUQma9fSCVEldCXDRQY7w 7Bw3mApXNJcb7woEpL6C/945jiF3JHs= Received: by mail-io1-f45.google.com with SMTP id ca18e2360f4ac-844e7409f8aso39929539f.1 for ; Fri, 13 Dec 2024 07:56:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1734105366; x=1734710166; 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=hANs0KTrn4AbTh3ILmowq5bBaAQVBAkU7MnXkJd6Hic=; b=FBnYR4597HosqMVQGgoBShfc9UQMlmYrWAoIrGDSFDZxm2vtc00ZlPKlvGQOUXSD/6 0TdACxe8byaOBrKADjaDcN5NxfkfhnQXhur440g9siWdIy9Gz26VNYTxW+zTsSF2Aych sOHyGzst9iLpllrTORYnGgk9m03nemnM/dXUiGRSTs2C8TUsVXsrECiIAc6Q+we6H0FN zmGkXZciItsoLPSJSeeZh1i6J8TCER0kKZYqEAbJ6aLmXbZlAxo5eB7Dr2n4VyGbeoK+ xfJ0VpqOr1pis48q5xt6Ayam+C7uYEj5xJWJ0Jz/eD8wZXqu4ABKVIRwkH9hE7nm6nmD Ni4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734105366; x=1734710166; 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=hANs0KTrn4AbTh3ILmowq5bBaAQVBAkU7MnXkJd6Hic=; b=jXWvnMddaCkO6PMQFLLOUMV+STAWIP7Tl8WKzjnDiTR+UDvzFIgxRRikiED3J70Emw 00rVSXF0uxEqe8nqqoQ1CPWPhJDWQqhwhuVLaoKfdA8c3tzmjnkWLgXS/sg0xSvDdIT8 Xq8MDqAxkYrtFUL+BAM/fbBdecvE5UqzMzKkSKdAs1VChM2yTsZxvImf7F+0agbOmelB i27jDDS6CKAoH4eaQYnkpAnhXmeNQTiCZzikNfiVMPjTbWMB84G0TNfiB//EpoOic1mk Hkg+zmCGDxcyKld6PuWpYSsONRgTfNJbcP89/A5AYA/A9Fblrv3W3/KeVignJce3iN+7 3NgQ== X-Gm-Message-State: AOJu0Yw51b7NdmeTs32UTGCzyELt1oOHRWN8QDLyJpxjQWd5Cifj1YIg h3TBtMjWQbnGFbhfnPYP4jZd8VswwPconqWBLhvYDVoKjZ3QmLNNe/k4WQpnIxPo+ZPhCmaGPIu G X-Gm-Gg: ASbGncunZUVjG+vdxM2uOYt2zk5GiYQqUFCY199LldJgjDzRW1b94RulyEF2vdIn9oW +ge1pmp8fCHYBHwHft+nj630UHeGnCJLHzAf6U5e5IOyXNeWPcFc2PE8d0uojx7Vkwl/s7CKSMJ xWuAfvj/KfiFWDQenFO5m20Ww/xR38us6qPXv+hd7a8AiRy0N9MAlxDI/sG6vC+BMoMmEs4WB+o /6+WiOPKypKg35GKISrjaKqC0Y3TAupEe0aqhctxgKXcU7HsLMTmciZ2qaR X-Google-Smtp-Source: AGHT+IFVLcWwM0MIr7oz/Yvc9CHKROeMGY95g0ljJ88B+/rBynMSTGl1ysoTz/aE+AP7fUiTK21pEQ== X-Received: by 2002:a05:6e02:1a07:b0:3a7:8040:595b with SMTP id e9e14a558f8ab-3aff50b64a0mr26251175ab.9.1734105366472; Fri, 13 Dec 2024 07:56:06 -0800 (PST) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-3a9ca03ae11sm35258405ab.41.2024.12.13.07.56.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2024 07:56:05 -0800 (PST) From: Jens Axboe To: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Cc: hannes@cmpxchg.org, clm@meta.com, linux-kernel@vger.kernel.org, willy@infradead.org, kirill@shutemov.name, bfoster@redhat.com, Jens Axboe , Christoph Hellwig Subject: [PATCH 02/11] mm/filemap: use page_cache_sync_ra() to kick off read-ahead Date: Fri, 13 Dec 2024 08:55:16 -0700 Message-ID: <20241213155557.105419-3-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241213155557.105419-1-axboe@kernel.dk> References: <20241213155557.105419-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspamd-Queue-Id: E616DC0022 X-Stat-Signature: e9i3bp8dzrt7s9y6jyc33wftztjxxmto X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1734105338-376387 X-HE-Meta: U2FsdGVkX1/c7Aw4Cz3f0AmMZFZA8QuVuTJiBk6i9xGM9XxPr8fmg451glvY3g940K+M+BQS9Alf58TFMxaS07SFZl8SMhp/Elur9X3lAKwyiJILLh1HzO0EsdllEZqHTEpSAfgv3tJhhjmUJxP+rRWURXufXSlKuJRp3al0k8B8wE3JRDv9ucIEh5zQmMdwC63jYjCseDhDGoovBuNSs9OZhfa+5h9KugQvL+J1FzZEr5MdhGG6i9t/uT8k95F8R3NxFEZfx55zgOXvnNq3SWKc6QkliVVezghSavGGrWTxGImB82IqGJvG8xq8flB3/ziC5TVnPlwy25QQUAE1fYP08DhFpRd5zb5XYuw0Y0KyB3zxw6E3WpT4q2x1Q9vQGPaOMVqXsE1vM3s6X2U6j6ar2DDyU8zfjKD2wWRyKYB5RFxZurNGb+oBw3GWyAJWwF2zCFw7up6yF4CreDQmBJmorHA2eDsvE4RxEXpfxsvwO7d0vJzy0WfnKB62wiEj1FQJGBn4Vls8M152J/c61e3ju93WOkQK6HdNAKmiLcUl9L2+sBZOjKlaaRJMGsbjZHrWqVSLtiGhuzbdTzZU4mCL+PtNfTS1AnZ6i/rXefbqYb8ZkT/Yc3yomB6CGNbfeho+29m0qYNfakOk4hV5IpqkXYyML7m8I8dhLZg59k4FvOE+XAlIltUFw2JUTKqxT+EA7Hk4PnrlMpgp/8/Ty8YybV5lCTgBOGYLOP+OAaEDOl2URknROSU2blegesE+i8yedCumOI1QAYPbl8gdcOqxe82v6f/qpuQ/hydq1D0PWjIXrkKrNC2YNBhOUs+5TX9oPmigHkfAwMmXbrn49UUAXCkuL/Aw5Nu+8t0/JUy7kT9HdkVmSBaYBT+9t7QmBwSsdWcYgl5nvF6br21S38b43LqyA01DSHRQFQ3lNJhx6V/sBqBpWZeOSKLoHfgi4S7b0UYEE2+qTFlNXdD mtM+Bt/k dNJQ+D9j4lVgJOrCsjsBS84dbui4nZy0BmovjjVZbCq1Wz4cosF283NGcJb0raWoRGTRj3pfHf16vnwFCDHfz4wVjlTMgO4FcZQIKPKFerse6szUP44nK1xNuiFcL8efnt4siRvsjY1yl2lIySjrrxvA3yEu00R+k03LXPO017tUetWUYXBkCw6P6G3x1BBLGyRL9GGTLJpTm68LqCioEfhf9l5ey/FzLcHvTVbhalcRP+ZAPvpJyv3jm7apwlHbMyYBTXq8ELKcvRBrACZ8rMSxTa0E1ZzCXAsIfRUerORtRwkRr0O4+r5fQ9FmakBoKzTwwwCmNyKLedK7dptk9GT139xyuu97PHt8b X-Bogosity: Ham, tests=bogofilter, spamicity=0.000268, 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. Reviewed-by: Christoph Hellwig Signed-off-by: Jens Axboe Reviewed-by: Kirill A. Shutemov --- mm/filemap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 8b29323b15d7..220dc7c6e12f 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2527,7 +2527,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; @@ -2542,12 +2541,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 Dec 13 15:55:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13907400 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 A280BE7717D for ; Fri, 13 Dec 2024 15:56:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CA7696B0089; Fri, 13 Dec 2024 10:56:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C2CCD6B008A; Fri, 13 Dec 2024 10:56:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A7E9A6B008C; Fri, 13 Dec 2024 10:56:11 -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 851F16B0089 for ; Fri, 13 Dec 2024 10:56:11 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 0C1C480DF6 for ; Fri, 13 Dec 2024 15:56:11 +0000 (UTC) X-FDA: 82890387090.14.93B19AD Received: from mail-il1-f176.google.com (mail-il1-f176.google.com [209.85.166.176]) by imf25.hostedemail.com (Postfix) with ESMTP id 97FBEA001C for ; Fri, 13 Dec 2024 15:55:50 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=tATpthmC; spf=pass (imf25.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.176 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734105345; a=rsa-sha256; cv=none; b=4AQ4HZqUFh2CAajsFQV3HK2A0bInSFAa0cAkNI6T1O57is8BR1TdMHKSxJyr5PhNfKJe96 me2JwvzMFf2e6QJI8jl4y4rBIecxVfwpXG9Ee1f30IKO1iJU+gXkNAUAKCChG4JfTQyRIQ h3RM6Chg34AYAOZMl1jz3eQAA9LBDNA= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=tATpthmC; spf=pass (imf25.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.176 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=1734105344; 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=BpcNvbMq6OW5fN6dnGRgZf80nNArt3mFYuYvhVaSlK4=; b=v4zNRbeaSdmCtTFoGi1RGsI0VgR56nh458TgOOSrOq8kX/uQlhfSmjaXMro59y0Pos9+Iq 4R0xgIJIOn+CwnqiuTNnIz3BYe1bVD2WZvzWqhBqzHWkFxVVHg08xeid1uPndOKyfFoqIi bGBdh+iz4QMnfBqfiQD46NwOaiNL1bk= Received: by mail-il1-f176.google.com with SMTP id e9e14a558f8ab-3a8165cfae8so6325355ab.0 for ; Fri, 13 Dec 2024 07:56:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1734105367; x=1734710167; 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=BpcNvbMq6OW5fN6dnGRgZf80nNArt3mFYuYvhVaSlK4=; b=tATpthmCXFnzm25wCPtZXf+CvDYUCQYY6lzvV68kqxmDDkOQX3cOUxnHUPn3s2RnE1 IUNH8CSv1NnyV0MQa3RWFK9QjgIh6D/QODFcq4q4CVCkmi/y7dQJG9CyDYrYQmERwn4k Xw5A9/a/VpdqDZnz4L53CRD1+ltpL/BWDSwb7zCQlXYg0YEDOFydu8cTU6au67AACoZV hBDwMIHHr1DR9sPgwE9JNummNeo7h9KN6jvvg5FiYZ4eyTG7bOjJKDC43fBj9qL+/ze0 CdEQVclBl4gm7+BD8tc7/NDD4symjhxnLAzf7o5pO6GZWj4IwNus2VmbD8vu8Ell0Hfa j95Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734105367; x=1734710167; 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=BpcNvbMq6OW5fN6dnGRgZf80nNArt3mFYuYvhVaSlK4=; b=G6tODy3qzmF8a/RImgDKsgCGI9QziXTb5oL90RdHjhutRJxaFnVl+Lrhr63NH2woup unzae4X0mOfznfLSm7fmZRKWCXGSfBPqsMv2YH6Mv1mMBZlpwSd/cNVyHPQl6RZ1lIXr Li+J5VK4xGmINgHIxXTgUkmVxcsjKqyBcIlTqRAPXOuWsLR70w0H7nOZA0hwCO7ed44V hSHuQrXH8snkjeHRTqMhgtVQ+7oDUVVfg7/25bkg8pUiIw0+BXCdZ5IbStCMuDrCRRx4 Wzqng+GT1W8wAttomhrY88bsH6xY0BdWtjRBNa6p+Mvg9Y4neXLpiQTN5Ek/2zYb/DMt PPlA== X-Gm-Message-State: AOJu0YyirHXdRuS//3/DddllxUCFOK7X+VzL0gvq/1HMhsHfGFRDIO7A /uRCT1i4zVAC04g0oQG99njbfeQpy66Q2sqS+dFSfMuXVoJ1vzo2w8hXEFnlVifqTjlQD7EnCUA 4 X-Gm-Gg: ASbGncsGXmE5RHg0YU8vb6KJTf1ZrsCjfKlFVPsB8B46xoCCe7zShSlfpt8jNlsVjWA qZrKwMljQWJVKcObBTJC7wtn7lNjo0tcDxKbP3z1CADU5dzKJoRxBpY9tKeefjDDfFjkURTzS/1 IQ/pODK9oTJ6gtmCDjgBpgzgWQylhBjrN2mOn7iMiJFFqpR8l6uwnqKrrBR9zfJ0rwwwYQq2tI3 VeEno2GVu5s+X0pwGIwHLnNxhA79GfqH4RlUeEMxvzPNmOVwtxsxEE3K0R+ X-Google-Smtp-Source: AGHT+IFWkhf2olmYWP9+u8WH9KgVfslThGYwEFiU2/KIyOObE8orPa/AadsJR4yt5f2xYXvlvdRoMg== X-Received: by 2002:a05:6e02:1a07:b0:3a7:e4c7:ad18 with SMTP id e9e14a558f8ab-3aff80107a2mr31899055ab.18.1734105367708; Fri, 13 Dec 2024 07:56:07 -0800 (PST) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-3a9ca03ae11sm35258405ab.41.2024.12.13.07.56.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2024 07:56:07 -0800 (PST) From: Jens Axboe To: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Cc: hannes@cmpxchg.org, clm@meta.com, linux-kernel@vger.kernel.org, willy@infradead.org, kirill@shutemov.name, bfoster@redhat.com, Jens Axboe Subject: [PATCH 03/11] mm/readahead: add folio allocation helper Date: Fri, 13 Dec 2024 08:55:17 -0700 Message-ID: <20241213155557.105419-4-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241213155557.105419-1-axboe@kernel.dk> References: <20241213155557.105419-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspamd-Queue-Id: 97FBEA001C X-Stat-Signature: p9hxiea9ukerzpfer39gpp4s1emifiou X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1734105350-11503 X-HE-Meta: U2FsdGVkX1+eIw4A30uC0U4KLBhcxGSYpcoesiWAufGuTrn+wzQfWoY/DvXCDsZ5TmzryDxwxzFGMcnEILr1+1SbkOa1T0rViX/0IbL0nbJWJgiloYLV7jv4U/bGNJXNzgi/8t66NKO2X9Ss58MkuNIIKsPbcupX8chi+oT04Vc6rT6AzdAKbA+vhT9IP5FA+hdsKtZwB5JnLu4T6RTFJR+eiKS6qL3PtYqKlOqe0Ar0RVRb0lReA7/XSG2EAay3NDFToJrA4IlTxjP1n/XpqinYjUL1vT41tMJtIB4V1B7I10E64IZ9UzBkJG5mX9RpodFJb4Q/V2GWyGZ/DtxM1xZeDAKDRr3WXLZ016vMnUZBy45S/qZPeD2bZHvFWUSZpjpkPk4mb1f0QwQBe6tHyJO7b4xUFhdH5w+YWETHN2KmBJVIVD1RaRYyH899myxKct00cL0g+rAj0U4jG9nsVXWcHjPp0iWqvtrFslkZzH/uH4wloh1/5OQSTlgRx7FKB786ZvA05f1OSSFrr5FXhXFdLIvYj862V7tYqzR4CY5GocK0B+cj9P6rSjdDrCu9XSQbpBhUmH44JD0jke8CNafibm9htsw+aRKVZSgaBLrrw/5hCBxr70TR+9UcX0+qSsKMXtEUhI17xuEMHwnG/Q98pCP+9a9dzOXkXhooNoHhF66s7ue5/uoSKFJU8BmUz7zcJPH4G6Fi9X9ksM4uSrTf9LG7fK2yuIUiIFDxBhygk98FkkMMdR4Df/bsA3tGMXjOTzq9b1wTg9L4grNJvc1JsHCQWOWKddqqi0PVTOXBGhY7J5iT6pWnmr4O26fze48xgzCFA9aYkd9eodxwHZozpcfu7jSWaYmru39W8DkdMCmAVarjGAvumRCEaIk6YgNALIOC2dKKpoS0wlJsTkWYM/ccuiKzF1EpKSk2gLGucFP5rm/pM1j5BpH81XAWSo0p3YZxWUrxMTdU21e bLEe7eJ0 zEq3GA5A4AzQ1lCd3ZyLW29I7iLQUZ3RTRbRhy0Ieqq+cVd7RCXVGSsRwzlKgzH6QOAUHRkkLIlMpUK17tsbx0jtEyx7zh8ys0tE3+b+KiUuMZjaOe4iNDcm7CjeH7kegGYQAmEKUNU5phwNZlvQBnfCkL4V6Gn7y98qdJpXY2Lkg5WLONrKzG8RYcX1MD0vm/BfzKXkAbzb3X3ZZsiEkqVMKdd+FhmZCUP74L1is7CnSKAtQLZocDh7HYzYUdsJuECKzjb1iPju9LrPDCVxjvWvm/qAFrdHYgtWXUaoEPHySuW6hbPR0LQLIVQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000139, 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 Reviewed-by: Kirill A. Shutemov --- mm/readahead.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/mm/readahead.c b/mm/readahead.c index ea650b8b02fb..8a62ad4106ff 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. @@ -265,8 +271,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; @@ -436,7 +442,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; @@ -750,7 +756,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; @@ -779,7 +785,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 Dec 13 15:55:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13907401 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 0F6DEE7717D for ; Fri, 13 Dec 2024 15:56:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E78C26B008C; Fri, 13 Dec 2024 10:56:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E28DA6B0093; Fri, 13 Dec 2024 10:56:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CA06F6B0092; Fri, 13 Dec 2024 10:56:12 -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 AA06A6B008A for ; Fri, 13 Dec 2024 10:56:12 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 645F080FA3 for ; Fri, 13 Dec 2024 15:56:12 +0000 (UTC) X-FDA: 82890386166.19.3393A99 Received: from mail-il1-f170.google.com (mail-il1-f170.google.com [209.85.166.170]) by imf08.hostedemail.com (Postfix) with ESMTP id 59AEA160009 for ; Fri, 13 Dec 2024 15:55:53 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=hOO2pCAm; dmarc=none; spf=pass (imf08.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.170 as permitted sender) smtp.mailfrom=axboe@kernel.dk ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734105346; a=rsa-sha256; cv=none; b=sHcCMpCevNQ2rrZix9y6veK52Xys6c1ymOrI4fMC2RIUNktYuCzOFTj46KnkASgO/QH74G Ggg88EaRX7GsEnftm0lkC/58Ozlw4BrKHI3pKYuT0RPe2yY3VMayfaksqVKX0DWzxkT7G2 pXO5NE8V7zNqY+ER2hrUFaTzbOPOVMc= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=hOO2pCAm; dmarc=none; spf=pass (imf08.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.170 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=1734105346; 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=HOQaUrSMrbMaSJ8tKHsfpEHyiDws1YYfXq+2bH3/e/Y=; b=LZaITabHbVZPO9pJj10vJv1vOKCAI27fcpedLRHUIlsGwacqcFMwTs4NE2Cryes9G1yC9o yzh8QSocONcuCthwTq3C3ia/4E9SoE7SrOBK1IP811Int3x4lsuTCBX93t8IP/Gh0Q3XPS XkEirwuY7okgJGgd9l8NZbDPfJuQ/KE= Received: by mail-il1-f170.google.com with SMTP id e9e14a558f8ab-3a77980fe3aso6265565ab.0 for ; Fri, 13 Dec 2024 07:56:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1734105369; x=1734710169; 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=HOQaUrSMrbMaSJ8tKHsfpEHyiDws1YYfXq+2bH3/e/Y=; b=hOO2pCAmHqd/4Y8+0daFh9K+3AlX9aMbAn98s3gN1Dzs+7B/bT2OoJV2oo4Xq7oxr+ 7XDTZvTibOXbO+UmU5MUySPbAo1ud85p1c+xckY0zLJLWj5yhPnnLxAebEoNVPx4LFic zE/c7Y9GKmD9W9dgCAtsAGbKuwxz7OKO+ze18dQ5p4x9EnaKlB+QGEkwVWUZrNrgCLLQ XJ3uKrdgGvYl7qBI/P9/A9THOPKcSzJLd1HIyAvEUXplsPS5bChRShDMrjOktN8iNFGY MrF4kVaWvkkt80A0DrZSzTryg9kd3VtP7I/N+jampUmR6LsfDPgegkLR4DKU9nKpOGS0 VMsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734105369; x=1734710169; 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=HOQaUrSMrbMaSJ8tKHsfpEHyiDws1YYfXq+2bH3/e/Y=; b=NHLtckplRTH10hdp7CeNTXozfRHtWgm+qHY/DAT2Jg5NgREoPxRqZDKOubyzdKzz7V gIJOtLDHqdjwZ4Dg4JoDBrm1Bx1sdr1ORGsC0Erc9/heDT2fRfOnEHssm3eaHuXU/UvE a3oRMwFgQUB+INxvBHzNKu0eseB3Nv3ReCoUermBQgDEJkWLSBnR4MVR6wIjTjFTgqbL mO6dBptGU8XB4S9JkjTP3gocKL/kjDWXyVqPL0OSzYbdJf0RnoXf4j4kd1ztt8SqC19/ UGelPEx/g5HvYMW9Jaze6VjqiHPSIXCy/TCI//u3kr+xtVDvx4vBtT5Luu0pUKTfRGb+ UEIQ== X-Gm-Message-State: AOJu0YwMQaPxLBEZRS5rBIR9aZp7nFIS1Ti5UXD5nmUlR4FC7F14Hzeu YTdND+zcpWWI/HF/YTqruvcWRpg0zOg1k5smwagaSquG77jPOxzbWYKvBhncYIfWAk+xj+sp8Xk F X-Gm-Gg: ASbGnctqFwJJRHTYZPsBu7NK1NRwfLHe4K1I/MnKR10pfD/NXY675yOHO9OBhIosOTv Sre7RBuSUjOi8YR/RwGDbKaW+c6SO0ES7jf2FvKHEjdoUu4worcNV3xYGBgJ7UWhq5bp+oH8jac eB4gugGFgzK7h95nRFgiNrEYKuXb26MC8cz23RWjtS9hL2mhH2t2qv8hcd4+twbR7QvS2ADo8Ld mfDwZCJDUGwHETnCu5AIj/DMdS5WILXkKYHeq+bpkMejc8PJsVZTvAIajtS X-Google-Smtp-Source: AGHT+IFBVlz5yZz/k+skWWprsCIycLK8jgnRkqf8RE4HqF0RJQv2gkIr0yeXfbClfRWoooTGgqlEcg== X-Received: by 2002:a05:6e02:156f:b0:3a7:e8df:3fcb with SMTP id e9e14a558f8ab-3b02d788a63mr20845625ab.7.1734105369001; Fri, 13 Dec 2024 07:56:09 -0800 (PST) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-3a9ca03ae11sm35258405ab.41.2024.12.13.07.56.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2024 07:56:08 -0800 (PST) From: Jens Axboe To: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Cc: hannes@cmpxchg.org, clm@meta.com, linux-kernel@vger.kernel.org, willy@infradead.org, kirill@shutemov.name, bfoster@redhat.com, Jens Axboe Subject: [PATCH 04/11] mm: add PG_dropbehind folio flag Date: Fri, 13 Dec 2024 08:55:18 -0700 Message-ID: <20241213155557.105419-5-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241213155557.105419-1-axboe@kernel.dk> References: <20241213155557.105419-1-axboe@kernel.dk> MIME-Version: 1.0 X-Stat-Signature: b3n7bip4rrjfuj7auub4oday3k4de6gy X-Rspam-User: X-Rspamd-Queue-Id: 59AEA160009 X-Rspamd-Server: rspam08 X-HE-Tag: 1734105353-37284 X-HE-Meta: U2FsdGVkX19hkpfAtKkyRhZk7XuDa7ODrr6hq55I9w0MdDxyPvIBkSSWtW4+x7LlpGyT+Q1Yfu3RQqX+/OjxYj+eOMaqOiKbOgu222qlyRRMjxdySgBdnEGz1jMUUx88EJ/uKszpHwmaAoFWCI4IGbt+1FNzt8E/hBcH+ZRKRVWZsE8GXYzjLA3eDphIiWWRXJLo8dC1rGTpD1w5Pre0yreU6SbOdI2ScatPwxgVZ9/2syeHJFuPX4eV2eK4JtcKFww6XpduT6ilxZf0cld+u8C2Y/GXxGAdx721Q+P5y08zVHJwAc8ulYJQs4/zIhWNIWRXHOnYOSDAo7F7MWtRek+I3Kds4OPE0vcQWfvUpzBXMxP+HTamsyGJeGfZVwSHeTlHT3V2J5VWBROv6FzDfG7sO2x9HDSADJk4QFQTDM3Km98HAm6HhzN1HRrN9GcB8i+4Uq14w28eFU+Yh8w6o1H+XX6dt2zwUz7AsXIR89My0ohPWLpIuPXq/ZpEos7/VD4lOqE4+Eh5hVND8kfHe0rqWRLztyPNUQ89XLKf1mr/3cya+nFT9P+t0CNGAdnOna5Jcm5pIMhNI3S059H7HP1mbN9liXfCnAiFJF+gA6K8NNqiAvPJIGKQB79GBJbEQ1vq3LrckNZPRljuw5ChQqdwOTgJpi/NY0VPvfnqiHMxPxWfskbtfQyOIS8U5rBuvB77gZhezPWpfa6D1EZv+O/vdypb8QI16mwZjT7lCDH57TXv4Wv9VSfMuRxKIbljcbyBXQHNov6ZBaZH+qWBOGOIhhWexEp1D90fRPT3GZxKf31atFzNhe0UMPHV0GZTdBO50pXUzNwe30A6fANU2eRSH8OwePZrxA1expCUFSCTcIXNcQM1bEjtfXuUoxTx1L31IejK24UbufUC16m5RaBuwW/+saiSSlsT9+vtz9xilHuFTzGZ0V4zHRbGmedJP7xPBmEOPpVsn4nkLqW DsVMqR46 c674JmnMyYjh1QnwjrZ6ObN2k4wqrXGPJHjZfuIZqh/ykSplualChvAitDB7KNvTBJy4MzgMdB6nRJmCWLStaBoxFLTtLOzB+k80XRta+PLXm3fBZ0t45FVGBJr5LuRopZKgMH91c75T5Zixv3kRy5kH+EI+uz1rnsMqr3rdvRcGyp1BhIT+Qwuj2Vf0r6yqDHBorkrTsXccUTi8EN0L5jbG3KM6MR4hUvakWq1k2HSpcDgoe44w4vyh+wviJhBlTpOcLGy/1MQnylRvB88A+oiQptpIEJ/hJTugQTK7qTfKG44pgKtvtX9T7GEHutFp4g9+hw8kk73Z57dr5Us8iebfhiS8yYFOxipNF X-Bogosity: Ham, tests=bogofilter, spamicity=0.000020, 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 folio flag that file IO can use to indicate that the cached IO being done should be dropped from the page cache upon completion. Signed-off-by: Jens Axboe Reviewed-by: Kirill A. Shutemov --- 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 cf46ac720802..16607f02abd0 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_dropbehind, /* drop pages on IO completion */ #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(dropbehind, FOLIO_HEAD_PAGE) + FOLIO_TEST_CLEAR_FLAG(dropbehind, FOLIO_HEAD_PAGE) + __FOLIO_SET_FLAG(dropbehind, 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..3bc8656c8359 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(dropbehind) \ IF_HAVE_PG_MLOCK(mlocked) \ IF_HAVE_PG_HWPOISON(hwpoison) \ IF_HAVE_PG_IDLE(idle) \ From patchwork Fri Dec 13 15:55:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13907402 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 DB47DE7717F for ; Fri, 13 Dec 2024 15:56:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 448646B0092; Fri, 13 Dec 2024 10:56:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3C70E6B0093; Fri, 13 Dec 2024 10:56:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 243816B0095; Fri, 13 Dec 2024 10:56:14 -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 012036B0092 for ; Fri, 13 Dec 2024 10:56:13 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id B2E3AA101A for ; Fri, 13 Dec 2024 15:56:13 +0000 (UTC) X-FDA: 82890385914.09.DFFEC70 Received: from mail-io1-f51.google.com (mail-io1-f51.google.com [209.85.166.51]) by imf24.hostedemail.com (Postfix) with ESMTP id 7BDFB180011 for ; Fri, 13 Dec 2024 15:56:08 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=cp5hu6qy; dmarc=none; spf=pass (imf24.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.51 as permitted sender) smtp.mailfrom=axboe@kernel.dk ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734105347; a=rsa-sha256; cv=none; b=yth+Ax5h15jqih68Jh+tdA/pYg5rOrq8bofpbPJd8QkK6G+K1j3WTPMdBVrVWpVgJaI2W7 w/GHMqhbUmL5YY9LvoVX7aGpy5bYonjSu5xWusT5JUNH4aEfBTuHsXgysqjAQRSwDH8yml HgnfrejdMyfuApKz4y1LvUr6SiWtjNk= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=cp5hu6qy; dmarc=none; spf=pass (imf24.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.51 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=1734105347; 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=kz0Pdg9jqnEJMYLqH2tprv5bkemx7uetlhB6shaJiPY=; b=FAy3Ih23bhL8mOgknSrzsfeUxwo7ILVS4nEaLvyghFBMIJ8GYR/T9EF0uiBfkYjjsPG5jb FgU887Ei2azR6uQDQMZI8+hzFdeBaDfH2i2uQHSFR+g45vQUcC3EN//WkINqJVSKeAbrKi 4cn4LXfthj11Cfa4iJ10mCfIiiumL1w= Received: by mail-io1-f51.google.com with SMTP id ca18e2360f4ac-844e6d1283aso39025739f.1 for ; Fri, 13 Dec 2024 07:56:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1734105370; x=1734710170; 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=kz0Pdg9jqnEJMYLqH2tprv5bkemx7uetlhB6shaJiPY=; b=cp5hu6qyfsFVukVTbYmFv9ncuqcZYuJ5osejelS96cThx2txfUkhdkEOJh3YtHHB2E z1ujd24PhrOcVlBuJ5Y5bp998fYvWth8rWOhu69QxV7w3yTvh70f7EZIzTDrYeIO0Mcu owKjPdygsQDZVFB+NF3tiq/lzl3AgO6vHd1U5f9S/1Iy80K9uw9DPdsLgo3e0IxohvcV 4MHyCxaLqwmqF7AV2B28SO8XD2s3YHru3Yqfp7O9QloPFFpOmrx4ZMa/SY3qmbzpNYVX GDfWVqpDOoQ2DEdTc8OTH4hn2UqmpnnCQ8R/b6tRUBAlu7T78XOw2ZrZQO+cIn65GOej yPCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734105370; x=1734710170; 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=kz0Pdg9jqnEJMYLqH2tprv5bkemx7uetlhB6shaJiPY=; b=C95Bb9bsR/JFG61qyKepwz7ILU8alMIgBSXOL0MOuY2woh03epUpAlBIpctHYxGo9i wsEaU4pDc2X8PxWz9MAQ0DRarqwpyXyiv7i947etKD1cE8qTh7TKJNOiL5sqq/fCGjdT bWm+Ddb4Zhtxs0TUBg/h1Q43dhhewPp94MtRu7QBXszggeoUbzBpEGo2b+m9SggMCSpV 5cRwjxFNbu+hUYZXR17aZJmnNDAPAfWCY404m+KTxRhPXb3Kr2d72f4cXcwkJRZbqeSM WkU+UyrqpJ0hQE5SNKgom8z+a6qw1j1Z6fWTLQPkPibTeHO6iI/zzo+IECD+jnXmp4v/ ydhg== X-Gm-Message-State: AOJu0YyBVA1jNmXio28s84ALybKI3BT4yo/tcxZCgcs71Q7H6Yz0+hYW K8ezclNAhkDU49gBGwGy67Rfyp94UdURWqFm3ZF+iGO/Y+CWsFiSW7K6RVgFrem4Jw86MA3vQwa T X-Gm-Gg: ASbGncu3hsgJT631EVZ8UfR5xmANDzwFI9vHFDlKtwWDGA82EkMDkbaEA/wzq/QNlqr Ah8vhguEt6CCGPp8btHaLrDiN4KSmrn6cGC/G632lXyHOuc0NNmxo/V5zq/8izj0GH59QLKsAOd WHMya0YoSVJ4Z/qHSAAQpIKlOX/DbX3aARwJL2SJC4HMMfEo92QBCjt//chJxQS0DdckJmhpkwi X++T/2DlSp4Nzsf1gPlG03oAO64fdfaS7lWKV3dZllBgHgDqIlP4zkZaE9o X-Google-Smtp-Source: AGHT+IHcUplw3Q6ECt5DnQxOZIMw6sSCxN/kZ+qm1VNkzK8N15/r675oe1NRLkEoEeFprb07mxKCyg== X-Received: by 2002:a92:d10c:0:b0:3a8:13d5:bd2c with SMTP id e9e14a558f8ab-3ae61f23bb3mr46583235ab.2.1734105370422; Fri, 13 Dec 2024 07:56:10 -0800 (PST) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-3a9ca03ae11sm35258405ab.41.2024.12.13.07.56.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2024 07:56:09 -0800 (PST) From: Jens Axboe To: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Cc: hannes@cmpxchg.org, clm@meta.com, linux-kernel@vger.kernel.org, willy@infradead.org, kirill@shutemov.name, bfoster@redhat.com, Jens Axboe Subject: [PATCH 05/11] mm/readahead: add readahead_control->dropbehind member Date: Fri, 13 Dec 2024 08:55:19 -0700 Message-ID: <20241213155557.105419-6-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241213155557.105419-1-axboe@kernel.dk> References: <20241213155557.105419-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 7BDFB180011 X-Stat-Signature: y3dyhmq6so38gd5b9xrim93nuc6p3tw1 X-Rspam-User: X-HE-Tag: 1734105368-249582 X-HE-Meta: U2FsdGVkX1/tao5OU4+2CwDGZas18EEiQjyr3YsWQaxum4mFkCPEApj6mZa4tFfX/HeS7JeGEGXaeq4ib827iDABbmh9gJICAdxWEkIUqCTJkwUxzpLXYwHNkMvJZorUKtmc8Da2tL8yl1rSinI0bz44cE1CTi+/L1T5dXIGiLTbT8v4eC4/tVMPYEIFYa3RGZLpx7dmL6RSW0gg1PlB28ZoKbGMenWBzs7vjALLrpgJ6728VgF8rnoCd5ZJXwtURG8dKijQlPULVnr4H8osz5wkbvwfxe8qiapbLJF198OgcuTqdZgql53Vaa7WY38z5BaReV3ay36c8vh1wCWuiA++H/k2h4mTvkitVcYym1WP76QNodNfF1REl4LYgHO3pXGkWlSon9xgL4rBdy5U4a3Db+RaJSFRTzU9Me0Q6jegGfOxt7AA4ZXiOaafo+HfUkpsFVG8zXN483v7Z530MPP3xVp/IXXO/II6sZxMF3yQ4FwveQzmyWPOPjNPF/kRFz4fH0dIf8P8kuSqvJxtwP7zjkzrMeTfKVN+N419k09DHDFoZljmK/LAbfVGbS6I4KaLzJbfi2oBixnwGfkXo4HiLXfPpOBplcxtIbEVlNrJ/89FYp/KVd+62Xf5vCOYgzXn754S+HyzQK25QyB0O+XF0yyalD5aXUxv7HvbZZFHaVubbIn3GmnuxAf8TEHKPsFkKNSrOPdZDAmQEIWXExz6pzpcGnI18uvDWdmgWy1fAjLjAiiYSWZOWP6L45LjIa9Dxzz+fw7aqMGj+pHrwlT1Gy56KlKk+D6wkofmOGR5SotA28gTC6ltstkyEtRpeO11Q1Jp26WBy1hsqm2PYXoaKES9TWN8n6GXJR0pta6UoW3rF3I4LBqt8V5WOX94m5Amwa6UUQ8vD7H6eVEvRprYEzJR8x3ZKMaSAtBpEhsc47l0JA/kUloivKjHKLALMRz1EaaBhWsxPCMufkp UWapojjZ FuUGlyr0akFVfcyo3sIh0Ti7uvZMkvcLT8qkLzfUyhRDk7isXXbONLBc3VC1rBQKXj3JiFafbgMSDNfgeLqapNB0gzUI0iAonQVr2DUR2wWRmzrbZs0s9W8RDxZMynKAGrba+wAKGcTv9cmDI9Cvf6kykVJikSpjwj6uAG5EeRUH09WxPlOg6XajmUY9ogRugeTrrqQVnfe2rlkiTLhc7Q580hIIJFELXISmo7YxnqBbioJOIzQMe3TIaxjl0BjZv7ac73Kl4PrHBSdA1JHoJknC4UCD23QZTmbo3nA2GNkH0HBLu9evTTjTNx7+k5ZzkBOJC/dQMW20V2yNer1//CyRRtFoA38xXV6uP X-Bogosity: Ham, tests=bogofilter, spamicity=0.000075, 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->dropbehind is set to true, then folios created are marked as dropbehind as well. Signed-off-by: Jens Axboe Reviewed-by: Kirill A. Shutemov --- 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 bcf0865a38ae..5da4b6d42fae 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -1353,6 +1353,7 @@ struct readahead_control { pgoff_t _index; unsigned int _nr_pages; unsigned int _batch_count; + bool dropbehind; bool _workingset; unsigned long _pflags; }; diff --git a/mm/readahead.c b/mm/readahead.c index 8a62ad4106ff..c0a6dc5d5686 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->dropbehind) + __folio_set_dropbehind(folio); + + return folio; } /** From patchwork Fri Dec 13 15:55:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13907403 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 6311DE77180 for ; Fri, 13 Dec 2024 15:56:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B91F86B0093; Fri, 13 Dec 2024 10:56:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AA71D6B0096; Fri, 13 Dec 2024 10:56:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9221D6B0098; Fri, 13 Dec 2024 10:56:15 -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 6C09F6B0093 for ; Fri, 13 Dec 2024 10:56:15 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 28B8A41B2B for ; Fri, 13 Dec 2024 15:56:15 +0000 (UTC) X-FDA: 82890387216.02.08E16EE Received: from mail-il1-f177.google.com (mail-il1-f177.google.com [209.85.166.177]) by imf05.hostedemail.com (Postfix) with ESMTP id 1B48010001C for ; Fri, 13 Dec 2024 15:55:23 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=QevZKSsp; spf=pass (imf05.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.177 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734105353; 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=S6x6BO6+6Zb8b9h/4S7enLTX5qkkGgQROhVyQCWWxzU=; b=a32l1Pxm/8xN4+xBUjZT9aMfjUxvZEDgEAzEM0sBz/zL8GUbxIDQU2no0PsEFOJgi04UuJ c6jnDwZwpnF1YxltyzqEYJ+llEbYZTe57OBq5sGITe7gaBk//boxCPVR5By34hElZ8mvSi erCEjvKn2mprTH+w2fWC0y/9tHjsd+4= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=QevZKSsp; spf=pass (imf05.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.177 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734105353; a=rsa-sha256; cv=none; b=bg5ifqPQojZMCReOZefHR/jF+PfmwLu9XgRc2ErNXo+wV0vUIRP61HkWTuU1XcKNSLaJgD Rr1iacnb8QCDYN9uR31Buk0qbn72mMzQZUecSxQBJuYsb3iUN3Uu8gcghEMiwlr8ZtEwUm I80BOaqE5LFSB630NZToCb6J0Aiwg0c= Received: by mail-il1-f177.google.com with SMTP id e9e14a558f8ab-3a78b39034dso6048295ab.3 for ; Fri, 13 Dec 2024 07:56:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1734105372; x=1734710172; 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=S6x6BO6+6Zb8b9h/4S7enLTX5qkkGgQROhVyQCWWxzU=; b=QevZKSspdL7uoYImfZPT8G1IJ3/mj+DiVIpEPoLIYG6MVT4L9XQ1ssVE92ieY7ZhAv K9r+gSJj+r1zSnK5dJQb9bhw83qfsDDnrSXME2A6rIG4wtP7okQipCiccSSa9CfGaW/Q 5QbEafCjkf1k2yY1x4FiA0UcbPD6Bb9Gdj9dVeSAp2AJ2zffNZPLr11n1hKNqiO7VMpg HRZPd0GQb2UIi2bRIwRhwHTTSa3D9Tyfy5N77B87kGmrSklJN/g1/h5Yo1Oa7X+scoHR ADIsb/d6VSt8KgBjUZKGEqJNt0r62HKgRR/XovXPx2Wd86BmxFvrMSk3zoowmUIQcX1k FJWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734105372; x=1734710172; 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=S6x6BO6+6Zb8b9h/4S7enLTX5qkkGgQROhVyQCWWxzU=; b=VpG8lL09ZNbk+KirD9TUx3hbNhWvaHuVdQ8KY5lSVI0kLoCFA3wAEtJO4zrafkOZv8 GW69tYdpxa/0StMZoPAI06lu0DFNZRxCC/+gY6qEhVT1W3ZFp/jRXznzdc8uPTIfc4va 9dxg/JIxD9FY/9M+0RRbl+CNr8IHz/oVkmmMn04cnEQHwwNyk3i8T0KH0qQJ/VPzrSEJ QUpT6TX5CglNaSIGAEo5f7N4m/JXik63kMdpqnAX109ewie5kKEHtdBY1iRRNDkUYCLp dE00+6OhnoaACDdg1brokEJcEgYdOcxBoGBZAzy59MkVTyBVYgngWsfDy+QpNPPkjZTK fv0w== X-Gm-Message-State: AOJu0YwQ3d3HxWqKyHANpG3YlIRBneNBMhf8cd515HeISrad/osQModF jme2zJFbEQxBqQEMC3qFUY312zBAgiprCAGqSqID+97NNa/wyTKgpIZEX7scyw5sJkISGv0g7LY / X-Gm-Gg: ASbGncv0dg3d6SWmROI18yJzGRzNA6OMujiZb6eTH62keZf2PXNXBwvEdP3Ho1zAFuC 4ZZhV5uPgmUtDN0vljqB+mytG/E7DVNStoqF5Dfwf0BLYHH3x+X1XG/+XCkUIn9+qWszdPRNIh6 o6JXrHWAs+hBaW71NZtknlvFSjy3m1dYlAHzettetprcSdSFQADfjGUGDWO/YB19iBw7plwZqNV B1ZI06hKWIGkRs2DwqvooyG1UTB6Q3x7zP/SUhbnP7b1ESLFrkFwmW1Asih X-Google-Smtp-Source: AGHT+IEynku8b05ugapn+xW5MO4tP+/urn6SKqialSRpaetMXPe/mw9YxvkBEr2Hl0/nNihyBVcVWg== X-Received: by 2002:a05:6e02:164e:b0:3a7:7ded:521b with SMTP id e9e14a558f8ab-3aff800f100mr28298385ab.17.1734105371849; Fri, 13 Dec 2024 07:56:11 -0800 (PST) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-3a9ca03ae11sm35258405ab.41.2024.12.13.07.56.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2024 07:56:11 -0800 (PST) From: Jens Axboe To: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Cc: hannes@cmpxchg.org, clm@meta.com, linux-kernel@vger.kernel.org, willy@infradead.org, kirill@shutemov.name, bfoster@redhat.com, Jens Axboe Subject: [PATCH 06/11] mm/truncate: add folio_unmap_invalidate() helper Date: Fri, 13 Dec 2024 08:55:20 -0700 Message-ID: <20241213155557.105419-7-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241213155557.105419-1-axboe@kernel.dk> References: <20241213155557.105419-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspamd-Queue-Id: 1B48010001C X-Rspamd-Server: rspam12 X-Stat-Signature: kpoq6466fk9yfbmqmcxfyqio4xgu99id X-Rspam-User: X-HE-Tag: 1734105323-916933 X-HE-Meta: U2FsdGVkX1/5G8vFCU56t+c2/Iy3CM19YBRy+oYESxcAHnj8+n0AWvMB+GgTMeh7aCfSOMJZV3h29p0S6SbNO6n0ofdEGBiLAANZMj6DKUQPduem6/h3/j/vT/o0gkAHSKxexMLo+iO3++3XrrvweGyyIfUckHWlPg9oSgxJhVOB90kWqkEPnsE+agmGNamOuksngwUSJK9tc4VsIvNLy9ywbHE2k/VLW6QSjwrY58xMtfV1KqdDHITmjOHmmJ8wD204J2rT2bnM1oPYsDQK00q5kbFIsa5WiLu+5Ocwi1qx9tDTubQSurjZSq0aalABYq9pMfP+zAkKzRXbHjKOdyaruw2HEFOGE9R23zAYd6BeVgexuAwsahWz+21+Yi8m0yHyY5sz0yf2m/5BYZf5vK2+l7tLAE3Dzh2+n6Aq6Br8DbBRX01KhQo/24zIXF1iBpDg/aQwFxxy8f+0hQeGYdVtjur8nX149gUlA0QOAwU2yNTi+vJ6tTeHn1dB93mEMPkA/0C6CW7xSruXJD8rApAf9djFq9NI6EQPj+N3QRUlyrNyC9NOWV4Zzh4yqBgy7NRqbzhgKSXpRIceeOF9e1eeIVTDhTjOI1OevBBY+rYP7z8Fokal6XU6h9XJnig0Yg8uJoQML7oen81KEP5Yk3I953J4jMKdJwdEy3IBXXJmYmK//wOXXgRQyNpijWxmFvUjfqLL7SRdfooCxVG3Y1nR/LYQCeyhiFthM/8wi7KlBsVpYFBnq8OwRyFVuoHJBEG8sqQ8nKDE+umg5F73T0BlzU3nvtmN+HR/bXT89oDjjGrV/JoqN7MFzriVfJcVIph9ZlznHG9LXZgkZCQhvAE21oYWOiQor9v3CSRBgthGoPFL6mU+UBB+/Zxi9VUYD7SFjb//T4libzAVGt8WVrbJoSlxL8qqMH4o+2PkOioYmH38PApaXOwMfXx0nnJsAfkJD7+gxE1EWUcqArq K7C3lhmZ 4BTXEcJEw8KF5DWDoByaIWkQWYJIOFb2xy5j14A6WmeH4vT8udNR5GlKmrf7h3Mj3dWJ+GuPuqi4ku9M54QgZfxneUsZeg2Zpt2yqZDJdlb/Hh0mDcq5enYDFAXlh/5GVa7R5dcy8VijHS2mx8b3ovLsdpclxqGQYRfqnI/XZvcKnscSBVUnMIi+wHe+Qyl7Yb3AI1U1kLMEPF7+2dZSuy3bQ44MlQfUfUSvAHjaEpbZT8e5IegryWOUxN6o8MKL5ag2E/t4QArYXZ+m86h4jonieZgJNJASt2fPbH3kjKDEsiqQ4MszxG6D3ZPDLBU6DA6qN9d5fwwRkWLVwhqmFgLhPsVR0HbeFuffd 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 folio_unmap_invalidate() helper, which unmaps and invalidates a given folio. The caller must already have locked the folio. Embed the old invalidate_complete_folio2() helper in there as well, as nobody else calls it. Use this new helper in invalidate_inode_pages2_range(), rather than duplicate the code there. In preparation for using this elsewhere as well, have it take a gfp_t mask rather than assume GFP_KERNEL is the right choice. This bubbles back to invalidate_complete_folio2() as well. Signed-off-by: Jens Axboe --- mm/internal.h | 2 ++ mm/truncate.c | 54 ++++++++++++++++++++++++++------------------------- 2 files changed, 30 insertions(+), 26 deletions(-) diff --git a/mm/internal.h b/mm/internal.h index cb8d8e8e3ffa..ed3c3690eb03 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -392,6 +392,8 @@ void unmap_page_range(struct mmu_gather *tlb, struct vm_area_struct *vma, unsigned long addr, unsigned long end, struct zap_details *details); +int folio_unmap_invalidate(struct address_space *mapping, struct folio *folio, + gfp_t gfp); void page_cache_ra_order(struct readahead_control *, struct file_ra_state *, unsigned int order); diff --git a/mm/truncate.c b/mm/truncate.c index 7c304d2f0052..7b6f4399319f 100644 --- a/mm/truncate.c +++ b/mm/truncate.c @@ -525,6 +525,15 @@ unsigned long invalidate_mapping_pages(struct address_space *mapping, } EXPORT_SYMBOL(invalidate_mapping_pages); +static int folio_launder(struct address_space *mapping, struct folio *folio) +{ + if (!folio_test_dirty(folio)) + return 0; + if (folio->mapping != mapping || mapping->a_ops->launder_folio == NULL) + return 0; + return mapping->a_ops->launder_folio(folio); +} + /* * This is like mapping_evict_folio(), except it ignores the folio's * refcount. We do this because invalidate_inode_pages2() needs stronger @@ -532,14 +541,26 @@ 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 folio_unmap_invalidate(struct address_space *mapping, struct folio *folio, + gfp_t gfp) { - if (folio->mapping != mapping) - return 0; + int ret; + + VM_BUG_ON_FOLIO(!folio_test_locked(folio), folio); - if (!filemap_release_folio(folio, GFP_KERNEL)) + if (folio_test_dirty(folio)) return 0; + if (folio_mapped(folio)) + unmap_mapping_folio(folio); + BUG_ON(folio_mapped(folio)); + + ret = folio_launder(mapping, folio); + if (ret) + return ret; + if (folio->mapping != mapping) + return -EBUSY; + if (!filemap_release_folio(folio, gfp)) + return -EBUSY; spin_lock(&mapping->host->i_lock); xa_lock_irq(&mapping->i_pages); @@ -558,16 +579,7 @@ static int invalidate_complete_folio2(struct address_space *mapping, failed: xa_unlock_irq(&mapping->i_pages); spin_unlock(&mapping->host->i_lock); - return 0; -} - -static int folio_launder(struct address_space *mapping, struct folio *folio) -{ - if (!folio_test_dirty(folio)) - return 0; - if (folio->mapping != mapping || mapping->a_ops->launder_folio == NULL) - return 0; - return mapping->a_ops->launder_folio(folio); + return -EBUSY; } /** @@ -629,18 +641,8 @@ int invalidate_inode_pages2_range(struct address_space *mapping, folio_unlock(folio); continue; } - VM_BUG_ON_FOLIO(!folio_contains(folio, indices[i]), folio); folio_wait_writeback(folio); - - if (folio_mapped(folio)) - unmap_mapping_folio(folio); - BUG_ON(folio_mapped(folio)); - - ret2 = folio_launder(mapping, folio); - if (ret2 == 0) { - if (!invalidate_complete_folio2(mapping, folio)) - ret2 = -EBUSY; - } + ret2 = folio_unmap_invalidate(mapping, folio, GFP_KERNEL); if (ret2 < 0) ret = ret2; folio_unlock(folio); From patchwork Fri Dec 13 15:55:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13907404 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 4617DE7717F for ; Fri, 13 Dec 2024 15:56:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 158866B0096; Fri, 13 Dec 2024 10:56:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 043C46B0098; Fri, 13 Dec 2024 10:56:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DB29B6B0099; Fri, 13 Dec 2024 10:56:16 -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 A7A836B0096 for ; Fri, 13 Dec 2024 10:56:16 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 4C9EE120749 for ; Fri, 13 Dec 2024 15:56:16 +0000 (UTC) X-FDA: 82890387048.11.B87DFCA Received: from mail-il1-f173.google.com (mail-il1-f173.google.com [209.85.166.173]) by imf19.hostedemail.com (Postfix) with ESMTP id 43DD11A0019 for ; Fri, 13 Dec 2024 15:55:47 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=Lk5MRJvQ; spf=pass (imf19.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.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=1734105362; 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=4w74VD3kuQguRINknUSjUP4VNHVLoGClDPYL5LdL0oM=; b=GSkw2O9MvlIqrpnaZu3vqR/UQkDcssp7vRMzGlrmmEklnTv6TtXzvkaQperayVcoSYyRm3 EpTVqrld2ptYXfP8ZRCIG2Zr4eWlrJzjwD8qXsT345yajpPK1gSt45GHCZdoMsjMwmILCt ATuWKa/+QsuWiM/Iexn2UZB8PiHAooU= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=Lk5MRJvQ; spf=pass (imf19.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.173 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734105362; a=rsa-sha256; cv=none; b=kKHKwlIQaJlb5PZOYkQphr3ugQ89BX+WucglNESJDSh6/LRgpJfsfnYjyD/7aoS70siQIV Wna1qTMS1Ml6a9DLPg4VPDfQTLdPx8i7hmlxjMNt922yDw8fLr4IgUu89W6+a5HhUFpY/5 JTcrSTqMlge3dZGSUM+2wV3VrMYtNqs= Received: by mail-il1-f173.google.com with SMTP id e9e14a558f8ab-3a9cdcec53fso15576795ab.1 for ; Fri, 13 Dec 2024 07:56:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1734105373; x=1734710173; 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=4w74VD3kuQguRINknUSjUP4VNHVLoGClDPYL5LdL0oM=; b=Lk5MRJvQ6nwCRts6ZvYIxtXHFLNasFEM0Cz4VNebMjXYYpea9uikTLAaM9BlClDA1w zFJAz4OVQsT8JxFfFdMzHcnMXAMfs70oEjgMnBo1WDaLmQyMH228PJkZR4C8V06vSa+p a+gz3rH55K0LV4BkkP+O+tQnglZElcEaS5fYnkK/9KDSKHGXT2D1rzwHm2YI+8qrVuHo CIcukBrMquc9JlVCYOeiHVNY8rlfP6CSs5uVPAzFKmG03vSeI3ZAJQKsSwCcB5zbFSXE uzG4uErfknVujBLD6bEy9xws0DVH5WBW6xKXe3tTs3V3BLzOc3NGwDxd49M8eWguvFhA KNtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734105373; x=1734710173; 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=4w74VD3kuQguRINknUSjUP4VNHVLoGClDPYL5LdL0oM=; b=gPCyqpzlRYvi9dURpnAZAL2oZLjUScWu937kUIzmhnr11SHEYkTgu1NSz+SwXEeOrj mR+e6Ut01DqSOIDbB2gsdepdQ5Y7Y/jYSHgKC9ORR1MOFwY4VQbCRBo0CvI/E0J87Vre 44GSoJ2vAdd7aRnoigLZKLAu3tl58x1qSlQ/XDgRy9gfV4PfFoo2cymziEd/f9hzeRZY AHSKWCrKB0IIs08opOMySciZrJ8+KlaiVUfcdiSV4E9gvyBQHntN4/gfyL0HCmw0/Q8b De5w3fvgfu0l4tfq+FCkZnskMM1R0sfWz8o1sOYxwPWw3RwMoV/lfx0z/VuXfXBuaVfA c6dw== X-Gm-Message-State: AOJu0YxUvzWUEjVNd2Eu0i/zDB971EsBc+IjMff0mO9U9aGXcTNlyJ4n YXjNZkLjsADMAD/VALNdUXCNL536YhPUfuYCC5eNudfCuBbjct/pe+gsfOAzzVcMK19JBPh9Chg x X-Gm-Gg: ASbGncvYUap6TcP1GXww23lU6AlMoKp9TMzz+wY1OuKUVGXCef9GekBOMSKk+nPie/T BoUPUa6PXlCoR/f75jO577/7MxlKV/UNkrAWio2B+qPVsE/9EpQysbWqT7F3YXggIDCY6M04qpg eLXiKMxdjpZsHcRJO4GzzCR9OeeUjvcYSZeeTeC1kQpblwJuimfNOqEf8oH8QPc5rOJ47CMVEvT igFf7gCSVqs4YCknVgip+iNYM1TNowKPWJGYRTytQSHV7nCdDAt1Rs8hqoT X-Google-Smtp-Source: AGHT+IHLruDe6Zg9uYRMCFFj0re5LQoOZLn3MM3DvSbmN1NLcJuI0/2En87svfvn51ITwB5/NqHQ+A== X-Received: by 2002:a05:6e02:3042:b0:3a7:8720:9e9f with SMTP id e9e14a558f8ab-3aff4619d10mr35119105ab.2.1734105373195; Fri, 13 Dec 2024 07:56:13 -0800 (PST) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-3a9ca03ae11sm35258405ab.41.2024.12.13.07.56.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2024 07:56:12 -0800 (PST) From: Jens Axboe To: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Cc: hannes@cmpxchg.org, clm@meta.com, linux-kernel@vger.kernel.org, willy@infradead.org, kirill@shutemov.name, bfoster@redhat.com, Jens Axboe Subject: [PATCH 07/11] fs: add RWF_DONTCACHE iocb and FOP_DONTCACHE file_operations flag Date: Fri, 13 Dec 2024 08:55:21 -0700 Message-ID: <20241213155557.105419-8-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241213155557.105419-1-axboe@kernel.dk> References: <20241213155557.105419-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspamd-Queue-Id: 43DD11A0019 X-Stat-Signature: ip96stfysg19fy456wj43f64594yo46w X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1734105347-828786 X-HE-Meta: U2FsdGVkX19dX9v2wjP6mtpK+Rotngc5FUlQs9X2Dp//7lfKED0XZZpfkcmuBKdg6L6uHt8Mvaqb4WuIaXIu5+qS5zDqiUxeWjE42Tuj2cI1/8UibceCP27S8b90i72vRehjH62yLRmaFc+MSd2RNIw3gYTBHoEYuccmUabJ1+rk6irEL83o51d5qFXFEhD3XexCuC9v5VIZLx8xPlUt4R1JpLgVv0d9Fpb8SfxZpm+7l6InmbZ91YVgjIEmALJ1Mlu5EFrbx1VOAeEa2i2VOaZvgyNr0HQbLUvOwyNRTOTR5aFSR6jtLugFkEzXGnLZ62v0zXFEKpMIH2/gYB1tT5581bUxzu+q7ut0aYQYBWQZXdaAHmMglje2D+lb2YQyPTOzi0Wp4Dp1iG/JUV3jRj28EsGqC0rKE3U40ygXHHBvr+Tl5XAv027ebN/2z2LsMdUq1+8W9yKX41hK02hl/itkCg0G1v2mmeXFPYUW+u4LcyC8a6xEoNgSBGMe0JOQDumUsw+jEPsUadv48K8eUvUkhFuegn5n5NboTjyKY2SiPIMxkZuDPRoRvFSwNZ/ChjfurKJK8bp7y1JEYAuylXZQZkzMRVtEAgPg5sZ220KPSyw+bMPTSnz9nJrHXkZEsO3jJUbs1MUWhuENFFii4TRgXpugN9VuFBt8ostos3NsHG3L0B3Pvt9eYcjIBGYqLj2bTngeZQ1/LzitYItchBm0k9VyNgQ2QHr0mexwZrFjcOrj12moBLm/MhwNbpEFIDlKSAxQrTDnji+JSfAcQzvmllmKoDN3sO2ejTJCjYUAZWN7xQOk8M8OGOGhO3HAXbdjcYwQC29/M8pXUNHhhbME4kg9RPgbFt/xyHMlLiPdbNUWvbEOsXJePMj7/ylfafhCTwVemM2KwoPvauJdL6i5h0ZBVXGbSDizT6qVrGblNTBHD5qhn3u0rsaTStLpdmbcQeMWqHPVIC0DGrX mx64DyWc dhUzdSHK0mc4cu298aB6AIvRtZCC0/ffwGu5kRm6ATK8zk1hO93iQ5wDQ5fnjvS5FFT2cIGFXvKm12mpO/8Ul5+aNPsDuM1FAfvmkIHFySMWAXE4Khfv/3aAVnDk2lWlaA9HPoiFYcAGLWFgvwnQXhLIfkLNb9iEnzNtH02dN2WjVYLwXZiOeewF98IqZEUxF5AKsBKWAs37ApJSfjIBX5nysobmmbkzhlmqoHG2ha5Ad1cbXEu7pk5f3e7mwF1Qx4T1wnSlP7s5LmmvYpfIThD8ITOBk8aGwDJq2TwcIxD6WXWyQJKlQC8EpVQV6XdHFKqmWfC0uWbxBr0Py2xcYKSMuvXMMaiSYSU5b 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_DONTCACHE and enable support for RWF_DONTCACHE. If RWF_DONTCACHE is attempted without the file system supporting it, it'll get errored with -EOPNOTSUPP. Signed-off-by: Jens Axboe --- include/linux/fs.h | 14 +++++++++++++- include/uapi/linux/fs.h | 6 +++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/include/linux/fs.h b/include/linux/fs.h index 7e29433c5ecc..6a838b5479a6 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -322,6 +322,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_DONTCACHE (__force int) RWF_DONTCACHE /* non-RWF related bits - start at 16 */ #define IOCB_EVENTFD (1 << 16) @@ -356,7 +357,8 @@ struct readahead_control; { IOCB_SYNC, "SYNC" }, \ { IOCB_NOWAIT, "NOWAIT" }, \ { IOCB_APPEND, "APPEND" }, \ - { IOCB_ATOMIC, "ATOMIC"}, \ + { IOCB_ATOMIC, "ATOMIC" }, \ + { IOCB_DONTCACHE, "DONTCACHE" }, \ { IOCB_EVENTFD, "EVENTFD"}, \ { IOCB_DIRECT, "DIRECT" }, \ { IOCB_WRITE, "WRITE" }, \ @@ -2127,6 +2129,8 @@ struct file_operations { #define FOP_UNSIGNED_OFFSET ((__force fop_flags_t)(1 << 5)) /* Supports asynchronous lock callbacks */ #define FOP_ASYNC_LOCK ((__force fop_flags_t)(1 << 6)) +/* File system supports uncached read/write buffered IO */ +#define FOP_DONTCACHE ((__force fop_flags_t)(1 << 7)) /* Wrap a directory iterator that needs exclusive inode access */ int wrap_directory_iterator(struct file *, struct dir_context *, @@ -3614,6 +3618,14 @@ 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_DONTCACHE) { + /* file system must support it */ + if (!(ki->ki_filp->f_op->fop_flags & FOP_DONTCACHE)) + return -EOPNOTSUPP; + /* DAX mappings not supported */ + if (IS_DAX(ki->ki_filp->f_mapping->host)) + return -EOPNOTSUPP; + } kiocb_flags |= (__force int) (flags & RWF_SUPPORTED); if (flags & RWF_SYNC) kiocb_flags |= IOCB_DSYNC; diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h index 753971770733..56a4f93a08f4 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_DONTCACHE ((__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_DONTCACHE) #define PROCFS_IOCTL_MAGIC 'f' From patchwork Fri Dec 13 15:55:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13907405 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 2D57EE7717D for ; Fri, 13 Dec 2024 15:56:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5ED216B0099; Fri, 13 Dec 2024 10:56:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 59ECB6B009A; Fri, 13 Dec 2024 10:56:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 355216B009B; Fri, 13 Dec 2024 10:56:18 -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 023D46B0099 for ; Fri, 13 Dec 2024 10:56:17 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id BC2A3A101A for ; Fri, 13 Dec 2024 15:56:17 +0000 (UTC) X-FDA: 82890387048.05.34F4319 Received: from mail-il1-f176.google.com (mail-il1-f176.google.com [209.85.166.176]) by imf28.hostedemail.com (Postfix) with ESMTP id D7237C0024 for ; Fri, 13 Dec 2024 15:55:46 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=tNvm+qXL; spf=pass (imf28.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.176 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=1734105348; 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=IP/eZVPa/Uul8epuK9rEl1xWlFc7aGT1EOVSfKN8LMY=; b=3MOBPYzfnW9skJ6+GJvC61c1lq65mnA2AEZeaJvsp9u+RguKALD+cW719hdclVkf0saJWJ rjb07v8ffuWKwEKkBe6fB2I+o/yRZGNTIsdMT3nOeVJTaCbqnrLRmeGj7CXEWXAGFf/JAJ fko3rhxOl+UBBEKGPpPW5GwDClUY/6s= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734105348; a=rsa-sha256; cv=none; b=V22Rx9GOrUK/FPsvIaPe4ceHZgHFSAbMjD1dKPoGsK3ITMycvOcTIaUkubpfb873zyLm4u FSpz5p3mpC7vYIifOS0IgXLBHplFp/x9C1S55ejf9/DyCgm2V50n3Wey0tMJ2E5oYx/t8c dRGDMAH4yR/5dlIkpYz1mqev+29Y+7w= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=tNvm+qXL; spf=pass (imf28.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.176 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none Received: by mail-il1-f176.google.com with SMTP id e9e14a558f8ab-3a8160382d4so6010925ab.0 for ; Fri, 13 Dec 2024 07:56:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1734105374; x=1734710174; 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=IP/eZVPa/Uul8epuK9rEl1xWlFc7aGT1EOVSfKN8LMY=; b=tNvm+qXLkKSP+zQH3ocDLkAgrAaAtDXEj7e38V/ad3i5fFD9yZTI7WX1JSTica4IRJ xAwmiQfUWSWvGjD689OZiznxHkcPYqDqwylJKff8yV2jdm/8Q3pldAg9WvW9hR+qoskW kzT+qEgn4EPR0bm/UOjymhLupVFyyicSbTIbeTxGKBbUOYCAjYKT3O8U0pkokVd1/la3 0/VORTQdgDI/ah2T+taymjKfCyt2YmKXUuOwIu7artwcOtUbNxW7RhlBLy5zbQQjsaDh kA1GJS3GXL1v0ETqU5s5Nu8ibCvdg1l/cen1hm6Yccsc/RKlbgfJMriG8/CvRttYKM5T W3AA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734105374; x=1734710174; 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=IP/eZVPa/Uul8epuK9rEl1xWlFc7aGT1EOVSfKN8LMY=; b=PHpKoqrGzmcxfQpjQFxkYoeHvQX/HTGoPsomt0wO6jGhBDzl5znU66BHIAiCW8DhcL s2Q4pVvsoi7DobjDlWZPfLjLkR9NLhjzY9J0TK3d1E8XbVjfwKxFgAxsYHEhGfCWfZLN Lm0R8UvmV+gtAfyH7eF5PQVPdNCBcTjPp+kL+blWJSJqnSfMYsCP/Q9LGhbWu2eAmXDK F25Q1aaBLU9MfXF6fkiEo9I8drRliBJpR8561YNe1sbmAWp6n7DSD3ZNzjlYpTYqfchl M3os+acGCBiQd578xk0DRdMZvTIV4uNPK4NlW6kyWNUmMv7FN5WxhSMJQYAJ4cCzP96B pNbg== X-Gm-Message-State: AOJu0Yytm3RWKvR7kNKzXXe+nvqGhocYCc+EXaGyF2YULh7xYovp2vsx bWifewmdCpk5G0VJcskZU2adGDWEFUZTP2LIaQq9frd934U1HFS2zc8a+OoYU6OedMVPxAwOUrU i X-Gm-Gg: ASbGncv65eQoO/kFAoAowc7cgBIsd3Xa0b5puevD6k/1utfjikdeSYxj8B+nYDZCa3B VStZ4CjJ1sB7FSpkYIXmvkMPYJnRG91Mm3KtAMzJB11ANWrY6hb0Pegz6eiVYLrvLa4g2z9h+HT WWnT9AEt6NMAbEQyw81zRyIwJvzyzxP9mTRFxKDKpuU4YGNgW1h6X9k7y7ss2tQIIvlpcH+XA3k ydXO5SLkl0SQnAlIxJY6SSok9WP5oZMUOgVL9sjHB0iuPSQ6IUC9HouwYEm X-Google-Smtp-Source: AGHT+IH9sg/APOeVcvmxNi3lc/CaFUy261G7dVBoU1ZPhJ36GVox2hlXSW2u68WXUBo94t1FWfRBpA== X-Received: by 2002:a05:6e02:168d:b0:3a7:c2ea:1095 with SMTP id e9e14a558f8ab-3aff4615779mr38827345ab.1.1734105374532; Fri, 13 Dec 2024 07:56:14 -0800 (PST) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-3a9ca03ae11sm35258405ab.41.2024.12.13.07.56.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2024 07:56:13 -0800 (PST) From: Jens Axboe To: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Cc: hannes@cmpxchg.org, clm@meta.com, linux-kernel@vger.kernel.org, willy@infradead.org, kirill@shutemov.name, bfoster@redhat.com, Jens Axboe Subject: [PATCH 08/11] mm/filemap: add read support for RWF_DONTCACHE Date: Fri, 13 Dec 2024 08:55:22 -0700 Message-ID: <20241213155557.105419-9-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241213155557.105419-1-axboe@kernel.dk> References: <20241213155557.105419-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspamd-Queue-Id: D7237C0024 X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: iztm979xd7weh6ihnrzikkn8po4j37zh X-HE-Tag: 1734105346-398930 X-HE-Meta: U2FsdGVkX1/gXrpHWqmWXqRrkjywJfstTrDPqp3MPZGBQrlqXY+GbNdpiDJqFLIGwGJSK4jr617Hlel5enm73ZGNCyCHuWXLVuVW6IIQXr+4soHqZeuxFkCXyene0/kSv7wE+j1tA1C92GjgXx5vPzTvmOsGsGUGZZeFYFlBNLHz9wzkhZx5ZB3nCZXaaMl3UFkShuUmTUVjhJfBTUv8VSbAQSlcTjYq9VmUdP4sWm5/kcYlLqyKMO/kwV34Df94TaKffdLLD2C6zBbMoQErXTuQ4noePrZKxJVSw1joKVBhkzjQDW3drNW2+Vrqa6bXe0j38FrMibWh6vz/m355CIREd6b2igj9NCkwmQfAC36DnaMtgP5s4rOswzjkRk+xRKkORLuw/0lRgeImtY3LGnpnBgPEyz6Zyb3EL9SP8Ez0T5h1ouw5sLgB5sjzQdIlrOD7Yikrc+jAN2Rj2Q9+xnINs9cy1xmsS0G1CR+DPf2ae9Scha7p4gPFY69fu7fFIBNKmRaLYk1uxzlQrlq6QhNk7fHBqYJsWCqjaP10sbtLF0oCvvMryT67PBEEjv9GgIa7FZpaqQUrWq0TBzaTCT+DpuRfK4HD4yReK22iOpnaHizAwsOklNc9fiU2yVn+56JoIK++lWhX37gUzg4Yf3/rA6K5igWLAcS3zIfKAEzg/ixFgMclCUlXtq/WEV1Xdc6OsdeDmsLWsLdI6lkS8xjbn6iGllaxxQuiunBI6uEJd1/WWtNwi0SXc9lhdfuUF5NuRyLn4wwhOShHAHl0TWolVhJcfypAHBqHxuytq881zDxx14YPdDuYT6R1WPINY0lAcMmU3anpqeAmQuYu+KOaiaWppPp6Onpyq1KLipg9UtAwY4WuF+eOSfUj5TsAR7yNjultnUvUf6tVUygveusS5GQAuxTKy0wsKJRNxJkrCv1ibJuK8P72IleEptBxAyGIpBFKXgioglyf4vq roQuq/yZ 2B76K2jP1GA/0/baeAnzLyBkBQqT9SR5YxlH6eWY7ebyq9nOEaopCUzyNudRFWoB2q46Cu4mVMvlw7eTQfLjQ4ZuA1YWGw2JLjCNPpgahPjUY3mvkOxG+JtJg81jhwqgG/a09fgQefx7UmoXqiHtFZttZnRXmxxY8et5U6pdEknDpNcP3NMtgMB2ihIs8Jf4QZHOORIc10Unx9uSlVZh7Ope0aqjKuyRqWaNfdI5b41Obv3XJlNgENSMWnHYlRH3O4n+AGa2jHjRJbasttMheeAUXgFi0kcolmwqC71n7gJEQLVQZeQB3p+P8CBW+Fo8msZUR9jbMD8lcSyIZPi4lCaCQUV10QWpjWumW X-Bogosity: Ham, tests=bogofilter, spamicity=0.000521, 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_DONTCACHE 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 cousin 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_DONTCACHE 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 --- mm/filemap.c | 28 ++++++++++++++++++++++++++-- mm/swap.c | 2 ++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 220dc7c6e12f..77290ac205dc 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2473,6 +2473,8 @@ static int filemap_create_folio(struct kiocb *iocb, struct folio_batch *fbatch) folio = filemap_alloc_folio(mapping_gfp_mask(mapping), min_order); if (!folio) return -ENOMEM; + if (iocb->ki_flags & IOCB_DONTCACHE) + __folio_set_dropbehind(folio); /* * Protect against truncate / hole punch. Grabbing invalidate_lock @@ -2518,6 +2520,8 @@ static int filemap_readahead(struct kiocb *iocb, struct file *file, if (iocb->ki_flags & IOCB_NOIO) return -EAGAIN; + if (iocb->ki_flags & IOCB_DONTCACHE) + ractl.dropbehind = 1; page_cache_async_ra(&ractl, folio, last_index - folio->index); return 0; } @@ -2547,6 +2551,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_DONTCACHE) + ractl.dropbehind = 1; page_cache_sync_ra(&ractl, last_index - index); if (iocb->ki_flags & IOCB_NOWAIT) memalloc_noio_restore(flags); @@ -2594,6 +2600,20 @@ static inline bool pos_same_folio(loff_t pos1, loff_t pos2, struct folio *folio) return (pos1 >> shift == pos2 >> shift); } +static void filemap_uncached_read(struct address_space *mapping, + struct folio *folio) +{ + if (!folio_test_dropbehind(folio)) + return; + if (folio_test_writeback(folio) || folio_test_dirty(folio)) + return; + if (folio_trylock(folio)) { + if (folio_test_clear_dropbehind(folio)) + folio_unmap_invalidate(mapping, folio, 0); + folio_unlock(folio); + } +} + /** * filemap_read - Read data from the page cache. * @iocb: The iocb to read. @@ -2707,8 +2727,12 @@ 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]; + + filemap_uncached_read(mapping, 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 10decd9dffa1..ba02bd5ba145 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -427,6 +427,8 @@ static void folio_inc_refs(struct folio *folio) */ void folio_mark_accessed(struct folio *folio) { + if (folio_test_dropbehind(folio)) + return; if (lru_gen_enabled()) { folio_inc_refs(folio); return; From patchwork Fri Dec 13 15:55:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13907406 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 92EF2E7717D for ; Fri, 13 Dec 2024 15:56:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A82CA6B009A; Fri, 13 Dec 2024 10:56:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A0A126B009B; Fri, 13 Dec 2024 10:56:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 85DE06B009C; Fri, 13 Dec 2024 10:56:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 66BA86B009A for ; Fri, 13 Dec 2024 10:56:19 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 19C36160F02 for ; Fri, 13 Dec 2024 15:56:19 +0000 (UTC) X-FDA: 82890386670.07.34E2DAD Received: from mail-il1-f180.google.com (mail-il1-f180.google.com [209.85.166.180]) by imf07.hostedemail.com (Postfix) with ESMTP id 58D6E40003 for ; Fri, 13 Dec 2024 15:55:45 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=wxgu2dzw; spf=pass (imf07.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.180 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734105353; a=rsa-sha256; cv=none; b=N8FtteKpwt6tHZFy32sj9dh+cTfF7crb02/rJpb1Ma6KIbVoidswf4ejHsoB/wiAiIW00u Slz2ObLG3eSH6F1oxw6iKszoidv+VLU8j+SClddRhihNl74muixHqQzOhtCkyW+rPMgSKo XQLaWsLS+YAMUlr8a3ncsfucwdIPr9E= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=wxgu2dzw; spf=pass (imf07.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.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=1734105353; 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=eL7TH1+psm5CeVquxo+D9Ecvv3+RlpadAVoxegN1mFk=; b=Iq1NaGu8xFCfSKtv6WX1VtiQDGAf5N3QPZDS+6KUFASQWr+Bkn8l0Y1Ta8xpj2rc4iGj84 MG7XnNwhRzl16ICaQ+wnDtrb51D81cqbpwaEyFAW3o5vH6lB8fK+jYrIWfnmqDjDnIlxLW GplDdZkmNBc3WVj/aY9guYTKXqBrVog= Received: by mail-il1-f180.google.com with SMTP id e9e14a558f8ab-3a9cdcec53fso15577085ab.1 for ; Fri, 13 Dec 2024 07:56:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1734105376; x=1734710176; 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=eL7TH1+psm5CeVquxo+D9Ecvv3+RlpadAVoxegN1mFk=; b=wxgu2dzw/AUR37WEvWNTqHjbJhSUH5fL6qZ8DwhjO9A+9yaRV8lRP6Q/4EqJAXP049 Fvyq5T/bk18QnYeTQoGlxlHfkCHXySnlfhHlGb8Id/446O57Y9nRi01F+gvqfGtj+FKv R8AqovYlZ6hLv5Ihu8zG5mqkdNiJUcLX3ur6lSKhhTxh/UzrpwTKVLDFn2PY5x8SbhJI M+H06SJJJMqjCq/bulBk2WNiF2uiN3e470dI7AwcZzdYsWLRZkfClfwOXZjQPrBDGM2A upbStvE1xy4zaZI3umPO8w9IzpgyBkQPTRuuvUxF/8hoE1gr6N9UTJF/CzH/DDbeITgq aWsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734105376; x=1734710176; 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=eL7TH1+psm5CeVquxo+D9Ecvv3+RlpadAVoxegN1mFk=; b=CvjgDJsilYims/jofeK27VROtf7Tj7NQREsnnPXXt4qorAl75G18lkOo3oIacQf/2v xq/gAb57iOk9qPOIKXpnN5PlzxZ5L7n59KMPfplBP9KoTZh4RqffM+Im9qOI/usw9Xip y5ckgXgh3qvA7yfaSWp3HduQTP5r7c4Yfl7fAENlMJPiBy6KnnmLyK83oH5vBaiOo8OL ur/CSxASXyvRXNLsl1WuFbFzb8sDIUAOD02c1oNxTO/gaXeWt2qFJQtR2B/TZKRsLO1V a0kLJA0uJHNSXrRwSDnF72IzrAZouIHvc0eCfCUYa1D+aqXFXf9auScmF0+3QGpAOued C7ww== X-Gm-Message-State: AOJu0Yxa3TGPbst2yRUcUXRB4WR8CETJZIu0uGE7qsQLvsbqJb5KnFez sg4KT2kHQ9qOxPqf01qcZG5cbMJSSjFtbRoJbCROxSKOSS9tUmXWDxjTQI45iaJQu08f7cLbWbz X X-Gm-Gg: ASbGnctd0afF9fJnnEE7yYNlsl1S2r2idnIbkg9Z81zKo1fAKF2SOszOtYa0H1LKw5f VdY/A1WFSeeev+nlg7GWwuPWPYPkZvqnFmMaKObc/JoMdQM6T4NRRpS6d+KS9J+j+BuvyfC8OMu hWS01bgJYB4G8ybXcnTbLn1aMQGwIWe4QY/JlsW6kIugexV+RujQxPYzQ16By8JIeA2nLKZMZSD 3M8zH2i66M+VTsC+p8wE9aDlOPCK0CU1xYJRwfqb/oXnHuOaqKw3cVlPlTT X-Google-Smtp-Source: AGHT+IG5PcGGwL+OAF8BWXN0MfzrquLg0U95m3qvCvU2aqYiecyxUUHKeEBe+q/HNr+0PzMX/oeVbw== X-Received: by 2002:a05:6e02:12e2:b0:3a6:c98d:86bc with SMTP id e9e14a558f8ab-3aff4619e11mr40735545ab.1.1734105375832; Fri, 13 Dec 2024 07:56:15 -0800 (PST) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-3a9ca03ae11sm35258405ab.41.2024.12.13.07.56.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2024 07:56: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, willy@infradead.org, kirill@shutemov.name, bfoster@redhat.com, Jens Axboe Subject: [PATCH 09/11] mm/filemap: drop streaming/uncached pages when writeback completes Date: Fri, 13 Dec 2024 08:55:23 -0700 Message-ID: <20241213155557.105419-10-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241213155557.105419-1-axboe@kernel.dk> References: <20241213155557.105419-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspamd-Queue-Id: 58D6E40003 X-Stat-Signature: po49s615g4ct597cjwwodooanpyqabbx X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1734105345-435510 X-HE-Meta: U2FsdGVkX19rPxM39uHJBzznSP1ASVA/kz9Ye2zv2wmGf8gJ6UrBKuQML4Ksc9ZbF8cKnBxvEUE4vE6xZ/u+Bp+d+2/AgLBDcGnsw6eav4UXI8MqLtTERHadGP8X8x2LOk5mF6iKEc4QLQPXixcVD1HWSFs+ZaIRwBKkz+PFO3fHvYhMeCK2qsS0l9XxHjOP0Mtn26YBz4e4/xIckkD82yx63qD7zlY4w0XWyD40ziOl65oeeZ/eSn/m9rwIYJhnsjuuPl4wFxKRkdfIHxFn0LtbwT8S3k28S4l1QQwJ7NzaDeUomsChzdNDeHcD7PWBirbXfTAivQGoaxmCEI5hm7uM+oukCXvEleJ6Vzg8IQaAlSYZ4PXD2gI4FSroT2SKW0Zr1g55/wQbIP7uwN36o+XmsLgIIRl1pDDKaqnWIrcH+PP9EMXmL69E6vvePL1eJLhV4P7Bqa83XFkenng9tAw+JpczLqcUoLQ2EelbvjeDeQejQQCb8oeaQ6Xfco7hVv6yoj7Pqmo2erEBiwfXaNQgwbydPxl53lHFvVjBA6V5lKwYcj0ipH1uhlJrsmgVHHVtBT6Xj7JdaXbUYF3pNJFWyPrgsGBz7IjgK4erlOPTFRSRz9y+KAAms21gmz++FVHGDG9fr5DYARlHD13ZJk+SUcBlGuI6BLvyU254PM6/sDQsMxIcob66VXhSk2G1Qe2+Op8GzNw+35u9Hz4BgZngAOmn5HHm8JZskoDlPLTZO4O63o5YBfj3JPyLhOOavlDyMMuVyDS59ybKZkrEez4CEz8U/pwvz+szWP4tkSGc77yuAiiQvCjzAijpKb3b3So/18eSZTt/NMIpbdltMSr0pgTRoQkEtWAHucLXUnZwiLLyBZmSNl5+9fjIrrnr2j1fNL0RM24xhP8SVUJQtdL69jX5LftHUJA1YFDvqEdPMRNI1s6KiufnxmFENY4vLa7kn8pJdH8g58SGt0w g9Q+TWPm j+OUNY44xZRefo5XbtL7X0ORjf37SWSvw4NJTtGfYZF2Vf3pLVT15chiQFXQXAlRexvAx2jQID6+ReQvmkE9OgujmjaLXxtSv4WOJZVaKhJHGcw5DtS/pfP+du0hnaW627DZVm4I6xr1CSvCOuvu3aRnzrKt+jpug9/eoPfyBzVYJlHO0/KrmYe1amRRYJsaZ5B+8mygqUMz9BpqZ3l0hvtSmbvOqegmaQ/29oHdR9cPy/PH8cL/a6gveofac5cjCMXR8Ew3muAzduBEcPteIcVPemcAEl+QtNtw6hEZvceRp+zHSdd9pM6I/uQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.019161, 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 streaming, drop pages when writeback completes. Intended to be used with RWF_DONTCACHE, to avoid needing sync writes for uncached IO. Signed-off-by: Jens Axboe --- mm/filemap.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/mm/filemap.c b/mm/filemap.c index 77290ac205dc..ec087bab1c97 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1599,6 +1599,27 @@ int folio_wait_private_2_killable(struct folio *folio) } EXPORT_SYMBOL(folio_wait_private_2_killable); +/* + * If folio was marked as dropbehind, then pages should be dropped when writeback + * completes. Do that now. If we fail, it's likely because of a big folio - + * just reset dropbehind for that case and latter completions should invalidate. + */ +static void folio_end_dropbehind(struct folio *folio) +{ + /* + * Hitting !in_task() should not happen off RWF_DONTCACHE writeback, + * but can happen if normal writeback just happens to find dirty folios + * that were created as part of uncached writeback, and that writeback + * would otherwise not need non-IRQ handling. Just skip the + * invalidation in that case. + */ + if (in_task() && folio_trylock(folio)) { + if (folio->mapping) + folio_unmap_invalidate(folio->mapping, folio, 0); + folio_unlock(folio); + } +} + /** * folio_end_writeback - End writeback against a folio. * @folio: The folio. @@ -1609,6 +1630,8 @@ EXPORT_SYMBOL(folio_wait_private_2_killable); */ void folio_end_writeback(struct folio *folio) { + bool folio_dropbehind = false; + VM_BUG_ON_FOLIO(!folio_test_writeback(folio), folio); /* @@ -1630,9 +1653,14 @@ void folio_end_writeback(struct folio *folio) * reused before the folio_wake_bit(). */ folio_get(folio); + if (!folio_test_dirty(folio)) + folio_dropbehind = folio_test_clear_dropbehind(folio); if (__folio_end_writeback(folio)) folio_wake_bit(folio, PG_writeback); acct_reclaim_writeback(folio); + + if (folio_dropbehind) + folio_end_dropbehind(folio); folio_put(folio); } EXPORT_SYMBOL(folio_end_writeback); From patchwork Fri Dec 13 15:55: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: 13907407 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 51CAEE7717D for ; Fri, 13 Dec 2024 15:56:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1F44D6B009C; Fri, 13 Dec 2024 10:56:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 17C696B009D; Fri, 13 Dec 2024 10:56:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F12DD6B009E; Fri, 13 Dec 2024 10:56:20 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id C68876B009C for ; Fri, 13 Dec 2024 10:56:20 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 53F031C5FD3 for ; Fri, 13 Dec 2024 15:56:20 +0000 (UTC) X-FDA: 82890386922.23.10C2A92 Received: from mail-il1-f175.google.com (mail-il1-f175.google.com [209.85.166.175]) by imf22.hostedemail.com (Postfix) with ESMTP id 5ADA4C0008 for ; Fri, 13 Dec 2024 15:55:51 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=OHXfHkSm; spf=pass (imf22.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.175 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=1734105351; 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=CJvpEUV5aCutO0n1vzbjd3IdvpDLlQuRWwd0hw2DTJ8=; b=z+66DkKUumlncpnYTwXCq7uLIIviHe0jPNkO29pQ+lbolsaBGExM02EcVmNupB5k/wuWoU yW3WbbckAqapc3Fth1Q86wCw8T1wrn9bh04FMaQhlgRAe61reJwFh8CWdcBx9OM0y6p7qV fCDS7TodDXIarQzoGL80VD9yCLA8uNc= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=OHXfHkSm; spf=pass (imf22.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.175 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734105351; a=rsa-sha256; cv=none; b=WOhiygi7lkc6TiGqXvKPDAd9lRzdpl5QjWSZgN4hz08bwRJmxHwYpjdgUPwGNjx0u61l1q FR0C71GQpch3AJf8BidRljq70IzPp3XysrAEb1VaOe5hVi64ap4uAAJgkjKaQAX1KlqXSx O4dC2iLm44hgobtCUTuHaqL5g1CRQJo= Received: by mail-il1-f175.google.com with SMTP id e9e14a558f8ab-3a7dd54af4bso7236845ab.2 for ; Fri, 13 Dec 2024 07:56:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1734105377; x=1734710177; 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=CJvpEUV5aCutO0n1vzbjd3IdvpDLlQuRWwd0hw2DTJ8=; b=OHXfHkSmxXEQfu8Lp5DjKcSLar4Q7lWonGQs8F56tgeMzgn1xZVff+6PzHrsvDYmwO mH76kmp9e9g/G7UHHYL1shOKGM2h8+In424vLlBOyzOJ9oqgpp8uksgFlslMgo4WizfK Cb2dphoMAfLiKwBgNt9f8wJRr/dtGu8hGDdl6VowX7zSPOFFF4FKn7qqg7yAmJeS+yhg ehHFkr4W0o82z5nGJoyWGC04WbnRumBEnHgkIZ0Q5t4Q22LdC1+UHgwNwX5VfdYeZyr5 fGmstLLmkJu7q63pfZ0CjpLSR0bJEQ2ohF/3a7nd5HV/u6oo9Itbb7bg1kau0qP3YEwz e9+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734105377; x=1734710177; 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=CJvpEUV5aCutO0n1vzbjd3IdvpDLlQuRWwd0hw2DTJ8=; b=KicHliW1y//XbreY6Vx+5R6Y3uTmfCeC7KZH97Ge0kyrMFY7h2Bmsjv2iAo2YIa4Zn RzyFkzAQ8uvNnSNnIp/xTAydC1pzmB7FVRAQ8+Ka/UnPerkkDGLnaTS4bhXS2UvgcK2L cXqZ6g4IbxyBjlj9Hf+o8j8JxccJKD5LAJSQgJX6K5DKVhl2fTCSMVrYTI8U3qkJGty0 AZgN2IIkwVVD4FNnUm1CkKCgl2UL4n+m+3waDhjUqOBvhZPthSIibsngiNXEGLxmx/cL v4w3p+35S3xXkljidVVNWYvtCui7UWEguoa5Jq++HGaOcmubv6AlvW+yedmaGzC2j1H4 DRSg== X-Gm-Message-State: AOJu0Yza5HLOkRMTypf4Gribjl8cUJ60FRIUDNI+bWQZK/YAb63gx/km Fo3gjCXzr42RMmIgL0GttKT/mwlx5a5gVzVpGkVEOQOsV10xV7XjUSnrP1v9YPZLC+K8Lesw4IC 2 X-Gm-Gg: ASbGnctCA6RbqciiKtMhwD71RgkHSHNfCdwFVWfxd87/W9/Z4uDepoYZpiLNmrwJqF/ rLhEXyXq2w1Qi4w99MpIcdEZMyZtsiXBMMvh2TGptLR4CWU3v0P+r74wHMN6vJd8elaiBEy/dVY QAVhnfSJbb6ElN3So0Q0N1SDj5dS91qadQCzZveEFP8dPR0H1ThI6mUMWcYxqo4OzVAzwf30i4J dzhSOOOHNOc1Lh0RLa1XMs4FBKJoqwcYZmC4L6DiDxbEvu0rkcoh3WQTdJf X-Google-Smtp-Source: AGHT+IGauJ9uKAF5WxLAKMTF0QyH5oGnff/+E24GczIOzswP0NPnXSGxgq/rQ7IZv36KxS5lv0tqHw== X-Received: by 2002:a05:6e02:1564:b0:3a2:6cd7:3250 with SMTP id e9e14a558f8ab-3aff50b64c1mr29557815ab.10.1734105377176; Fri, 13 Dec 2024 07:56:17 -0800 (PST) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-3a9ca03ae11sm35258405ab.41.2024.12.13.07.56.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2024 07:56:16 -0800 (PST) From: Jens Axboe To: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Cc: hannes@cmpxchg.org, clm@meta.com, linux-kernel@vger.kernel.org, willy@infradead.org, kirill@shutemov.name, bfoster@redhat.com, Jens Axboe Subject: [PATCH 10/11] mm/filemap: add filemap_fdatawrite_range_kick() helper Date: Fri, 13 Dec 2024 08:55:24 -0700 Message-ID: <20241213155557.105419-11-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241213155557.105419-1-axboe@kernel.dk> References: <20241213155557.105419-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 5ADA4C0008 X-Rspam-User: X-Stat-Signature: x3tw7zxz97rau5husx3agmq6bstz6gfj X-HE-Tag: 1734105351-932977 X-HE-Meta: U2FsdGVkX1/bJ24yf0aKmTwrgzV47BgmFMlLeV54X+jCHO5hmUe+cCBrHKSG/xdp2hyP7OwNvd7AO3kVIfXZEjlo9qbKZks0miB888KTg6TEJyEuCgoT6WcuwtStXZOtS+9ldkyjRkUDDbU/sYB2qWnDIyqglloJ8HUWQ4FuQqbXPWOUcfdRPSAmllYf5y1LWTZEigbDjTC4GOUYy20PdVrBa53MfS+S7a9499P3LyHdoTmcVIPyBh/nLBAjtVD90xKb++uiKoM7VQeIfomsoMApwQ2D539jo57KtPLmb0jouZ4zB+nyCabdasUH9qn//dShk0Vc9bv5ZN5ZQdQ1sCqBTcSKHNXRkEddMpHiVAUsPqOp/AcFFz3v2q7BPs37D2QI5aRoxKfFGmaY/CkwGFQ4ryKJdB3JRZ7DUJxz9cCsaHXrZG839j46jLGOxa6ZI19CPdw5vVXlwWNFG05NdOvPNBSFyqPCggSYF+pBE8sm8SXX1po0NTBoBp+UtYMlfIhEkCk3hp6dgf/hO/tF+UyUS6fVgfLjYDqQln0Iqx+zU0la0jYUaxT6TyHszkmfiS2+MH/DmiA3ivtpkZAF+20qYndJE1ITeod4P3dt/CDi/t83oP1HaSuiFRR418p3KRrwOVSaFNHufHPqkk15WMwXOPMZ0W/S7Wd/cD8eQ4nN6fchy2JYqW/WGIdCZIay9rSEECGCDOlq9w8etL0pYBe613iuNZqhKa2ulcji159IKRa/n5jnGZz3ZKcn4dWj+46VfEa+Wp93PKfR2r98lse7GvftGrtLPMBYkg4Y/i6oVdlS/eZN630az2tQItZFA/G3Cbdnuz1HVWsWyoH5C2suaFKB+2bjbnOVxc7JXf+haqOyBm5IZfX0RvI3sWJzgznSekq+RHf63md1RZDrGvEMo/KHeglZIV933th225m6WDDWSWKSK+OwdGp+kApbMGuXx3hBhBl07XgBwzf b55uZkt9 rkZlqxBW6cm+gySTOe/MAZ9tX30ujYlKkzqjbH6fGhpePVHd+9PIVDmdWTvXCzZcf2jl4L98CHoYgO6YGkjxdEFOAC482zQCs70p/ueyNYAq04hjADnY0rivFyzkPV1VW8kR7/MHvQFb/zMYCk6X6hcDA6iYGZjsHmDxoXzjhwrqdFxh4r/bOSIlQB8MFNXPEUVWeccn2uSHuK7Lut987dX93b/BRuaz0N94OUdg8pXVnfxsc6qC8+1hcfs6l4L4Z9LQjwKQR07xZgRMKGkoBqxsTiynOQSkkUyLxJQbdpqSWezxw+WaDCGSg5WM5iT6O1cCR+n7NfJn2LXjLXD73CwXNEvkno0XzpIl6 X-Bogosity: Ham, tests=bogofilter, spamicity=0.003758, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Works like filemap_fdatawrite_range(), except it's a non-integrity data writeback and hence only starts writeback on the specified range. Will help facilitate generically starting uncached writeback from generic_write_sync(), as header dependencies preclude doing this inline from fs.h. Signed-off-by: Jens Axboe --- include/linux/fs.h | 2 ++ mm/filemap.c | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/include/linux/fs.h b/include/linux/fs.h index 6a838b5479a6..653b5efa3d3f 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2878,6 +2878,8 @@ extern int __must_check file_fdatawait_range(struct file *file, loff_t lstart, extern int __must_check file_check_and_advance_wb_err(struct file *file); extern int __must_check file_write_and_wait_range(struct file *file, loff_t start, loff_t end); +int filemap_fdatawrite_range_kick(struct address_space *mapping, loff_t start, + loff_t end); static inline int file_write_and_wait(struct file *file) { diff --git a/mm/filemap.c b/mm/filemap.c index ec087bab1c97..7db995cb5179 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -449,6 +449,24 @@ int filemap_fdatawrite_range(struct address_space *mapping, loff_t start, } EXPORT_SYMBOL(filemap_fdatawrite_range); +/** + * filemap_fdatawrite_range_kick - start writeback on a range + * @mapping: target address_space + * @start: index to start writeback on + * @end: last (non-inclusive) index for writeback + * + * This is a non-integrity writeback helper, to start writing back folios + * for the indicated range. + * + * Return: %0 on success, negative error code otherwise. + */ +int filemap_fdatawrite_range_kick(struct address_space *mapping, loff_t start, + loff_t end) +{ + return __filemap_fdatawrite_range(mapping, start, end, WB_SYNC_NONE); +} +EXPORT_SYMBOL_GPL(filemap_fdatawrite_range_kick); + /** * filemap_flush - mostly a non-blocking flush * @mapping: target address_space From patchwork Fri Dec 13 15:55: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: 13907408 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 26F46E77180 for ; Fri, 13 Dec 2024 15:56:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 947886B009D; Fri, 13 Dec 2024 10:56:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8F5E96B009E; Fri, 13 Dec 2024 10:56:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 74FFD6B009F; Fri, 13 Dec 2024 10:56:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 539156B009D for ; Fri, 13 Dec 2024 10:56:22 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 15BFAA04D6 for ; Fri, 13 Dec 2024 15:56:22 +0000 (UTC) X-FDA: 82890385956.20.A70E506 Received: from mail-io1-f51.google.com (mail-io1-f51.google.com [209.85.166.51]) by imf22.hostedemail.com (Postfix) with ESMTP id DDA63C000A for ; Fri, 13 Dec 2024 15:55:52 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=YSXQNuDo; dmarc=none; spf=pass (imf22.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.51 as permitted sender) smtp.mailfrom=axboe@kernel.dk ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734105367; a=rsa-sha256; cv=none; b=wW9GtsadMoFR9yTjdwp0gvYMX5qp6hqi2chDd02cHnJCP7zoBZXUUEZveSzwf+i1xmkbT7 CzAaf4rDAMTuYvsop1kbwxsq14fHHFBHThuJ/yXU8AdFi7FuP7ph85bZ9MGEjKAZbQGDcz efDFFIlEJhWmzSbZKkAgCnHJM9trt6M= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=YSXQNuDo; dmarc=none; spf=pass (imf22.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.51 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=1734105367; 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=ol/7y93UZDywrWGNYi5AP2kj1AIRWUpJ2p+2aggyqzo=; b=kJwGVPn+96aSQWxE6BU2tishKGRyQtlCS0vMJXC51wPeH0PCWQ8dw5uZjP+lP82IEkPY+/ q8A1ftEYNiUXG1SfwSolQgzq9MmXZnV8vwu4/Hdk2UZJbGiHIbzJ6vzbyT12uUgr7TH7fW 3dBKDdB+rkjTole+mDIBxIDGKJKH8B0= Received: by mail-io1-f51.google.com with SMTP id ca18e2360f4ac-844ee43460aso34513639f.1 for ; Fri, 13 Dec 2024 07:56:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1734105378; x=1734710178; 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=ol/7y93UZDywrWGNYi5AP2kj1AIRWUpJ2p+2aggyqzo=; b=YSXQNuDoBcvucr28t/C7xBGIg6teIT8mwgtc/UB7OpLu5o/AghTKsffTGZSlmsMV4L lzKrWQ0mus9PUFwCjZw9/VL7FWi+9+uEKwdQ752nBo9oDg0wn+9j/5lRm2hKzc/Xc/u3 xTZ1d01HPlKo2pcGfa5h/LoVH0d4nQ42UY5xwc5lMwS8oVSX6wH61cHBpJFr/x843ZVr 02voPR9Zln9LdsZ6X/PRbkKQYfSCJwFxswIEJTv6a10GLuAHhBwVJY4kZW2o05dOyQBc 7BJvpQ97veO263odt+SMQZS616/SUg905PhqZHYwmmFjBiH+fZOGXRCXrKnRdxRMGdQS 6fBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734105378; x=1734710178; 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=ol/7y93UZDywrWGNYi5AP2kj1AIRWUpJ2p+2aggyqzo=; b=sl0PBpQcQ2KlfTHqOHuamt6B+4uyyXlCov1V5fMZZ0/DSyZ6C8K7z/KIjEfJPz1kqi 99zOxZ7t/mQoGA+v21J8oPxqT0V1OFaM9GQlVZ/zz0IYrOmEKjD2CyAR8zhFBXno9Zk/ YVqKJ0JwK5S2Qvi9Tv74cwZ72cpA243lQcslUE6yFMDZtX+4jY2YHLCexFebTRzStR5c hOMnkJpVqGZaUZ4kek7Z0p9v6XQswKa/88xHlcaaZBDcllTcwoS0aTponTHD8SBmokAb npENowUPLgMVqv3o4UkDe3MbTGmhNco7qFujSV1A/QrMrHqqSeD2C6PGPWW4zsOpklIn JUtw== X-Gm-Message-State: AOJu0YxHQ1Ep7sKAst/3iLqKeLJMXI+HiFfsHW6H7p6lpVqMcea0bY0z RZH4CfogAdeRMjcDd+Y34i/nJ01Z2qfcwU4ikNsqrRTWhwRUWTp9sV6WKRH1PH0wekxy32jEmho V X-Gm-Gg: ASbGnctvV10J49cU8bTQhbeubg2b1U8Z0fgNMXVDT++swFGEkRA1tTgEkTjCrZaggZL RHVyKcyOgclCCdtc5yT/5nXpdqqOxNjbHIkWOqBIq+2OaQwqB+fF+InIEOyOIvVg1WSC4WXE/ey SW1PyX7zlFZsYb+GQLhyllP9fgZ+wKhZIaAz6BedSUz0kvTY98X21NgL2ZvekcWrQj0eCoE9dTE 6a2RTq7Ag4gtC9ZPBwWucnH/ITj6vi/yHZhjy5a+XNyohk0Hmnwd0jMEFv8 X-Google-Smtp-Source: AGHT+IFA+GuHLn3+MK1ZeRZZP3C9VMVBGmb7rBcbA1fV4I0OGtHKvL+W7OoGXWUKvvS+Tr+1pcK1JQ== X-Received: by 2002:a05:6e02:2169:b0:3a7:7d26:4ce4 with SMTP id e9e14a558f8ab-3afee2d0367mr35186015ab.9.1734105378594; Fri, 13 Dec 2024 07:56:18 -0800 (PST) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-3a9ca03ae11sm35258405ab.41.2024.12.13.07.56.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2024 07:56:17 -0800 (PST) From: Jens Axboe To: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Cc: hannes@cmpxchg.org, clm@meta.com, linux-kernel@vger.kernel.org, willy@infradead.org, kirill@shutemov.name, bfoster@redhat.com, Jens Axboe Subject: [PATCH 11/11] mm: call filemap_fdatawrite_range_kick() after IOCB_DONTCACHE issue Date: Fri, 13 Dec 2024 08:55:25 -0700 Message-ID: <20241213155557.105419-12-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241213155557.105419-1-axboe@kernel.dk> References: <20241213155557.105419-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: DDA63C000A X-Stat-Signature: 1qwbsmzht8zg1uz36z6o9yfxogjt8upz X-HE-Tag: 1734105352-278766 X-HE-Meta: U2FsdGVkX18GxqpY6dYFf3kTmGV9hj/nw6Y4qPzi7KMjt9LRCwM8mmKCr1LrBuQJiZ8RH30nfbyFI24UPe2mpUfFfZvzTtnt6UzBgUXw0QQaH/Kw0kGea5eWsOsZYek7JaqCBEqKKHS56lCdrZVr14Tc6FQ/GPScwqX0+q3tg+A2QEjKWmcoeDKGGdSkm8DrJgav6qVKsrleluj0zn+/85srFfEosAyhXrtTBD6ENJbnPsLktAixl+F0O8GvMNHRPPg0bkIXK2UwsK8Y2NA7oWgA0yEHsqHW4Jfwdjq151SD80enQS1nsUhpVYpTWM4plOqekQxsIEdjOUsQY/hnm4A8l0EKzFRU/oHXaBGHGzyYk0QYRycDE1roouoMCZ2YlDklcZExbMwtRrEdzkifBtOYJae+u1ckVeTspOQKbN8GsU8wKcwvPxAT5e2KV8gRO73u81waZ1mAG0NlIZssCZZ8kxNQMW9GQss9u/TUpYtYMSRfWEAeQXYIKr0fRBH8O/CoZGorORRQ59oX2/jeanXiE2kB7YEcy9QQJEzxbtx4wINB/+iGpdhInHqkV8+6szmeQXLyB81SQ1Pr3U0fYLimzXbFYzUuZ6P44CBML6Zf6orkcKNOIlCEOHHlM5hmOuQwmqcAKJb2eT5zmOh/0emO52sJQjpE+g4KOpso7Lxj+Z2H1QVQmosH8QM1xz1ZNvBhEwnxAjjHbqKdLjR4mFWXjSt2g8HtOVOw+h9u9TxlIAqZXJWfwbPgFXsh+0+2YCOzpWLVq0pbQ8dKeWq1g5uSDku2XD92BUMwd70lAgeSE54TbBjEZhD3lpGIAtmGCa8/KsTMQpLfUXfRpasocSNNMuIhOxktOtdlQgwOMZBs6iXbOBHvZgp40JvOIF8hxhrPtYmV+w0xNRZFjUh4v7lPvXJsio7kAAUiqgXOssrj1d+CHELoAu02eKLVyje7i030pAYg1Y8HPvPeyMH 5OxYKroz 5XpM+o3WWRaUD441Jmrcj0QPafHVPqrLCcOrzKs4+wS7wft2C/AJxHaNE2M8s9zNBBLxsE8RlipojzEohtSM9IxCy5K3468lkO33twgQMIHEfxCn8JqCh8sdwO3kNn2n1LPlkQPrSV8Z3hHgdw+GI/x4rYWzog9oxjGujrWeEBeXqBGMwhD71h7UwPZsRoHVuW8gNHQQe44+D+HPalCqeOLQi3OzIWKvGDXbwHguPTNlqFjL3CHtzAzCIF+3blNiu/1HgjzmVN5pwgCcb4VrzBuaJ2JcsPInZ/dmpQ20HK4buaaNFRiozjacYz616p+niDceaOE8CCFPxt6XYjEA7dSdWRXgHdhleE18g X-Bogosity: Ham, tests=bogofilter, spamicity=0.001286, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: When a buffered write submitted with IOCB_DONTCACHE has been successfully submitted, call filemap_fdatawrite_range_kick() to kick off the IO. File systems call generic_write_sync() for any successful buffered write submission, hence add the logic here rather than needing to modify the file system. Signed-off-by: Jens Axboe --- include/linux/fs.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/linux/fs.h b/include/linux/fs.h index 653b5efa3d3f..58a618853574 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2912,6 +2912,11 @@ static inline ssize_t generic_write_sync(struct kiocb *iocb, ssize_t count) (iocb->ki_flags & IOCB_SYNC) ? 0 : 1); if (ret) return ret; + } else if (iocb->ki_flags & IOCB_DONTCACHE) { + struct address_space *mapping = iocb->ki_filp->f_mapping; + + filemap_fdatawrite_range_kick(mapping, iocb->ki_pos, + iocb->ki_pos + count); } return count;