Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp1166972lqd; Thu, 25 Apr 2024 07:48:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUGtryklGucn7rUZichDMTWVBxo76J7vye57TxuVp1KBe16q+6bWmCxf//QgpWGZ23+I8hq1zGWs+ZQJIJ5chcGQUTXDv6rK6DbOAOiXA== X-Google-Smtp-Source: AGHT+IG/ZMsk+llqIXBLdQmFrRMqRc/od2Rtw2tCuxfjZvOOgm1+oguwQZtMGcRPFwe1SxnbWNFu X-Received: by 2002:a05:622a:50f:b0:43a:3632:e92c with SMTP id l15-20020a05622a050f00b0043a3632e92cmr5405254qtx.4.1714056486343; Thu, 25 Apr 2024 07:48:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714056486; cv=pass; d=google.com; s=arc-20160816; b=AGy+VqLaYHzDjQpElypCyySd3oVR/XCosVMRdu/VApPJaxLy4XPW8/sawNNKARjEGt eMeOOpS95Fl7M2WkFwgfZNwMkuoytbQz7JOL66xIrEv7jQvv9Qum2lprCHoq++MEfD8r YE0iM+JD/MP69R89UfFefyzxxqC07vMDdABQqZY9grhFap6Izg5lpwyhGLOG1x/OB7n6 IQvFZaNbvvold8TmF/6hqGcRtpH0PVoC854g9E98UXesgjQf6146D0EctKmb/gHdz/fp a3jZCznQV5nXstUat+HMuem/i9l1ftjizuUWhvW/TbhiSDkQf6ENgJf6+tKxZ/XiMsQI MA/w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=2uONcSOBmYm/zEIn/RVoq3cLXjOll3fnF/QGfQtQU1Y=; fh=+Nx2ETA5UqdQlUXi1Q7m5/mNRi78D1k73RLEjRkyY0I=; b=0UI8RB2jGum8swZgkw4I90RXnGR8RSONx5Eorfq6bsQwtW76Yv02lpNU9JMNSWDOXS soPaXTzijIuhCfbrPUd3kg6Oz/63FIGxPDYZJYjA3LkLrUZH5mlcbqlJDuBp6/iL86XG z7wIuV5Q6u30YWpvIejpcUQIXcBw1oog3QjLMU4itWOe503jqByY/kTYj/zVeqfW0vsM QEjT/1+ft5zhChBS9G8RTj6OEeoCmNayOoGGrKDnjaeYcB0LyAlE4Uq0cYtaJQ/C+xAa HvaHqA2/VVbn7fZJ92NRsztO2Dr9sTz/V+KPImLzBhqvN/FFi3gQTPv8lrSdZi0ixrok pJig==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@pankajraghav.com header.s=MBO0001 header.b=lGc1j8mm; arc=pass (i=1 spf=pass spfdomain=pankajraghav.com dkim=pass dkdomain=pankajraghav.com dmarc=pass fromdomain=pankajraghav.com); spf=pass (google.com: domain of linux-kernel+bounces-158739-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158739-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=pankajraghav.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 20-20020ac85754000000b0043a0d2a41f2si4959853qtx.753.2024.04.25.07.48.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 07:48:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-158739-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=@pankajraghav.com header.s=MBO0001 header.b=lGc1j8mm; arc=pass (i=1 spf=pass spfdomain=pankajraghav.com dkim=pass dkdomain=pankajraghav.com dmarc=pass fromdomain=pankajraghav.com); spf=pass (google.com: domain of linux-kernel+bounces-158739-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158739-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=pankajraghav.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 17B3F1C21D53 for ; Thu, 25 Apr 2024 14:48:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 08A7314A604; Thu, 25 Apr 2024 14:47:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pankajraghav.com header.i=@pankajraghav.com header.b="lGc1j8mm" Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [80.241.56.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0757312BE8C; Thu, 25 Apr 2024 14:47:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=80.241.56.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714056475; cv=none; b=eQ/Oq+qpgJlVsqfqcW2iOm86BShR8C5O+lQyACiIJMikrXh0j9kdz8rg5Kf286Drf/IF3EPfkLdiWeArwC4mrhnLE192EmsSqn/Ew9HHnBgqID2Uv8A0wwKYE7HogAPI+60yZ7jU2BR3YVBr9ql/nX6OVgVYCtkjZZ0H16ZArfc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714056475; c=relaxed/simple; bh=xirADQnND4LpW3On1CYVvqiaJ7dFeYmjfzo0yqz5Uvs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=G2C93yoMv3y1wulCv1FH1hbGEamsSdUt+/fGFUzWv5AVDsTVywOJFhKX36jNtWnvnuOuJbyZRUD3NHD2kz8yw8aBmTtZYUZt8m/2iEjVuxpwN1dFjQ0tawQPq+HCC51zWV7WaGTejbnUbhzlf2glJUBvyqmoRYAH+pc38ZRPhvk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=pankajraghav.com; spf=pass smtp.mailfrom=pankajraghav.com; dkim=pass (2048-bit key) header.d=pankajraghav.com header.i=@pankajraghav.com header.b=lGc1j8mm; arc=none smtp.client-ip=80.241.56.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=pankajraghav.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pankajraghav.com Received: from smtp1.mailbox.org (smtp1.mailbox.org [10.196.197.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4VQJcN6X9fz9sn3; Thu, 25 Apr 2024 16:47:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1714056468; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=2uONcSOBmYm/zEIn/RVoq3cLXjOll3fnF/QGfQtQU1Y=; b=lGc1j8mmeffOqT4NiHrF7eoMXpDqgwvRCENRJJWBxgfN5pSWO/HKcAt9zSSDb0c3D4pvJa CW6TS2aHiXV16VOTzsX0x0YtSjv3SeljbDFVXOO0oBtzZlm3AKnobxFZNd+vYqbV+CTv+r tDnFzSd69F+bXUA01ebmZrATefPMztZaphHe2zCk2EPxMjAp1uVd2CxW+wi1v7nyguDKUF ilTj3f3nl4coS3k23fbERU7i/f9+ZZpVVbPonTUT8gMYTpCLASLFCxl8ogCRmONnG+BEp+ ms5v36t6TERhrtEjb3ArfqGDXTEBZXNQypQOQNRA10K2e/IqwM7sSzZdT0ezWQ== Date: Thu, 25 Apr 2024 14:47:41 +0000 From: "Pankaj Raghav (Samsung)" To: John Garry Cc: axboe@kernel.dk, brauner@kernel.org, djwong@kernel.org, viro@zeniv.linux.org.uk, jack@suse.cz, akpm@linux-foundation.org, willy@infradead.org, dchinner@redhat.com, tytso@mit.edu, hch@lst.de, martin.petersen@oracle.com, nilay@linux.ibm.com, ritesh.list@gmail.com, mcgrof@kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, ojaswin@linux.ibm.com, p.raghav@samsung.com, jbongio@google.com, okiselev@amazon.com Subject: Re: [PATCH RFC 2/7] filemap: Change mapping_set_folio_min_order() -> mapping_set_folio_orders() Message-ID: <20240425144741.houv6uoflhwmcc2u@quentin> References: <20240422143923.3927601-1-john.g.garry@oracle.com> <20240422143923.3927601-3-john.g.garry@oracle.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240422143923.3927601-3-john.g.garry@oracle.com> On Mon, Apr 22, 2024 at 02:39:18PM +0000, John Garry wrote: > Borrowed from: > > https://lore.kernel.org/linux-fsdevel/20240213093713.1753368-2-kernel@pankajraghav.com/ > (credit given in due course) > > We will need to be able to only use a single folio order for buffered > atomic writes, so allow the mapping folio order min and max be set. > > We still have the restriction of not being able to support order-1 > folios - it will be required to lift this limit at some stage. This is already supported upstream for file-backed folios: commit: 8897277acfef7f70fdecc054073bea2542fc7a1b > index fc8eb9c94e9c..c22455fa28a1 100644 > --- a/include/linux/pagemap.h > +++ b/include/linux/pagemap.h > @@ -363,9 +363,10 @@ static inline void mapping_set_gfp_mask(struct address_space *m, gfp_t mask) > #endif > > /* > - * mapping_set_folio_min_order() - Set the minimum folio order > + * mapping_set_folio_orders() - Set the minimum and max folio order In the new series (sorry forgot to CC you), I added a new helper called mapping_set_folio_order_range() which does something similar to avoid confusion based on willy's suggestion: https://lore.kernel.org/linux-xfs/20240425113746.335530-3-kernel@pankajraghav.com/ mapping_set_folio_min_order() also sets max folio order to be MAX_PAGECACHE_ORDER order anyway. So no need of explicitly calling it here? > /** > @@ -400,7 +406,7 @@ static inline void mapping_set_folio_min_order(struct address_space *mapping, > */ > static inline void mapping_set_large_folios(struct address_space *mapping) > { > - mapping_set_folio_min_order(mapping, 0); > + mapping_set_folio_orders(mapping, 0, MAX_PAGECACHE_ORDER); > } > > static inline unsigned int mapping_max_folio_order(struct address_space *mapping) > diff --git a/mm/filemap.c b/mm/filemap.c > index d81530b0aac0..d5effe50ddcb 100644 > --- a/mm/filemap.c > +++ b/mm/filemap.c > @@ -1898,9 +1898,15 @@ struct folio *__filemap_get_folio(struct address_space *mapping, pgoff_t index, > no_page: > if (!folio && (fgp_flags & FGP_CREAT)) { > unsigned int min_order = mapping_min_folio_order(mapping); > - unsigned int order = max(min_order, FGF_GET_ORDER(fgp_flags)); > + unsigned int max_order = mapping_max_folio_order(mapping); > + unsigned int order = FGF_GET_ORDER(fgp_flags); > int err; > > + if (order > max_order) > + order = max_order; > + else if (order < min_order) > + order = max_order; order = min_order; ? -- Pankaj