Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp1619177rdb; Sat, 2 Dec 2023 03:15:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IFEyjDkEXQp9e1A1rKuZSPWw0AUjZGevVqRn6sKAviCmEP0rpIl5Nj/JQlb/cNmjjF3Lt+b X-Received: by 2002:a05:6e02:151:b0:35d:3623:db5b with SMTP id j17-20020a056e02015100b0035d3623db5bmr1447380ilr.3.1701515754049; Sat, 02 Dec 2023 03:15:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701515754; cv=none; d=google.com; s=arc-20160816; b=juQxBV+KWAzw0/G+ehB5PKEgeCBAh4jJ0FdWE067isVpfc16Z5ZDzSmxV+sLICbr+I uWpkB5R1a3z8vJrcY2uiRtid880d2jivbADKMmVkYZnL2iD9suaPo6ebyEJG1Qi1M4Pi Pxndx4OwPFKLFsScJPkHRO0elZbGJyp5WNwTAK6nTLZYLkBVAPT5EDKhNDcd2fuACR5K KnIDL3+1MPYKWfbCZPYkOW6/rp3gCEiTaoZMd9m+vOQlBiBw3FDxJYZLZk9e353LEdvw RX/Pbf6D8lvyn7GiWUG61BtaXEXJE9S6CCkCMNSIWMjcQFnvOJ9TthIxHEea1iuO0BY2 7iPg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=v4UHd4uT25TxSUzWPqsFRoZZNpRl4b4/7589i+JJ+rU=; fh=P6RRRpTWxvofOXHeqZhsCFgD8zlsvEHaYdPegDfVEf4=; b=vKf6S4orYNgrloDpFUowF32gFPtfH5EI1yQmp4wkuxydGFYg09YZwivhMX+d+LdXLb MLsqBCjvc7lsiVOljp+WbC5+LVqs3MQvcNVK7vKYd59LW7X/Fp43x+g1So0vcf6lbzGn HazrseDZj8rWOt98JA4adeIF0IGyWh0F0L7nfMRK1eCd6jt4/mP1gOOzBUJJCDLiB7iY ZUUZ/OLiQgOtfJXp8L1Y1PPx5QCjiWHsdxgKkIYmC8h4xZGOapqpcLxfY8wp0nCss6if egnEHl1BKKrzw3m/c34X+fNoEFYissvrqAjYfAbNMTGbhPGXOkklF4TCIDpxGsuVcHl5 q79g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=HfZFF7nN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id m16-20020a170902bb9000b001cf647a0c3fsi4615460pls.530.2023.12.02.03.15.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Dec 2023 03:15:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=HfZFF7nN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id BD0B9805C148; Sat, 2 Dec 2023 03:15:50 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232643AbjLBLOy (ORCPT + 99 others); Sat, 2 Dec 2023 06:14:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232545AbjLBLOp (ORCPT ); Sat, 2 Dec 2023 06:14:45 -0500 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 248A6197; Sat, 2 Dec 2023 03:14:51 -0800 (PST) Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-50bd8efb765so2280969e87.1; Sat, 02 Dec 2023 03:14:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701515689; x=1702120489; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=v4UHd4uT25TxSUzWPqsFRoZZNpRl4b4/7589i+JJ+rU=; b=HfZFF7nN/oDW4wix+atLctYMRShwcmwalhtabQ9cZATlVxB4WAgWsV9+TiFCSHbuFv ACUiiH5ol6NAIK8jI9ak/uBkf47n2TyfMrJIZMYI9E3K1kiQZ0Kk7XNkIDV+keeT2Rfn SWmztovrDAcAZ6gI6PqmxXchUplEyyzZMmrjeB2+kPLuym4iOHqTpmBBW8OexEHLiF46 ItDckB54zXmycUXLaj92EE1O8yDAergFxGFs8Cym17KNreMn+SO8YPNGRJNOTnMaWjOL FH+fEVdol9uxzx/4mG9mFuWlNi3FVaUQqNMThsJVFyWe6LmLU+v3lQNvPq8BTM1+bIrz ynyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701515689; x=1702120489; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=v4UHd4uT25TxSUzWPqsFRoZZNpRl4b4/7589i+JJ+rU=; b=nW6NltFONyARU5kc7AkU8yM7Ajykvm+STK4Q/VI2jpcgLyl6BMxB1Bj81umdrqoSUm FxEXzzOuPq+7WhGfBsnMCmCkGI8NRZ6murZZZQqvetGXHhph4nKtS03MMDJsdtsYL+Bd DbCCkXyQC+8nAxvaRDYNa5T2d5pEt+2wdI/ijhWkdg+KSGNjLHooBst1Y4dFFkBVY87H 4Uw3BBHPPZ00/EPveF1ZKM2gnNDT+4fRnEq/RsUb46641cNRAhXdzeYl62vY+iQ74pxF zTkXHVIHj+5x/kIpgWKcFrlzyvAyUnjwPae/vQLsO5d5uxQVfbeox5qH164BLgfH5g1U mt4w== X-Gm-Message-State: AOJu0Ywx4O3m++gIMOld3b9kqfHhTZP8yPcyHSB8rqK3GXHGgwe8oM/b aDnkTE5qAhAWhbgJkO09Frs= X-Received: by 2002:a05:6512:110c:b0:50b:d764:969d with SMTP id l12-20020a056512110c00b0050bd764969dmr1786496lfg.129.1701515689264; Sat, 02 Dec 2023 03:14:49 -0800 (PST) Received: from localhost ([95.79.203.166]) by smtp.gmail.com with ESMTPSA id c6-20020ac25f66000000b0050bed336e0csm66231lfc.162.2023.12.02.03.14.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Dec 2023 03:14:48 -0800 (PST) From: Serge Semin To: Thomas Bogendoerfer , Jiaxun Yang , Andrew Morton Cc: Serge Semin , Alexey Malahov , Arnd Bergmann , Aleksandar Rikalo , Aleksandar Rikalo , Dragan Mladjenovic , Christophe Leroy , Baoquan He , Chao-ying Fu , Yinglu Yang , Tiezhu Yang , Mike Rapoport , Matthew Wilcox , Marc Zyngier , linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 4/6] mips: Optimize max_mapnr init procedure Date: Sat, 2 Dec 2023 14:14:21 +0300 Message-ID: <20231202111430.18059-5-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231202111430.18059-1-fancer.lancer@gmail.com> References: <20231202111430.18059-1-fancer.lancer@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email 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]); Sat, 02 Dec 2023 03:15:50 -0800 (PST) max_mapnr defines the upper boundary of the pages space in the system. Currently in case if HIGHMEM is available it's calculated based on the upper high memory PFN limit value. Seeing there is a case when it isn't fully correct let's optimize out the max_mapnr variable initialization procedure to cover all the handled in the paging_init() method cases: 1. If CPU has DC-aliases, then high memory is unavailable so the PFNs upper boundary is determined by max_low_pfn. 2. Otherwise if high memory is available, use highend_pfn value representing the upper high memory PFNs limit. 3. Otherwise no high memory is available so set max_mapnr with the low-memory upper limit. Signed-off-by: Serge Semin --- Since I haven't seen any problem with the denoted misconfiguration on my setup, the patch isn't marked as fixes, but is supposed to be considered as an optimization. --- arch/mips/mm/init.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c index 6e368a4658b5..b2dce07116e8 100644 --- a/arch/mips/mm/init.c +++ b/arch/mips/mm/init.c @@ -421,9 +421,13 @@ void __init paging_init(void) " %ldk highmem ignored\n", (highend_pfn - max_low_pfn) << (PAGE_SHIFT - 10)); max_zone_pfns[ZONE_HIGHMEM] = max_low_pfn; - } - max_mapnr = highend_pfn ? highend_pfn : max_low_pfn; + max_mapnr = max_low_pfn; + } else if (highend_pfn) { + max_mapnr = highend_pfn; + } else { + max_mapnr = max_low_pfn; + } #else max_mapnr = max_low_pfn; #endif -- 2.42.1