Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp1495913lqp; Fri, 22 Mar 2024 18:05:53 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU9rjAcIXiuXqCxJ/AOhQKoT1rJKgBnwBW34afR36TpjDZkNApUcrGGo2qLm3tVGj4i0BJz0/A9dqGJXigdUEIbdb1gWecOI1vzLtNpww== X-Google-Smtp-Source: AGHT+IFgjD3qvkEkfTR8ImgLZ6XHqB0iYC1/9sOf72cZHi27KZiF6mxA8kR2XrVWzQiXotb0j7/A X-Received: by 2002:a05:620a:22ad:b0:789:faed:fcb4 with SMTP id p13-20020a05620a22ad00b00789faedfcb4mr1017783qkh.21.1711155953133; Fri, 22 Mar 2024 18:05:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711155953; cv=pass; d=google.com; s=arc-20160816; b=UVrm0ohtwT2JuMdaLW+Rfc+hkVrLQ4+lkkQ3O0AMgu8WeeCLFAhwhhmmxvi1zz2FlG jRdhOqUD7a5ys4DA2hfq0jNGXq1GVki9KVoyMtiSAZbs4exI09y67qKKByGJYUheffgn wOdboVUxu1yA+6C1yMmcJs+aVc2c1Wrwb2xzzevxMl4LGf6dB+Toah5iw6PEJbiei/jg mNj9Sfvq8CD9Ib3pb9kaJ7IW6ZlFtQ2EZTOgX4ck1vJfrs62GlhXgbziUVwR7HZaTBpv 103DdodiYrKl2d8anCkJ5lu02ev8+73mOpu+XgJ0Dy6x59bGTkZUf2dV/63dR+9m7pFp tIgw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=qw4e8xfyGYKKEFEJ0g/Iuhbg+Kwe7B07eexTuW3SMxE=; fh=DBC6om/xrnuwgM9YHT8UnLnbLFmX0JgjNwMBl+/jiHM=; b=Ha2zeMnXjEsg9oMQN7jRCDg0G4a+pdY+GZ8hYzVFGvw64np7kZ7kWizXlRbO8xUwvF KbjtSbikwzPepvZnEot3M0y5+9BaUzp26cbjEH71qZrwbkEoyDSEXDx5fbwAOezukPMy +A56XLAHuBF2xSO7JEvCisCAReM9c5sN9gYDrg5gDaKaUiSxUikmrMUtBNWRPk01MUMO o71Ba/6++iuJHBaPNXKWefgetCGajoATmPOjUKOH6Gh6/9iioqwUmtT/bbIIfaAYh+kn lR2g8lJrgX9011vCN2thH2uSMeo5n4q+N7WpW4PIwVgsvl5Ftg+HqWtO2GbG3owGD2L6 iSMQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EcMiWiUk; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-112152-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112152-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id a22-20020a05620a16d600b00789ffa4a3a2si833471qkn.214.2024.03.22.18.05.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 18:05:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-112152-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EcMiWiUk; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-112152-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112152-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id BE9DC1C22A03 for ; Sat, 23 Mar 2024 01:05:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4B6BEA59; Sat, 23 Mar 2024 01:05:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="EcMiWiUk" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 4C50F7F for ; Sat, 23 Mar 2024 01:05:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711155946; cv=none; b=pxK2Cxx7lFyiflf1kwlpk/PVVsbGUyM3RWiOJGT+F6cHieXbRJug0iZ8XZXA0/62SjbHoOhRlCXSh+lOxSprw6/eEuqdSnlSkx1lzwda5st1R4Fp3wfAI7Tc4CB0h/rGnG3VTRGOzIdm392oQvOT5GXW1v8cF/UZlCYi3GqtWho= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711155946; c=relaxed/simple; bh=3+zZh3XFJnxQpCAGDeyGmKq33BNtz2+66eAEGL4876Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To; b=aCQdHLD0kmck5yROBP61AfUBC04zQlhbPF2xcqMiOJ/MS/rp5N+UIl3vxC6dGuQlvhU5pknCvoyUFKNtVZWIHVjPjGaVpw6H2kS74MgsaPRflxrjxGn7dcDE/dTw8k9HyTFcVzFYVd6aEOK38skT4Ay2pRILnI/texxygi4RONU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EcMiWiUk; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 04826C433F1; Sat, 23 Mar 2024 01:05:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711155945; bh=3+zZh3XFJnxQpCAGDeyGmKq33BNtz2+66eAEGL4876Q=; h=From:To:Cc:Subject:Date:In-Reply-To:From; b=EcMiWiUkiXF0pmTkhVhDvP+BA3m6SBMpMePHLS3lgvhzbCdo9T5o6x2xTa8QoCvtQ ZiIr3laXn2TxW1OUddMIfS1+bJqiPdQdS/W9Rj6yvZxknL1k5q/DKyC9sWIyvTCsmL qjz9g+3k55UpMTkbn5Fmp2EPQC/vmOSHUkLHq5nPc1YFOdstql4q7f52P4kaf6kZOe OK6Xw3iZcQy36q6zjiD/Nq4FMHprCktSrO9wXGQN1nYHgDgHW9odHpf0M4qlTAphIv Qt9VjffONOVJFRHRVRK9EkkPxU/upViU53CWHBYVwXM057H2FC5cyRrlr1LY92qHmO G5ofpS5wd8PeQ== From: SeongJae Park To: Peter Xu Cc: SeongJae Park , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Michael Ellerman , Christophe Leroy , Matthew Wilcox , Rik van Riel , Lorenzo Stoakes , Axel Rasmussen , Yang Shi , John Hubbard , linux-arm-kernel@lists.infradead.org, "Kirill A . Shutemov" , Andrew Jones , Vlastimil Babka , Mike Rapoport , Andrew Morton , Muchun Song , Christoph Hellwig , linux-riscv@lists.infradead.org, James Houghton , David Hildenbrand , Jason Gunthorpe , Andrea Arcangeli , "Aneesh Kumar K . V" , Mike Kravetz Subject: Re: [PATCH v3 03/12] mm: Make HPAGE_PXD_* macros even if !THP Date: Fri, 22 Mar 2024 18:05:28 -0700 Message-Id: <20240323010528.10959-1-sj@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Hi Peter, On Fri, 22 Mar 2024 20:30:24 -0400 Peter Xu wrote: > On Fri, Mar 22, 2024 at 10:14:56AM -0700, SeongJae Park wrote: > > Hi Peter, > > Hi, SeongJae, > > > > > On Thu, 21 Mar 2024 18:07:53 -0400 peterx@redhat.com wrote: > > > > > From: Peter Xu > > > > > > These macros can be helpful when we plan to merge hugetlb code into generic > > > code. Move them out and define them even if !THP. > > > > > > We actually already defined HPAGE_PMD_NR for other reasons even if !THP. > > > Reorganize these macros. > > > > > > Reviewed-by: Christoph Hellwig > > > Reviewed-by: Jason Gunthorpe > > > Signed-off-by: Peter Xu > > > --- > > > include/linux/huge_mm.h | 17 ++++++----------- > > > 1 file changed, 6 insertions(+), 11 deletions(-) > > > > > > diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h > > > index de0c89105076..3bcdfc7e5d57 100644 > > > --- a/include/linux/huge_mm.h > > > +++ b/include/linux/huge_mm.h > > > @@ -64,9 +64,6 @@ ssize_t single_hugepage_flag_show(struct kobject *kobj, > > > enum transparent_hugepage_flag flag); > > > extern struct kobj_attribute shmem_enabled_attr; > > > > > > -#define HPAGE_PMD_ORDER (HPAGE_PMD_SHIFT-PAGE_SHIFT) > > > -#define HPAGE_PMD_NR (1< > > - > > > /* > > > * Mask of all large folio orders supported for anonymous THP; all orders up to > > > * and including PMD_ORDER, except order-0 (which is not "huge") and order-1 > > > @@ -87,14 +84,19 @@ extern struct kobj_attribute shmem_enabled_attr; > > > #define thp_vma_allowable_order(vma, vm_flags, smaps, in_pf, enforce_sysfs, order) \ > > > (!!thp_vma_allowable_orders(vma, vm_flags, smaps, in_pf, enforce_sysfs, BIT(order))) > > > > > > -#ifdef CONFIG_TRANSPARENT_HUGEPAGE > > > #define HPAGE_PMD_SHIFT PMD_SHIFT > > > #define HPAGE_PMD_SIZE ((1UL) << HPAGE_PMD_SHIFT) > > > #define HPAGE_PMD_MASK (~(HPAGE_PMD_SIZE - 1)) > > > +#define HPAGE_PMD_ORDER (HPAGE_PMD_SHIFT-PAGE_SHIFT) > > > +#define HPAGE_PMD_NR (1< > > > > > #define HPAGE_PUD_SHIFT PUD_SHIFT > > > #define HPAGE_PUD_SIZE ((1UL) << HPAGE_PUD_SHIFT) > > > #define HPAGE_PUD_MASK (~(HPAGE_PUD_SIZE - 1)) > > > +#define HPAGE_PUD_ORDER (HPAGE_PUD_SHIFT-PAGE_SHIFT) > > > +#define HPAGE_PUD_NR (1< > > > I just found latest mm-unstable fails one of my build configurations[1] with > > below error. 'git bisect' says this is the first patch set started the > > failure. I haven't looked in deep, but just reporting first. > > > > In file included from .../include/linux/mm.h:1115, > > from .../mm/vmstat.c:14: > > .../mm/vmstat.c: In function 'zoneinfo_show_print': > > .../include/linux/huge_mm.h:87:25: error: 'PMD_SHIFT' undeclared (first use in this function); did you mean 'PUD_SHIFT'? > > 87 | #define HPAGE_PMD_SHIFT PMD_SHIFT > > | ^~~~~~~~~ > > > > [1] https://github.com/awslabs/damon-tests/blob/next/corr/tests/build_m68k.sh > > Apologies for the issue. No problem at all, this blocks nothing in real :) > This is caused by !CONFIG_MMU, I think. > > I thought this would be fairly easy to fix by putting these macros under > CONFIG_PGTABLE_HAS_HUGE_LEAVES, however when doing this I could have found > some other issue that violates this rule.. mm/vmstat.c has referenced > HPAGE_PMD_NR even if vmstat_item_print_in_thp() wanted to guard it only > with CONFIG_THP. > > /home/peterx/git/linux/mm/vmstat.c: In function 'zoneinfo_show_print': > /home/peterx/git/linux/mm/vmstat.c:1689:42: error: 'HPAGE_PMD_NR' undeclared (first use in this function) > 1689 | pages /= HPAGE_PMD_NR; > | ^~~~~~~~~~~~ > /home/peterx/git/linux/mm/vmstat.c:1689:42: note: each undeclared identifier is reported only once for each function it appears in > CC drivers/tty/tty_port.o > /home/peterx/git/linux/mm/vmstat.c: In function 'vmstat_start': > /home/peterx/git/linux/mm/vmstat.c:1822:33: error: 'HPAGE_PMD_NR' undeclared (first use in this function) > 1822 | v[i] /= HPAGE_PMD_NR; > | ^~~~~~~~~~~~ > make[4]: *** [/home/peterx/git/linux/scripts/Makefile.build:243: mm/vmstat.o] Error 1 > > static __always_inline bool vmstat_item_print_in_thp(enum node_stat_item item) > { > if (!IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)) > return false; > ... > } > > I think the problem is vmstat_item_print_in_thp() uses IS_ENABLED() however > that won't stop compiler from looking into the "if".. so it'll still try to > find the HPAGE_PMD_NR macro. > > It means, I may need to further change vmstat_item_print_in_thp() to make > this work in the clean way.. by properly switching to a #ifdef. > > For that I'll need to post a formal patch and add people to review. I'll > keep you posted. Thank you for this kind explanation, all makes sense to me. Looking forward to the patch. > > Side note: thank you for your script, just to mention make.cross has been > moved to kbuild/, and it'll also need kbuild.sh now to work. So you may > want to fix your test script (and it worked for you because you kept the > old make.cross around), like: > > wget https://raw.githubusercontent.com/intel/lkp-tests/master/kbuild/make.cross -O ./bin/make.cross > wget https://raw.githubusercontent.com/intel/lkp-tests/master/kbuild/kbuild.sh -O ./bin/kbuild.sh And thank you so much for this nice suggestion. I'll revisit the script soon. Thanks, SJ > > Thanks, > > -- > Peter Xu