Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2250516pxp; Mon, 21 Mar 2022 15:00:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFpK7pNTBZ8pxNieKzfm10Pbk+7vVgp1pz66NM3mqNxnsDRvchBjw5LPAR0gHfMnC3W0lw X-Received: by 2002:aa7:8a13:0:b0:4f6:dedb:6c52 with SMTP id m19-20020aa78a13000000b004f6dedb6c52mr4018397pfa.31.1647900031396; Mon, 21 Mar 2022 15:00:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647900031; cv=none; d=google.com; s=arc-20160816; b=m448wh1x+ciMoFUySga+aTzKo8fw74CbrRgZMvIdxzSCHPLAhUlj/czyZInbHvifSu 7HFaUCitGhGsMk47CmggIHK9ATXtWnmI6MxZmPCY6FOEA3r9To5aesMgL3DdzKn6rOtp 6YxP6H45Chhin0VAXmhUbInFVA2d1iS9ZnvQy8+ZnbvQBbagAZkSwcNbBmjRV30sCVOq 6Rn24dW4pV1N/nP8WllvtoSJsinaC47bJz+aoXpZ43Jf+CLq/ccWBS1a6Ws0FHoMtoaG fSWVlpKF6Xuz3HDrFKuvMkwm7aHctVV1IO2+VOV4pk9CwdCFXlegI3Ik43BTK72/bMU0 IPYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=0gA2qXzSRl9qE4e/yYCKLgAXKN8MMVbC49krdg3yp3I=; b=ba+Ouq8XSaI9a4zKr8i89P2o0u54sil20bPZyuaB0ZzxaR/yc0zaAGoDwrRxhL8ck4 cf8ZwiVnI+l66a+MiKeDA+/2PS8H+GpoBLysG4AD3DinqwCJ0rjgTJz/+0fsEli1O8Wp 1kevSMWiG5h0decH3HLB79OOwtJ5Ukmx668dZ3Q4XiZwPJSqNIa0shLOeZVtG7UwX9iQ UekU2r6ahe29fenmNHcbvfvcVjpAkSLRMYAcGKzTgwgnwZEasZBJEbUu0pbwPuGsjb3q HP9foo/aSUgxahAZOVDJqW5WbnJBP46ACGZdNnGU+GRNOFtixOnignJvHFdYrB96PVGN 3XIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b="t6/7N1sZ"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id n18-20020a170902969200b00153b2d165a1si10858684plp.425.2022.03.21.15.00.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 15:00:31 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b="t6/7N1sZ"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5001E347367; Mon, 21 Mar 2022 14:25:18 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242112AbiCSEAg (ORCPT + 99 others); Sat, 19 Mar 2022 00:00:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242192AbiCSEAG (ORCPT ); Sat, 19 Mar 2022 00:00:06 -0400 Received: from mail-yb1-xb36.google.com (mail-yb1-xb36.google.com [IPv6:2607:f8b0:4864:20::b36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96D578C7EB for ; Fri, 18 Mar 2022 20:58:11 -0700 (PDT) Received: by mail-yb1-xb36.google.com with SMTP id z8so19065415ybh.7 for ; Fri, 18 Mar 2022 20:58:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=0gA2qXzSRl9qE4e/yYCKLgAXKN8MMVbC49krdg3yp3I=; b=t6/7N1sZ0ZkI6hW5qc6ora09i0y+N1UhwsfsFLFL74GSygv+Glm57pstuNI/fDtPTR /fzfKTU47bUXAyFve35zGys6ry7fp6P0n3+dEej8JfBkQdDoQAVOkSyEZckc23r1+dyJ QUoVnunu1WTQClkMrK66Hmm1eBAJ9zjuNNTYKYEZi2dBucihutg0niDaBEEG7K+Eiuvt PFgHrBK0esrxgY3edNfwPqWYoy00o+SVWwFtQpGqvDv5L06QOJ+VwgWAkDqZOMpEKYHE lhEiVpiVcZ8O6SQEdGLZjdqUMdL8QlXAIk5aBozC8b5DWbPVHxfc7xuf612ezBUZnwkY Ki7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=0gA2qXzSRl9qE4e/yYCKLgAXKN8MMVbC49krdg3yp3I=; b=2nniIT+xMDd9PVEl91h/erfSFekfVMOUSxVFMqtBuGRWbnKFnSbGTY7D3bf09XjG/E pF8SKAJhAbT0z4Tsk7t529MLcFurpMssu/gXC45us4yKM5VbNTLJ/IT/DymYCcnH7tBU 0X/zL2CZalkECbbgREM3Qr6QGiNKRhuWMQ1qh7vOJcNsconHWBeCZBZlQ/P2FIZIMsoW ds6cdxP9lOrIRSi5PIkM+1Yly31p2Bw10Fomr/OkSuEX1P7aa3EJxFL4e1MxjNKDZJpz kx2ZU6KTjWoAkUiRayXHb9dgeFOvJy+CRWrLExhBRmzOXOhAJJBpo98AdKaVSXmmf/bj YRBA== X-Gm-Message-State: AOAM530KM2v4vBEIwofAFTffRhUVYrzQOa/EVd+Fsh6BejVrG8Xy5Q1b aZHYnRqXG46Nm+TbZ6CLPtxqwEqopgSMAc7OwnNHEQ== X-Received: by 2002:a25:33d7:0:b0:633:134a:6e7c with SMTP id z206-20020a2533d7000000b00633134a6e7cmr12855599ybz.89.1647662290616; Fri, 18 Mar 2022 20:58:10 -0700 (PDT) MIME-Version: 1.0 References: <20220318100720.14524-1-songmuchun@bytedance.com> <20220318100720.14524-2-songmuchun@bytedance.com> In-Reply-To: From: Muchun Song Date: Sat, 19 Mar 2022 11:56:18 +0800 Message-ID: Subject: Re: [PATCH v4 1/4] mm: hugetlb_vmemmap: introduce STRUCT_PAGE_SIZE_IS_POWER_OF_2 To: Luis Chamberlain Cc: Jonathan Corbet , Mike Kravetz , Andrew Morton , Kees Cook , Iurii Zaikin , Oscar Salvador , David Hildenbrand , Linux Doc Mailing List , LKML , Linux Memory Management List , Xiongchun duan , Muchun Song Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 On Sat, Mar 19, 2022 at 12:40 AM Luis Chamberlain wrote: > > On Fri, Mar 18, 2022 at 06:07:17PM +0800, Muchun Song wrote: > > You can add Suggested-by tag here. Will do. Sorry for forgetting it. > > > Signed-off-by: Muchun Song > > --- > > Kbuild | 12 ++++++++++++ > > fs/Kconfig | 2 +- > > include/linux/mm_types.h | 2 ++ > > mm/Kconfig | 3 +++ > > mm/hugetlb_vmemmap.c | 6 ------ > > mm/struct_page_size.c | 19 +++++++++++++++++++ > > scripts/check_struct_page_po2.sh | 11 +++++++++++ > > 7 files changed, 48 insertions(+), 7 deletions(-) > > create mode 100644 mm/struct_page_size.c > > create mode 100755 scripts/check_struct_page_po2.sh > > > > diff --git a/Kbuild b/Kbuild > > index fa441b98c9f6..6bb97d348d62 100644 > > --- a/Kbuild > > +++ b/Kbuild > > @@ -14,6 +14,18 @@ $(bounds-file): kernel/bounds.s FORCE > > $(call filechk,offsets,__LINUX_BOUNDS_H__) > > > > ##### > > +# Generate struct_page_size.h. Must follows bounds.h. > > + > > +struct_page_size-file := include/generated/struct_page_size.h > > + > > +always-y := $(struct_page_size-file) > > +targets := mm/struct_page_size.s > > + > > +$(struct_page_size-file): mm/struct_page_size.s FORCE > > + $(call filechk,offsets,__LINUX_STRUCT_PAGE_SIZE_H__) > > + $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig > > + > > +##### > > Shouldn't this go into mm/Makefile instead? > We should guarantee that the include/generated/struct_page_size.h which Kconfig depends on is created before processing Makefile since processing Kconfig is before Makefile. Right? > > diff --git a/mm/Kconfig b/mm/Kconfig > > index 034d87953600..9314bd34f49e 100644 > > --- a/mm/Kconfig > > +++ b/mm/Kconfig > > @@ -2,6 +2,9 @@ > > > > menu "Memory Management options" > > > > +config STRUCT_PAGE_SIZE_IS_POWER_OF_2 > > + def_bool $(success,test "$(shell, $(srctree)/scripts/check_struct_page_po2.sh)" = 1) > > + > > config SELECT_MEMORY_MODEL > > def_bool y > > depends on ARCH_SELECT_MEMORY_MODEL > > new file mode 100755 > > index 000000000000..9547ad3aca05 > > --- /dev/null > > +++ b/scripts/check_struct_page_po2.sh > > @@ -0,0 +1,11 @@ > > +#!/bin/sh > > +# SPDX-License-Identifier: GPL-2.0 > > +# > > +# Check if the size of "struct page" is power of 2 > > + > > +file="include/generated/struct_page_size.h" > > +if [ ! -f "$file" ]; then > > Does this really work if one is workig off of a very clean build > like make mrproper and then make menuconfig or or mrproper followed > by a defconfig file ? Have you tried it for both cases po2 and npo2? > > Because isn't include/generated/struct_page_size.h generated? At > which point does it get generated and why would the condition hole > true that the file exists at a new 'make menuconfig' time? > You are right. include/generated/struct_page_size.h does not exist in this case, CONFIG_STRUCT_PAGE_SIZE_IS_POWER_OF_2 will be default off in .config. Then it will be switched on/off accordingly when you build the kernel, for instance make bzImage, which is done via "make syncconfig" which follows the generation of struct_page_size.h. While testing this case, I found some bugs. The following patch could fix this. Thanks. --- a/Kbuild +++ b/Kbuild @@ -21,6 +21,8 @@ struct_page_size-file := include/generated/struct_page_size.h always-y := $(struct_page_size-file) targets := mm/struct_page_size.s +mm/struct_page_size.s: $(timeconst-file) $(bounds-file) + $(struct_page_size-file): mm/struct_page_size.s FORCE $(call filechk,offsets,__LINUX_STRUCT_PAGE_SIZE_H__) $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig diff --git a/scripts/check_struct_page_po2.sh b/scripts/check_struct_page_po2.sh index 9547ad3aca05..1764ef9a4f1d 100755 --- a/scripts/check_struct_page_po2.sh +++ b/scripts/check_struct_page_po2.sh @@ -4,8 +4,6 @@ # Check if the size of "struct page" is power of 2 file="include/generated/struct_page_size.h" -if [ ! -f "$file" ]; then - exit 1 +if [ -f "$file" ]; then + grep STRUCT_PAGE_SIZE_IS_POWER_OF_2 "$file" | cut -d' ' -f3 fi - -grep STRUCT_PAGE_SIZE_IS_POWER_OF_2 "$file" | cut -d' ' -f3