Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp825776pxb; Tue, 12 Apr 2022 14:31:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwEGGrf642JPYQhtR41IdE0zuhYWJ0wANJOOFetSozMMv20V7K6zmcWT9GZsE+mneW+V2EW X-Received: by 2002:a17:90a:600b:b0:1cb:8ba5:d3bc with SMTP id y11-20020a17090a600b00b001cb8ba5d3bcmr7213001pji.42.1649799115325; Tue, 12 Apr 2022 14:31:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649799115; cv=none; d=google.com; s=arc-20160816; b=KJNmOzSU1m6BQfiRLn3xkQY5opHins2bUOmv7NliXiz8GXupUjynx+/eWLexq8wKtN ImiCSReXt3b5KykoylSRJPh5ReQSe7xg2kzBJ4t/gzPGl1eFcqCjALt+2SlgJSpJBA/e EShhVfFLUIEaqC4yMYTzwbr0JLxeTdzAQtrZr/fvUMFHo4Mq0FTzd9K48baN366ih99k VSZwRagPpddIIIKHdahxqcIkY3Fnuq/IJYfh3dl+RktRIDpiUCP0N0B/RekKjAMphZ4K PV0gqMvnDocdbH5FUUi18z7oFUujECbWvGS6iSbaFyfpoP2gKwl2Xthc2er9f4VFOArQ oE/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=MHOm1tS6UY0+dHUTJrUMw8Q+8aCJ7sp8oEsef1gcb+c=; b=y68VtIyhqNfzLGCtT0ExQ3+UoYd/fBqVrQcNy73a52F+qBCjkxX7o7pBl4IKfbz3LK HGIk/IJSsrOM52sQBz/QpTXymjmwTQtOvy7WhTjXmx6GWMvfMHSBmh5ArTyRBHPrpq+8 tj0qK5w1l4PHYjPvEHNGAB5pqCHeQDgjqV7FWk4TNSLtESjKxaAKXe/c/rg8HdjoI8r3 1ZAjIX3lyKNqbnmAEb1iNnlDrZX0Fj2PKrE2QuKDwIo7iKrPTGEl4tqtCrXIQUE6mW0Q wDr3Mp2YkUmLg2LijTA1wr/vJ3gSG4YWwya34DmSLKGYPx9oRsLJC+TJ6Q79ePRyM1po SK5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=Woo11qLt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id b24-20020a170902b61800b00156d87887eesi12202202pls.83.2022.04.12.14.31.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 14:31:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=Woo11qLt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6C61BB3683; Tue, 12 Apr 2022 13:38:51 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349479AbiDKTMH (ORCPT + 99 others); Mon, 11 Apr 2022 15:12:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231857AbiDKTME (ORCPT ); Mon, 11 Apr 2022 15:12:04 -0400 Received: from alexa-out.qualcomm.com (alexa-out.qualcomm.com [129.46.98.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 693FE1EECB for ; Mon, 11 Apr 2022 12:09:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1649704190; x=1681240190; h=from:to:cc:subject:date:message-id:mime-version; bh=MHOm1tS6UY0+dHUTJrUMw8Q+8aCJ7sp8oEsef1gcb+c=; b=Woo11qLtQ4gk1p33DRKnd/BeFG7N7Y9hWZqTQ9Pw3r7JJz+Av+qTRM4Q c0mcHmhq1+kZ/wP+nH0bxz8uct8Ko121p9nPVcfEcAeHx/0Wv4eDU4sY+ 4D7kgjN0Xccg+QrM04Nj9vAk3k0Q++L/XWbVkky/ZYgWA2E4/ejtiPmCE o=; Received: from ironmsg09-lv.qualcomm.com ([10.47.202.153]) by alexa-out.qualcomm.com with ESMTP; 11 Apr 2022 12:09:50 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg09-lv.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Apr 2022 12:09:49 -0700 Received: from nalasex01b.na.qualcomm.com (10.47.209.197) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Mon, 11 Apr 2022 12:09:49 -0700 Received: from faiyazm-linux.qualcomm.com (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Mon, 11 Apr 2022 12:09:46 -0700 From: Faiyaz Mohammed To: , , , , , , , CC: Faiyaz Mohammed Subject: [PATCH] mm: memblock: avoid to create memmap for memblock nomap regions Date: Tue, 12 Apr 2022 00:39:32 +0530 Message-ID: <1649704172-13181-1-git-send-email-quic_faiyazm@quicinc.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01b.na.qualcomm.com (10.47.209.197) X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 This 'commit 86588296acbf ("fdt: Properly handle "no-map" field in the memory region")' is keeping the no-map regions in memblock.memory with MEMBLOCK_NOMAP flag set to use no-map memory for EFI using memblock api's, but during the initialization sparse_init mark all memblock.memory as present using for_each_mem_pfn_range, which is creating the memmap for no-map memblock regions. To avoid it skiping the memblock.memory regions set with MEMBLOCK_NOMAP set and with this change we will be able to save ~11MB memory for ~612MB carve out. With change: [ 0.000000] memblock_alloc_exact_nid_raw: 115343360 bytes align=0x200000 nid=0 from=0x0000000080000000 max_addr=0x0000000000000000 sparse_buffer_init+0x60/0x8c [ 0.000000] memblock_reserve: [0x0000000932c00000-0x00000009399fffff] memblock_alloc_range_nid+0xbc/0x1a0 [ 0.000000] On node 0 totalpages: 1627824 [ 0.000000] DMA32 zone: 5383 pages used for memmap [ 0.000000] Normal zone: 20052 pages used for memmap Without change: [ 0.000000] memblock_alloc_exact_nid_raw: 117440512 bytes align=0x200000 nid=0 from=0x0000000080000000 max_addr=0x0000000000000000 sparse_buffer_init+0x60/0x8c [ 0.000000] memblock_reserve: [0x0000000932a00000-0x00000009399fffff] memblock_alloc_range_nid+0xbc/0x1a0 [ 0.000000] On node 0 totalpages: 1788416 [ 0.000000] DMA32 zone: 8192 pages used for memmap [ 0.000000] Normal zone: 20052 pages used for memmap. Signed-off-by: Faiyaz Mohammed --- mm/memblock.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mm/memblock.c b/mm/memblock.c index 2270e3c..a4fde9d 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -1175,8 +1175,13 @@ void __init_memblock __next_mem_pfn_range(int *idx, int nid, r = &type->regions[*idx]; r_nid = memblock_get_region_node(r); + /* If memblock region is nomap then skip the region. */ + if (memblock_is_nomap(r)) + continue; + if (PFN_UP(r->base) >= PFN_DOWN(r->base + r->size)) continue; + if (nid == MAX_NUMNODES || nid == r_nid) break; } -- 2.7.4