Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp588900imu; Tue, 27 Nov 2018 17:57:27 -0800 (PST) X-Google-Smtp-Source: AFSGD/UqHOv+HJPsJxyy1vC1DrasbkIQgWk5YxBOIPfjzP/dGLboFGsE5V7JCw73IpSVhAs+UlLD X-Received: by 2002:a17:902:f082:: with SMTP id go2mr34981372plb.115.1543370247818; Tue, 27 Nov 2018 17:57:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543370247; cv=none; d=google.com; s=arc-20160816; b=Gu0mXrFCLxAXNwj/CXxxl01pXuU2g2dymFy+6uR56bT9c2W8hbryxYmBVU/kc/9EZV zLEzGrtPT6NqfJOw7rx8vyyazQ8PRxzfLjcpTHr7Fz0egUoYNmswyyU7kQdTBrMncUYL hHjPnKjsRjEjEzDDUxuqoL90dlyhKoqlXfobKiHwaQ+9GPAp/Wf2B2whfPvnevtUX6/u Y6KtBEJx+zXPK5sB+ahrjoAwsqUBTvyErpedxvd3ul9HjZePjHYZHcfvZS0HtFUDWNYs gPkLaT8AIbGTtaxYM7HcZs3tCQZyGOy5a0eWe45nD528ohqc14XeNhLsVDk7TY4gyFTz jIDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :references:in-reply-to:date:cc:to:from:subject:message-id; bh=BfIKBebR7jnC/6TS04SoP1Z6BU0xiGUnxFKJldPKniw=; b=Bx24yy0gcuLtVUrWsJjDdkcw++Bmf0xtZ+4aslpv134bA5XoS18qONDzzGi2cHjqDl 4EgM98fxk7tXGy2Wfly9vO6+uK5P8gv2wcnAtzeHH7218gK5hD4xc+hcfHOMlstPuxNB Ks1Qc3ePzjc5HpAZdkGp8XiMWDhX4DHNeNYTgVvyvJ6ghUQGAwS4B/o0NAMOZkdnuS+g Op8gAnfwxsnuxfYY+8A6YQr9t8LwiG1EZaPNlKsxk3UmzKb9NLm0naA+d4cmVAiKtbSH IIQ9bUWpVFxLBHLlyDDqtZYBVIJ+fLm/rwsGSFgfwOAfFqMRQtEDLEmV6t8xZqE4o5QM larg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s19si5279213plp.151.2018.11.27.17.57.12; Tue, 27 Nov 2018 17:57:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727071AbeK1M42 (ORCPT + 99 others); Wed, 28 Nov 2018 07:56:28 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:59989 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726567AbeK1M42 (ORCPT ); Wed, 28 Nov 2018 07:56:28 -0500 X-UUID: 6542eafbb3714b4f9ea02bbbd275962f-20181128 X-UUID: 6542eafbb3714b4f9ea02bbbd275962f-20181128 Received: from mtkcas09.mediatek.inc [(172.21.101.178)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 57205632; Wed, 28 Nov 2018 09:56:16 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs03n1.mediatek.inc (172.21.101.181) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 28 Nov 2018 09:56:04 +0800 Received: from [172.21.77.33] (172.21.77.33) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Wed, 28 Nov 2018 09:56:04 +0800 Message-ID: <1543370164.29143.9.camel@mtkswgap22> Subject: Re: [RFC PATCH] of: make MAX_RESERVED_REGIONS configurable From: Miles Chen To: Rob Herring CC: Frank Rowand , , "linux-kernel@vger.kernel.org" , "moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE" , , Date: Wed, 28 Nov 2018 09:56:04 +0800 In-Reply-To: <1543196004.21289.1.camel@mtkswgap22> References: <1542787873-8429-1-git-send-email-miles.chen@mediatek.com> <1542855088.15789.6.camel@mtkswgap22> <1543196004.21289.1.camel@mtkswgap22> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3-0ubuntu6 Content-Transfer-Encoding: 7bit MIME-Version: 1.0 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2018-11-26 at 09:33 +0800, Miles Chen wrote: > On Sat, 2018-11-24 at 14:56 -0600, Rob Herring wrote: > > On Wed, Nov 21, 2018 at 8:51 PM Miles Chen wrote: > > > > > > On Wed, 2018-11-21 at 10:39 -0600, Rob Herring wrote: > > > > On Wed, Nov 21, 2018 at 2:11 AM wrote: > > > > > > > > > > From: Miles Chen > > > > > > > > > > When we use more than 32 entries in /resered-memory, > > > > > there will be an error message: "not enough space all defined regions.". > > > > > We can increase MAX_RESERVED_REGIONS to fix this. > > > > > > > > > > commit 22f8cc6e3373 ("drivers: of: increase MAX_RESERVED_REGIONS to 32") > > > > > increased MAX_RESERVED_REGIONS to 32 but I'm not sure if increasing > > > > > MAX_RESERVED_REGIONS to 64 is suitable for everyone. > > > > > > > > > > In this RFC patch, CONFIG_MAX_OF_RESERVED_REGIONS is added and used as > > > > > MAX_RESERVED_REGIONS. Add a sanity test to make sure that > > > > > MAX_RESERVED_REGIONS is less than INIT_MEMBLOCK_REGIONS. > > > > > Users can configure CONFIG_MAX_OF_RESERVED_REGIONS according to their > > > > > need. > > > > > > > > I don't want a kconfig option for this. I think it should be dynamic instead. > > > > > > > > The current flow is like this: > > > > > > > > for each reserved node: > > > > - call memblock_reserve > > > > - Add info to reserved_mem array > > > > > > > > I think we should change it to: > > > > > > > > for each reserved node: > > > > - call memblock_reserve > > > > - count number of nodes > > > > > > > > Alloc array using memblock_alloc > > > > > > > > for each reserved node: > > > > - Add info to reserved_mem array > > > > > > > > > > thanks for your comment. > > > > > > I reviewed the flow and it might be easier to count the > > > nodes and setup array first: > > > > > > for each reserved node: > > > - count number of nodes > > > > > > Alloc array using memblock_alloc > > > > > > > > > for each reserved node: > > > - call memblock_reserve > > > > The order here is wrong. It is important that you reserve the memory > > blocks before doing any allocations. > > thanks for pointing that out. You are right. I'll follow your > suggestion. I got a problem while implementing this change: the array allocation is done successfully but the kernel does not create mappings for it yet, so the array is not accessible. (kernel will create the mapping later in paging_init()) For example: aarch64 setup_arch() setup_arch() { memblock_init(); /* early_init_fdt_scan_reserved_mem() is called */ paging_init(); } Could you give me some advice, please? Miles > > > > > > - Add info to reserved_mem array > > > > > > What do you think? > > > > > > > Rob > > > > > > > >