Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp5065295rdb; Sat, 16 Sep 2023 01:08:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFJQHOmiW3RfQDLFywgbWzIr2mNOFxgbVBTxFhYXy76cmsNOFmWM4UklYBJWtHsr/5rzmBV X-Received: by 2002:a17:90a:6f47:b0:26d:1f75:7fa3 with SMTP id d65-20020a17090a6f4700b0026d1f757fa3mr3299513pjk.4.1694851682680; Sat, 16 Sep 2023 01:08:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694851682; cv=none; d=google.com; s=arc-20160816; b=IrqO4M2OXD4xaKxrx1MHv/6QAmeJlneshUxjvVMpYQ4qLi6GXBcHJkUhDKyVEPlEFX R6tHl977E/QcA31QVl7/bZiyuK3hZIhuwxDADzzmAcuDBh3CM82y7QOk3mo/cypRdQFY nayJ7aQzNndlut4NhtE52pTC3DfKjOO0rFz3F1ZGA1pI8o7bfSTUsWMMT+kDIfzGY7Zx B8bm0m4mV+ta3ZkGYUbuOLRbqbcfXWEi9+NzgbRldXlL7SLidCDYkeRftubR9NKtaYLB e7usQbSXo5PMvQjk3fV1IxxyQjBAxg6tfTyha5ZyuKuUB8VMC+kSrsidsSLqPqmDKFpY v4hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=7TVRLEu9EJ9mGV2bipP8Xm97KGB9uZNTupnuQjSJdsE=; fh=vwAm4eY2boZzTddYdFuwrV0/5AYJRFuP7fC1k+rg/58=; b=Z+Fnaqbo0s7CVpr6gh7fj5WgSD4Hc/ZOtlxzPXMktyctnjwnpl97rX1Ka58c1SUIu0 76k15aP7jKH0uEid6sH6Sm2+bA0F/tY+2SBw+bb0lPZlcWET6ub+k6UX/QAZydOEl1kX LsJ2/yfVyypposdl/FB4aQX2LFrIegvN/6rU6YaV7l6jtX+ROEokcUc1rikrf+MmRr5t IqiwxlJ2CGB5jcFsXVcX5/zt12pEEq0TAzoxaZhuGAX98fQJj4qKUIWcuKxCd3MPLJ2q rXJr+m/zBoyuvsP5f3aw/yH7+M5VoZmtTbQRN18FULmQJWpS+z0BZzf+AhgZV7wd0m1L 1xqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=sKKT+kRR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id bo6-20020a17090b090600b002745c4e215fsi5043567pjb.175.2023.09.16.01.08.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 01:08:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=sKKT+kRR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 1A6AD825A6DB; Fri, 15 Sep 2023 11:29:13 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236346AbjIOS2m (ORCPT + 99 others); Fri, 15 Sep 2023 14:28:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236507AbjIOS21 (ORCPT ); Fri, 15 Sep 2023 14:28:27 -0400 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1867D271F for ; Fri, 15 Sep 2023 11:27:18 -0700 (PDT) Received: by mail-ed1-x52f.google.com with SMTP id 4fb4d7f45d1cf-5308430052fso1270912a12.1 for ; Fri, 15 Sep 2023 11:27:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694802436; x=1695407236; 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=7TVRLEu9EJ9mGV2bipP8Xm97KGB9uZNTupnuQjSJdsE=; b=sKKT+kRRXdqHAoUZgMTugOxbcrbgqDgkkXjasxrWctWJd77Sw8TlsGuTd98pSRft9A jN/MMQ3oP4/QuTKHBD9/YypfLSNU+2cuvu8u73JxBHsdsSFjo1rojX5WJRXSO1lIrr4X Q/i++DKlLWUNrBbI96a2DUSv9ydwwnivZJKP06X04/cK0r2bQFBArjWiQF6VYJBobiMX PGK/u5s+F2yWQLPEdRhYCODQlNQ8S+qDRhy7Nh2noe1XmCVyac1kWiIlCNg4DMBP7SEd a3S1lxEG5glLqSDYO5PGcLNoSDLKwOIaoa1Db4onOn/2goDJ5rYfzEFwI2eODMv2KWvJ JQEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694802436; x=1695407236; 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=7TVRLEu9EJ9mGV2bipP8Xm97KGB9uZNTupnuQjSJdsE=; b=whazpXa/evq9m1CldhFtVqliStjD+5WeykDYSUZP62ucEVyivfnRP6218ebDV4rt3S egyT36LtIeX40YzRxV0l3DvXBl7JQ9zsGcc1nfz5Tx9B/TXjsr4LE2UNGPxkgFc0OadM vqwPYpmt/83WeUsQEaGRiGnLk5+5pp9qV67eh4wIcOZ/ff1dmcJvDpJhSsmnLe8jQp16 L75j35VMKOt6W6s7SneJi4WDqDzJw+pZs7aIqyltqoD/N6FAgcooLcBrNGa8VmptSc+N odzHtpMxRts1WFwWmGG1v5HPcoQE2XehnjBxYdZumpKDDEZQqfe1uq8QTA0km5ejem+q Butg== X-Gm-Message-State: AOJu0YwYfp8woMzIKDKXfpm/ncRGWvjlk06zDPbOz0k94bFdIuHOOYsk hOKD2CmHtBEEQ9K+0xl8VtNpRE9Ku8475c7sXrR01A== X-Received: by 2002:a17:907:75fb:b0:9a1:f3a6:b906 with SMTP id jz27-20020a17090775fb00b009a1f3a6b906mr2140406ejc.36.1694802436299; Fri, 15 Sep 2023 11:27:16 -0700 (PDT) MIME-Version: 1.0 References: <20230915095042.1320180-1-da.gomez@samsung.com> <20230915095042.1320180-7-da.gomez@samsung.com> In-Reply-To: <20230915095042.1320180-7-da.gomez@samsung.com> From: Yosry Ahmed Date: Fri, 15 Sep 2023 11:26:37 -0700 Message-ID: Subject: Re: [PATCH 6/6] shmem: add large folios support to the write path To: Daniel Gomez Cc: "minchan@kernel.org" , "senozhatsky@chromium.org" , "axboe@kernel.dk" , "djwong@kernel.org" , "willy@infradead.org" , "hughd@google.com" , "akpm@linux-foundation.org" , "mcgrof@kernel.org" , "linux-kernel@vger.kernel.org" , "linux-block@vger.kernel.org" , "linux-xfs@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-mm@kvack.org" , "gost.dev@samsung.com" , Pankaj Raghav Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 15 Sep 2023 11:29:14 -0700 (PDT) On Fri, Sep 15, 2023 at 2:51=E2=80=AFAM Daniel Gomez = wrote: > > Add large folio support for shmem write path matching the same high > order preference mechanism used for iomap buffered IO path as used in > __filemap_get_folio(). > > Use the __folio_get_max_order to get a hint for the order of the folio > based on file size which takes care of the mapping requirements. > > Swap does not support high order folios for now, so make it order 0 in > case swap is enabled. I didn't take a close look at the series, but I am not sure I understand the rationale here. Reclaim will split high order shmem folios anyway, right? It seems like we only enable high order folios if the "noswap" mount option is used, which is fairly recent. I doubt it is widely used. > > Signed-off-by: Daniel Gomez > --- > mm/shmem.c | 16 +++++++++++++--- > 1 file changed, 13 insertions(+), 3 deletions(-) > > diff --git a/mm/shmem.c b/mm/shmem.c > index adff74751065..26ca555b1669 100644 > --- a/mm/shmem.c > +++ b/mm/shmem.c > @@ -1683,13 +1683,19 @@ static struct folio *shmem_alloc_folio(gfp_t gfp, > } > > static struct folio *shmem_alloc_and_acct_folio(gfp_t gfp, struct inode = *inode, > - pgoff_t index, bool huge, unsigned int *order) > + pgoff_t index, bool huge, unsigned int *order, > + struct shmem_sb_info *sbinfo) > { > struct shmem_inode_info *info =3D SHMEM_I(inode); > struct folio *folio; > int nr; > int err; > > + if (!sbinfo->noswap) > + *order =3D 0; > + else > + *order =3D (*order =3D=3D 1) ? 0 : *order; > + > if (!IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)) > huge =3D false; > nr =3D huge ? HPAGE_PMD_NR : 1U << *order; > @@ -2032,6 +2038,8 @@ static int shmem_get_folio_gfp(struct inode *inode,= pgoff_t index, > return 0; > } > > + order =3D mapping_size_order(inode->i_mapping, index, len); > + > if (!shmem_is_huge(inode, index, false, > vma ? vma->vm_mm : NULL, vma ? vma->vm_flags := 0)) > goto alloc_nohuge; > @@ -2039,11 +2047,11 @@ static int shmem_get_folio_gfp(struct inode *inod= e, pgoff_t index, > huge_gfp =3D vma_thp_gfp_mask(vma); > huge_gfp =3D limit_gfp_mask(huge_gfp, gfp); > folio =3D shmem_alloc_and_acct_folio(huge_gfp, inode, index, true= , > - &order); > + &order, sbinfo); > if (IS_ERR(folio)) { > alloc_nohuge: > folio =3D shmem_alloc_and_acct_folio(gfp, inode, index, f= alse, > - &order); > + &order, sbinfo); > } > if (IS_ERR(folio)) { > int retry =3D 5; > @@ -2147,6 +2155,8 @@ static int shmem_get_folio_gfp(struct inode *inode,= pgoff_t index, > if (folio_test_large(folio)) { > folio_unlock(folio); > folio_put(folio); > + if (order > 0) > + order--; > goto alloc_nohuge; > } > unlock: > -- > 2.39.2 >