Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1834720rdh; Tue, 26 Sep 2023 05:12:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEB6U7eAixenIkgQfoTPz6EzzRgaydmfttkGoaJtOUBvpZmnKEuyC0KZmY15OQrKxEpv0Qh X-Received: by 2002:a05:6830:2098:b0:6bd:c865:a618 with SMTP id y24-20020a056830209800b006bdc865a618mr11807964otq.13.1695730328085; Tue, 26 Sep 2023 05:12:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695730328; cv=none; d=google.com; s=arc-20160816; b=wtFoGd/57biG4XqiLjgchtQglYnJt/A3k+J5WT9sGryhFS15eJSwK9y28dBe0KAk4H 6rVy+oL0DvwskFB+UKjQMAsVPFs5yja1lD+ab8k/hlEfV07whSSNU3EZFgh8QADv4/Ec rVOBojuh3NCYZfruQeo16Kq8235wh+aIXKMiHmaN0xlOKeYYTrMl4B8I871pYe8m4tXD UekgWifjfQRJrDSMIw+7VemMg7QokTfq+B1rMR2rWUA/1VcLBk4qNxIqaQc4t5OaB4eB 1E/TFQc+i4r/fF+mkOMdd/n2BGIbvKTzDFT7LzPbjIm5Y3p6lKde0puR32Dx1vphRAYk v5SQ== 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=TJSw/TZm4IXSjiH+N6IvV6fjbang/cpC3BCGa8UpJqw=; fh=w0HqZQH+LVeyaZnAul4E/a2u3mVPqUHxdfbQabwvRps=; b=HR1NTxUraKiAYFl63Jz18pBsOPTn/BDAsqRuQPNCwUUFjbXn7bCepnr2UNWTAyECne m8fdS27dFzidV3+1/dSFAMdO+zqULcmjCIPDRyGMXJLHgSwm5+4rIi53b2VAPS9XfGyW ZxnjPCYfLmQeWPEaW7JghmSwY0Hs1POfkNVJ3idUdHGY1dHPuA6r+m4c9uCziQH3xrh4 xv3+yLumWHkaVz67Qm92dfqvy5O7+amZfWOTSGLSX6sQYFCjfaLpI8LXoQMcCho1zZhp vUB84y5pNZaLpKQnGtqtBJicYtak92bAkJbXVhJg5a8Dvn+jMvKjsKi2Op+rnhiD0M7/ qn+A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id q17-20020a637511000000b005779c97fae5si12262183pgc.480.2023.09.26.05.12.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 05:12:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 80BD2829F67D; Tue, 26 Sep 2023 05:10:58 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234511AbjIZMLB (ORCPT + 99 others); Tue, 26 Sep 2023 08:11:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230231AbjIZMK7 (ORCPT ); Tue, 26 Sep 2023 08:10:59 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0AB29E6; Tue, 26 Sep 2023 05:10:53 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ACDDAC433C7; Tue, 26 Sep 2023 12:10:49 +0000 (UTC) From: Huacai Chen To: Arnd Bergmann , Huacai Chen Cc: loongarch@lists.linux.dev, linux-arch@vger.kernel.org, Xuefeng Li , Guo Ren , Xuerui Wang , Jiaxun Yang , linux-kernel@vger.kernel.org, loongson-kernel@lists.loongnix.cn, Huacai Chen , stable@vger.kernel.org, Chong Qiao Subject: [PATCH] LoongArch: numa: Fix high_memory calculation Date: Tue, 26 Sep 2023 20:10:31 +0800 Message-Id: <20230926121031.1901760-1-chenhuacai@loongson.cn> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE, SPF_PASS 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 26 Sep 2023 05:10:58 -0700 (PDT) high_memory is the virtual address of the 'highest physical address' in the system. But __va(get_num_physpages() << PAGE_SHIFT) is not what we want because there may be holes in the physical address space. On the other hand, max_low_pfn is calculated from memblock_end_of_DRAM(), which is exactly corresponding to the highest physical address, so use it for high_memory calculation. Cc: Signed-off-by: Chong Qiao Signed-off-by: Huacai Chen --- arch/loongarch/kernel/numa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/loongarch/kernel/numa.c b/arch/loongarch/kernel/numa.c index c7d33c489e04..6e65ff12d5c7 100644 --- a/arch/loongarch/kernel/numa.c +++ b/arch/loongarch/kernel/numa.c @@ -436,7 +436,7 @@ void __init paging_init(void) void __init mem_init(void) { - high_memory = (void *) __va(get_num_physpages() << PAGE_SHIFT); + high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT); memblock_free_all(); } -- 2.39.3