From patchwork Mon Apr 22 07:02:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 13637717 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 AAE7AC4345F for ; Mon, 22 Apr 2024 07:03:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D7F8B6B008A; Mon, 22 Apr 2024 03:03:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D2F656B008C; Mon, 22 Apr 2024 03:03:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BD0176B0093; Mon, 22 Apr 2024 03:03:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 9D3216B008C for ; Mon, 22 Apr 2024 03:03:05 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 5139840ABB for ; Mon, 22 Apr 2024 07:03:05 +0000 (UTC) X-FDA: 82036275930.07.AEB1845 Received: from out30-133.freemail.mail.aliyun.com (out30-133.freemail.mail.aliyun.com [115.124.30.133]) by imf26.hostedemail.com (Postfix) with ESMTP id 4C168140023 for ; Mon, 22 Apr 2024 07:03:02 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=tDCV8JxE; spf=pass (imf26.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.133 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1713769383; 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=BV2U/IeVyqp2XSH/3wx9gpceXxijONOM8cRleKyQmTE=; b=X4tm+FYSpZq0NsjVPfBcgod5vW/Ojoza5a+AYbUGVoZOJlJyOR2OzgtCIqAQrctUl3CQjG ItrlyIMB73M26WG9cQl1/Ir5b5C5VSjVHA3TgQL2Rg17NCj4dnsNzLEVBQdXEkV/t9Ki0K 1nfIorjAeASJ7DkdkfHxO8vVCDyOxs0= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=tDCV8JxE; spf=pass (imf26.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.133 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713769383; a=rsa-sha256; cv=none; b=c4wicyA0nRzKnd/8wLdPxIx38uYnuyE9dVG8568Y+2bXG5OXJNe/xh7iwtDZcGrrfYNN2s WsDeDDBmsvzORw4tCvfJhTNHmI2b6UpRi1xfjKiNMuPD18MD+J1uOtQXtbbZCYOK1SVDFw Kxkspwn0vpYl/mpggcbFEhCBD8Nlmw0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1713769380; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=BV2U/IeVyqp2XSH/3wx9gpceXxijONOM8cRleKyQmTE=; b=tDCV8JxEBCbqsQDyR0vP1FoyKkyzBNksQ1vUo9tSdXVQLC+8aj9bSUOj1fJ8OyL1HC1zu90J4qQ21uq0mOdfF2zWdEUhtdb7Q5z29x2j3J+9g9y9v/iUG9NQL5MtAuuh6jL4rlYLap2RbNR5G7N5jlTe9dTMuZ3xMRCuNqwqEys= X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R891e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045176;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=13;SR=0;TI=SMTPD_---0W5.T-YL_1713769377; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0W5.T-YL_1713769377) by smtp.aliyun-inc.com; Mon, 22 Apr 2024 15:02:58 +0800 From: Baolin Wang To: akpm@linux-foundation.org, hughd@google.com Cc: willy@infradead.org, david@redhat.com, wangkefeng.wang@huawei.com, 21cnbao@gmail.com, ryan.roberts@arm.com, ying.huang@intel.com, shy828301@gmail.com, ziy@nvidia.com, baolin.wang@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 2/5] mm: shmem: add an 'order' parameter for shmem_alloc_hugefolio() Date: Mon, 22 Apr 2024 15:02:40 +0800 Message-Id: <2014bf7370d78bc1f5600731af5bf8f569e5868b.1713755580.git.baolin.wang@linux.alibaba.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 4C168140023 X-Stat-Signature: jgoce81w1d1q15hw66uais4hndm1inj1 X-Rspam-User: X-Rspamd-Server: rspam07 X-HE-Tag: 1713769382-727366 X-HE-Meta: U2FsdGVkX18wPj53CdkZf0bZxlp6c5WD0LQNXL+8XUnmSDa8riN8r/TchVyKDClZCJRZo8Wp7K9kgwwxteTLSPHDlAarpCSNkCDess7LT/c6Q+X5gO1F5SOtc50y5dg+62DmhK6U2VtpZSg+IZ8smbJS5svPYt6FeyAhnxs4FcEQ6Q84x+OGQhCrH7Q5da2Qggz9bPQOYXXo6EhAh1Mw0EP++MAcEYKjL/60f0M0ZLZGbFkS/Q7iEfpOVaoViXXQzYUJjJWWEb2ea9LyGSQSmcWAAxEDHmDOY2wJm2m0D9vb6yW1M1B+XhoXLNEOb+ZAjLcJnWOVkBB5k9RJxmNrtJEw+hJ7h+fkzlkTfHJ1SyQqYP8GBch4G+WOJKE2nQ7CYn6WbdCgZxh42mN8IAPoQjCoFoQEclH8T7cDk5f3s5mJ10dT++TMK3ngaDobHOokYng5YMHL0aSsj1ZFrs2OYAZUAYq5PBfDHM++csOv3NHmMTEaM3DrnrpY0vh/VtATU0Lx904712mV42jY8BhU9WU0RKKDnwta+s+sOwnFz4fmPNmcFkEBGr/5+sHfYge2duO51bHDZvvQcB/1K/mjf4ovGxY4p25sESIa5PPJ4RPognwxdWnrONHdMftMekDfhDxtoWfm29ba4ZYwFrT/OltoNl+7yulamXT86eNwehQLEx6LjwSbRe0onGTMcx3Vb9vCnBWVFx+9aEB0B1LLzr1OI+jdzyBEYjtIL5ruWluR3mKMSZsLHoUkat96EdVGhe8nCJylXJrMDCZxlg4HFrrd2dlTHTMvr2XjUesZsmBpp+kUpekfR+Eoh1irMzO3OEvLyLSgHcLGVL1j4WTON0cgJ0ZFih49qC0+2wpmnI+9I+foQNaotRiD7mk/1kx0H7rdEoIrHsWR0t5Kvmf+oFQnHEWAQ9Taw3OcZtVh4gfA+/lxzFojva4yWcZE34aNhQUfs96/5nRslQa2PvF eUNXyaWL kJq8UCwBgC/oSEc302u6d4pTtY4Ao+0gGynflMrQ7F1zTBCGfRLlE5o8wi2fCtdkOblh65NHKzz8a3j4nVWINXYcf8rLSSjgOBU+p/JtwXlrYlWVlWX4ox/o5FB1zSkiv5rgD+/xpSlr5T6Qb+LL2ysYhhnYqdVhcoijPXFtgrelwjk9QCRH6guXkNZvRAoyc+96toZv2c/JQf7RKF97Jgw6XT4iqY5Fb9lGTeFXLLLHREJho53Fl5lvFb2SZn+3AKiHuq57X+8/FP3hqNeUO5ItqVvgh4KMvsCKQ 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: Add a new parameter to specify the huge page order for shmem_alloc_hugefolio(), as a preparation to supoort mTHP. Signed-off-by: Baolin Wang --- mm/shmem.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index fa2a0ed97507..893c88efc45f 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1604,14 +1604,14 @@ static gfp_t limit_gfp_mask(gfp_t huge_gfp, gfp_t limit_gfp) } static struct folio *shmem_alloc_hugefolio(gfp_t gfp, - struct shmem_inode_info *info, pgoff_t index) + struct shmem_inode_info *info, pgoff_t index, int order) { struct mempolicy *mpol; pgoff_t ilx; struct page *page; - mpol = shmem_get_pgoff_policy(info, index, HPAGE_PMD_ORDER, &ilx); - page = alloc_pages_mpol(gfp, HPAGE_PMD_ORDER, mpol, ilx, numa_node_id()); + mpol = shmem_get_pgoff_policy(info, index, order, &ilx); + page = alloc_pages_mpol(gfp, order, mpol, ilx, numa_node_id()); mpol_cond_put(mpol); return page_rmappable_folio(page); @@ -1639,13 +1639,14 @@ static struct folio *shmem_alloc_and_add_folio(gfp_t gfp, struct shmem_inode_info *info = SHMEM_I(inode); struct folio *folio; long pages; - int error; + int error, order; if (!IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)) huge = false; if (huge) { pages = HPAGE_PMD_NR; + order = HPAGE_PMD_ORDER; index = round_down(index, HPAGE_PMD_NR); /* @@ -1660,7 +1661,7 @@ static struct folio *shmem_alloc_and_add_folio(gfp_t gfp, index + HPAGE_PMD_NR - 1, XA_PRESENT)) return ERR_PTR(-E2BIG); - folio = shmem_alloc_hugefolio(gfp, info, index); + folio = shmem_alloc_hugefolio(gfp, info, index, order); if (!folio) count_vm_event(THP_FILE_FALLBACK); } else {