From patchwork Fri Dec 20 15:47:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13916932 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 B6A11E7718C for ; Fri, 20 Dec 2024 15:48:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 738B56B0083; Fri, 20 Dec 2024 10:48:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6E7BE6B0088; Fri, 20 Dec 2024 10:48:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 588296B0089; Fri, 20 Dec 2024 10:48:40 -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 3C0396B0083 for ; Fri, 20 Dec 2024 10:48:40 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id D3554120BBB for ; Fri, 20 Dec 2024 15:48:39 +0000 (UTC) X-FDA: 82915769328.04.F3AD808 Received: from mail-il1-f174.google.com (mail-il1-f174.google.com [209.85.166.174]) by imf22.hostedemail.com (Postfix) with ESMTP id EDCD6C000A for ; Fri, 20 Dec 2024 15:48:01 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=FfY53oW9; spf=pass (imf22.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.174 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=1734709695; 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=1VCPzs6l+RtFDMTSDAiMfSmCwqht+PTO7Juc8Thzg3k=; b=tbVz26qA5C/3GRqTtOPj7aQyj/WQafCjPmMnxbESUrkzSolvSXupUflZQE9Qi2IQXW2L+O BCOFEe11WAq3X3zkpjw5OT4lRYKJkjMUTSeU95lkhCg9ysIAddGcyW8u/0N47L1O4Q2AS1 lm+AZjrPpYF6tjfJ5yU+m64b24gxts4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734709695; a=rsa-sha256; cv=none; b=23OHADy+zPhXlL5H+UkREQBHkx9QpJa3q+/MfPWBEc3yTNZ8cKFXl1meOW8urf58BUP6A7 a9+/Lq4d3WcpUYx/lf5im9f+vDjAsNBIxUC3oek7lfsNaAeFc/gGGOj2D4QTUqi8FbhMpU bJs5JQft1oDkS7VdQwjOOLC8WKtplus= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=FfY53oW9; spf=pass (imf22.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.174 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none Received: by mail-il1-f174.google.com with SMTP id e9e14a558f8ab-3a8160382d4so5925905ab.0 for ; Fri, 20 Dec 2024 07:48:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1734709716; x=1735314516; 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=1VCPzs6l+RtFDMTSDAiMfSmCwqht+PTO7Juc8Thzg3k=; b=FfY53oW91vwovZXGphBn48G2842QdBbeO9zvIZydZm8P/fN2uDKg+/co1Js7DJoAOs y72Zvp4iSPqPW0zzgZgmsG9tEzKhVdm0T5K8Vw02XhoypDQ8kW7zS1UZ4ZqSYcZa2tN+ 9xQc565SjZ9NxRWV0BaTvsT5o0ziL5zXqmbXR3E2CVFcjl2qDakhBvR4vw6lutbvmd/2 1WFxwSmJp+vvb21SvvWE+3PQc/n8fowVXvs7+q0hpVHWiQn7fu2jBeGWZdlmekkGIVuG Fs1q1R3+G45v/X1JTYigt6QR7NORpq9bxrjX+dShJKpLsku0d9e5uI97RhQIgaSr6qK3 FaVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734709716; x=1735314516; 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=1VCPzs6l+RtFDMTSDAiMfSmCwqht+PTO7Juc8Thzg3k=; b=L4JebB3cLuRUi+YVdy/romF0ebUe0B1AbhPVXVpUhK50yLzAdJUGYmvrWBcElmQ2xV etBRdzC0bvlrOcrKchi/ezZHipBNl9frWbDErlFq/oJfLXVpc0Cc2QhPdKhBXfYyVZgh BzJr1Wt3hwhQpJsIs2fV+GtArVDKx1zfiO4OkVOnFAYu/CTxjSlRvrxK1WvkBBJQhT/u oJx5ag3VJ38o23bEKIMuYcaNC7H8APFKgK1BedxyeEaOhjjIZ0l3Rv4AxArMc/BDatbx EdYWGEQJmOPkrh148XzKS+aOGGaYljiCpMdFxYI85vGSdbB2xqY3FSajL/7vFy1810do fJCQ== X-Gm-Message-State: AOJu0YwjrJUFSD1o0pCO3EsV5W1EC6RejCnD5yKXDarzo83EEEq7nLHJ 5Q3hnF2FoRjGDeDd6Th1QOMyK/DUb3z4ff+x0KqGQ7BDermL7syRUZVQvQyW5QvAKIMqioqmyjG l X-Gm-Gg: ASbGncuZ5zopGLHpykhmoeCn5odVJG6rs9nUYeYjB6/D5lv01Xx9ULXXu8EL57bSG0F 6n61lsSwZisX2v5je/fG0Wk99F6l8cDXwnKU/AQvX+u9T2f0rUJ5vG+B3P3VjAAL0Y85r84AHBP qLHdMVHS3cSBWohaV5Swe6BUj3js4VztpkuyLgW1QvtGE6lINyMCJiFEdwi6DU2P61Cc6F4DkLI pyEs4webt8RmMRY6QDRctku/GwdM5EvZfi0MuEM5iNOQKxGFICXaoIIAM3P X-Google-Smtp-Source: AGHT+IHcbw9zIKJRxdjYyzhRRbFlhvov/fILoOcF1iNDb9M6UqXSGlIvkLvTLfoaxOcUHsgp350Srg== X-Received: by 2002:a05:6e02:1e08:b0:3a7:8720:9deb with SMTP id e9e14a558f8ab-3c2d2d50993mr23190015ab.11.1734709716455; Fri, 20 Dec 2024 07:48:36 -0800 (PST) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e68bf66ed9sm837821173.45.2024.12.20.07.48.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2024 07:48:35 -0800 (PST) From: Jens Axboe To: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Cc: hannes@cmpxchg.org, clm@meta.com, linux-kernel@vger.kernel.org, willy@infradead.org, kirill@shutemov.name, bfoster@redhat.com, Jens Axboe , "Kirill A . Shutemov" Subject: [PATCH 01/12] mm/filemap: change filemap_create_folio() to take a struct kiocb Date: Fri, 20 Dec 2024 08:47:39 -0700 Message-ID: <20241220154831.1086649-2-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241220154831.1086649-1-axboe@kernel.dk> References: <20241220154831.1086649-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: EDCD6C000A X-Stat-Signature: c9hequgnpk3axmqjfah5scmjykodqsm3 X-Rspam-User: X-HE-Tag: 1734709681-383144 X-HE-Meta: U2FsdGVkX1/z1tbuv7ODthqx2OuzeQ3T1lVcp2hOMTEanadBpp1dkdoCsvy5jvpDopEt7CGUk+3FRKqkj8sHWgm9ssBU0wZasfpxQFEiLgKa0ikuiMpQDFapOI5aK+ADLEofRYxNQ4D4yJUqr9cxh9s70nHsr4iolutYkFrR0SFY3baNr6+1LAmhaGpnxgKQvnSxEQ0TSC4AQDovbjLb5q7CSRMiyn4XTYt8yk7DMzV/8exeO0JfPCQDJQAfeyxYAaxVk47HrUHbCoXgNB1l38aMWGj3FbtzqlZOJn+mNwzAMbnfT10eZExzhiTfz3UlKuZWFPXLRDPvKD9KmPVbdAqpTMvUggjuDuDjz7X5napp1gAVbndWUShq5ntL1T4UW2QspiCb+Z5dA3n88j/+l7bJzA9gANqBMSIQKZzgXUqcsTkSodpvahnfPLZ09eYK91Q4Rjv4R6k3UNDSd5ULqAGbeayS6lqttO4+9snVHbzR/bhF7J71F2awHNJJgv/r/VQV6tRKgwxakdShJj3qSOkb3QYOaBSTAkkWFTq4FrfkcvG1gsuCdpqJZ52IN3cBkNi4wDC15SH9VLNfWtvFnDBZRE9DWZkEmOdzrAUuxsGP1LiuQuniFKvNLVqMCac7jLceyEB31bIHMqvujbnXJ5L1FJxRez3fFglYjuWaafs45FWOIAOL+BDZ9RAfDo7VvPLUza+AuAlciDMjAncKBxBnsfWzcfiObS2104sbAxeDpc9csZUDvgfhaRBLJ04zG4a6dMrnNfrEZMQSagp9tu852MuIJF8dkyKyAATcV5N6SZSsWoZrI8GQF5ekMJAMKBLz96NeLRqV8O4Lz4AxiS0dKXDJuBwZ7tvDGPIbykotKAFcmNWxypIbLrbPv0R7uyESwETivSwOl1S6sl2UaVj8j7K25+cK2tbbhehZ7wcjGUfj6GSTKxY+H9462BrCRnb1mlZs3NJ/iOv272o ZOAV5+cF xsChhVOUcf1MRdtjPmKNip4PtDOGTAcLsV2eq7XbOLDG9TRzxLDQ4DJXFbLHBff6Z/Eai4NG4tPoR2fpIhjyMF+/ZyRVClf/D0xGYseeF6mUERpcRpnGRXtPN3FYLUcOtjX3BlJXtxhoiXZGE1uy8qglaDQGu7BJjlD+j5ew4MiFsIFvfSwjY3IqHzfTiGmp2CiN+e4gqfRHgkplqWMzbnBMCc3WSy+6oVHW/qP0arn15jk3E/UNRooUWi/zskRV7ETOpRnwIpfA13Gp0CYBnKhM5lblBUm7Fp5f4nViLPWmqlepuSTozXxnq97n4pjJM1t2mP+IovcSe/tksJUHAtpD1M7cRksMHCJCJSknplyCun5LamLCTQ2bZhQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.003258, 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. Reviewed-by: Kirill A. Shutemov Signed-off-by: Jens Axboe Reviewed-by: Matthew Wilcox (Oracle) --- 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 20 15:47:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13916933 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 12234E77188 for ; Fri, 20 Dec 2024 15:48:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A208F6B0088; Fri, 20 Dec 2024 10:48:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9CF346B0089; Fri, 20 Dec 2024 10:48:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 847FC6B008A; Fri, 20 Dec 2024 10:48:41 -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 651556B0088 for ; Fri, 20 Dec 2024 10:48:41 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 2982044BB0 for ; Fri, 20 Dec 2024 15:48:41 +0000 (UTC) X-FDA: 82915767606.20.9577038 Received: from mail-io1-f52.google.com (mail-io1-f52.google.com [209.85.166.52]) by imf25.hostedemail.com (Postfix) with ESMTP id 9EEFDA0004 for ; Fri, 20 Dec 2024 15:48:14 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=lrNHkzVv; spf=pass (imf25.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.52 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=1734709703; 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=ymwG1n6nWD/uJHK94RoKI8EVCXuU9v7PVyju+T4v7w0=; b=GI+ZPMdNas89GkwB4iqD9qxpY32AeLO0hIVZcwRksUE7RnlPeEXFf91qsgib5ClGb2uwTL bk2hgs5QvpbfVd4zASbC8IzcJdgVR3mn2wWbdn6hmTuCJfC8HPBBk8/wIU32TsujOq7M6Y jPzwVKN1edck6/K/X40nAhmCyVoqBjg= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=lrNHkzVv; spf=pass (imf25.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.52 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734709703; a=rsa-sha256; cv=none; b=qK++gQKmlMF0rA0fS8MhtneSb1JXtw7y8KdL6jVUajwhB1cm18ePyfgmPhzY90TbI9OA3T PZEhf1TBwUYEVw6Q7jGDPp62ZiX3Ns1RdnF+pqmxi60HtLSVvqtS18RFCe+bp0dE+uNuTf cbEldELrfT1EF5H4CpTY0Y/YNMhOMeA= Received: by mail-io1-f52.google.com with SMTP id ca18e2360f4ac-844e7409f8aso74948839f.1 for ; Fri, 20 Dec 2024 07:48:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1734709718; x=1735314518; 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=ymwG1n6nWD/uJHK94RoKI8EVCXuU9v7PVyju+T4v7w0=; b=lrNHkzVvgTi8e/mYkao8j+juYH7FtI6UGNHPfSL7Z7Hz0cKdrudKeJbpV2ZzDu921c dfd7FiiRKdU7holmcs/IRZXnWi+/soHPgeBvfkpPXxWaoMemHVk2YZeQeCj3k8fvHC+z LHDyUS3a0s40PkNCpdiLIaMoM3BCtb/opJycGylK9l9s7wIU4QDhD8tSnSxSuiMkkAb5 SN6WEXxbucIQhh3g4N6RGZ1R+RgdVfyj/7rUHqY1QTR7fdSU00JrZwKtdxFdb3H+EzCu 9vMtehceInK6NhOq0du9tRY0V0nr4Lo3rvJPh2YHIBYy2yaMneWdH+4qtkEU85Js5kRL PsLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734709718; x=1735314518; 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=ymwG1n6nWD/uJHK94RoKI8EVCXuU9v7PVyju+T4v7w0=; b=XezKHlPcs0G1U2PBxVW7y02huWycdOYtLTfd2ElOvYxv0uJJiRVRPc3ZDMahEAskJd XuV92lIo8TY/fvI8/mLoe/5NyStxd4yOUG+Q+Dcx1WUhjNdyfbPbDIxtnGTmxIumSxn2 0IkK+g3WM3sKYGC+wd+w7ZLFW4Ia2VwIc7efLlIyGl1e+2UmQIGIO6Mwo8Le0NwBTf2e eLCHkqPpTXhFmFi74z4+6TKyPRIFXzwNvE9uDUEVabGVJAy4Gh8hz8DhUKDLEDO1qcWS hqGnOo9G+5+RAaTuxp197LTGVrDDgqHG1Vev4QBohc0tynvmissfVHRAUVZm2JZb0/ha DDoQ== X-Gm-Message-State: AOJu0YxYo9fVD6mQR7mrpfuWmuoGwQW0UMH17x3owlyP7yosd7qGSxey ZSBOQ2hoVngmbErei/vu/bq+uR0uhY7yCXXBJxYH7Y42XXvpAIj6EuPBvgdNbXf/SyhriOFG2Tk g X-Gm-Gg: ASbGncve3Qm2cDGFeHcH3klAGk48liF6IJkb65Pnz7GCR61KzSsyHamOkU8eEXn/An1 +leeV/AmEH0+O3iuUVVGTu98XQorZdYAPrOtoJlEEvJghK+/C/6m9t9aAKjD+uTijUGvc13t0By +XGd0UAXr3qZihHvmynIfAIUf99IepfC+r/wXF/RAana6eVUXS75ny2DDDRFJrwsmzmaKBoDopa rLFre0c7UzULWmvRHVYDN0TdK3DFIeD5FNQWJbwq3vYYfV2iKVzhT0ldtFx X-Google-Smtp-Source: AGHT+IG3fN9OsN4GGTbFHoS9tD5hs657TGN6y3Qqvn5pakOnrgdzlOR3L4/c6Fhv1UMBXZPo8R74Hg== X-Received: by 2002:a05:6e02:156d:b0:3ab:1b7a:593e with SMTP id e9e14a558f8ab-3c2d514f9ebmr38935955ab.19.1734709717719; Fri, 20 Dec 2024 07:48:37 -0800 (PST) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e68bf66ed9sm837821173.45.2024.12.20.07.48.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2024 07:48:36 -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 , "Kirill A . Shutemov" , Christoph Hellwig Subject: [PATCH 02/12] mm/filemap: use page_cache_sync_ra() to kick off read-ahead Date: Fri, 20 Dec 2024 08:47:40 -0700 Message-ID: <20241220154831.1086649-3-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241220154831.1086649-1-axboe@kernel.dk> References: <20241220154831.1086649-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspamd-Queue-Id: 9EEFDA0004 X-Stat-Signature: yqeq14hxq1ei4qohp5zjrhykgshpdf1w X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1734709694-459686 X-HE-Meta: U2FsdGVkX1/Stk06K1/lOMrYcF1WOWTDV72th1AkBQ8MTzXMC1kCA3Mdr0974AzoqyXRzEqelgpFSkCdgv1I34k1IbC9SPY5+WD/Pv3hvo6qilxlXxy8GaH5oQjqf9VZbi4IH5EUoyVDIc3pr5NHnp6rYpGASpTkcmT97r7vavTFpvcvzM4QBc7Kws+TUX9p44cK7FZ353NTO/0HYG/dYEZSkiB59k+GCrzp6nXr7jZBkIsubfUOJ3DqOHm/OICEgFxP2sGBIJtfSNN5W+beOXVJKoWjwYht6zP361RM9DvF+WDvmVET7+ztUCfNsXEzxnSyZ04+DbfuizL50HHCrbjTW1zpp/S1uUIVnsGf5KCtW+6aBedhbSXOyCROZzY57yvVTJJh+QIdzwlvJc3EDt4mW8fC52eLqUaZzpkF1W7cfZRJB1sndsxWvD8aK+9ViGrfYmtXQ10MtVdmRqNvL5QtOg5OW42qO1UctDYxenTwIC5gyRMCM4ytl2yZNC6S8cvTrScYMzU0tf8c/4R+CdtRjxjyHGuVmG/1ac2V0Hti9C8FONG4puTPls+6bgVn5VvfHHkpFPAONUXOn0yUuDy5RCXZxUD1w1t+GwbWExw326bsqyDoze3lBOz4Y05kPNPUZm69o22JOpCr7yDUD8PjtbRxt+NV+kZAoet8t4hq5omu4LrpZvkqvyKUjV8AhpE6Rx3iaDpo9aSy+lswicXe8j/Ge08UainoN4m/hHJVrVwDB8BkNuz+yDQS2jf24I5jINhE7WIU0nTGXBGiSgSi4v0zqQ9zhES1KbRMQZ0sVDJ+WEcRG92UPwEw8JAmfsf+u4j7n2rbSHsopXj51T9NE8l1xdySKJ86kwsUirZUQuf4GaOyShb1CdAvq8+8psnsQkU76CEQNVMrlnVUikACg4BMUcDbGMFPOzz9y6NYjPRappA73NyAqbhVdRKjrwQcTSBH8Z0qOJPQvtB 6C2kxvpB yUy87plAvop9krSCccm/VgPO5rKKpqshU79cwQfzfYtM6/x7FYqVXP8KRlOT3hVz7DxryPHSRheEY6y+YmzllSQqGrAj6pirpSoi27MfNPCvIEVF+vNGLTmsFlcgPl+oakHTGsneS32Rjls87lAgT1dwKv2Ra5BX++Ojo388WBfKPGgeysacknoZ6nJeGQxhsxwqrvpcE3hMsiV7bkGDloxACVZkKyPWsneveZ2uytHjvFUmaPYdryRUE2Ui2qRTXculfAzzm2CThffPXW1/P4E3+MdxguYhsQEVLgYNbiH7UtUgry3XIyvzLCYMLJZ1RL5uN/OzjaRKARxgtAt5paP0V7Uum7kzptT7W6/xAMR3rZZqEH4NSx+MxgifvNrPI4k96 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000014, 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: Kirill A. Shutemov Reviewed-by: Christoph Hellwig Signed-off-by: Jens Axboe Reviewed-by: Matthew Wilcox (Oracle) --- 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 20 15:47:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13916934 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 BB577E77188 for ; Fri, 20 Dec 2024 15:48:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0F8E26B0089; Fri, 20 Dec 2024 10:48:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0A8196B008C; Fri, 20 Dec 2024 10:48:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E15666B0092; Fri, 20 Dec 2024 10:48:42 -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 C14056B0089 for ; Fri, 20 Dec 2024 10:48:42 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 6F56B140B37 for ; Fri, 20 Dec 2024 15:48:42 +0000 (UTC) X-FDA: 82915768404.01.84D085E Received: from mail-il1-f181.google.com (mail-il1-f181.google.com [209.85.166.181]) by imf25.hostedemail.com (Postfix) with ESMTP id E9250A0015 for ; Fri, 20 Dec 2024 15:48:15 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=nBCU5czp; dmarc=none; spf=pass (imf25.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.181 as permitted sender) smtp.mailfrom=axboe@kernel.dk ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734709704; a=rsa-sha256; cv=none; b=mfX2SPYphpNJICF54s9jowzm4rNt8NNz8KPX4YmlEaveRwdwlCb+qA3SKPnj7+CABAEMlX il4wIsREU3AlcfN4NXpDXBNpKAr6IIDv4pIG3Nm4Aw9o3FcOwTlZEC+EklOJWB4f49NiD/ 5OOsQGzCQWwS63XvJzRPobxAvbRZKTs= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=nBCU5czp; dmarc=none; spf=pass (imf25.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.181 as permitted sender) smtp.mailfrom=axboe@kernel.dk ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734709704; 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=U1i1r3ArZkX2vgdPDoEq+WK9gDY1/MkPULwwiAP9Trg=; b=u8I8pJLSAP2GEYYKpT1RNd3tgvbULfp0FGZvm6T2HtfSJ2JZfBFlKGVzUK00wPIH1228Tt VxqLTqbYmigeN5t5F/YrDXgWxwFqwmoUKP8oweNHoM/i0s8FNvufVxE9R1/5hDhLfWHs+p m1iwCQZFKOrHvQRe3EK0ACQmV529tBc= Received: by mail-il1-f181.google.com with SMTP id e9e14a558f8ab-3a9c9f2a569so14406105ab.0 for ; Fri, 20 Dec 2024 07:48:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1734709719; x=1735314519; 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=U1i1r3ArZkX2vgdPDoEq+WK9gDY1/MkPULwwiAP9Trg=; b=nBCU5czpKD6Sqov21UNXUmeypZSA5OMPvkAEb/bBb556wW3p8NhthQnvcLF5XnMBve BFZqf/mkpWlfkmY3o1cT69SC/mev4ha9137TLupUwTuXe5wYuhckFnirEyp8of5u8WSm YAGpH1aqMI54cIi8wN/Zh1FybH6w0n2caL9OUbFoP5K4Y1BeNh48UR/AJ4ORDmEduNz9 k3DPj8dWSN2QKcaHzJTdcmWO+N18n7XDuMKaiMQK45TWYbfNFsLpVDbzkNMVwfO0qVso c1W20TDrjP0B5jcfqdsn2ZNfMXAF16zCWEk8F9WzZNQbmne/8Tj8VIEzeMZTczLZpves ylHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734709719; x=1735314519; 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=U1i1r3ArZkX2vgdPDoEq+WK9gDY1/MkPULwwiAP9Trg=; b=JzahqpG95W4QWeDLPdtig6c0Cr53+nl3BDa4zmGz4LVl5mhdd83azE26MxGBFhPix0 KN0caYLtQmh/H3BdrSUh4d8VLT3O+z4jp6fVO7YIz2NHihf8Ok3NIuzFrWmk7IdWOeX1 ls6LKLE60WIlHTt4VQDOj/k7+t6g1+8n+9O37GELW+OOPMbR3b8iLPfV9aNQNFFCIhz6 ALqF7hPrJ/nIre+KQJjzZ0c2W0w+BoOcMMvWXTq1UAy5oR4jN9n2azjlchD5QGTc/Up7 9aSJCnfgpKhliA7F5SqdFXna0SDSXBkSCjNDbAifNGe6ppz0MXzwEsLSgQIB1FzxB3/Y 64Hg== X-Gm-Message-State: AOJu0YzN5e7T0HIChEoPMBcVd5FriqKhNXgiPwgbpMvixytYNVCeZDPd CFKjAYfrPZC+nQgDH+y6OouIcURUUKGvfoDmK0i7gBRDraIV+t2z5bGiBAtcYcLIHkl3Z0IoIkd 4 X-Gm-Gg: ASbGncvOhmIDT31af1+gEqlR07Vqhxk27fXZMbC1T2Xd3JqOB0g7Y2Ua+fP4ndI05iR 2XBDEztWXlzoE2Lkiq32dNQPKeh8gwRLRasWrIBOcUKK2AN7DC1K3HTjiYWqJewpQZ+euztvDeD QRCs2UEuaq7d3cRm4kM28dcIwYsw1I41GTNAs4bO2QZLrOXDX7a4gtlr//DvsP/GI9prp3M0MNY UVKKHbC20aU36dlFjo7zwqZ/mNbZMO2zFRD2c5CdHP4bxHL5ECopiJbtzMW X-Google-Smtp-Source: AGHT+IEQ+rQahAFsMNf0wBgiaHc3ybkwynnm3ue1l0Cc7XmizswXF3l+0I9aVhCYoLyroOrTRrUFJg== X-Received: by 2002:a05:6e02:1ca5:b0:3a7:88f2:cfa9 with SMTP id e9e14a558f8ab-3c2d2d50b1emr32075375ab.11.1734709719216; Fri, 20 Dec 2024 07:48:39 -0800 (PST) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e68bf66ed9sm837821173.45.2024.12.20.07.48.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2024 07:48:38 -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 , "Kirill A . Shutemov" Subject: [PATCH 03/12] mm/readahead: add folio allocation helper Date: Fri, 20 Dec 2024 08:47:41 -0700 Message-ID: <20241220154831.1086649-4-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241220154831.1086649-1-axboe@kernel.dk> References: <20241220154831.1086649-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: E9250A0015 X-Stat-Signature: jsqgpoytzmokuogfpxn4jcdyspzryaf7 X-HE-Tag: 1734709695-867528 X-HE-Meta: U2FsdGVkX1/YevE+6+e8v6jpayCotdH9/r5TfQiKnrktiYUE9uabcRxSkZlHHrSfr/WuqPTDF1/qKkzmuZ7tfIU275IacKPVdymjewqMYzCRNd8Tk2yv3AtgY2kS1gRojCdPuBFeyUW1X41aJNuN38B8A7A57IpkAehy+Th6HqBQvqzE/dPDP9dNLfcR+Pd+dxG+wfFWSyCkyZCH3ActDeX7VKx2NZPG2YwImV+21pyaTRvCe1C6YDY2vGavHG7stKfz+c+VkJ1GLYbVSOnIwEuAE/3p3ViRGNsBE5d3jgGEyoq4G1FW4DckeYyQctgUZYqG+SiIEZkm3Zbzd00ghAhQluCGgLmrn8bo0XPygru1ygZL95Yqj1TPSeEkGZko/J4vH9mItes9Q3G3QtFgGs6D4Ym14GwJ8X55NsaNM2mjTOyK86sg90qM+XVP0KMLCvtOCa4J8KdAtpa9Aqvk81lB+4E0obTPz37T4YP26E4T8tQGTj2U7oi6cpR6Mz8+bCfbjaz9EFCVlK4UkOvlwz3HAIRz3FLDE2KMxP3q6zYL2VMKJwcJ8npeLXKu9q5W3SGJjYHyO+14eUsesUykEKFFCbcTr+Han9fy58VzzlR2w6Mjhhlj9LZPrxa7N9mxiS3/uG6HMZzJ+J0uiK0Is+7hgn1YpKg53scPXV7oRN9XWSCw7Tb5aHL+yxcaw4oi6CNW1qXWP79HpXwMo+5ary9fd9rBIRNElVUqy7xyXXmXaePc9SdIVoUQWu6lpbVp9jieom9+cgYkz44HUou3JIpIaE2G+C82kTS2thBINI8Gu6LBXX8IE5d5tdUB8FiYWm4+FPhJicgP7TSdFzmVFuHGmkLNsFusk761O8W3S7pS2Qkd6PRahUZ2hLAA1PWxzZIMG2ki9x4vMmadyvtVMJ85fo39tB4D1QWT1835Y05qXiyDEJOegkIUHos6WdpZZBZXR5aAGGhNsm3pq7o eKlPesBH 5mwldo9liZ2NdYNr/6VoTipihF+vUhykYc+YAzKS3oiEXKWqJ90KmXY6+DgtT3i3UJfPYIyoEawFT/GKVrs3Sqe1Yu0Ud+ZDf69WCqNeAcswJmKR43Zc0ZD23ckxVph54xEaLIaSR/Hx996TAkYL+iHgknLXtbe0z/dpLEacoy0IEbRmLJGOOAvg1zkgSbuxx+LTC3EtjXIS3jPSX/aydeyF9FjUVLHNh2sDb/xqBRcUR9h1Oln6rnEwFQBfLfuTqafT7710aKjQf0hcjr/wT3tAERT9FOmrILUbl/NTgE9RMcllq8elqVwrKQV2PwUBFcVWwFN++aRRVWms= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000072, 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. Reviewed-by: Kirill A. Shutemov Signed-off-by: Jens Axboe Reviewed-by: Matthew Wilcox (Oracle) --- 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 20 15:47:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13916935 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 54E93E7718B for ; Fri, 20 Dec 2024 15:48:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5DCFC6B008C; Fri, 20 Dec 2024 10:48:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 561E16B0093; Fri, 20 Dec 2024 10:48:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 373A96B008C; Fri, 20 Dec 2024 10:48:44 -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 135116B008C for ; Fri, 20 Dec 2024 10:48:44 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id C3D69A0C3A for ; Fri, 20 Dec 2024 15:48:43 +0000 (UTC) X-FDA: 82915769748.02.C220BE9 Received: from mail-il1-f172.google.com (mail-il1-f172.google.com [209.85.166.172]) by imf09.hostedemail.com (Postfix) with ESMTP id 70E6D14000C for ; Fri, 20 Dec 2024 15:48:18 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=qPIgD16y; spf=pass (imf09.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.172 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=1734709695; 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=TZWY6vJPfqFGr1DBynm1KpCMDB4zdovTdnWkeolaIOo=; b=HV35s9pf4zdK4CvMEdsDs0X2G82x8krciIoDIYigHTDyVwf0uxJko+tFkEXv9YfR/ugXzt lU2AGeOlpDw7tNLk8g6Gxx6doBVFYtS2CjVGPApbMoFwmQNEWzFTPwgXcXvV1iACg495tr zUYqq60cJ5AV0dB+TcBQTiguzz72b+o= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=qPIgD16y; spf=pass (imf09.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.172 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734709695; a=rsa-sha256; cv=none; b=eYZzOhzj7r/dPTQwJPEHnFbZml3YtR/XVNu1QayFaAXyWKzz9F50USjnHKu+d4+RuM6pMZ ohSlRi3edjDg5M4WEcWg/wybKWrhKuw5nBT2i28eFSbAmiIaOfSLs+20ZQqzLfAlI7372M Yyag/SQ2T95wRyrTsS2kktWMUbUbYQs= Received: by mail-il1-f172.google.com with SMTP id e9e14a558f8ab-3ab37d98dd4so6582885ab.3 for ; Fri, 20 Dec 2024 07:48:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1734709720; x=1735314520; 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=TZWY6vJPfqFGr1DBynm1KpCMDB4zdovTdnWkeolaIOo=; b=qPIgD16yYcvRlL8yge6honRNfoiZWcJJ1Cd9A75ASIBcMuSxbtpV//ysEEEkkr/Yit aM2ktcBO+RBli0lRBDW/CI9Y+OLYKvQAOBBpxC+WXh/fNzEZPYGea5kNNQuJXnejUapS mU1D9H09/WIutbPb6/PkB6q4/JJEwJF6uQzxQ5M/BCezu51KR99yfZDAd9+4LrbUQB+N hTMBTW4+zVEVVr/kp5pxYq5s3llVJ4xs7c6Lnrbai89kqvWCxM4GgjHZBLqcrbkUuDEL TJ/mnmaeEUswKiTTo5hvVkAw8qb0zqPA6CJlO39NV4MsxtXpPpTvseKiRLS6fCK2aXod riCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734709720; x=1735314520; 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=TZWY6vJPfqFGr1DBynm1KpCMDB4zdovTdnWkeolaIOo=; b=qAwnuLAINVmaoE21Xh+J+Oa8phJjuGTbahNMnT95iOEe+7hMHOtRIPL41v8yudI2Ai Ab+dfTuTd3FW2pFcy4Lnoyj374q7TYTlOTGTfut4/+TvoUmeWFoFOiU6AmWJ1/ktI0xB 6XBAaIn9OFhtf3c1Q+InsOTsnjNSmlAMfpaBud6VK/AIMEJ1Lsw8G6HL/Jj00YIRXtOJ +V7rVaEf5G1JU6K1lcEq2jehzaxRmOzJNsOgbSWbWZiQoxmDaBHmBkJ/cWskjIqCK9/0 Bfr+Qp4v/4Y69OiVdtJclh4gDP5wixT22/JcCjMkgvmO1+vxlJkDIYIm73972CDan6kT KHdg== X-Gm-Message-State: AOJu0YzvRBfLUssoluqUtcRD0dEbYpHpAXRDGuALlNvsLqJwpQkfiXGc THy8Y2VbkgPxTt4T7b0Z/UBMLgIVYOBtXYkqEKJD5qqLcA6gxC8Mkg3yBORgbqZ2hkrkQydlHTv p X-Gm-Gg: ASbGnctKOG56J53byaBtV+crkUOtWIEbCXsFAigw73yOt+bLyVBovXsYnFHuM6c0DoL /toW1dJLyUN8Bqyz+JHWXukr9NQBT44de+InquYgnzB4zoB4RB6mXcmKkYYQnhXTa53LInO7vMl Ja4hHCY7ioD+GcQ0LoMVrSpKJS1nz5XEswApEWp5NLF4aIWxGjFjZxMT9c5WSYjf8Ga6gFfDqrS ZfRrbO/J7c2tOhSeMCud923Ej1R3jzmWuuOBTVCarx/rTH96oMmFl1557qV X-Google-Smtp-Source: AGHT+IFvp8gxmeuG0px26ehs16GxVvbXtCVpdcyc+9Br4GzsJzwQZ198tT+fp2EHMgvEVKANcydJew== X-Received: by 2002:a92:cda6:0:b0:3a7:a738:d9c8 with SMTP id e9e14a558f8ab-3c2d14d1839mr28931745ab.2.1734709720617; Fri, 20 Dec 2024 07:48:40 -0800 (PST) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e68bf66ed9sm837821173.45.2024.12.20.07.48.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2024 07:48:39 -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 , "Kirill A . Shutemov" Subject: [PATCH 04/12] mm: add PG_dropbehind folio flag Date: Fri, 20 Dec 2024 08:47:42 -0700 Message-ID: <20241220154831.1086649-5-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241220154831.1086649-1-axboe@kernel.dk> References: <20241220154831.1086649-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspamd-Queue-Id: 70E6D14000C X-Rspamd-Server: rspam12 X-Stat-Signature: mfrejbnz79tu4chnff7pnctm9xbf7tqn X-Rspam-User: X-HE-Tag: 1734709698-413814 X-HE-Meta: U2FsdGVkX1+NLcXeb1WYe0SbBavmK9EPn0ygk6AKYUT7DWI1/NlvXSCM8N0yKvFUrP7tVNISmiKxQ2wm4frbtY+aJAxhD1pt04E8/DzzVLwV+CtBXk1V+u39vBWhuof0NL5bUZXjZO1a0iymL6k9HAXEILPMMNatRaCIXgU+7JVdXNhCs9luCyVdtXPOIqXQMEIFFtN1NHqU71X46X6Lsxrl6HpsepGYvwU5i+6iV1MIAe0RV4KeP8Gq6exLzfmn5n3Ip2OcQxJgUJWFo5zTG3IM7Br5pAS3muvI5e8N+d4MnGpapNn8XVhkLKPRHetorCth4ZVjCzzirhN7Xi5ql8cu44CGWWiLXeGgrSHj8JA4hqQGgUnCmzMoG543S6J+FJGmwIpokPaMFosrHcDXEHe3c4nusyojixMnGck0rGPit37LWjmEKcK6RNi+RrVMHuT4jZhxjptav11vpRJnr8alG+55r2oNPDI5JlZ/Bae1/9klYmTLgGaCQjz5imWBMMGaQurFMMrrNhSDTJZ0geegzdQFPIdVLqFWNJ5uRBzmriBVRF7mhCoMJMGZXrsjK4kyMV1JpnfiGdwykusvexc2Pf3l+/5ARwx2Al666EL7bKu/cruDd0dIAuu+t2H3BOndM3RQrR+kWCJg73Y+814spY4gyb6VYFXJESj76/p9yGOOtZ7oSNS0+9A8eln47LSKiG3lI/93RajIFiQF0aituup9SNMGjgg6nXkqNkZqlczshBA/qWXvBPXxHgNSmXJ5mh1dv/wbcLRLGzri7HJz8ne4VWFshm0YEZs1Hv1A9q2wglE9wsBYcAVxLRWNor92QZAxDnsnnJg4iCT+CMzboEEfcVbIzBVtAuH4u67a+bn9RNyS59PTv6eWPb571CTMQKk0dqv3MwGRr4DaLfbmyjP7mHf88HJbijdUM1xRFNSTlzSnPfkaxNy3OmY2TlRoQHzUeSSk/te4FRA shRoqN3Y LubN1ctn9kDh8Cn0AbCe08/cvoFM3q2LBzm6onYfprxnmnT8Fg2RvFnuVLYLdLMId4rvmQqNAAUXNazOUQ501vHxDGi2HoDDps3vVyO/PKNqYa5DOdJM560Ep6FNPrPxv/fsVnFrf+RHjvMfUdvBq23c3wVKFV7qFqOrFtXrohoukKVcrgVbNbzuIQnFe2UwGCc9baPIHyWSWOJ8qA/XDo0bCkUu7onlDu9qbllAkE1QH0g7O+Kj2k3Gj0bttXQANIjTELwjXmrUXH3ldIxbn55cVlXy/w/qgqOjzjv22g9bykxMmlXYMjMBLS9YhF6Lo66fA+aEnu1ok31kEu/P6n9CrDmSSgsvgbGq2CCDpVmdkmqKBjEN6YxkC3A== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000014, 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. Reviewed-by: Kirill A. Shutemov Signed-off-by: Jens Axboe --- include/linux/page-flags.h | 5 +++++ include/trace/events/mmflags.h | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 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 20 15:47:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13916936 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 C5F45E77188 for ; Fri, 20 Dec 2024 15:48:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 961496B0093; Fri, 20 Dec 2024 10:48:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8E4EC6B0095; Fri, 20 Dec 2024 10:48:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 69DA76B0096; Fri, 20 Dec 2024 10:48:45 -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 491AC6B0093 for ; Fri, 20 Dec 2024 10:48:45 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 03D00140996 for ; Fri, 20 Dec 2024 15:48:44 +0000 (UTC) X-FDA: 82915769076.21.D045353 Received: from mail-io1-f51.google.com (mail-io1-f51.google.com [209.85.166.51]) by imf11.hostedemail.com (Postfix) with ESMTP id 9C7DD40002 for ; Fri, 20 Dec 2024 15:48:11 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=BEjMXWVN; spf=pass (imf11.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.51 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734709707; 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=Qy66q6foyU2ZBCe4X6zLGxi2eTMkd0mxpiy36jLMGYw=; b=sHTe61JD+l8EK7qgnQvKf0DMW+m8I09xmPhcp9cjHh8bFs/wb7kFzo7nvZn6QerHQc7eX+ qP0DKHToSO84YcXhhTq9E65YbzpYhRwQerAepBSfJt0AUMGX9OeNL8PfmsFolQ4L0Jpswd 6K57ePQ9t9b3qUmzDwaMtgE/zHRV/G4= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=BEjMXWVN; spf=pass (imf11.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.51 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734709707; a=rsa-sha256; cv=none; b=LPXh204RsJMy0HXuuioOoDj5hrbJDTpcnRwht31KAWPP6n6Sa/1s1umT4GwyTj/3Gu0N9F sjd0uCudvjU4i+0+ki9oht2cRqDojfFLifLHBNg+KATPkQYikscxr1b6kcmvgIfmVqONEt NsHVplix7/FT+ISl2QuujDtbGgi7Mls= Received: by mail-io1-f51.google.com with SMTP id ca18e2360f4ac-844e161a957so154729839f.0 for ; Fri, 20 Dec 2024 07:48:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1734709722; x=1735314522; 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=Qy66q6foyU2ZBCe4X6zLGxi2eTMkd0mxpiy36jLMGYw=; b=BEjMXWVNhEffzqXrnnroqqCPWxwem7xQejP8YSRr6Q17ZvfoZS0li6Z0/Jct0hLHDx zKVO0xC1sUOQXipNuKca9B8KP58IBpYb1pftJHoM2SBx2THVi6VZjgF1RlOOO/TO43D8 hw9kGaec6ZTbDJzmXLJuDdtuZLVewY6grCiD35yDgP8RdtT3b9XJSL8cEtvu8jVUxTo2 h1nj0jxy0KmtEdyHlXWlxFK7AqTPkVpTfgPLzTaNlTK8yw/ZysuoROAnid4aCh2W9ZZF gZQYsJytK5aUU5fe0GrveOFG8E3SjmQnomXm1RKgChFLQzlpfCusbjPVip+BhL/Z7K+t qq8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734709722; x=1735314522; 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=Qy66q6foyU2ZBCe4X6zLGxi2eTMkd0mxpiy36jLMGYw=; b=U+2RMD149qdb3hV98oyK0OR7EG/0UqZsXU9AzbJO1X7AOL4jyRUnf76CYRkCtgDXOY me+lDkdr5F7jZ4zBb7sS9ZCs5sLHC8w61sD+Ru/clFCl1iX4Um3c2/KvhShzsbTIAoOG HJXu63RbjfJ+cLzgrjUbsi2kl0qAcFKnvPXSNZ52mV6i66yJ0+hki+HZdmphrpuYFn1E f+PpKO1REQNLUCQNIf70mahJXHhko/Tbytvk9ioYo18sraSNiaVGNEU8EBrS4vx8IHgv op4c8W35yRUz/T/2/FhLWbCWy4esiF38fvlYpXflgjefXC8pDc9d1NiH+xj8hkv9Ur8I zHpA== X-Gm-Message-State: AOJu0Yy3TZ2X2xCLbEU5Jkjt+qqc90S8NN/WXSp9PcJqyDtN86gQ5mcf fE8l0AN3qrupi1tE63BslUG/ALastKJJOBhD3VcBcxOKsIKnheh0+8Bgo4KqAgubut7wnOymt9/ f X-Gm-Gg: ASbGncs75Fukh0VApaEx7Nr3TCZ0hS6ObbflKFA3RWH5LrLywyQ++n3T2E/BiwebSdx O9sNkw6eSePzevi+90xLZLOLuDH6prGztdFOSnXgfHqwxfWU7iFqxErS85SiCB45KJtfZgqwkS2 UgMUrQoFt/bWIocVVGl9pd8GT39Qkc4slhHUYKNFa47sU9Vo+OhFcpXDyjCXa0ow5XWW/nYX2uR 8sBq1srlKEQYHWLP0YCENeOa/5eXz7yWuecF0D1nc+g9Rd4ozOcWoEsZZbs X-Google-Smtp-Source: AGHT+IF2sIPl1WVDVbn7fgvbpII69l3j4cwL7QghFjhSCJ3SFTcAXuckA2Q7OzRuPKU0QQKKTwe1pQ== X-Received: by 2002:a05:6602:26c6:b0:841:81ef:70b9 with SMTP id ca18e2360f4ac-8499e605a2bmr323110339f.9.1734709721832; Fri, 20 Dec 2024 07:48:41 -0800 (PST) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e68bf66ed9sm837821173.45.2024.12.20.07.48.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2024 07:48:41 -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 , "Kirill A . Shutemov" Subject: [PATCH 05/12] mm/readahead: add readahead_control->dropbehind member Date: Fri, 20 Dec 2024 08:47:43 -0700 Message-ID: <20241220154831.1086649-6-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241220154831.1086649-1-axboe@kernel.dk> References: <20241220154831.1086649-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspamd-Queue-Id: 9C7DD40002 X-Stat-Signature: h5x5aiefdkonsis7c9ygjgy9zjaw5898 X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1734709691-782733 X-HE-Meta: U2FsdGVkX18BdQz3n/2KHB9UJ4Vxz2pRr5gMa9cQ0dOwKfrqOw3duQTOiLIIEjny2JgJ4izuQJ5DeGu1GtQqyiB6ir1OnPG4GbixDocManQJvGxs5iVqOw8QXdSefHJcPMcm0ikS7CiGorWFtb0jSuapECox82fTj2p2lAYmKSuYkFURcxpmfkXQ3pGEUNJePAJCz8bhw2p0i3sWKLk44rWV05hwDe3yNdoi/5ePGIhKhyi3VW/y3VSRZ9dt+og2Za4SZY9BZB/bIYnCb8sGfdeOAfUGQsqKwT86aPov+b3qO6YzYU70oTphogF+vTPuWvmyr7gCorWYDgB+dIjNo6sHBUkI6NdDuUTbEfANyicLlFXi9ewDLYMWMHdFvWqjUfEt1Xy/lWqcOg9s9ogXf0vIMs9TBuW+jC2JDx98rXH269kKz8lnt1GHFNLHev34abR5PlX4kFgTyyXuPerLZUyoEijajoUTMmFlI5xdlrHil2JSh+SnkHu6dnup4MbXjQT+Ugr86vUCR8Pj136IHDK9K6raBMWhRbp17kk3BXOVcUgeYL3Dqo8yfjlyo1zA4rNH0HM1xhwT/xo25J9i1xXGNRl0GXBNjW2fyY1Wj3HbAYnjSyNSLrPbyZlXVMC7v42ew3TVfytSfaEB6Yesqd7EGkEF6atRxnDutJt+U1Yv0eYUMmT5YBHHz6sBqirUaMrHATBnc/9TsNSmMoz7OMXKdMRsspQTOQo7axz7hB9l+oIwnKCBUII2tz/BSq1un5XHIsD4UF9Umn/V0u0yxMIRz8HrznY8K/mpTthB9Y4E9avgXoIxQ2mA4S9pdln9kTcXNpVqd9Oc84yBTQ1fH4/x3g98r7MQtQNwcQMmCTofo7ReEGQaopsmRIGuzCV94cxud1UC2omPm2wCSQ4WemdP9H4xo5WvFGzaJGctbYzggSwrvZ5x8RJvUN1TfbzouLmGVod3HdCXdA7CbzP YgEqUAVd 7TR1gakL+6ksn97AMv+lMv4cRF3BDFO0Uc6mc76hp5SBIXGbugZJ9HeTAREnANwNdI0hXzN3tyj9Mb0c0gHIkNUfgzNzE5v8EtcYG3eMtx5D6esXeOPXTVoaX8y78hYSWzPZmSyKE2FBGHQzskgYLNjP0oI1WRUGxtzWjdDHRpiM7x7cWKK32ikJSuyaj1DEI6249par8QcSUGBgluAoCXSTuPTMvaIhrYqpDWlhpdytyFvxa7I1azT2BS9G6T27ezu2qvoFM/XY6NRQx1TYUncYnWCC+2MLkU2jBr9AkPnEKVGLf7DQbO0rGvGfXKElBEqnUQF85P3EeltG4s7/QvloddeKDgDfSoh31Isvtrahqt4EU+SmZDny5bGaHQxtIXrRu X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, 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. Reviewed-by: Kirill A. Shutemov Signed-off-by: Jens Axboe --- include/linux/pagemap.h | 1 + mm/readahead.c | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 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 20 15:47:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13916937 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 51A7AE7718C for ; Fri, 20 Dec 2024 15:48:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EB65F6B0095; Fri, 20 Dec 2024 10:48:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DA0E86B0096; Fri, 20 Dec 2024 10:48:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BF2846B0098; Fri, 20 Dec 2024 10:48:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 9F4396B0095 for ; Fri, 20 Dec 2024 10:48:46 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 4B91844BA6 for ; Fri, 20 Dec 2024 15:48:46 +0000 (UTC) X-FDA: 82915768908.25.90AD4F3 Received: from mail-io1-f52.google.com (mail-io1-f52.google.com [209.85.166.52]) by imf01.hostedemail.com (Postfix) with ESMTP id 4628D40011 for ; Fri, 20 Dec 2024 15:48:18 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=2KNrBsFN; dmarc=none; spf=pass (imf01.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.52 as permitted sender) smtp.mailfrom=axboe@kernel.dk ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734709708; a=rsa-sha256; cv=none; b=vg9YEVsvXZzMuv3OE6i9LJ3vW8gdUNHSiGLt/Lhw+y5UOYQ5/1TiS0h8xLK3FRnNS+dIvC lMt6QYbehpNikZe4SeAkJE114pB8CuS/zMJFacGG7S9T00quLjMgmnQxFCrmjFLSfD+O6A n0VTCLH/25dXch9PNGdF0A+77i1UeRE= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=2KNrBsFN; dmarc=none; spf=pass (imf01.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.52 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=1734709708; 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=hj114LsQAeZlZx1JIhp9yNhhSBSN5VfiZ1DE7mn9M1E=; b=w4XPYYH1X81BuBtRyu9gnUdoCvkYK+wvq9Q6ThITh/H6Hv6MxSfN0vjzMM+3YAe4s7Al6o Qptgb6ZY1rSi0mR4xfryOIemFkeuQH90EgVII+9dQgBoP1GGjVIOXUwHfA0F04gBgskfBA inHjz1UGUpnk+91fXKkFK9k210o2jV8= Received: by mail-io1-f52.google.com with SMTP id ca18e2360f4ac-844ce213af6so72926639f.1 for ; Fri, 20 Dec 2024 07:48:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1734709723; x=1735314523; 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=hj114LsQAeZlZx1JIhp9yNhhSBSN5VfiZ1DE7mn9M1E=; b=2KNrBsFNL2EjEhRyP5iXp+7ZKHUhnwlSxvCeY/Ij1XPqjqNAiMS6y5WRHhKnUpHZgH gksDqeIt5UZ4yaTnxImykHPO+IK0zo3vX29w559ghX2LTRNyE48tOKGI/hwYaASCwWNb hQNDtDzVVlwPMRGuAW72tdtrSB01L/7//CKgnasf0GfP9Ka2BFaUuz1OE6gcj5fmyMTs fe9hy+jIoNwfD4ZR//DK60tmwjhly2BqjYVkAaMht6MPHypRhTk2jI5W2JZFsZ6N8vw0 wFidwEF47kXZFaXskYTsK1n1n5s4WoVA+pzVdkk1WRmtvDrqZNracWsUV+VzzlGMa/m5 tY6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734709723; x=1735314523; 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=hj114LsQAeZlZx1JIhp9yNhhSBSN5VfiZ1DE7mn9M1E=; b=WpxIdQ+Vmzq492qSJK7Imh6Fs/+Wd57uz7znJSkXRmJsktPLTi5MgXZPWC2dDdh4Ih dwwsrlsHveeUCyYbpo+RpkFDiAcF7VLQfMHFOhd0a7M5zfk3jSmijdcURHXtuKfS2P25 KwXkmtmd/ZCaP4QsNkGaSyNqMxnj9PjYP2lB0nwwThZanDTwK8JHKRcluaPMLoy7o2iR 8oxbZiXTvID67hCamehVdIh7MiXIhuQQVxXTpGvXYGGY5t/ucsC/P+9OYqrMZNg235tL MRYuhamBQpoRGFXmYike+bvBFOmMaa/i2yILinueUC1BMH4mpAA1MDXlpkgWTUMYmlc5 KbjQ== X-Gm-Message-State: AOJu0YxARO39RW+wH5uZ8FqqW/2OCGewtgeq5oLJA5h++pEUpbbuN7FX sxuZBshNL9EHAjsQVFqpZjeQ1lQCiVdY+6+OnnZG7rrhzuZwMozr6O203EcIhTzhMBFTjI3/JnC x X-Gm-Gg: ASbGncuy2M1SrEw3FWQ6CBJItLHerzF5Kf08GsSiFu1/USGYJkm4QkxlDKJch4c4/r5 dgdvAfRlAfUhGvwbqlRYcuGP8pDOdhIBmn5tYduXtWFAkPmZxkon5TL0PYBHdVu0Vfh4OdSZKqP njr0mdbgNBYyLTqxwO5wYJd6YDLlhnhO83GB7x4bH1OweBiTKMUFQK6ojAfzY7AS5njDyyvieQ1 saojheaTWyrFvTnYqDJsWI0QcVci7wzkVrMb4Vh/Idh1bScy1GrQ0AQxYWP X-Google-Smtp-Source: AGHT+IECOzR43hLv/D5wLt0YmDzKJdUpeT0f1YGhsBnnrmOZn/oym4rW0bRMY26iQGlNbtfBjUSBgg== X-Received: by 2002:a05:6e02:3683:b0:3a7:8720:9de5 with SMTP id e9e14a558f8ab-3c2d1aa27e8mr34276355ab.1.1734709723099; Fri, 20 Dec 2024 07:48:43 -0800 (PST) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e68bf66ed9sm837821173.45.2024.12.20.07.48.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2024 07:48:42 -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/12] mm/truncate: add folio_unmap_invalidate() helper Date: Fri, 20 Dec 2024 08:47:44 -0700 Message-ID: <20241220154831.1086649-7-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241220154831.1086649-1-axboe@kernel.dk> References: <20241220154831.1086649-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 4628D40011 X-Stat-Signature: wg4a8j1b11rbpso159aj6aa3x1zyg4kx X-HE-Tag: 1734709698-82185 X-HE-Meta: U2FsdGVkX198n24IYjFcJRs9XUTO95iaG3jQb3VoDyh0zdc7lDvgAtg+BchfHhy+3NNBph3jJX5AY98I4H+Qhv08H7rULk8TfujFWL5Zt1Q2tsmh6//aFuRw5xCFVCxCDYBW79kAxgY/grzgMwk9qawjhqdb6UI2JRQF3HZFIagHPAfYEA0E+KWQdFfCL2eqg9YSLO0CwyUcGUGID9TRUmNduUjggFau4b2ovxaoI0jert0p6hPkfn/pbfTNMSOKJ7ZZbTs6RjSx4jeSuvgs5BGNtaVxF+gInvqsf7piR08gGfI7MFDPXs6AFzTWzTOGs5q3whfRiQpJk3VQzTz9kvd+0uqoA5veFyELwujY1L8IgYzvUGLdIEOIpkPbrPSoZ4oLJzrrp6N3QuBMA1IIL2Bchs2BqqGghw3ph8GX3sqUi7y6nZqgwitmswzXRgN3vQcmzlZ6CG/jYxi8mOehpQL6zvmxptRG6id2e9r64h7irc7UFNnlMj+5Kvo7JHB1SshfUwMtP45upR6O1wuMxaOyZhsmOmTcp/4PBBY+h4XeVcVpbstCVfh4YKiorKNV3AuvvgQ9PXJNQUQVIED2WdhB69uEHkndolas41/zBXctj3Tvdp2n3EIz4t4ogsc//ydhsLfx3ql2nNrzhVt+Cg+fnocLgBjmb3t4OkMhQRyTYmo+lihyEU16Z7/Hz7pfNbgTYwwit7MyMCrEwKx+VGu2pdwwn8qDKphq1UGTUZa6b/8Sk1btovZ1dIYW2UMXgEOgP7qrb1Q6q1G4WzwZQsp8CVZfuCel/CPzPyp/+qYHYS+NOzAlhTuWVl/33g9/cYAc8hK5AZpVWPCfdoa1fnkwD7aH5wV9zHhoooiNIFYAlXrqac0V80Jcc4dgzJjApNpWHxilR1N/FuM16+XKhUuKpBWWBAEr02sQfEnVt4Tnyti0AnxJ5KkW1KYF90EoSvJY8X62RC6tzF7D1R2 jKnsw4Er 5Nqwi8jRVRTwVn0zfSWywQSAClkk5sjUI9UE2lszmjdEH8aurWTEPiGMbB/azvBlGhk7tSj1lRV6DymVZ/OjKykc6lXeMlsw2W1Cj1udIWPZHuxYD19V07lRtFYFuAijHP0cDnTvuTqHUkxAIpB8e08EzLMy+U9LRmgQwYMVznqoBp4G4P7OSF4+IIgc1NHD5jl8cTeTo1aU4r0xW1TBCfFn3w3qC8kt4QV3cGuu7xWKuKcnGJ4KqeyBFN5cD/uZXcBXUqVTjfPqEVRx2gbqiZk1D9gGHvgKkU6gqGmHfB23uZN2KgSqKXNOg+JF7C0P6hrsRASdSo/sssD4o2xUABT51dlobJV4cyWRU X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, 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 | 53 +++++++++++++++++++++++++++------------------------ 2 files changed, 30 insertions(+), 25 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..e2e115adfbc5 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; } /** @@ -631,16 +643,7 @@ int invalidate_inode_pages2_range(struct address_space *mapping, } 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 20 15:47:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13916938 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 347C3E77188 for ; Fri, 20 Dec 2024 15:48:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2CEDB6B0098; Fri, 20 Dec 2024 10:48:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1E3046B0099; Fri, 20 Dec 2024 10:48:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F03076B009A; Fri, 20 Dec 2024 10:48:47 -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 CFAC46B0098 for ; Fri, 20 Dec 2024 10:48:47 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 92878AEEF3 for ; Fri, 20 Dec 2024 15:48:47 +0000 (UTC) X-FDA: 82915768698.19.A3336E7 Received: from mail-io1-f42.google.com (mail-io1-f42.google.com [209.85.166.42]) by imf20.hostedemail.com (Postfix) with ESMTP id D89451C000A for ; Fri, 20 Dec 2024 15:48:09 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=uvGsjowN; dmarc=none; spf=pass (imf20.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.42 as permitted sender) smtp.mailfrom=axboe@kernel.dk ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734709693; a=rsa-sha256; cv=none; b=pT12vSWdOhMd2OteW66Kft0/GnHSHPEf2i71AV1BkkbEVMfOz2Tkq5QtgcM44WmAPN1d9j 5glS7cj4vS6abtH+8dm6D/jHZNWMKtWKrFzOgRCZcbK02ZRC2KsXSuZxOjnsMcIxbEpnxW X0MimRAg4EpL01eL8NeLyWwDVMVeIUU= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=uvGsjowN; dmarc=none; spf=pass (imf20.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.42 as permitted sender) smtp.mailfrom=axboe@kernel.dk ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734709693; 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=LbafXs5kS9xH53BRsUlC23/QyztJelE/n/gaKisYPdzo7k1q7Lu6sQExARIoS2FHsnzNLY Y/pOMiALdEc27kyMrfDkXNY+3VBTrO7oHTssfWmcimqhRUoYQcUISOJ0DIg492xufB0g3j BBF3QTF7j5nUh/eISYcFb2n+H6qJEH0= Received: by mail-io1-f42.google.com with SMTP id ca18e2360f4ac-844ee15d6f4so158514039f.1 for ; Fri, 20 Dec 2024 07:48:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1734709724; x=1735314524; 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=uvGsjowNZMOEk+83jamCcivzA+PkvKh+SdrUHOWbEWOtShT9S9+IvYvByWCP/nKQ++ CPtAGyPG7TPBS/ZInEspiSMMdCx+ZQBaIi8kAy2a4X/Vpr85xO3uEN9X6mxckUCEcz+9 wIGPJ9UF+ODbQCE6rYa1673FNcb1lMU7mHIPFCrUowlJCedGWz0JBKBiMA+YAIiYIUEy nNflkRKmmcZbpHN/o/BszjNHJykvEG1yfr0turPFKQ1F2dhqE4F8HHAMstDXhvkGgh6C 2jvTKHSIG41fYr1b6a1naoeBs3RYm7x55wGRaHXEzhOAQozWSr+pVwNlHIWKXCXQYxoV lNEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734709724; x=1735314524; 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=u0onHsZY7xDOQ8bez1UCAjeT5AkN86PPDYTpIkIXQIihrlC62v6JhOuW+++TTAMKH7 qy0JqJ/ZquRI4xHHIEGASe+ShOIG/9Aw2ZgIReqxTDeB5K3v6vRM2YoCuffLnuyXWhYd /CHqE8tBWlt8BMX0dXbCYxF/vx0fT5JB0ZK5p9XtTSV29K5wJ7EV+YK4WDr9CrYGrWWm OoxS7n20llP0alL2gCmam3RifIgtDUlq/TfIzi0//UQpqfNP4J6uETuvjMrYEmqjVCKH IwfLUXv3Ayb8p9QoLoPM8JZw1pHNYp/d2fa5ITJ1GXKtklOJ8AkwuiZV754AOe5tHoxn ivnA== X-Gm-Message-State: AOJu0YwZw/f7muSzRtR0tvxFBDccH5E78/LcY8sFG04Czk1fempbtSN1 uVuS0Y1V09zblu0eo9gxAJBTWuaLWqOtBaoANGz8UYPD4Blo/3HKa1I6KA6lC4267R6gV1N8gRC o X-Gm-Gg: ASbGncuclhv6lEC6OplUG3/Kx/dXivnjcv7OVEfO5wCfDGhldyhlLX/5zJz+MF0BZmY amMpdUoVEzDHCvco42DyBZs1ds+ZELjydiLzt3ABhsj8T8irNqhgHlS4qI4jZ9YZdh6Wh0EnK/D 7aIUv3tM31c8tT/+tAwuhLbxFNi47ZLfOcgleWglrkMPiS+TXExKLOTAS1KYYpk4qa9tlkrNd/H 3LAuVH7fPT0ov4xUcYu5rT5nKkLSXAy8BfNIRsYIBSTMaRMD3DBwVtzaD/R X-Google-Smtp-Source: AGHT+IERkjVXfRiBHnc8FlfnVZJTgamzH1zCvDow9NijC4/j/GJhywdFRh297ssQYYJsqQo3rjiWFg== X-Received: by 2002:a05:6602:60c6:b0:83a:a746:68a6 with SMTP id ca18e2360f4ac-8499e4d888bmr383870539f.5.1734709724489; Fri, 20 Dec 2024 07:48:44 -0800 (PST) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e68bf66ed9sm837821173.45.2024.12.20.07.48.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2024 07:48:43 -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/12] fs: add RWF_DONTCACHE iocb and FOP_DONTCACHE file_operations flag Date: Fri, 20 Dec 2024 08:47:45 -0700 Message-ID: <20241220154831.1086649-8-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241220154831.1086649-1-axboe@kernel.dk> References: <20241220154831.1086649-1-axboe@kernel.dk> MIME-Version: 1.0 X-Stat-Signature: ieyrdiat5yr71nnieyrkuirw19pwhx83 X-Rspam-User: X-Rspamd-Queue-Id: D89451C000A X-Rspamd-Server: rspam08 X-HE-Tag: 1734709689-316975 X-HE-Meta: U2FsdGVkX1/Tw7L4lv3bdUe26Wnn2ck59VhTRFtC7szDpPHWL9Ox3hJwVc3G3/OcxB6AdwdZkcic7psBz0DeCKtJau2VXPKxH87idQMGNX7d+rPYIDtzlXTEpJwe3XOz0Xq2pbdg4HesZLGh9LJ94DfT5XoEUewMWBo90YeQH6slF7XIBAGQk9MC3DulSwHFB6FlwpCbVYNAr+DIb3pxwZ5O/KuahQEl5tDHKAUfbsmXFa+t08C2nPgpmsnTIOaykwdmQkbzRAGRmq0SPwwDU3Iv2/muO3x0G/mA5OpS3BLbXyMtAsfpMRRJaM7vsiCZKw1m4xRcJ0i6FkrFa5MGdoVQcZ0KT/SXLZCLOgqehJESsNYHSHH42MVYwLMO9x45TtOOBA/bn0a4S0h4WUdUwkWMzOQBLojx2cc45PDK0DSqyS38QgGaFc9N0T0R9q/RPxqJERYn1Mnb36utcno63hiswLkZQ+PDSOn8sb1u2/6GTgUO/j3chtKN7fFNQZVu1HHjwwhpfNXAYBC8O+EnWNlE5HIV6CzpWSyoXWeETEgwrL+sw0/fhJ+eHxhQOXkP9GI5M/h4s7ID58Ky9U8VFFRh6yRFPe3jaoC//uaTrV7KEf+urXUvcUrYx0pOAwFZBxfEqNedreG47XySo/avQrwD92aNa1MK6nqBi0gr+GWmVuK1DrfM55GA4OBphJMbE5Qy3V/wY+kw7FQ7mKQm2+eLXpxSwAVI+wVbbCzTeC4lIYMGU3g2pitifBdcbi1wUi8k1tHMOdzrVia3sfyAwclHnQ3L/5beGFZyHM92OkWc9WMaj9GlnBuN5jAUg3uf6e7qVqxA8FjbQJGPoGZ2VFczBSvge9JNfF85bgFA7KfnJhB5kz2B4CtNHeL1p2tuLzTFPYB1lLaHUwk5ainQoBJzXGcVzD8AkQPpqlZPOP1USmQ1Dal64DZ5PS0/pZAqn4E9/9eGSFV+IBeyUtT lV7QBpl5 UkiKJ9/Kl+E/gOsdM8UjaKSE88craL+Zy0x/NwQxfggCWVhyk6tp4TgYuRqdawQGkw+c6a9KFeOzirIrl9/xXgeH2uqx+nvibvTybgl064bu+gcfsRRivnq/ObA11A8K+RhkaENF2NG3zcCGLwoO1GU0uhvEHZLvB1NlR6N2bH/Y5gt4ksacVwW0K5dfNlZVYDczGE1pcfTZz26L3lagEBjqdLix/CrwAG6GtDBc83iop5GcppYl28sBxTwS4hyz6MIY5RH+W3ECEGkn2JoRQUD3WbMSXASBMp68ZTR43MoKDLMBh1Ej6r/2bRIgbuBwjuwiFV3w+L1eNbE9hVP93DHllp2AFkRudIYjC 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 20 15:47:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13916939 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 E3870E7718B for ; Fri, 20 Dec 2024 15:48:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9AB2F6B009A; Fri, 20 Dec 2024 10:48:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 95C8F6B009B; Fri, 20 Dec 2024 10:48:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 787A96B009C; Fri, 20 Dec 2024 10:48:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 54DB46B009A for ; Fri, 20 Dec 2024 10:48:50 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 131A2AF883 for ; Fri, 20 Dec 2024 15:48:50 +0000 (UTC) X-FDA: 82915767984.20.A9654ED Received: from mail-il1-f178.google.com (mail-il1-f178.google.com [209.85.166.178]) by imf18.hostedemail.com (Postfix) with ESMTP id 945391C0017 for ; Fri, 20 Dec 2024 15:48:31 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=2eX0Oqxa; spf=pass (imf18.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.178 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734709691; 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=ks2mp2gCJ77yF3ZCGIs6WN32l2VaUGiu+2pglDT6eiI=; b=DEX9g5q7LaW+9yRq0XbDvucMqKDkc5AdnKVU3XbzWluIdhpCOg4n7A7pAt66QKZA7doSH/ jGejtPBAKNjY02qUhwaFZ6AIy0f798MuPKHdC8YxRp81F6u7rZ4D0oVbvlvYUetKYhK5eT JruCvV+F72t7a0IfN6wV6u/Lf9Dak10= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=2eX0Oqxa; spf=pass (imf18.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.178 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734709691; a=rsa-sha256; cv=none; b=8aMgRONF5xNS1JKHX7k10jJf08BSyxJi8hLlaCOSCGtGPSqNk2eawqKfNAFuTgWF6bMJKo xneqhiQDgsgBgSxAxmX027dO2+wYVUCR19mnGeQ8THki5CUBJCAaBj07R8myTItpVGhiJs 5oE0mckC9ibnI8ISkdaeNxhPTwEBjq4= Received: by mail-il1-f178.google.com with SMTP id e9e14a558f8ab-3a78b39034dso6240935ab.3 for ; Fri, 20 Dec 2024 07:48:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1734709726; x=1735314526; 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=ks2mp2gCJ77yF3ZCGIs6WN32l2VaUGiu+2pglDT6eiI=; b=2eX0OqxafDINvG63AdrPljvfhsQ7cjr2teE9Er5bA4he+8NHVCDhS2vKSusfrd0x1l gI/gMVOADmj5qUdYcuhrQW02bwkD7WMdU1ggCIFYU1MoyppWiOb1VQKV19O+XyMopbuz OpNn0fVc6175cC1rB9eUdeE4IlPa1O2v6D67pTep6ZNbhPSQOiIqSYWAtYcxGJZPbHyS ePd96Eo/O80yomiitTxowUGPz0hlQDvq1rDA9GsDAWshCKW/yjZl+E4Lyej5Q1hBLcSF PrBRSCZXldPCrfm3mlGeE2sWvKnKiwgPbKJPHBuXBDn4LnnviZ9HRjoT4CrVIbES9XgS FKrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734709726; x=1735314526; 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=ks2mp2gCJ77yF3ZCGIs6WN32l2VaUGiu+2pglDT6eiI=; b=R0kwmPf+j86bRlVqtnNiHNKa7Q/WOxxTlTzjVEyeX/pRlaNfozk6QsrWEwixbTdi6p qq8gSAT65XmQ3296FDZqc8hTAYN//e9UVd1MPjpKVhVN449tKr0xdHpSGytgtrgFzuyg NJIsmgyK3J31GsTfdiv2hsgXimrKtKLRMTY6pTzHSn4z4SpgjZNspvBVPvl1sXnKX2xp 9WFOwn306zow9JRKyGQLbo/9PwEPcvfm2QwzNg1Me59wsA6BSxWZ6NOt8WwC3bDTLCzR UIcx68n8rUjciWDZziLgJZOyzbaG7tvqJHy4AHrUx49mBwCv8xAHBymkdIchYDxf8NLV f6+g== X-Gm-Message-State: AOJu0Yzr1Ug1SsDEE9B5xkKYzq6/0rg6/HYoJardPm9bXYYDNmuaGhUk HaD82u5+1OWYxvK+aB9YOVRFq1EAYhjZdCqwspcp//KChRclVbs/8reydXN5voqHV02cXrVsE/z t X-Gm-Gg: ASbGncuk3Y4OIpWN+h4+7xSAhbcjcL+WMt05LcM7JU6rv7OPlJ6hIwpf1g/kkHYKsLK IJZNST+1w02dASTjnKSbnZfQBGLhDo2//+zbES7ERfbYPssirppppAX9BToraksNfm6CBAyzfqQ rU7VFwJmOPWI1UdseJAhhRyTFD4B5WLQ7khekX13mo4HmLd1njLbDHFb3qxRXwTXVhh4fPlCR1A 1/gpMlApVhIhrsjO73FOLq/rrIwi0zpi3cUatrryAK77AHyP6itJFmJtd1n X-Google-Smtp-Source: AGHT+IG1Q5MpgKTbxJc/Yphg2SqFQXSKzJLSB4ruy07feq+/t9lmMQDAi0QHm0P3EjCYdC27xoRmeQ== X-Received: by 2002:a05:6e02:3201:b0:3a7:be5e:e22d with SMTP id e9e14a558f8ab-3c2d1aa3e86mr30848135ab.2.1734709725732; Fri, 20 Dec 2024 07:48:45 -0800 (PST) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e68bf66ed9sm837821173.45.2024.12.20.07.48.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2024 07:48:44 -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/12] mm/filemap: add read support for RWF_DONTCACHE Date: Fri, 20 Dec 2024 08:47:46 -0700 Message-ID: <20241220154831.1086649-9-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241220154831.1086649-1-axboe@kernel.dk> References: <20241220154831.1086649-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 945391C0017 X-Rspam-User: X-Stat-Signature: cgy18wiwu9x7ncxpeytwdohtnk8mmnfi X-HE-Tag: 1734709711-625257 X-HE-Meta: U2FsdGVkX1/3ioBYfIwMAymCHmb7H3TV5dq6hp36EeXce/UbvX0v5IX0shOO7wSQcqKGTzR/JrM7cED7crPRxi3fdSpoQs5g854BWdMoofOequwPC/HZ/otxnKHoZhGZcQSURNYnPSIe/aZ9CDpfgnhfJHFC1geDbO4rHiIngQLNybPKq8XAyORwHRShDzs4Wd6TUYMbfvwpjIBwDaeinsVjqOAyYfMAdm8UFMsSfcVgrFTGtN464kPdJzepYPl1GtSMCwYq1iHKXlcpAcV4dw3fhVMFhEbasrB5J8hTZidVzZ0P/H8sMNgT2tmDUZNZAoe3IaKZ2ZtsIvO9a6yAo6xEAY5P/gxCP51aie76JRQI52YyC/f+zMKdR5ed2QFCUqwUXg1SkV5E4Q7Z3ei1fykcs2kOJNXEdSK9nn53GbisTsBgyy4CYFE/f1z1oXgAyaz2fbpKXqSMbSl5MyHthkzPFlqIW0aK2Ybiz+j0d3gFtggA2lq5Nvlf8HaXBoV99M6RF77bPJnVD06yPSs6yYhKUaYC1wpmCfF6EwnHmMmmj5TwXYxS9Q7A8k/tv/Il2Vpsw69OcLsrQevOXTMgRE3UQNwz+GJkqvb81PjswO4aHrmi+md/fKEG3imLL3YdH+vXKfbOUqbb9LAwyjF3nOOr9gUu+IT6I11CiNGeA8DStHn7DfvwQc6hwbtJTwq2Sa2tnxGC8JfFKvCigZxad+o63yPMap+llAmNwqssrswqhuZWHpefk5Qk1a5Roi/NmkgdN+nA3RfAumg0vovZPgc/PkkZUXhYF69pdNQSRttVEt0m2vOvTzWDjWsI8jvzNBA0M23+LyBnl5O6fIcTfBLgQuMtE6jqk5GPW8NjBILYry0RxlVmAJksWixxgLAv6+TWr4LN8RBeSVh58PV7yxpCJNtyctpOHhkwuFX5bMko7HwSed16U3JnuMoK7bUOu7dKPuguGOl6puiHJRe zmR0bRhF WOvc8RrQYTLGP1QaDWcRWwuWo6MkkT2dBkYfpHDLK8PGdxkugGJNH0GJWxZkQYCM0JWUnqJRJvEPsyKMsB78m5AZSjOTIvn2yEZqT6K9gXwd6oEFI8x7B4JO3tApxXCc5ryB76UaY9pBqvFt4RfnixIXnxUl9gs9UrmaEdIoBbV145o2yga4PqaHuomFpI22emgNVK9wIFfBHXPDg5cVHqVWrkeCGRccGAT94NdXVnursaDxdX3t7hCPpFvjOJOLtGtKU1W/0JBphKTdSjj7PggIj3rziDiBFogzv+VIWiAoLh88yLa8ISuVtwMGdtodWESiVz5Fv9hDEw4xjmgVyuylc1HelKs5C1sOf X-Bogosity: Ham, tests=bogofilter, spamicity=0.002999, 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..dd563208d09d 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_end_dropbehind_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_end_dropbehind_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 20 15:47:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13916940 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 B2BB5E77188 for ; Fri, 20 Dec 2024 15:49:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0D1166B009B; Fri, 20 Dec 2024 10:48:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 00AA26B009C; Fri, 20 Dec 2024 10:48:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DA0B36B009D; Fri, 20 Dec 2024 10:48:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id BA0D96B009C for ; Fri, 20 Dec 2024 10:48:50 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 4BE9E44B91 for ; Fri, 20 Dec 2024 15:48:50 +0000 (UTC) X-FDA: 82915770000.28.1B1E17E Received: from mail-il1-f182.google.com (mail-il1-f182.google.com [209.85.166.182]) by imf30.hostedemail.com (Postfix) with ESMTP id 8F3D680017 for ; Fri, 20 Dec 2024 15:47:42 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=gD5SDLdE; spf=pass (imf30.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.182 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=1734709689; 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=CWUKIERhmBif0xELkyRs9dlqXC97dRJQR9fjviiscOo=; b=LNXgW8YhXQF9NKR1Vq9IXb4U8reoioKr4D/Xui6xJOK3Izk2gKXlGug8y6mWTBpQfms5Ke oWgnQ+Lni0mHO5avfvQwFJmvcQfUgLWzIeuedMNL5ZW6PMEMdLcfpu3OWzirst6CUq75zc 4xXSA+0hQcxY9gH+jhi9CG53ALHi054= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734709689; a=rsa-sha256; cv=none; b=e6BWzRZmYNZdzMAQ7+wvZfyo4HqMXt3zS4t+CMWqAbHUv3t+GxEV7uWDekZ+Hp0N5NIL3i DJmxhkusuT9nLpGtKRnj1Q2jn2lnIFINd1zrPEfa+/t9qmG7EGd+aMpmR/BnwlIRHBAamU fhnlCWxhnw2/wp+8rE5slT1TxXbYZmI= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=gD5SDLdE; spf=pass (imf30.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.182 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none Received: by mail-il1-f182.google.com with SMTP id e9e14a558f8ab-3a8160382d4so5926695ab.0 for ; Fri, 20 Dec 2024 07:48:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1734709727; x=1735314527; 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=CWUKIERhmBif0xELkyRs9dlqXC97dRJQR9fjviiscOo=; b=gD5SDLdEGC75hacCs4Bwt4h/Wug+AxvmDHirqYObVOoVNGZ36pFmntmXpF+HhzqqiB AEQV7Qj5tJXlGIljaBdTS8+RV6sv8M3JVe73hbgS1lkTCVAKLk1F1JJtHM0qqHQqKd7P 8kk/3CRnYYWDapYAfNqohd/A5OXoVjWbjjUNNn6Mz9oB9j5xJe6SzA/nn19NB3ljz0GQ Ov0NxaT1m6cCWzhn23A1lrysXSIRwQANqtRJcKTWzdYq3sRpJ80UDx3vF0daqCW3yeJw KCfNcnWSIeFPb1X7/drKMRhqlk9zX0S8KsXi4nZgVxrKAEynCkUGAMy1HfjjMF7mtQbu jvYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734709727; x=1735314527; 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=CWUKIERhmBif0xELkyRs9dlqXC97dRJQR9fjviiscOo=; b=ALuEB4O6j5U1o4Eg9UnIsBHXxxkdiZIavHI55OE4Y2uYqZB2wSG0vL5nQxAIh5Ne2v Uhgpc0LGhzgvb0cM2yXfhelEDtA9ddTq2vHRxM29DsiSVUqQeBLLcxuUpRr2dR9ticoy g/lOAz6DEoHl+x0hPE2tj0tAvSP/xeWQinYuiFlLxO7PEVHfD1VAu2HCi/CX0IyrLaYY fVtNVVbIrfrlvvt2455RTGEaRfAANjmTTFRn5iSGqWyoBMObKUGufYbZ/JJw3gByRssH 7AerwJIVthnXCukqaAH7K7VwQGNTnUQGn3vNTcmw7jIxXf8Lo1mkx6yGNKCO2ghugOPx Bd5w== X-Gm-Message-State: AOJu0YxFZJ73KPc2vDcyfvcI8/lNGb90i9bXBmsAZ5EAi23hTbSq/yOB XbjkHzUgNaFaTN9Zh68aM1YFkTGNecH03rMaz6LKyzYfIhbmCgi4eJkySKVW44BELut3ocw9JAZ f X-Gm-Gg: ASbGncsZnQyFgISkG9BWBiRsU/dpEUK6VGSLN0PnoOjkVRqP2b2JnDrcFooLfUt1pph rakuHeuaju7wCeDJBGjv0uH+EV/QJ6eY7BObJV6yNdGklgPFie2kwND/P51Y4JZchT4FLW+iHVb T65r6Npb7toggnpDfeM1EAGLCxkpJ6QsrM5FBCJlzyDpHTHS3CMR1ur4V9rOJ/xjDHMUwDAW2+q Tyjqxcq0Y1abHK2qI8dLX9O2pd2Q1LhPEU4n8pjyIvkRcPDqGkGB7Di7mms X-Google-Smtp-Source: AGHT+IGjD+wBfW2QpC5lojTx62UJZa1o0QwQiIlqK6Hx/4wukTE9KhfBEOmSehD69MzvwKGp6r7FTw== X-Received: by 2002:a05:6e02:522:b0:3a7:e0a5:aa98 with SMTP id e9e14a558f8ab-3c2d2d509b6mr25164805ab.13.1734709727201; Fri, 20 Dec 2024 07:48:47 -0800 (PST) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e68bf66ed9sm837821173.45.2024.12.20.07.48.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2024 07:48:46 -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/12] mm/filemap: drop streaming/uncached pages when writeback completes Date: Fri, 20 Dec 2024 08:47:47 -0700 Message-ID: <20241220154831.1086649-10-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241220154831.1086649-1-axboe@kernel.dk> References: <20241220154831.1086649-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspamd-Queue-Id: 8F3D680017 X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: ennfz7q1z5qn8ox3qbfqthf4a6dwtsrw X-HE-Tag: 1734709662-522190 X-HE-Meta: U2FsdGVkX18b2kcXsodhHtBmEYk8TQwZBAzUvUhfW2D8appr2HdwoPopdnDagC/08IDPt/xaJLhxDzkaz1+PHcWTYE8Ty78y3+6dotAhUPRt+lfTvcWZncVWj4yCVKxoucMY4088WoYHU+R6iq8HvHI5gl/NZwisQtgsqy7hnLliUvQVPUZvtI9iBhzN4Af3RYSGKRExe1Mt3Ub7BoZx5rP/ukq8ozX2B6i6a8lxznIzEHP4sBOT2vwoSpe55ZIzidwRWrRt61+0MT3cXf2Zc4/l1YN+k5vO9tbBZs9vcYNKmCnlRlddVAqnTSe+7ko4g8AYWz93Iuk/zTzRZzHn3YVhZ+/fW6GgUWx5999HzS52QqMPMtbO5bZ9q4/LXaz4FjJn9Gu9yQf6+MFp33h3+1Hnfv/qDQ3LambGnh7psNWPkqPYzzzwdA+Al+1Ix3eJMcS5VzjQ1RXlUJgb4DO8ygaSfUeyjfD8a5hmwuY0WVG4HoCqxNqmn+k83DIu+ORhmcuhV2UI7fZVajkvngButULOucqQIQUdcLvbI4+mgAlVoDfcfCmVGeN4V4+JszZV95qrUhqSng8M60/+QkcOH3FLzoS+HpxXTVkiHypd0wu1oxRAAUibGtZ+RbLr0YU9KmLj7nlPGH+JYTfBbJr590t9j6BnxUrvSUE84X0uTusIOXcwZ0cJIJHIjYscg7AMgjtVNDb+i0rYflB6hjobBLnYKzUdWl/W50zmeDpcCvTFl8b5uG8DSqkRl7JFBX6RHo9D2eJQflFjLVu4fceHr22uJxSF6nKTfE+iT/nmxZ7Z1QspJdtIob7QYbd6GpF7z/566iuD/1qQENRqrYx4EeWxJoXq6xGK6ITRB9bUYB3RBOJPiS0vegZ4jqlTj2TORGJFIVK9hSRuG03MXyFFJPirUUexi937n2KnwjF41nNTnPsPYEvcXM6JVcdT5AQpYhnzMfhWsn9drfIR7dw 5e9ZpRE4 XAM/dJAC60vI10ADz1gV2obqHj/dHQ6D9idXWo/EasYlmE3XRhaxtKk5rr+DRbDw2WuDBGvLvqzTxCCo8cBPh0MSTDunGsrxd27WQZ6c4uTs5KrB/IN+HCLf2ZOykHFa2RQX0O9Mh21fGiN/SH9ahThpXEWgtbdsqmXvYeLcpj73WVWZFlBUelhS2PNJ9jrhsIC8hK57ZRKowqE8HpULmsPRHkcWBlNizChPYUufPyVL2CdGKoNntjcTlKqNMIHxtjYu4Zq+7gCNhkk/sZ2+aOKp2uZenJj1Jta7Omm7tTqbmHWw= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000474, 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 dd563208d09d..aa0b3af6533d 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_write(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_write(folio); folio_put(folio); } EXPORT_SYMBOL(folio_end_writeback); From patchwork Fri Dec 20 15:47:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13916941 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 6F3B6E7718B for ; Fri, 20 Dec 2024 15:49:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 16E116B009C; Fri, 20 Dec 2024 10:48:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0F8F76B009D; Fri, 20 Dec 2024 10:48:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E3D2C6B009E; Fri, 20 Dec 2024 10:48:51 -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 C074D6B009C for ; Fri, 20 Dec 2024 10:48:51 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 7AC0544825 for ; Fri, 20 Dec 2024 15:48:51 +0000 (UTC) X-FDA: 82915769370.30.F2D7F45 Received: from mail-io1-f46.google.com (mail-io1-f46.google.com [209.85.166.46]) by imf27.hostedemail.com (Postfix) with ESMTP id CD7A240015 for ; Fri, 20 Dec 2024 15:48:11 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=S4AKQo1D; spf=pass (imf27.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.46 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734709697; a=rsa-sha256; cv=none; b=xYKvKSC0yV34K6WZq5YRf4RwjbISeM9BRjfvuL7OsuD189VfrThHr1bmSNdHqhS9DSzyWf n9Fc2uPfhHgkZ+mDY/j7cRkviewrL06F6M4fp4r7yuYqp7XDudU2d/he1GO/ZuNC/IKXH5 PM98uGqeGrVvCzuZ92IaB3v5ZVaR4fw= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=S4AKQo1D; spf=pass (imf27.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.46 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=1734709697; 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=Z4qQwDJE6vdlPLyJQIpmMrltr90cAGUkJZOMxstE6os=; b=0m/YbHondvlxajIHSsFS3IMvCi7isr/N8oDBwgpiYTbZ+PzvEVH/ft8tijDZ9PoneBBckn 1JaN5fac2UZCjpM6yydYXAMl8OhTGwc7mWTuDh9D+5ASnMX2t10rHnKBQcRH4hrBG0JVMX t4EaqccEWEsl0svMm7t/T0RkOx2AyvQ= Received: by mail-io1-f46.google.com with SMTP id ca18e2360f4ac-844e10ef3cfso154742339f.2 for ; Fri, 20 Dec 2024 07:48:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1734709728; x=1735314528; 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=Z4qQwDJE6vdlPLyJQIpmMrltr90cAGUkJZOMxstE6os=; b=S4AKQo1DJSkhSznA/WEuA6y8EHgiCOAj8dC7l2MPBNkqW319iXnayNThKZ6EIxdL4I OdU4Xylkty4IYppioo89MKtGv8tt7B+djavKPJ5GKkPTTrgpa59uq606p4XGJgO9/fZo IFgnosMwYH6JKLPrlT0BXn+qGLmJ6ybwOkUANIdSqPxGxSPTpci9cD6+xYzNNlzWQogX ZPvaUIX4Dsuta7ztOm4os/VFPV8vdeNrKEd141u53XlRbUzREyGtH4WAXny1DwHGkjdS foIRNgcJKtdK13WrXum7IGV8XYXpE4vXQo57r7+vjn0rUbXMIlVDhLxEUIkvRAlwC3e5 13jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734709728; x=1735314528; 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=Z4qQwDJE6vdlPLyJQIpmMrltr90cAGUkJZOMxstE6os=; b=mvkHETzqCLHOdqaN/Iu82PBOf+ytU4G7hc7D3p7El6QxMCer0XwtCc+abpLMJmIOsr PSb1BD1+n3XrdZLfMX7PXPPjP2eWVv56GLNlM4wVajrj/xvwWIpjGg/GRdFcnxT/YERp FQV7fq/rl2z8Xz0cJTQoGo4lF3N34ZWLNmjn/nkRc1n3BMDKWpfJAVoXAShi4cVlir9c f8Qs+B1L/gC5q6XU+eTLl02+IMzGQTDbIrr8JXSXzwSGlLsjClGMMW0xIh4XYcGobvhk t4BxXxN1/B/8RfIdYxDF5w0nS08viYYo4SHT+yRPU64WctoYZ3Cjif0Y9khdRNchAlui 8VPA== X-Gm-Message-State: AOJu0YwJXf7j8XLQ8g50xZt1kLvUMiUR8aqlYHnuSMJ6E/DHsySUurbT U2tHeksssm9u8KWgRyi+nNJR4YdciRf2KaX3vb6s3wv6U03g8/jJSXSqP4vXX7T+7zB3FjTrgN3 v X-Gm-Gg: ASbGnctMw6kuowCEjBgCU5n3im+w2nLcf6WSFsdv+Hbicy5aUvNxdPACWKH+siA4ozL lzNtIN1uScsFtw19mEYXx8jvCEFi67uKYm41h2FuCuDyKPYeVyvFQVAn6ntPWd9ZssXwV7kcGYM TMzksEptw4d/Kg0FGhqwUkgbYa+wWeLI4KkCxvK2VSYqpGQAtUDP9ndAsGPKig9sQruT4CJ1iBq 3j5kdW2HcvoObI+fViPxeqH8lRTHs73TI1xsoz8cgNunJD3pcgNNQ+uJHaG X-Google-Smtp-Source: AGHT+IFGv05g9yMPyknBeMlKwprAW5pwl3vrHXnYcOynrc2BQ0O5hQEIENaNx6lgdvRHQ9LzhuK/ng== X-Received: by 2002:a05:6602:158e:b0:844:e06e:53c5 with SMTP id ca18e2360f4ac-8499e4fafe3mr298729939f.8.1734709728444; Fri, 20 Dec 2024 07:48:48 -0800 (PST) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e68bf66ed9sm837821173.45.2024.12.20.07.48.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2024 07:48:47 -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/12] mm/filemap: add filemap_fdatawrite_range_kick() helper Date: Fri, 20 Dec 2024 08:47:48 -0700 Message-ID: <20241220154831.1086649-11-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241220154831.1086649-1-axboe@kernel.dk> References: <20241220154831.1086649-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspamd-Queue-Id: CD7A240015 X-Stat-Signature: n1kz8d416ur1q9a8mwohoco6zscbo7bh X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1734709691-642805 X-HE-Meta: U2FsdGVkX1/sEXJ6Mby+qw7eQtXb1LlVWMake4tLTLAAhsPa4AiaI+Zt4ZH3sTjD0wXYTDgZA7ImxdfpkCVCAhIQ6CEKrxktoZhfM4c9aZc7QEnSiETozEPlm/uTwoc2oiSkJ4IAMjUVz9FhuR1GnxCKG3iVqX5V6qqgFM4N0FFWyyqPI8W5fACPh2sw94vdQGHKQ57DYNCgsBGHS483OIWrZBKJqz2FzOFIdYAmuky0L8i7QH95KoYZ5H8CeWCcVcFWgCBTK7hYTY21ooUeQ5CTb6HfFgVjPTk7jK+S7d88Kg1tyat4322pdZU3TMoUbK/BAobfMKOylxe+ehX1DlHA8acPzaetJM3dHXIRbPOoYhAc27qidedb5+Cf4+GQf4nzpKaQsXdVM75CwO5GqCV/Wt0WeOm44pKTDKQLplaGzkVavx6oPFAmyyOOLAeux76nEZUujzo1hXns7oI/jsAqgi/f6luAxzKZalFjX5K28GufZ2L5jBkaxS3bBnHBvyDZ/8ZFcDT2mHoZUab9JbIdG42w6dM1BjaMvgIAb1PhCa+EYjzjREDVahaRMH5xRz5L6MObkH3i6q265BqqlS7jewYruw2jbdgHuK4kytAWK8EEmTpW22qR4Z61BrRK85i+fBjSgdQm1JU8PhX3SJ3eJiiYQ9iaFulQ3a9i2ZON5rQ/JlPMrshYY/hiteyQLYHrzZ8JTFfyuTbkv3G6KF17rX3qzPXiE+IgtYyypakvJ3WAJOKQg/nL8IUv058ZevywQooGpr9E9SwWoUSy/rBtStZwCRjr6NWxkg/qnoX7of9n2Syupe4CE3K1+VphQd79lqnE1z8drvFB7/oCfwOZLFXWwi8hwfCwa673NFWsqaQk9PrWs+anf7gupij3IZgKDXAyjL4ksoHw3iPwZ8vRQLKpM0bXeZ4MHvQbiDd+ENWvFda893OUHcixGTVVphy8Gy0yAzKDJAKjm68 k2zmDYVm OhAx6QZtVFztYUOTZjiX7/4iX99V4oSOfhf7Z/RXV3jA/LuqWAIu10TVk4F3LR8td8RjsOykYhy2RPdG4MzMZrIjV1Eb14ASdd/V8B0aovuSd/eRrkAevjsQo2wLdKiytKpX/4WNsxLM8hTNlNOKkWgsd6kY7N0OOnsZBvHoq2/5iHrEtyqhnssDnRDxxmogVxHYMD1pugJbOeO6M5vm+JMPgV7xetw4cb13viiSuSfds/zyUukBU9yFSo7zyTa0J3K0gWb9RBw7qxfBrlALrrbo/ttOx18QTUC0M1Jvn+zWLL0oE4H2NV/HLcB1UHFHpFk5Wjrgq2kIyA/BDQiprGEwUinHM78R74E2J X-Bogosity: Ham, tests=bogofilter, spamicity=0.003928, 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 aa0b3af6533d..9842258ba343 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 20 15:47:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13916942 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 50AFCE7718B for ; Fri, 20 Dec 2024 15:49:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 898096B009E; Fri, 20 Dec 2024 10:48:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 849826B009F; Fri, 20 Dec 2024 10:48:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 64D236B00A0; Fri, 20 Dec 2024 10:48:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 41D2B6B009E for ; Fri, 20 Dec 2024 10:48:53 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id F2B93C0AC9 for ; Fri, 20 Dec 2024 15:48:52 +0000 (UTC) X-FDA: 82915769454.23.5C65638 Received: from mail-io1-f54.google.com (mail-io1-f54.google.com [209.85.166.54]) by imf03.hostedemail.com (Postfix) with ESMTP id 8B7D920008 for ; Fri, 20 Dec 2024 15:48:35 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=IbK7xUiv; spf=pass (imf03.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.54 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=1734709714; 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=uVoBVcpOeuigX1FPMguOJciyBXm3/j7EesIs4oUVbTtmF8/DMeboafx9RB+mOQkuhbLiB8 ftONcKlulfQRTja2VYLAi05iTCOmzly70rA/BCXBUZb1BuX8F/ptZqqq5nJfH1am5kFOwY ip7W97WvOom71y4gBOcwrV4pUx94dh0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734709714; a=rsa-sha256; cv=none; b=xpPTF4fR6xy4OkFQgN7dmV7LBraklUx0ey2l1EAwWwWM4WxgMLmHKYYXUw0PrFdXm8JuQd MJwph3nmq15/15jKGZ8SRLhzzaB1j507TFRZ+EZW8ehku9WYq93lGKQi+dY7Dpf7LVGZ6b gyPoPlyLnKQl21KzgdwknNsNfd0iJ64= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=IbK7xUiv; spf=pass (imf03.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.54 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none Received: by mail-io1-f54.google.com with SMTP id ca18e2360f4ac-844ee15d6f4so158521439f.1 for ; Fri, 20 Dec 2024 07:48:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1734709730; x=1735314530; 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=IbK7xUivchFkmTsx/h1hvsaU5DF7oLka4F1ocNpHLOy1CJLdqvsazsTgDK0OGkKiOr qVK73UTM0y8/TmWQz/6QPUUcr3fYDtMfvQpacWZPKW+NzXU2wqnSmughgvYUyCLc/i5f o9QeIrZI9810EpNOikoX3DNzG7lSsDEib53uhEpBoLf+9R8UcY6C7mDeinpBPClxv/Pl MM8cVbh3fdJXHCIz+xeBhxVtObUOUgqi0ZTcWyND7EQZ/FgkplWk3sgfhCHaJvtbEPuG TdQyKYXEa/+VdnEbAP9Vn7Kq8SJ1E/t4B/YSpQlLS3GcqyqLOwJKlW28LMz1YITwxD6u OCBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734709730; x=1735314530; 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=i+ZrFJ9O11R8IOYxE3+sz8tn1IWsAvQ687WudwZUfk1IlC/VbqakTon2+Q0jPkYsUG I06+FA0C2B1RPaDcOK2izZpedjW8g4tUDeCAtsFmOYLC/eo7E+JJ59UYz30PFDib11ku OdhvlojI/Hqzmy1YqxrqoMEMdWMzn9cExAac9ug3W4R7RI87pA3kZzs7lQtEmc1DvnoW nbvXBR+QFl7MDinbcA4CS79VErqxZ9kIkel+Me0b3BZ2/1rVuWQbBTAnyFIJr+kyrugo CB2vlXg4UFeKVmZuJYI8F3HrdGCQEJ8gNU9oVNbW0VyawFwwRcUyv2Jcqzo5Klklr+rZ xezw== X-Gm-Message-State: AOJu0YwzdA3kyXR7kpBjeT7yiR/CT/tS6tJWNVqj9bnFMZCw/DFBRnl0 Ds3I7qaqUOw7nSDqs29tryI8Sa6GisQS8l7RvGiLelh93kubQ1unZ6TWxbMztSEkovZvIUR0Kg9 A X-Gm-Gg: ASbGncsf642PK90a+oDUJxwXWAtVbom4aml9bgQUngaOR53LXDHPk4QLUjaRLtGUdIX YDRfK0IWWD0oO5rqsVVO9ZkmWfxtDa7JK/iFs2FQkG61GB7pSEC0SSimeaR/+tjG3AmpcPalMWk v7iRETOwjcwgLrbuk/5HQ9OSKiVkTY5bS1qLDahn+ptJJxh0zGFd/RseyjJZp/tJJBYmMppZaKU 1T44GcDqHmbJDFDV0iuzYFxNER2OGcQYM0/tEV2EM5jIvY7sxnMTiinTR5R X-Google-Smtp-Source: AGHT+IHBkJtXw0hIyGWIXWPfQ49T4FfZrn/htFVCpySmbejAxdhZ6x6C0BhRXfs8Jh6Ol55mQ+pxBw== X-Received: by 2002:a05:6e02:17cf:b0:3a7:70a4:6872 with SMTP id e9e14a558f8ab-3c2d257934dmr36428035ab.9.1734709729627; Fri, 20 Dec 2024 07:48:49 -0800 (PST) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e68bf66ed9sm837821173.45.2024.12.20.07.48.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2024 07:48:48 -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/12] mm: call filemap_fdatawrite_range_kick() after IOCB_DONTCACHE issue Date: Fri, 20 Dec 2024 08:47:49 -0700 Message-ID: <20241220154831.1086649-12-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241220154831.1086649-1-axboe@kernel.dk> References: <20241220154831.1086649-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 8B7D920008 X-Stat-Signature: fyrmrosgxp4c5jzdu43dz15xw6nydk79 X-Rspam-User: X-HE-Tag: 1734709715-444908 X-HE-Meta: U2FsdGVkX1+SbhzujuN8uL0QS0dvp9Oz0OJ2JnAzStgHjafxD57KogSpT9iJX4HADT3xHofvp5WnQj7W0xl1EaQJ6FmBaaIPXsKAyz3uGq3AvmzS5AhvofjLMb0gYWF91GmlNzuzM5hZ36FyUFaMarsbf5dW+oEFLXN1IQO6m5dHHySAYBvM7Bb7QXvrqi+ZdcGROkRzUd9zBEtANIpS/IZDex8v8tR0VN1io6M+/0tv6VEBJDD2imToDp6EuSg/qbTppxTNXqk4dMjzh1EUniQk35lC8NKamX27Fv3AXLSDD45kZJBROrZ/7dQXBb049uRnEIK5FIErCIqFXerHuhhXC+s51eW2WiSJJulIOyyZyLqor0KB8NJLhqGRR8N0tHJjV+7jCbp5vzLavUk7yFSrJIIf9+4YeZBgFS6gYvpinRohTkhn6fz1tF7nmtaN4S2jjs6znGJ+xt5sc95DYCOOuB0ezgv/s85HdGu4a9y2I00KWJkCVSlpINIaArXbZSSNp/ZPUPppiRN160Lkl4smQlwtDqvUevuGWuxcANCQuZQ2wAxujX7Hi2pJHP1oB1HZPoPXMWSEiMe7vMQED+cqFkXCT1ucXYOdAgH9luhby6DzUKncWs9o9aFSAzp/uO3IfOlBPvEN0lYvqKhiOJZAOTvcf0R5EvpXylHW99atl4v6yxqLTBCN0vIYT4nJDMFVNlxNYvLJDoZqYzGM6styeqktWvyP24viTMIt4otdcUo5cBY4cHKRDkT5pYdVFvRstldDCPVNIdhSKTN0wdUarotI4qBFUDxScVtUPjacCd3P5T8GHL1nZuyjef4Dvmwdu+SyWYs+rhGQY81zuYVuQT6brkN5K7FUjyO280lfCXoga/yhYzve9X6VrOXzLo9OeJHsgUiSqzNNDzndNBdTXuikUMH9rJNW26WSfjZ65JEQcnREkJZ46QP47vku+R94Afr5NUllEnTf/XE rNo2C0ax OeNoaLzTYa8V55+N3/t8Mf2ArpNzhhFcPmGQzxpk6Vxc2ulA/BeEY9cCX3uy3aspFmbq0C7ZiId3qxg4QaVijkwFpRGKP6OYKqdgtOdpeubhfnBy8FTQWUDlum2v9iRHRwT/osGtjZJDWJtNoT/vI1vI0JD85OFyoTtMtn9f0iGNYVp9gA8zHivQrGz3oj7+mEcSxesuVeCreSoRVpkC9g4Trr53hzWgb+wAqDnIG8XjHomDwDM4ndltTtaroAGthe2GYGUjQdNYtYEAhPQVpoCdgOVA+R8A3UVipfUYr8BROhzzov4I7925TbMo0QSTj7s+ysXtrI4Ls5cHqKKxMLTWVg7BQypBiU/lN X-Bogosity: Ham, tests=bogofilter, spamicity=0.009639, 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; From patchwork Fri Dec 20 15:47:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13916943 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 D9EA9E7718B for ; Fri, 20 Dec 2024 15:49:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E19296B009F; Fri, 20 Dec 2024 10:48:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DC86A6B00A0; Fri, 20 Dec 2024 10:48:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BA5146B00A1; Fri, 20 Dec 2024 10:48:54 -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 994CE6B009F for ; Fri, 20 Dec 2024 10:48:54 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 37A66C0B53 for ; Fri, 20 Dec 2024 15:48:54 +0000 (UTC) X-FDA: 82915769916.16.9A0D15F Received: from mail-il1-f179.google.com (mail-il1-f179.google.com [209.85.166.179]) by imf16.hostedemail.com (Postfix) with ESMTP id 4717818001E for ; Fri, 20 Dec 2024 15:48:17 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=dqVjau5L; spf=pass (imf16.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.179 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734709716; 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=86GdD84SMshyNZnB2LgwxYI5vb/3z8g/QfHnuRLr9vU=; b=5SLivOTERfF4Y0mdHERfAx87ekdKeWsme7Lyo2QtKKFLqTqHP0tEindctk3f4QU/oCoorc JQ2ORp89gXDPsyYShLs2/NOX0nTGY3A1TkV8KZh44F1RtPFVNW2K6PHxjM5pghEeDiv48W swIVlF0DZgVWRlQJEniQPLEwheafiBE= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=dqVjau5L; spf=pass (imf16.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.179 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734709716; a=rsa-sha256; cv=none; b=dDkp6QG0p/y2o7Fm04cW5JFSVbHygB0b7NCyjMjvbMQA1NlpPxZm55lLXiabIkpdAX7LFv t7DLzFn9ysfPDJvS0Rhc0TNAfBXukvYnz7mb0aYggGEej1YMxPeTXNaH6ILKXLSBQtVFge x8XK803TR7gJ3Ye2Pvdlq0uc6cW3V1I= Received: by mail-il1-f179.google.com with SMTP id e9e14a558f8ab-3a8c7b02d68so14944175ab.3 for ; Fri, 20 Dec 2024 07:48:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1734709731; x=1735314531; 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=86GdD84SMshyNZnB2LgwxYI5vb/3z8g/QfHnuRLr9vU=; b=dqVjau5LHNFoNCA9KK63lBJe2oSOtOzu2whqpRnj5buO03uuTAG2iV0pVrvQHAYSjC gsIyIkSrwPpijOYvkJclFZaKQu2hdSMr5ruaLwP+SBWKK2TyQyK279uhRCqA/VVoMbQg D8p4yWg41Qm+55FtphdHJEiK4vNhIV8HUv3BchE4JRAWGwaB12ZtyIYC7+b+beDBWxOF 88x5pn1LzGmt35KuwsfI+neSUysWukj3jB6TPdqvJctWttky0eT4RlciAiBbjO12HTho gy34uVIfPgMZ912arOEXEpcQcDCLX3zgQh2kaETS0oHqgAed+uMBlPCe7zRsPQ2gJybb 6zpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734709731; x=1735314531; 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=86GdD84SMshyNZnB2LgwxYI5vb/3z8g/QfHnuRLr9vU=; b=kKsMriLf2MiPK2WbxQ073qAOnDGWNoEhqemtApN44RKY+b3X6CKUq0UsNi+8Q3mOb+ DIaHThgReum66ag5BOcNH+9XtBRgf/eFFdHgZFsYYmBbwhOoxcQswJsxSMFhJl/DLJlw grMI35s51d0HoPqV1gUUkiabbdhGUqXt8dhxTPKwsJEbEPmdPhyLzX1408P1TFMe/qZD +jnd9PVoP5KX1sNpUI0x8UcUHslKfzkCmyQb1s9RX0OmaQ0MVnKGyFQWjgz1OVLh7sA0 Sk8ADcQUmYAM1iXGu/51RBA7G2WPbVMeHuwsetsTVL5okbuKK6NZFeCyGHaYyH/bnX0y 2/Dw== X-Gm-Message-State: AOJu0YwxCDl1i6LRprw94mrpOJrKIreVADdRlGs58gywXoSwGdBMKOYC vlsl0MjYrpidfmmh4Ak26BA1D/t7VWH68fz/ASfOzvEFoiedazUoey5OSEw98a6bAj2dwvtEHlj 5 X-Gm-Gg: ASbGncvjXr6+KtUmYAkxrZe5iNN31vYsUdELhv4pT/2mlQbuBI/npVLdYsUWiKuSr5n IxOwrnoa0af/h0AjRrHEL4td595SD/e9fibb8z93Dz5V9xcRAJI3B5raRGFptKcmvZwgc8eHM7U t+naomwcRZ6PkHLGv+bJcUPnwV9yQOYmwqTjoI75AirDjuLh6EMNi+xKMRsUflMz7ReH6CdaLcr Ae+JYwliFN/6qR+1wcWk6SuKkz1nWu8SLJJTkB+DOQ8khxPuKCzPUxiWZKW X-Google-Smtp-Source: AGHT+IENwEpB78XkZV/FFvO7zp/8wAKDMGCn+bUr8XfGQ9+IvUs//gy2KTAuIDXDGGYGOcgB+kegLA== X-Received: by 2002:a05:6e02:20c1:b0:3a7:e3e3:bd57 with SMTP id e9e14a558f8ab-3c2d533e943mr33235325ab.15.1734709731154; Fri, 20 Dec 2024 07:48:51 -0800 (PST) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e68bf66ed9sm837821173.45.2024.12.20.07.48.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2024 07:48:50 -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 12/12] mm: add FGP_DONTCACHE folio creation flag Date: Fri, 20 Dec 2024 08:47:50 -0700 Message-ID: <20241220154831.1086649-13-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241220154831.1086649-1-axboe@kernel.dk> References: <20241220154831.1086649-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspamd-Queue-Id: 4717818001E X-Stat-Signature: 63mz9hqanicqqm351riy99a7ogora7sx X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1734709697-773948 X-HE-Meta: U2FsdGVkX1+zW+00v5aHv7G7oLsPEX1BW2l1Na3ESropn+N3DfiWhxz1svZdj1Bf6OFGMV+N74BukKzeeIbT5+3BSkA4veXx3uStYWOr9F0kc1X722uLx0glapd9XN4XZ+uCI9d/SfSbwehbZTTeHZcscj3oPWnBmukk8zp11PhIzkQxCYzwi63iilThLmb2lLP7KlOPIinQ41Zv2X4sisM18L0NiwnRv44MaV8vjTaMSXjI9oSPDAEGdOFkkmFpvYzMuAX9MvimAOl8ODcZI83EwLCnkyulH+bhoX520Hw9RCoCpktBWv5XFrvQbbBP7mpAhNLeAU6zdao2EccaB5n5cUuRTwpbohV4aPKhVa2eXpIm1FBIXRSjApJ8i+gyfgZk+PjhKE5vRMy+L1+0CIVt+k1kX9KZKxzduuaMCdChx5HixEExWP8T/dfzfWDI3OOZKMHat2fsIijTKkgrO6kmfCb1vwBwNxqLfI9LiHKPKiVrLa30ySyCHb3CtBI3OqWYCUMGKLzKyT1qtmqSNn7QHtUvuTAU+xzDQCC3YrDV7qZCRkuhkomZpIEzT2vmzOhGPzOnN0V/Yh+TybtVZZ5bTkRvKkFqRE+VTCaWsNfVBpH0zWv9sf3DDCa8d6GnR8/wkxAruuqPU4HPADUM728gTPu2tgOKZGkZ+SevYR/e1WQQhmc61xwIiJCsvqReJ0QZN7Zm5r/HWTq1zJkU5PhDPxWhsgPD1JZAv3xafvOKa3NB1oVak+wZuIBkdpn0Xko8vZ+fSbwn0Z8ZYnv0FdY5jtX0Dowkz1zVfyiKIT4uXhxaOOxsLrPniuGAgi3zBWnOi1doj2O/sQeD4Jh5hUI/uuxePbx3OZzXvDTWYifp2SvmPOxa7JKj1BUKwzCDutdF0q9RiTiUhnmGlaqnpAdZ6DOP1WJAQcQbFeX/zfDej+5/c8nurzvrPcMKKMhMtJb0Z8pG83rLKdithIl Jt+Q2khG Qj2RPRJ9U+2lQwoZ1aMXcpvNatFZ+n1eMuTdDZh0Wm5hwO/Gasl/x+ORmvapIxFowxS8p8+F8i708yaOaqa03tSO3D3BS9y8J95p36OI50Ke74GHtDmK1GxlHlEUKwh55LEF1CHte7JgMI8QCZJsMLWyN5xKVv3Efn7+UbyC9PoYfyMaCldOy2BW775uY4RKJxeOeSb5bRuUn2wgQje/gW5EOcZ1xPPJkvQbIqTSR8Ybqi2jbxfY/yt0kl3+DUAPZCdfDbE2Fmp44mfX3KyELO/hobdj2JhNGRt0JCwM7cGS3ZmTPFKoLgB64WmdnghF5ZpXqds+DonfcJDduvx9IuvKAVc57pkXmyKwW X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Callers can pass this in for uncached folio creation, in which case if a folio is newly created it gets marked as uncached. If a folio exists for this index and lookup succeeds, then it will not get marked as uncached. If an !uncached lookup finds a cached folio, clear the flag. For that case, there are competeting uncached and cached users of the folio, and it should not get pruned. Signed-off-by: Jens Axboe --- include/linux/pagemap.h | 2 ++ mm/filemap.c | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 5da4b6d42fae..64c6dada837e 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -710,6 +710,7 @@ pgoff_t page_cache_prev_miss(struct address_space *mapping, * * %FGP_NOFS - __GFP_FS will get cleared in gfp. * * %FGP_NOWAIT - Don't block on the folio lock. * * %FGP_STABLE - Wait for the folio to be stable (finished writeback) + * * %FGP_DONTCACHE - Uncached buffered IO * * %FGP_WRITEBEGIN - The flags to use in a filesystem write_begin() * implementation. */ @@ -723,6 +724,7 @@ typedef unsigned int __bitwise fgf_t; #define FGP_NOWAIT ((__force fgf_t)0x00000020) #define FGP_FOR_MMAP ((__force fgf_t)0x00000040) #define FGP_STABLE ((__force fgf_t)0x00000080) +#define FGP_DONTCACHE ((__force fgf_t)0x00000100) #define FGF_GET_ORDER(fgf) (((__force unsigned)fgf) >> 26) /* top 6 bits */ #define FGP_WRITEBEGIN (FGP_LOCK | FGP_WRITE | FGP_CREAT | FGP_STABLE) diff --git a/mm/filemap.c b/mm/filemap.c index 9842258ba343..68bdfff4117e 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2001,6 +2001,8 @@ struct folio *__filemap_get_folio(struct address_space *mapping, pgoff_t index, /* Init accessed so avoid atomic mark_page_accessed later */ if (fgp_flags & FGP_ACCESSED) __folio_set_referenced(folio); + if (fgp_flags & FGP_DONTCACHE) + __folio_set_dropbehind(folio); err = filemap_add_folio(mapping, folio, index, gfp); if (!err) @@ -2023,6 +2025,9 @@ struct folio *__filemap_get_folio(struct address_space *mapping, pgoff_t index, if (!folio) return ERR_PTR(-ENOENT); + /* not an uncached lookup, clear uncached if set */ + if (folio_test_dropbehind(folio) && !(fgp_flags & FGP_DONTCACHE)) + folio_clear_dropbehind(folio); return folio; } EXPORT_SYMBOL(__filemap_get_folio);