Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2295280rbb; Tue, 27 Feb 2024 18:18:24 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXBXHKd85yLIPLzlCjCmkq2l4Abhlvn7VGv5ISxrSy5tQrl5vWa4qDw4e4igoniAywnOeK0KjjrI5ga71pEPOcjCL6I/bAgYuVGh1t7oA== X-Google-Smtp-Source: AGHT+IG5V4mDi4eKkUpIS89ZjifpbEZlMIOXPvu9rxFqp9EQyrOYZEUXkkwWg6atVE8VCeXGY8Z0 X-Received: by 2002:ac8:5cd1:0:b0:42e:a9d5:3b32 with SMTP id s17-20020ac85cd1000000b0042ea9d53b32mr1361457qta.62.1709086704069; Tue, 27 Feb 2024 18:18:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709086704; cv=pass; d=google.com; s=arc-20160816; b=bx130OeCfYcWStD+qDa+6WLZ01FNU4N4jVsNq22sYnkMvfa7Dz3cDXf99NiBdzcPrS Z3XW1uVeTpRvgvoeRffRzggiSoNn9L1uYVgLrhgbAdo0myRX3rYYzb6e8az+VWnutcI/ XbElN5ggKb9TL5PsNZf7zIUHkGX/s2kdhDCbNKLfsyb0wfSwaXVF5KpGsMMw9VqdghKn Bd4nkhJj76Ep23nuaVu/Cg2lyTQIy/csFRnLakx5czVuwyG/KBMDMC8FOBBsssjYwU8i 0+NS4mrMbg6fk9XOpBaoCVkvB2naORJSFcDKwDPtk4YrJOmkuzK6O75bxe2Ec6y28wKF l42Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=mnovH/WwqoUfUjM68lvOHqxD1r2xoiTwaBE2RBdRmeQ=; fh=Dw6XmeiOCdsDFpVV+cRjG7uPh4S2DnK4pdCP4Au99co=; b=paxEtOYSXv1BJjnxdA5NiFoZpkKR41KjbOVvhFR08rQWOTQ3zZW9jbs+iGT80BINuQ uyx2JvaoiEw72BXh947IIosnfFfph76wBku8VzRuqM6uXBJjzZ0X9XXiM8gxBmKQQnFp MV9Hn/RLEv5d47nc+siTqy38p82kmOxdB+BnQrmeMh+Fk7L0aFbBeoKuAepgHmyJ7CVy n9M++TxDTHzNYTk+RybbDplUk7NzqQzygmNVAY2FwFgHbQbnV5mSfoNJ2vDAO74yMSP+ dQ6P1tCbsvOJqOUENJCaS1wqG9NKUQUzDwNTWe9kPvFca3EmWZCdj5sxGvojmnCld2TR Kx1A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ppEAyUak; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-84411-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84411-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id s26-20020ac8529a000000b0042e813efbb1si6035354qtn.440.2024.02.27.18.18.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 18:18:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84411-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ppEAyUak; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-84411-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84411-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id CDC931C23E27 for ; Wed, 28 Feb 2024 02:18:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E59AC134AA; Wed, 28 Feb 2024 02:18:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ppEAyUak" Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7913C1FDA for ; Wed, 28 Feb 2024 02:18:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709086695; cv=none; b=DgxbWO1oDFyRvEPLDA1pFir93H6fhupY3XsgJ3v94TWd9wAKyj5Z++n1q/MiG+/RvOVKH3XMlyVRBwwTCUcXuVUlKW+Rldg5krdjITCxiGwld3Mhh5qZJLDn4xH5/R2uu5axbzLkhZbK7b5TolZ61d9Q/9M9wIyxrxQXvITmwVc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709086695; c=relaxed/simple; bh=wAJMP/rjGSTVeulk/izYYwgmW/lGJuNoksrR8Forbog=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=m/xl95W4zMmmZP2pWRWKQ+DuDyZtNdON6n0Z4p+xWO0gMdDxv51ljetiJ6LU7oB5nfph8agKOc5jvv0X4K3ImMiScyw88sQIOOW3avysqyMkfOwLXo4UUWK/Bn2Ze1L6oAPqslmGONi5ev2Y209xBoHmO1n0rmwm70L5DStpNXc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=ppEAyUak; arc=none smtp.client-ip=209.85.208.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-565ef8af2f5so3549989a12.3 for ; Tue, 27 Feb 2024 18:18:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709086692; x=1709691492; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=mnovH/WwqoUfUjM68lvOHqxD1r2xoiTwaBE2RBdRmeQ=; b=ppEAyUak2msSbz0GDvZoh8d+j7zul/4gR+KjBlqqEFZvzY9IVaJxCTPb+O3NgqFWIL LbRkCciGEEoDZh2XmdUUJpctWN7PGih0Tky99SnIW9ZWNvL2ZC+6X5GYSlJPrNbxyKiX 8+/spiuRQVywK+gmQCUO4yFxiYh2MPrqMynE/uEuHbvrMgyyMcjmchDZxyErze+6otb5 o/Vn4edZssixeJaST6EJtLyRnQjgXfNfxqlWB9zvARV33nCdzrNMBcSk5J0ppqvVs5tV vU2SX088K5YMZKp5XUg53UG8ZxY1Xf6Qm/ucrOy7co6xjIwYv8p2n17o0UZgKIAFAtDi As7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709086692; x=1709691492; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mnovH/WwqoUfUjM68lvOHqxD1r2xoiTwaBE2RBdRmeQ=; b=kvTQ9pyyLfrwihx4mXDDtYyUmAEcJmc5xlCg/VhzUo3ZyDBPRCzxMslwllSR67B93o xu4TB/iDJtvAn2FzueelY2Lm08oHP3Jm9kSFK3UNO/IncwP3zxK83x3KhOdz08v9rY/o jhfP2qXm9/jZsVC2L/eOpPo7XGEoi2d9LDEJYa7wN325BTBuQVKaL84kE617tynTwgH3 CbDnEPykiEkkGYtHHGx2pO0k1mB6GbAdnC8ojykaWQUXsAlubPPhZVo7SM9kN2qw6TRK 8EZKdvoXiQDSTS6rFe9nQoHG482ao2PqfYuD7w2dVC4NsQVCrSrBe/eoWJtKQ+6gncdU 8kig== X-Forwarded-Encrypted: i=1; AJvYcCU72FwdMumSI+3Jfh8Mmox0fhbH60RS1HujEPdqqi1oBfxo4WO5pUiNFIrx9Nlkg7FuPZZKIrSYjEPMxMe+fX1Tb9ibJ703ipexMPdT X-Gm-Message-State: AOJu0Ywdu1buchpqv6Y6FXchRPi48OA6IM0QXxLx3NaGwFaQgIPr3Bhz M3xhYyxN3Xjes71k2aKVlwB6w/i2jwhNP2tE+qi4o7ddfnYhc/pkGupSUdxlmLoZPqj3pjvkokN 9XC0SOTFoADrRhw/kOW+jlhRWHp2Uium58DHu X-Received: by 2002:a17:906:4809:b0:a3f:1b49:c92b with SMTP id w9-20020a170906480900b00a3f1b49c92bmr7585886ejq.48.1709086691753; Tue, 27 Feb 2024 18:18:11 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240227232100.478238-1-pbonzini@redhat.com> <20240227232100.478238-18-pbonzini@redhat.com> In-Reply-To: From: Yosry Ahmed Date: Tue, 27 Feb 2024 18:17:34 -0800 Message-ID: Subject: Re: [PATCH 17/21] filemap: add FGP_CREAT_ONLY To: Sean Christopherson , Matthew Wilcox Cc: Paolo Bonzini , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, michael.roth@amd.com, isaku.yamahata@intel.com, thomas.lendacky@amd.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Feb 27, 2024 at 6:15=E2=80=AFPM Sean Christopherson wrote: > > On Tue, Feb 27, 2024, Paolo Bonzini wrote: > > This needs a changelog, and also needs to be Cc'd to someone(s) that can = give it > a thumbs up. +Matthew Wilcox > > > Signed-off-by: Paolo Bonzini > > --- > > include/linux/pagemap.h | 2 ++ > > mm/filemap.c | 4 ++++ > > 2 files changed, 6 insertions(+) > > > > diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h > > index 2df35e65557d..e8ac0b32f84d 100644 > > --- a/include/linux/pagemap.h > > +++ b/include/linux/pagemap.h > > @@ -586,6 +586,7 @@ pgoff_t page_cache_prev_miss(struct address_space *= mapping, > > * * %FGP_CREAT - If no folio is present then a new folio is allocated= , > > * added to the page cache and the VM's LRU list. The folio is > > * returned locked. > > + * * %FGP_CREAT_ONLY - Fail if a folio is not present > > * * %FGP_FOR_MMAP - The caller wants to do its own locking dance if t= he > > * folio is already in cache. If the folio was allocated, unlock it > > * before returning so the caller can do the same dance. > > @@ -606,6 +607,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_CREAT_ONLY ((__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 750e779c23db..d5107bd0cd09 100644 > > --- a/mm/filemap.c > > +++ b/mm/filemap.c > > @@ -1854,6 +1854,10 @@ struct folio *__filemap_get_folio(struct address= _space *mapping, pgoff_t index, > > folio =3D NULL; > > if (!folio) > > goto no_page; > > + if (fgp_flags & FGP_CREAT_ONLY) { > > + folio_put(folio); > > + return ERR_PTR(-EEXIST); > > + } > > > > if (fgp_flags & FGP_LOCK) { > > if (fgp_flags & FGP_NOWAIT) { > > -- > > 2.39.0 > > > > >