Received: by 2002:a05:7208:1509:b0:82:bbfa:f723 with SMTP id o9csp219313rbf; Tue, 23 Apr 2024 23:59:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU79jaHDjUOvshDkFIra4FN3aTGQ9lHlInffpVejlIrcoCjsAd7s6uT0KFFXnfE37Y2IootC6ekMv9C0vWu6/F6ZbcrgshAK0Kf0MCKWA== X-Google-Smtp-Source: AGHT+IHQ/Su//76ENjwae1cvCzJS4LS8AC7qZZhv6gN5FliaspHQOwqP2NsYDp9PN3q+drEGMkGZ X-Received: by 2002:a17:907:11cb:b0:a51:e5ac:7b7 with SMTP id va11-20020a17090711cb00b00a51e5ac07b7mr854150ejb.71.1713941979428; Tue, 23 Apr 2024 23:59:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713941979; cv=pass; d=google.com; s=arc-20160816; b=p4rtbnFP1+eWQZQMwrMcxV3eHf9spF32r3L48/akAZQ/4TJjM8WuMs9QplXEd9mvhw CXbqqucryuX6Z/biSbI+2Say9ooE3GJVlx7kr0wUlosB+fsgydE4W+Oxo9yemIzobEom pvJevt+fI82QyZNwypDa4VBF1mBQOhP/hS8vUmYKNSke5bc8wlOwNmYPXV8op0oIpAPs gOzsYTCVIUl9XnuV8UHCEq7jSSpqQ+ApFnc0QOezL6KgcV3X1I6k78WI+fxEMy1uok6i UxUTI3Qn7xtRoguMacSnyauHMcovpoIUESd9FW/T8Co5dbaLBEcdTgw/gXxIFAzYR5E+ /x/Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:date:message-id:dkim-signature; bh=2LDS+LSReqfsB8JRylwTSVQ4K8jQm0x7cZkTh0Y40I4=; fh=/xg4DVa1Y/3j8CjymsU5a7afnWRWyZlwJdlcaEBBf+k=; b=bgA56/sfc5rQmlGuSsx15plH+sT1YI17lWuMT91hKKK0gMseeIXLbgze0IZQf3vmC9 qbLuYuO4FpOKJladjBK0VyIOK8XWC4DKm20QuLysojPp8Q/abGakP9SnLJvny6rmuslU z9cSe7/qS3r95f78uxksStb9fvGuspY0XvhqKmH6xiyqCYLihEyEdVDHlLqTh2b9yYIq u+/PMHKWQAU+LYoYyQWDUlYWLbA9jyiox7kx86i1rkoMuZvr494WOeLKWImu04qvnaTs NAKmfbKOR76+ix7JqJNs1idI3h3+u6/5UymRekmBpJsQrXajyxsUzBN//wHtlVUmLkiG gqCw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=YQKThryx; 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-156433-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-156433-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 am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id z9-20020a1709063ac900b00a4743988f95si7830681ejd.820.2024.04.23.23.59.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 23:59:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-156433-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=YQKThryx; 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-156433-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-156433-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 325431F22690 for ; Wed, 24 Apr 2024 06:59:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 137B315A4A5; Wed, 24 Apr 2024 06:56:07 +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="YQKThryx" Received: from out30-124.freemail.mail.aliyun.com (out30-124.freemail.mail.aliyun.com [115.124.30.124]) (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 8EA2A158A07 for ; Wed, 24 Apr 2024 06:56:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713941766; cv=none; b=QXseCng/uLNP1++zAkn/D/Gte8Z/fG5B0PnVwuMVcAVO1CbmncRAYStl7KmYLbkd/NhDtsZ3PHDkIkH4iNddi2X/5g6lhyncNXqK36jeH00QapndvdAvm/L6o8xjlbo3W2letL4zDHbJcqIYStOl+f/84zRnOxC6uILUsMD+XdM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713941766; c=relaxed/simple; bh=17fXrczM/USVDSV8Jtxa3v6EpsLB23z4oQSPwC3f+Do=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=oySyFozXjkNtGEHJpqLsBVIPJ/2w2Ez64j7rCEMe1aAJrJppfzwV5tauH0SXSWpA74KM09y4VNd8LDnWv3mfRr7i/5r/3llN0vD3hsA4ZIaL1JirB7cpG3EEMwCWEhOMB24MO181Exg+Tuw/XsTUG+TLCDxy5SN3SNxZIeG3OCI= 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=YQKThryx; arc=none smtp.client-ip=115.124.30.124 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=1713941762; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=2LDS+LSReqfsB8JRylwTSVQ4K8jQm0x7cZkTh0Y40I4=; b=YQKThryxABYHVng0HXVknTY8e1PSCv0Z9To+K+zwvfyMk/xgQPhRnPwnMfYaQgRFy1sEmzYwUkFw+OH9l9esc7vulPFRHXWILb1gf3wd2lkcBzeDVAtH5whyCFu/c44NMjDy6jpRdVL8hhPQj7/WltHloZXdDoAnLg+wj8OKVQ4= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R871e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037067109;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=12;SR=0;TI=SMTPD_---0W5BTi-m_1713941728; Received: from 30.97.56.58(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0W5BTi-m_1713941728) by smtp.aliyun-inc.com; Wed, 24 Apr 2024 14:56:00 +0800 Message-ID: <5b663fcc-cace-4091-aa56-e88b00ec1d1c@linux.alibaba.com> Date: Wed, 24 Apr 2024 14:55:59 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH 2/5] mm: shmem: add an 'order' parameter for shmem_alloc_hugefolio() To: Kefeng Wang , akpm@linux-foundation.org, hughd@google.com Cc: willy@infradead.org, david@redhat.com, 21cnbao@gmail.com, ryan.roberts@arm.com, ying.huang@intel.com, shy828301@gmail.com, ziy@nvidia.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <2014bf7370d78bc1f5600731af5bf8f569e5868b.1713755580.git.baolin.wang@linux.alibaba.com> From: Baolin Wang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 2024/4/24 14:28, Kefeng Wang wrote: > > > On 2024/4/22 15:02, Baolin Wang wrote: >> 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); > > Avoid order variable, we can directly use HPAGE_PMD_NR here. Yes, sure. Thanks.