Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp3111169lqo; Tue, 14 May 2024 23:00:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU6vr0rb7MBK9qrDtbJkFL2q3uTDkT+qChbRwcJ5KgTAcJ9xIsMvgyz/MMxdF7VEme0jsfalFC18m43kKSc7STPjtrbxcUlEPCvOXraLA== X-Google-Smtp-Source: AGHT+IGCNYKicVcB6QBpAlIXm3MeZ9dlVS5upLtIW5ekn9WiRSFJLh+A0rcla6CibktH3/nd2zss X-Received: by 2002:a50:ccd5:0:b0:571:cb02:418a with SMTP id 4fb4d7f45d1cf-5734d6f4e38mr8773102a12.40.1715752817673; Tue, 14 May 2024 23:00:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715752817; cv=pass; d=google.com; s=arc-20160816; b=rlN9+YMkkhrTxAi6eVA7YIzceJ2NkdrkyMXMYSGkrqe0dqIpzy43BcwRVypR2e6K6b NL7nl9NiMeTmmV9fprIVd3ZEbSvA3aWZh/PPYL2opUuKL7aacZdUfLb/0m4SsFTkV7lM fYLMMWs9/z9gP3Q0ZjhuNFz8DkHB7eJUMQmU6J9lEMvB35/hzrNKGEUSyxPaQVIQblsY fbGExKs8vofcMtSTuYvxizERdF+e3m0vtjNCheR0SUE1Z4eBS4QUBbFs2WySGvCzOQeE AoHZeXr1lit6GX6Mq8UZP6mA80QHopb4U3xJGEItJG+ZyCyuEgo/jBSk4qfUO/0vHDeF AlBg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:cms-type:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:content-transfer-encoding:content-language :accept-language:in-reply-to:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature:dkim-filter; bh=KSFa/00drIrpTPTVaHKTJFLNN4vEYokk0j2qhn9ASTY=; fh=boE2T1tfXWhPiAXKUEd+pJodvJpwHMz3xvNd2cVdM48=; b=CeuYHvowgXgJiOO4IfriAlyHVq2eO5VnfVnM0EyKb0cIjahNX544jsaFoczh2z1m20 BATWDZACpS/CJGSeA7DT+xuD1hN1xgR/8KWbDKuc1opWMBIOnX5CveLFhsdc/hXhZFXn PuOczg7ou3ZEg0pgmff5docqlfTyzLyRjhhNIkJwoaW1MDajOwWw6qw0DuUYnICjMOQ8 pKu6l6O5/mm4gLgqs+P2uuQupFHePryPJvF/r4oAhnTsTOwMGl2WoEAYktatRXJWRlYJ j1e2T4H1JQWdqQ2iTGQDLQl69cilH9iHKYH3a6s4q9ZmW0emsCXz1xpmoZbThIHmKod7 GLtg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=XE0WeUZ4; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-179493-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179493-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5733bead0e0si6887933a12.91.2024.05.14.23.00.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 23:00:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-179493-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=XE0WeUZ4; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-179493-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179493-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 2B41D1F23A28 for ; Wed, 15 May 2024 06:00:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E586E43ABC; Wed, 15 May 2024 05:57:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="XE0WeUZ4" Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) (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 C3F6C4AEF2 for ; Wed, 15 May 2024 05:57:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.118.77.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715752661; cv=none; b=BnlxjlQ5F3WIRTH36DRaO+K5W76LqURClscp82C7mxWpJcT33nydI8gK/uVuiwrMaaD64uIlL+u7tStLsRpoXIM3G6GxTbix3OTTOyK0hKYIqV3S32KkAVvOzxBFYoua3xVnzZmk5rFvzSK/B8BYH51DVlOmSpZJ7K+bRvPaPxc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715752661; c=relaxed/simple; bh=0RjdBokNWoS+vSi83hgJATS/2MIQWi5fahvmgWZkpmk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:Content-Type: MIME-Version:References; b=cC2fcxHzWwho3mo2JShSe1AYRqQ+WP6MtDggegcpyveua7/3ZLbNVg7pjWlAp+RmCeHIhdj/p6f+AYaPO/cZXo6s0UrTRITWLR/ZDcPjrdvvE3mhaTebCnMYWB6x29hUufd4ynim804cb9LEy3us4XKqqUEI+ynjZCtNabmQSTY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=XE0WeUZ4; arc=none smtp.client-ip=210.118.77.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20240515055737euoutp011585bad95b9968752aad794790304a2d~Pk-OWKCfC1508515085euoutp01Z for ; Wed, 15 May 2024 05:57:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20240515055737euoutp011585bad95b9968752aad794790304a2d~Pk-OWKCfC1508515085euoutp01Z DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1715752657; bh=KSFa/00drIrpTPTVaHKTJFLNN4vEYokk0j2qhn9ASTY=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=XE0WeUZ4/fxHAxJkG/mIY/WGU0C4ZHUEw5qzBkuqT9YA+ux6u/VMvXpPQ5QfXZsCN RAdqw8x6EFSJ3Uy0xmtAXcHqL9FipFkZbQdC03MkUvzvsQe44ht0ez97k3oK7S9HbB ZKW8iyeunnHh5sOncAza29RBBZxrEoJLw6eIoNhE= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20240515055737eucas1p2687839099f1491893036e9edf50d6776~Pk-N8z2ap0810008100eucas1p2W; Wed, 15 May 2024 05:57:37 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 58.D8.09875.0DE44466; Wed, 15 May 2024 06:57:36 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20240515055736eucas1p1bfa9549398e766532d143ba9314bee18~Pk-NPUDB_1859218592eucas1p1L; Wed, 15 May 2024 05:57:36 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240515055736eusmtrp1cd38f7c68e33115cb0f700536a34b1e1~Pk-NOpRJH0411404114eusmtrp1C; Wed, 15 May 2024 05:57:36 +0000 (GMT) X-AuditID: cbfec7f4-11bff70000002693-f1-66444ed03f5f Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 6D.F1.09010.0DE44466; Wed, 15 May 2024 06:57:36 +0100 (BST) Received: from CAMSVWEXC01.scsc.local (unknown [106.1.227.71]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240515055736eusmtip10c080390bd41a09baa29d247f828f893~Pk-NCedQq0562705627eusmtip1T; Wed, 15 May 2024 05:57:36 +0000 (GMT) Received: from CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) by CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 15 May 2024 06:57:35 +0100 Received: from CAMSVWEXC02.scsc.local ([::1]) by CAMSVWEXC02.scsc.local ([fe80::3c08:6c51:fa0a:6384%13]) with mapi id 15.00.1497.012; Wed, 15 May 2024 06:57:35 +0100 From: Daniel Gomez To: "hughd@google.com" , "akpm@linux-foundation.org" , "willy@infradead.org" , "jack@suse.cz" , "mcgrof@kernel.org" CC: "linux-mm@kvack.org" , "linux-xfs@vger.kernel.org" , "djwong@kernel.org" , "Pankaj Raghav" , "dagmcr@gmail.com" , "yosryahmed@google.com" , "baolin.wang@linux.alibaba.com" , "ritesh.list@gmail.com" , "lsf-pc@lists.linux-foundation.org" , "david@redhat.com" , "chandan.babu@oracle.com" , "linux-kernel@vger.kernel.org" , "brauner@kernel.org" , Daniel Gomez Subject: [PATCH 10/12] shmem: add order arg to shmem_alloc_folio() Thread-Topic: [PATCH 10/12] shmem: add order arg to shmem_alloc_folio() Thread-Index: AQHapozIzXRp8FIrX0Ow3XgDmWV32Q== Date: Wed, 15 May 2024 05:57:35 +0000 Message-ID: <20240515055719.32577-11-da.gomez@samsung.com> In-Reply-To: <20240515055719.32577-1-da.gomez@samsung.com> Accept-Language: en-US, en-GB Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrIKsWRmVeSWpSXmKPExsWy7djP87oX/FzSDHZ9srSYs34Nm8X/vccY LV4f/sRocemonMXZvt9sFl/X/2K2uPyEz+Lppz4Wi9nTm5ksLu+aw2Zxb81/Votdf3awW+x7 vZfZ4saEp4wWB091sFv8/gGU3b4r0kHQY+esu+weCzaVemxeoeWxaVUnm8emT5PYPU7M+M3i sfOhpcfkG8sZPT4+vcXi8X7fVTaPMwuOsHt83iQXwBPFZZOSmpNZllqkb5fAlTHv32L2gg3i Ff9/bmJpYOwU7mLk5JAQMJHYOuUDaxcjF4eQwApGid2LZ7ODJIQEvjBKvH2cDJH4zCjx9f1W dpiOWXcus0AkljNKzOxfyA5XtXDBaWYI5wyjxKO7kxghZq1klDjzUATEZhPQlNh3chNYh4jA bUaJp6fOgDnMAidZJf5s3skCUiUs4CSx93wLM4gtI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549398e766532d143ba9314bee18 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20240515055736eucas1p1bfa9549398e766532d143ba9314bee18 References: <20240515055719.32577-1-da.gomez@samsung.com> Add folio order argument to the shmem_alloc_folio(). Return will make use of the new page_rmappable_folio() where order-0 and high order folios are both supported. As the order requested may not match the order returned when allocating high order folios, make sure pages are calculated after getting the folio. Signed-off-by: Daniel Gomez --- mm/shmem.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 7a6ad678e2ff..d531018ffece 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1828,18 +1828,18 @@ static struct folio *shmem_alloc_hugefolio(gfp_t gf= p, return page_rmappable_folio(page); } =20 -static struct folio *shmem_alloc_folio(gfp_t gfp, - struct shmem_inode_info *info, pgoff_t index) +static struct folio *shmem_alloc_folio(gfp_t gfp, struct shmem_inode_info = *info, + pgoff_t index, unsigned int order) { struct mempolicy *mpol; pgoff_t ilx; struct page *page; =20 - mpol =3D shmem_get_pgoff_policy(info, index, 0, &ilx); - page =3D alloc_pages_mpol(gfp, 0, mpol, ilx, numa_node_id()); + mpol =3D shmem_get_pgoff_policy(info, index, order, &ilx); + page =3D alloc_pages_mpol(gfp, order, mpol, ilx, numa_node_id()); mpol_cond_put(mpol); =20 - return (struct folio *)page; + return page_rmappable_folio(page); } =20 static struct folio *shmem_alloc_and_add_folio(gfp_t gfp, @@ -1848,6 +1848,7 @@ static struct folio *shmem_alloc_and_add_folio(gfp_t = gfp, { struct address_space *mapping =3D inode->i_mapping; struct shmem_inode_info *info =3D SHMEM_I(inode); + unsigned int order =3D 0; struct folio *folio; long pages; int error; @@ -1856,7 +1857,6 @@ static struct folio *shmem_alloc_and_add_folio(gfp_t = gfp, huge =3D false; =20 if (huge) { - pages =3D HPAGE_PMD_NR; index =3D round_down(index, HPAGE_PMD_NR); =20 /* @@ -1875,12 +1875,13 @@ static struct folio *shmem_alloc_and_add_folio(gfp_= t gfp, if (!folio) count_vm_event(THP_FILE_FALLBACK); } else { - pages =3D 1; - folio =3D shmem_alloc_folio(gfp, info, index); + folio =3D shmem_alloc_folio(gfp, info, index, order); } if (!folio) return ERR_PTR(-ENOMEM); =20 + pages =3D folio_nr_pages(folio); + __folio_set_locked(folio); __folio_set_swapbacked(folio); =20 @@ -1976,7 +1977,7 @@ static int shmem_replace_folio(struct folio **foliop,= gfp_t gfp, */ gfp &=3D ~GFP_CONSTRAINT_MASK; VM_BUG_ON_FOLIO(folio_test_large(old), old); - new =3D shmem_alloc_folio(gfp, info, index); + new =3D shmem_alloc_folio(gfp, info, index, folio_order(old)); if (!new) return -ENOMEM; =20 @@ -2855,7 +2856,7 @@ int shmem_mfill_atomic_pte(pmd_t *dst_pmd, =20 if (!*foliop) { ret =3D -ENOMEM; - folio =3D shmem_alloc_folio(gfp, info, pgoff); + folio =3D shmem_alloc_folio(gfp, info, pgoff, 0); if (!folio) goto out_unacct_blocks; =20 --=20 2.43.0