Message ID | 20221026075638.9396-1-lvjianmin@loongson.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp120523wru; Wed, 26 Oct 2022 01:06:00 -0700 (PDT) X-Google-Smtp-Source: AMsMyM72U2lvN+Q5foNomsLPrpxuAh7JYYQRofBb2J5y3Zd77/+GRGjPd2CTQkNCS+n85eoB+J0S X-Received: by 2002:a17:907:1dda:b0:7a6:8ffc:7dc with SMTP id og26-20020a1709071dda00b007a68ffc07dcmr14494922ejc.163.1666771560729; Wed, 26 Oct 2022 01:06:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666771560; cv=none; d=google.com; s=arc-20160816; b=Z5RTZeAyQ2+8ITvP5DM/gxnOkfXBODgZs0lRv9RzyHo5U5q+nrLgTVt/f0CpBWVXUv xLHnvcWov77cwpqktvFfKIVfIDZFbUCNLWy5zIK/aGMkkHncI3IapTOmEikZkGyizTTF 6fplVOHapWj1eeF/x3ZX9eBKEDHJx2c9uPAlmbmVu/DF3s3ZgnloFHy/hb/bfCgyO3rm 50nCpS3VVInbr37uy6/yVXuO3OOkShEH7tjke8x2nGEKI5X2p3S6LH31RDZRL9X7tQ46 TzEVNW1N3VmmzvSchj/piXRnkMHWHA5/lH3qDsxta7EUlj47Gke2Alorw9GPJrk+w3Bu famw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=AfDlW7r17sm/lNwK2GudaQIpXNBup2Goj0stFppqiQA=; b=LyVGCpRfPkHl/+nwZb5TIc6obhyUD6XUrSRhAmqGU+Jf4LyMQggXgm7ORehbe82d41 bsxNzmZ7M0ujZo1QsNnYZpzar56bvcpd3oGkLAfVfRpOy5VNIudeCj7yAi/qvhUgR57S qn5XP2yj1ctU7mg1CT2FwOyaATxtdB9/NeI9QQyA58E4a/NpZB7O831IhlxETtMuOlba yyUQznNF7u1rJ5o7tOeQwgufmqhCvfmbDk3dDnX2H8kPjegcnZUFRXS0fEghZXtHVTR/ yUQ84swYfoYcf8dcxI4XzVAQGvml0Q5fW/1F9yTvOhrK1lNYNSvUy0pw+IwfBb0QUZho 96vA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b22-20020a170906709600b0078d4b605b71si4818370ejk.338.2022.10.26.01.05.35; Wed, 26 Oct 2022 01:06:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233250AbiJZH4p (ORCPT <rfc822;pwkd43@gmail.com> + 99 others); Wed, 26 Oct 2022 03:56:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232935AbiJZH4m (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 26 Oct 2022 03:56:42 -0400 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BFD3E9E2F5 for <linux-kernel@vger.kernel.org>; Wed, 26 Oct 2022 00:56:39 -0700 (PDT) Received: from loongson.cn (unknown [10.20.42.32]) by gateway (Coremail) with SMTP id _____8Dxfbc26FhjgI4CAA--.5005S3; Wed, 26 Oct 2022 15:56:38 +0800 (CST) Received: from loongson-pc.loongson.cn (unknown [10.20.42.32]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Dx_eE26FhjnjMFAA--.19364S2; Wed, 26 Oct 2022 15:56:38 +0800 (CST) From: Jianmin Lv <lvjianmin@loongson.cn> To: Huacai Chen <chenhuacai@kernel.org>, WANG Xuerui <kernel@xen0n.name> Cc: linux-kernel@vger.kernel.org, loongarch@lists.linux.dev Subject: [PATCH] LoongArch: Fix memsection size Date: Wed, 26 Oct 2022 15:56:38 +0800 Message-Id: <20221026075638.9396-1-lvjianmin@loongson.cn> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf8Dx_eE26FhjnjMFAA--.19364S2 X-CM-SenderInfo: 5oymxthqpl0qxorr0wxvrqhubq/ X-Coremail-Antispam: 1Uk129KBjvJXoW7Ar17Cr48uFy5JFyxZrWrXwb_yoW8Xw18pF nF9r1kKrs8WF4fCr4Iy3s8uFy5K395u34UtF98Z34DCw43WF1vyr4jywsrZF9rXw48AFWI qFZxXw4kZayUA3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj qI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUIcSsGvfJTRUUU b7kYFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s 1l1IIY67AEw4v_JrI_Jryl8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xv wVC0I7IYx2IY67AKxVWUJVWUCwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVWUJVW8JwA2z4 x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I8E87Iv6xkF7I0E14v26F4UJVW0owAS 0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07AIYIkI8VC2zVCFFI0UMc02F40EFcxC0V AKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1l Ox8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JMxAIw28IcxkI7VAKI48JMxC20s 026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_ JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14 v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWUJVW8JwCI42IY6xAIw20EY4v20xva j40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVWUJV W8JbIYCTnIWIevJa73UjIFyTuYvjxU25EfUUUUU X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS autolearn=ham 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747736656137452996?= X-GMAIL-MSGID: =?utf-8?q?1747736656137452996?= |
Series |
LoongArch: Fix memsection size
|
|
Commit Message
吕建民
Oct. 26, 2022, 7:56 a.m. UTC
On LoongArch, the physical address space ranging from 0 to 0xfffffff is
always memory, which is in the low half of the memsection range from 0 to
0x1fffffff with 512M memsection size, and the high half will be a hole with
invalid memory pages.
This situation may cause some issues. For example, the range of 0x10000000
to 0x1fffffff is io registers, which will be considered as valid memory range
since which is in the memsection of range of 0 to 0x1fffffff. During S3
sleep and resume, these io registers will be saved and restored as valid memory
page (pfn_valid() of common version considers that all pages in a memsection
are valid), which will cause exception, especially when restoring during resume.
We can use 256M size for memsection of LoongArch, or use the way as ARM64 to
walk through all memory memblock to check if a mem pfn is valid which maybe
lower performance. For simplicity, this patch just use the former way.
Signed-off-by: Jianmin Lv <lvjianmin@loongson.cn>
Comments
On 2022/10/26 15:56, Jianmin Lv wrote: > On LoongArch, the physical address space ranging from 0 to 0xfffffff is > always memory, which is in the low half of the memsection range from 0 to > 0x1fffffff with 512M memsection size, and the high half will be a hole with > invalid memory pages. The description is incorrect. For systems with less than 512MiB of memory for example, I believe not every address from 0x0 to 0x0fff_ffff is valid; and regarding the latter part of the sentence, what you mean by "invalid memory pages"... > > This situation may cause some issues. For example, the range of 0x10000000 > to 0x1fffffff is io registers, which will be considered as valid memory range > since which is in the memsection of range of 0 to 0x1fffffff. During S3 ... turns out to be totally valid, only of the I/O kind. (This might be a case of Chinglish that is actually conveying the incorrect meaning to unaware readers.) > sleep and resume, these io registers will be saved and restored as valid memory > page (pfn_valid() of common version considers that all pages in a memsection > are valid), which will cause exception, especially when restoring during resume. > > We can use 256M size for memsection of LoongArch, or use the way as ARM64 to > walk through all memory memblock to check if a mem pfn is valid which maybe > lower performance. For simplicity, this patch just use the former way. And the rest of the commit message is, unfortunately, a bit too verbose and hard to understand in general. I have to look at the actual change (luckily, a one-liner in this case) to confirm my understanding. I think your intent is just to *avoid stepping into IO memory region during suspend/resume by reducing the section size order by one*. Try reducing the verbosity of the commit message in v2? I can't proofread and edit every commit due to limited time, so you have to practice and improve your writing skills after all. I'll review that piece of text afterwards. :) > > Signed-off-by: Jianmin Lv <lvjianmin@loongson.cn> > > diff --git a/arch/loongarch/include/asm/sparsemem.h b/arch/loongarch/include/asm/sparsemem.h > index 3d18cdf1b069..05903b40a625 100644 > --- a/arch/loongarch/include/asm/sparsemem.h > +++ b/arch/loongarch/include/asm/sparsemem.h > @@ -8,7 +8,7 @@ > * SECTION_SIZE_BITS 2^N: how big each section will be > * MAX_PHYSMEM_BITS 2^N: how much memory we can have in that space > */ > -#define SECTION_SIZE_BITS 29 /* 2^29 = Largest Huge Page Size */ > +#define SECTION_SIZE_BITS 28 > #define MAX_PHYSMEM_BITS 48 > > #endif /* CONFIG_SPARSEMEM */ The change is trivial indeed but I'm not immediately giving the R-b.
On 2022/10/26 下午5:21, WANG Xuerui wrote: > On 2022/10/26 15:56, Jianmin Lv wrote: >> On LoongArch, the physical address space ranging from 0 to 0xfffffff is >> always memory, which is in the low half of the memsection range from 0 to >> 0x1fffffff with 512M memsection size, and the high half will be a hole >> with >> invalid memory pages. > > The description is incorrect. For systems with less than 512MiB of > memory for example, I believe not every address from 0x0 to 0x0fff_ffff > is valid; As far as I know, almost all designs use 0x0 to 0x0fff_ffff as memory even with 512M because it's difficult to set cpu to support a combination with memory and non-memory for 0x0 to 0x0fff_ffff. > and regarding the latter part of the sentence, what you mean > by "invalid memory pages"... > If with 512M memsection size, for the memsection from 0 to 0x1fffffff, low half (0 to 0xfffffff) is valid memory, and high half(0x10000000 to 0x1fffffff ) is I/O registers (of chipsets and cpu), so high half is not memory, I think it's better to change *with invalid memory pages* to *which is not memory.* >> >> This situation may cause some issues. For example, the range of >> 0x10000000 >> to 0x1fffffff is io registers, which will be considered as valid >> memory range >> since which is in the memsection of range of 0 to 0x1fffffff. During S3 > > ... turns out to be totally valid, only of the I/O kind. (This might be > a case of Chinglish that is actually conveying the incorrect meaning to > unaware readers.) > The whole range of the 512M memsection will be totally valid by pfn_valid(), and let me try reduce the example description. :) >> sleep and resume, these io registers will be saved and restored as >> valid memory >> page (pfn_valid() of common version considers that all pages in a >> memsection >> are valid), which will cause exception, especially when restoring >> during resume. >> >> We can use 256M size for memsection of LoongArch, or use the way as >> ARM64 to >> walk through all memory memblock to check if a mem pfn is valid which >> maybe >> lower performance. For simplicity, this patch just use the former way. > > And the rest of the commit message is, unfortunately, a bit too verbose > and hard to understand in general. I have to look at the actual change > (luckily, a one-liner in this case) to confirm my understanding. > > I think your intent is just to *avoid stepping into IO memory region > during suspend/resume by reducing the section size order by one*. Yes. > Try reducing the verbosity of the commit message in v2? Ok, let me try. :) > I can't proofread and edit every commit due to limited time, so you have to practice and > improve your writing skills after all. I'll review that piece of text > afterwards. :) > Ok, thanks. >> >> Signed-off-by: Jianmin Lv <lvjianmin@loongson.cn> >> >> diff --git a/arch/loongarch/include/asm/sparsemem.h >> b/arch/loongarch/include/asm/sparsemem.h >> index 3d18cdf1b069..05903b40a625 100644 >> --- a/arch/loongarch/include/asm/sparsemem.h >> +++ b/arch/loongarch/include/asm/sparsemem.h >> @@ -8,7 +8,7 @@ >> * SECTION_SIZE_BITS 2^N: how big each section will be >> * MAX_PHYSMEM_BITS 2^N: how much memory we can have in that >> space >> */ >> -#define SECTION_SIZE_BITS 29 /* 2^29 = Largest Huge Page Size */ >> +#define SECTION_SIZE_BITS 28 >> #define MAX_PHYSMEM_BITS 48 >> #endif /* CONFIG_SPARSEMEM */ > > The change is trivial indeed but I'm not immediately giving the R-b. >
Hi Jianmin,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on linus/master]
[also build test WARNING on v6.1-rc2 next-20221026]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Jianmin-Lv/LoongArch-Fix-memsection-size/20221026-155924
patch link: https://lore.kernel.org/r/20221026075638.9396-1-lvjianmin%40loongson.cn
patch subject: [PATCH] LoongArch: Fix memsection size
config: loongarch-defconfig
compiler: loongarch64-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/6f7453a9afb01ac06032833503f47f335a2623f9
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Jianmin-Lv/LoongArch-Fix-memsection-size/20221026-155924
git checkout 6f7453a9afb01ac06032833503f47f335a2623f9
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=loongarch SHELL=/bin/bash
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
All warnings (new ones prefixed by >>):
>> mm/memory.c:95:2: warning: #warning Unfortunate NUMA and NUMA Balancing config, growing page-frame for last_cpupid. [-Wcpp]
95 | #warning Unfortunate NUMA and NUMA Balancing config, growing page-frame for last_cpupid.
| ^~~~~~~
vim +95 mm/memory.c
42b7772812d15b Jan Beulich 2008-07-23 93
af27d9403f5b80 Arnd Bergmann 2018-02-16 94 #if defined(LAST_CPUPID_NOT_IN_PAGE_FLAGS) && !defined(CONFIG_COMPILE_TEST)
90572890d20252 Peter Zijlstra 2013-10-07 @95 #warning Unfortunate NUMA and NUMA Balancing config, growing page-frame for last_cpupid.
75980e97daccfc Peter Zijlstra 2013-02-22 96 #endif
75980e97daccfc Peter Zijlstra 2013-02-22 97
diff --git a/arch/loongarch/include/asm/sparsemem.h b/arch/loongarch/include/asm/sparsemem.h index 3d18cdf1b069..05903b40a625 100644 --- a/arch/loongarch/include/asm/sparsemem.h +++ b/arch/loongarch/include/asm/sparsemem.h @@ -8,7 +8,7 @@ * SECTION_SIZE_BITS 2^N: how big each section will be * MAX_PHYSMEM_BITS 2^N: how much memory we can have in that space */ -#define SECTION_SIZE_BITS 29 /* 2^29 = Largest Huge Page Size */ +#define SECTION_SIZE_BITS 28 #define MAX_PHYSMEM_BITS 48 #endif /* CONFIG_SPARSEMEM */