Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2077764lqt; Mon, 22 Apr 2024 00:04:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW39hUj/jCOVbIGTHwa8Ju9mXb+wOG4ipcHNRQjEp6+W4yQ/OxkB603+10zZJhKmvyTtvG0N86K3EfsBoxbCTumm7KCsABs5coVfCnbfg== X-Google-Smtp-Source: AGHT+IEA3PnFptYywb/r4LQY2Mhme5jPg8cjX7+65yApuOB+hNV0cT3xp1Cy2hP21zUZbgLhbu47 X-Received: by 2002:a05:6a21:4995:b0:1a7:507a:c9f4 with SMTP id ax21-20020a056a21499500b001a7507ac9f4mr9359212pzc.30.1713769495268; Mon, 22 Apr 2024 00:04:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713769495; cv=pass; d=google.com; s=arc-20160816; b=QbSdTLcJixF6yy3bQ8OPKt9K7CeoR5VlZxON/GQthjzqmSGqfgsTGwkyN/pYfFJnfB pksNlNubi/Y1YpWc+VfnQzYCGbt32GrNx8SCuG+VkHHmULPzaP3JhMnw9LlyQXpmRgp/ RiepfoTzTVchKFcPCzw+zTXuAS/4Op6jqpqBDaFIGIAs2bVENODfCLnGm1e3FGwpzHgN 6lyXwbov3X6GdlFNB2mVLntGNOpBem59WjRCHWCheHxQxu0qlc3eywBV/+xF0uuYlU6m Dl/08nuF/i3TfIcqCb3qJ1HZzEFbQCppSHno7N/AfBrrczGRQBX7ElqOjtMGfVlwIkLn Z2Dg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=BV2U/IeVyqp2XSH/3wx9gpceXxijONOM8cRleKyQmTE=; fh=g586Og5O/SXhL23QYbFhGrsFvTrke7WPI63lNAC0sdg=; b=Y/y+Lf41cWJymDOZqCVjvkbTWricH5rrhWSRqNMBP3gaOi/JYHyJT5lb/7Msb114Ch Tdmjj04XcAfhUbocBmaR43Ya4evwHS+h/TVHIHhIkxGtyl0bhoLmv3yAZ+BtGvqyo5dH HkVwO7gKFy7BEiRmw+t79+PbO+zp+wxvr1YJM+5jH9eO4AXJOjLBIuxB9yUxs9YFNX2V kZ5RwAIa0XDVWbeIemz/AGwSOFrDnp4tswHjJG+ebK9OoOiPaMjX6W2CWGaqIitrG8AZ j+oyqZouyn+jEGk5yrcg5X25TRByNgLGQl06viZCrCLa2SCoX4JvpLaQmH/JRket42Wn OIJQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=tDCV8JxE; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-152820-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152820-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id g20-20020a635214000000b005f057f31f96si7441435pgb.60.2024.04.22.00.04.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 00:04:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-152820-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=tDCV8JxE; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-152820-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152820-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 91F77B21C22 for ; Mon, 22 Apr 2024 07:03:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 23B2F4D58E; Mon, 22 Apr 2024 07:03:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="tDCV8JxE" Received: from out30-98.freemail.mail.aliyun.com (out30-98.freemail.mail.aliyun.com [115.124.30.98]) (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 1F97D4C62A for ; Mon, 22 Apr 2024 07:03:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.98 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713769390; cv=none; b=Ovux13yXhI9GzWSeTwROWK1UhYIW/03baYpC69MjPZkOMEqczf42DyyJCJ6k6A3J+o3wmAY0ogLvPZgmlXkqMiDmEm6+62XhX0QyFqU6vnphGSr51rbRUMyeghRMtogTDbnvXdQOyNrQeLi/kTX+/ngb2ZBdBSFTDreblw/0Zrs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713769390; c=relaxed/simple; bh=UVfFjDMATJJc4EWQb5F1toBkG4v8CsSGgcSCyesdW4M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OLmCEJY+1dEBJubeQrbvzv0Iw3RsUl8Hwd02ARDvdqyXcE0DQSqsDgxmAxjIf80t2I6ve5SEL2RLIVI+aUoM4HGZPUMiC/kiLGY5v4MkPBoSZLh/ZZK2oS5r5i74aGukQ7h+YZJxtSgb8wPUsNCTAax+psAI7DJEBkQCnTQ/fSo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=tDCV8JxE; arc=none smtp.client-ip=115.124.30.98 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com 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: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 { -- 2.39.3