From patchwork Sun Nov 10 15:28:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13869954 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E355D12D43 for ; Sun, 10 Nov 2024 15:29:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 867956B00BB; Sun, 10 Nov 2024 10:29:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 817CB6B00BC; Sun, 10 Nov 2024 10:29:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5F25A6B00BD; Sun, 10 Nov 2024 10:29:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 347E36B00BB for ; Sun, 10 Nov 2024 10:29:33 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id E6C2012081E for ; Sun, 10 Nov 2024 15:29:32 +0000 (UTC) X-FDA: 82770568608.23.0BC0AA7 Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) by imf18.hostedemail.com (Postfix) with ESMTP id B7D911C0014 for ; Sun, 10 Nov 2024 15:29:13 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=ZTwkxnCW; dmarc=none; spf=pass (imf18.hostedemail.com: domain of axboe@kernel.dk designates 209.85.215.172 as permitted sender) smtp.mailfrom=axboe@kernel.dk ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731252509; a=rsa-sha256; cv=none; b=P8ZqhsoSCBFLfz5ESlceAkR/eEyYaOsH1ad8nmG68Ttlg1uEHrDnhu4R6waIteHRTUYCFN dRiHcpTjrQs8aS8AyffHOxpDJQLp20YIG9mpR1AfhcSsJnZvKLgNDDfeJb/DWerV2Ds7BY lmN0Gf7FWEOB+J9xqxcPqG59EDjzsbs= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=ZTwkxnCW; dmarc=none; spf=pass (imf18.hostedemail.com: domain of axboe@kernel.dk designates 209.85.215.172 as permitted sender) smtp.mailfrom=axboe@kernel.dk ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731252509; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=2Ft1nD1O8TW6ajHAbmpyRJ7eqllXRgDsj9KVxLudGNI=; b=0JQtPgZqG/svYm56EerWUtC8i4HmpY2z7i6ceZIFWrniLNHoCcv1mHLybkm12QCPrgZ4F9 o5FHwnMsdp+1xW+Yhuet9a/wzJUK3KkmZ8wPinCVfGGiN4wD5s3qDcouM61tEsZVyUO0Ls zmFIuBBEB5/gtW0eFdftJIif1VE5JMc= Received: by mail-pg1-f172.google.com with SMTP id 41be03b00d2f7-7e6d04f74faso2601701a12.1 for ; Sun, 10 Nov 2024 07:29:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1731252569; x=1731857369; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2Ft1nD1O8TW6ajHAbmpyRJ7eqllXRgDsj9KVxLudGNI=; b=ZTwkxnCWWQXadgOi0Zd7ymv1hgIwnIPaFEqG4A7AH1ANtP7iJORUHorloLpouFlHFi 08dFExld5dGcnLz5ldXY9nbaBh0XFuV6R5eMS1gkXyh9+izk+pqy4QPP9dGZ7xsrHX9l 3HEebp2gJmsPogSMWfAfwZRgP+qfsORSiiYqbp+zYY2H9w2beUTUMEr50dziN9t+s+jz IAmwAub6ubmlZ6XgXfdEJ9NZk+6QDcMrJ3kvDar9fq1mcq+9lDhfZce5RaMYlvIpPHiG pJ1052zn3xmUA+CffRlPujq1OSsGvmu3pYynxMSrmyxxQD+xbvWMel4AEmvl4+1v3Npc Wsdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731252569; x=1731857369; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2Ft1nD1O8TW6ajHAbmpyRJ7eqllXRgDsj9KVxLudGNI=; b=lVK+QswUyP+2Hj730tpGi3keGtzDCF8iXgDeJKsdfExpXr4DjLKm0etbIriTb70t2W TbXZP4bWPVhrT4EqSkt4zes2cC7q03GFL9tQiCelnVI5B8bx6yX+ZrjH6j+H+3pxP8Cf k9Nb++DJ+z72qzUjAIKohCOCX35HtpsuqbfVYqau6lt4T8Oxb9RKGYT9LMO9QVf1CBpI gIo/GOh9uLu8S0Pwb46Qi8guzxYgAtkakZjlMaf8HD/ywn9XGEPWt3Qw1/FkrLFvCHAV h8X0P7ZIiUn/K6o8O2Ryi5E9uBAVLGfyKfTkFS9F8nJEEcTy3NAhwdhrS/Ye12PzZH1K 0UpA== X-Gm-Message-State: AOJu0YxD2YWDtzFQDfasZmeDK84AuhtVx5/tJQNUVu1iaYC0zgS+U3zh VrRMbeFYOlsMFjePges1pDRHxzZr5c7nWtBTKBOx9PctAc4hIjCJifuATI9kip9FOTpenZjaedu 6LIc= X-Google-Smtp-Source: AGHT+IGnzg2hDaZ2lVFGocJncR7soOdtnLL/Yc809zXi6ImqKmn+BDcRSWipzylZxh/jlIYcFDHDiw== X-Received: by 2002:a17:90b:1bc3:b0:2e0:7b03:1908 with SMTP id 98e67ed59e1d1-2e9b0a57d33mr14506762a91.10.1731252569648; Sun, 10 Nov 2024 07:29:29 -0800 (PST) Received: from localhost.localdomain ([198.8.77.157]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e99a5f935dsm9940973a91.35.2024.11.10.07.29.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Nov 2024 07:29:28 -0800 (PST) From: Jens Axboe To: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Cc: hannes@cmpxchg.org, clm@meta.com, linux-kernel@vger.kernel.org, willy@infradead.org, Jens Axboe Subject: [PATCH 11/15] mm: add FGP_UNCACHED folio creation flag Date: Sun, 10 Nov 2024 08:28:03 -0700 Message-ID: <20241110152906.1747545-12-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241110152906.1747545-1-axboe@kernel.dk> References: <20241110152906.1747545-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: B7D911C0014 X-Rspamd-Server: rspam11 X-Stat-Signature: erjjbgqwome6m5wifjxjawd3169m3np1 X-HE-Tag: 1731252553-108428 X-HE-Meta: U2FsdGVkX1+WBKvrwD4MUMZROEIGm2qCdu6SOv12UGPoNr6Lyb0+VRT4VPQrNxQv4O+jRAJ+BZ8X/WqyW+qoDhZ6YjPqTSmpGjNVToe2p859szGHikf1hX1N1WuI9Uizo66SwrWj0TWaRX0spKxoHIFfmmn+z5mDesSTExzVZxKfb3glfrNc2nccnrDMo5E1Q5iBb1yqzYC8V0k9uk/phNFPjuapcyGyKtspnrP89GOqGBjV4+R6NRVaUsDeLFxRMJV/GI9C9zzGdioXkeA2nmgMzeoBaSCeZPtoy3hRUspM1IQchfTO60RhnR8idtGXuY1ERgxpYTGTacHcgl5+KwcYztFuOF3sUiNk3zCrvkN0K04AEC6ouPX51/Grq04CCEiW5TX9dNDThBjfBYRPehoBuWQ2C8OMVYSSPqu6G5abFDl8JJ8sGqH1nzpwCN3VQkNIf6CPGFjMKxGovNtEi05jKBcmjLKhCw1ifji/fGgusjK1gb2GydA7Eeup1VqTUWiH5w2Sdew6vbwPeciL2vavWZzC76BzSCHM7VzISki25T5jTzsBIU3jOsOlWRAnFunMSkIr5mSc/FVdYUMxl2y2xoNhWD60rG1k2Bjn4TFEfMK3XXGPzWMaCCG3pfqmNZDnd5e4xNRva4+HyCsRR2RZdbF4dv7sdufRavfQ3q8/oabNOE2t370l+scsbPcibV9EXyVRqmejyhTYRO/Bedv+/dLYMEXLs7ZkL9+g1cS/QJV3AVsyqfLZ0O0JuWd2qianhYn3rn3s1bn/GL4V3akdhdlpTDSl9sRw49KcbE9ZijdxOhx293bJVhJ61iratWzY143h+DP9a4memLQKdAiBIAqDbseHTESpSc5oy9vY8N94toVi03Ww9dsZ5sAVdAYZOMTJdNlOmX/Ftib4iNhSY12rmVaAO3jjAD/uyG8sr/zDrcYZG+sRderOdznYU3Ey4/a/4a+okCiqbev h3rYOFww XS8TluMpFFnEUtfJf42p/13EwYjsALxUE/HKx+bCguvyyCffVQ/uSspsmLAMytme3he6r2MVtuMAXhna+O2QV/UdaMnbpkSkt1M5Adrn2p/l7N3JiAOuWSjrIpOSUHzPHFxl3YwE8Nsq3FCIEPqEe588BQIqn9+wmLORXzzJkVlRz6p5HlozHewp0jNtH6cEgi4AhlwTCMyoL4eeykEZ108Nnjjev2UL2UyKrNf5rMkQNiyroD/0EDIKgmitUy/bjHBAt+MU4so65qo7ueMNo4BJ21zCr173oViHCqukiJ1nTLyZpazM1x1L+UyW0H+4B8+5ED+eeFAoEphVe3+KMOKkHzDD1AJF8wVlz X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Callers can pass this in for uncached folio creation, in which case if a folio is newly created it gets marked as uncached. If a folio exists for this index and lookup succeeds, then it will not get marked as uncached. Signed-off-by: Jens Axboe --- include/linux/pagemap.h | 2 ++ mm/filemap.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 5469664f66c3..de0ed906cd2d 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -741,6 +741,7 @@ pgoff_t page_cache_prev_miss(struct address_space *mapping, * * %FGP_NOFS - __GFP_FS will get cleared in gfp. * * %FGP_NOWAIT - Don't block on the folio lock. * * %FGP_STABLE - Wait for the folio to be stable (finished writeback) + * * %FGP_UNCACHED - Uncached buffered IO * * %FGP_WRITEBEGIN - The flags to use in a filesystem write_begin() * implementation. */ @@ -754,6 +755,7 @@ typedef unsigned int __bitwise fgf_t; #define FGP_NOWAIT ((__force fgf_t)0x00000020) #define FGP_FOR_MMAP ((__force fgf_t)0x00000040) #define FGP_STABLE ((__force fgf_t)0x00000080) +#define FGP_UNCACHED ((__force fgf_t)0x00000100) #define FGF_GET_ORDER(fgf) (((__force unsigned)fgf) >> 26) /* top 6 bits */ #define FGP_WRITEBEGIN (FGP_LOCK | FGP_WRITE | FGP_CREAT | FGP_STABLE) diff --git a/mm/filemap.c b/mm/filemap.c index cfbfc8b14b1f..4fdf3c4ae00f 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1987,6 +1987,8 @@ struct folio *__filemap_get_folio(struct address_space *mapping, pgoff_t index, /* Init accessed so avoid atomic mark_page_accessed later */ if (fgp_flags & FGP_ACCESSED) __folio_set_referenced(folio); + if (fgp_flags & FGP_UNCACHED) + __folio_set_uncached(folio); err = filemap_add_folio(mapping, folio, index, gfp); if (!err)