Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3209507pxb; Sun, 7 Feb 2021 01:22:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJzP+ztYsNRy+6wEDrNl/ssYpQR1iPo7XJX6nrRIKuVzT5530247dWTHycEn4NbqInHlQ8nn X-Received: by 2002:a05:6402:b8c:: with SMTP id cf12mr11796061edb.320.1612689768149; Sun, 07 Feb 2021 01:22:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612689768; cv=none; d=google.com; s=arc-20160816; b=GOszIjHt8BJUW9s52GKC+cY8qT9wSORxvBFDHRdnWHJmyBWwbmQ/qkR3qLpZ8OY1Tg d7vlfX91MIlluj6sL0g6TX8Rc43Ri1vYVbbFCUOqn4ntJ8m0y/KmbG3NFwhPpwR1DNkb 7HXY0zBrhOnV9+DrMKjTj6qtHW7qXxRThzPS9fH2GzMcEwmmE70NxNM6Kx1knihPZgJH sFo+IAcm6WRbkF+xtA/mpKLSL4FWkya/nJvj8CAMdlktnvJaZ1euGy3kvC2/avQhC2id 4PNmOyQUsmXbxsiRDKYRF4gyARAa8xkED16QzaWxVHZ6H7QrARtxEd0K7eFoS8Cx+VLN Kq7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=z8ICKXxztkWx5oitwYMgQj6XJLP0YmRvZ+N4Z2061i8=; b=N5EYA2Uqm1ppYB1bzu6yasJN4yR7of86bRpE4iniLXV45kc6m7tXdfzyTsAnmnxZS/ BoohtsSgZoFzn7fVSLZyrMG4zL2VY6H/ahEeo7+0KI5pHZvYgsCoAk8rlLdQPtp8LNde xyT9BgoQElMGpUg2N1d9opxA+M9k2hVnzuuFmee9SXA3ouGAiBq0zMwuE3tDWV8JlEAb MGn/is3cfAOBnFIMWY2mO6E5Fg6eQBh3DMGVsqUlniCejAtsItRaGxTkbV5/xZ93bW96 0xBAy7vUGUrzWGog/qqUf6Tl1fI743Q/FunQcTQJHS7QeFhVVBpwYzabOGdZi+sxrO+8 83tA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=X9lHKJWO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l18si8850016edw.180.2021.02.07.01.22.24; Sun, 07 Feb 2021 01:22:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=X9lHKJWO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229611AbhBGJTf (ORCPT + 99 others); Sun, 7 Feb 2021 04:19:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:35408 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229522AbhBGJTb (ORCPT ); Sun, 7 Feb 2021 04:19:31 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2A91D64E22; Sun, 7 Feb 2021 09:18:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612689530; bh=OygoctvNrqCv3+yqvOUhM5F9TdXP26wbyygyZSDx/ME=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=X9lHKJWOTcXLEeVJj92+4bOk5plpSBCiUD1AypE5r32Qmh5QsMZIOJbBLHDaT+6HA 65APmYOmRlcQFMUwUFN56Zm8pqjfFjF6kTIylEQCqvE4k3S7AclrMV97kTBTgpU31Q u78Oh2yiQzNdaSEg9UozwxOTChRWdLJC+qt+4iRxBbUSBLER233XM299k35/a3f0VM 1zWxdnHdyiZyTJGWbQBpe4vdQ2Y6xv37G24qsZWjib2JNuPmWBSyu1aPEkgUUGtBTW cJu0Hir6ci80a3QQg9y5BnvFvCXiJ53IsbUy1P4+xbhmw8kesm6oKn960M4W5JoY4s sWLfjzEwnuGgA== Date: Sun, 7 Feb 2021 11:18:42 +0200 From: Mike Rapoport To: Ivan Khoronzhuk Cc: linux-mips@vger.kernel.org, tsbogend@alpha.franken.de, linux-kernel@vger.kernel.org, yangtiezhu@loongson.cn, ivan.khoronzhuk@gmail.com Subject: Re: [PATCH] mips: kernel: setup: fix crash kernel resource allocation Message-ID: <20210207091842.GU242749@kernel.org> References: <20210206125940.111766-1-ikhoronz@cisco.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210206125940.111766-1-ikhoronz@cisco.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Feb 06, 2021 at 12:59:40PM +0000, Ivan Khoronzhuk wrote: > In order to avoid crash kernel corruption, its memory is reserved > early in memblock and as result, in time when resources are inited > it's not present in memblock.memory, so crash kernel memory is out > of ranges listed with for_each_mem_range(). To avoid it and still > keep memory reserved lets reseve it out of loop by inserting it in > iomem_resource. Unless I misread the code, the crash kernel memory is actually allocated from memblock (memblock_find_in_range + memblock_reserve), but for some reason memblock_reserve() is called outside mips_parse_crashkernel(). So the crash kernel memory is surely in both memblock.memory and memblock.reserved and it will be covered by for_each_mem_range(). The mips_parse_crashkernel() function and the following reservation of crash kernel memory should be merged, IMO, and this can be further simplified with memblock_alloc() helpers. Is there a particular issue you are trying to fix? > Fixes: a94e4f24ec83 ("MIPS: init: Drop boot_mem_map") > Signed-off-by: Ivan Khoronzhuk > --- > Based on linux-next/master > > arch/mips/kernel/setup.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c > index 3785c72bc3bc..25e376ef2f2a 100644 > --- a/arch/mips/kernel/setup.c > +++ b/arch/mips/kernel/setup.c > @@ -473,14 +473,15 @@ static void __init mips_parse_crashkernel(void) > crashk_res.end = crash_base + crash_size - 1; > } > > -static void __init request_crashkernel(struct resource *res) > +static void __init request_crashkernel(void) > { > int ret; > > if (crashk_res.start == crashk_res.end) > return; > > - ret = request_resource(res, &crashk_res); > + /* The crashk resource shoud be located in normal mem */ > + ret = insert_resource(&iomem_resource, &crashk_res); > if (!ret) > pr_info("Reserving %ldMB of memory at %ldMB for crashkernel\n", > (unsigned long)(resource_size(&crashk_res) >> 20), > @@ -734,8 +735,9 @@ static void __init resource_init(void) > request_resource(res, &code_resource); > request_resource(res, &data_resource); > request_resource(res, &bss_resource); > - request_crashkernel(res); > } > + > + request_crashkernel(); > } > > #ifdef CONFIG_SMP > -- > 2.23.1 > -- Sincerely yours, Mike.