From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_PASS,URIBL_BLOCKED,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E7F0C43444 for ; Thu, 10 Jan 2019 07:57:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 20E69206B7 for ; Thu, 10 Jan 2019 07:57:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727478AbfAJH5J (ORCPT ); Thu, 10 Jan 2019 02:57:09 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:39564 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726137AbfAJH5I (ORCPT ); Thu, 10 Jan 2019 02:57:08 -0500 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id x0A7s0Ee073440 for ; Thu, 10 Jan 2019 02:57:07 -0500 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 2px131ah63-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 10 Jan 2019 02:57:07 -0500 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 10 Jan 2019 07:57:04 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp03.uk.ibm.com (192.168.101.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 10 Jan 2019 07:56:57 -0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x0A7uu6k1704262 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 10 Jan 2019 07:56:56 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 96566A4051; Thu, 10 Jan 2019 07:56:56 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0874BA4040; Thu, 10 Jan 2019 07:56:55 +0000 (GMT) Received: from rapoport-lnx (unknown [9.148.8.152]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Thu, 10 Jan 2019 07:56:54 +0000 (GMT) Date: Thu, 10 Jan 2019 09:56:53 +0200 From: Mike Rapoport To: Pingfan Liu Cc: Baoquan He , linux-mm@kvack.org, kexec@lists.infradead.org, Tang Chen , "Rafael J. Wysocki" , Len Brown , Andrew Morton , Mike Rapoport , Michal Hocko , Jonathan Corbet , Yaowei Bai , Pavel Tatashin , Nicholas Piggin , Naoya Horiguchi , Daniel Vacek , Mathieu Malaterre , Stefan Agner , Dave Young , yinghai@kernel.org, vgoyal@redhat.com, linux-kernel@vger.kernel.org Subject: Re: [PATCHv5] x86/kdump: bugfix, make the behavior of crashkernel=X consistent with kaslr References: <1546848299-23628-1-git-send-email-kernelfans@gmail.com> <20190108080538.GB4396@rapoport-lnx> <20190108090138.GB18718@MiWiFi-R3L-srv> <20190108154852.GC14063@rapoport-lnx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-TM-AS-GCONF: 00 x-cbid: 19011007-0012-0000-0000-000002E5C63B X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19011007-0013-0000-0000-0000211CCB47 Message-Id: <20190110075652.GB32036@rapoport-lnx> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-01-10_04:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901100065 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Pingfan, On Wed, Jan 09, 2019 at 09:02:41PM +0800, Pingfan Liu wrote: > On Tue, Jan 8, 2019 at 11:49 PM Mike Rapoport wrote: > > > > On Tue, Jan 08, 2019 at 05:01:38PM +0800, Baoquan He wrote: > > > Hi Mike, > > > > > > On 01/08/19 at 10:05am, Mike Rapoport wrote: > > > > I'm not thrilled by duplicating this code (yet again). > > > > I liked the v3 of this patch [1] more, assuming we allow bottom-up mode to > > > > allocate [0, kernel_start) unconditionally. > > > > I'd just replace you first patch in v3 [2] with something like: > > > > > > In initmem_init(), we will restore the top-down allocation style anyway. > > > While reserve_crashkernel() is called after initmem_init(), it's not > > > appropriate to adjust memblock_find_in_range_node(), and we really want > > > to find region bottom up for crashkernel reservation, no matter where > > > kernel is loaded, better call __memblock_find_range_bottom_up(). > > > > > > Create a wrapper to do the necessary handling, then call > > > __memblock_find_range_bottom_up() directly, looks better. > > > > What bothers me is 'the necessary handling' which is already done in > > several places in memblock in a similar, but yet slightly different way. > > > > memblock_find_in_range() and memblock_phys_alloc_nid() retry with different > > MEMBLOCK_MIRROR, but memblock_phys_alloc_try_nid() does that only when > > allocating from the specified node and does not retry when it falls back to > > any node. And memblock_alloc_internal() has yet another set of fallbacks. > > > > So what should be the necessary handling in the wrapper for > > __memblock_find_range_bottom_up() ? > > > Well, it is a hard choice. > > BTW, even without any memblock modifications, retrying allocation in > > reserve_crashkerenel() for different ranges, like the proposal at [1] would > > also work, wouldn't it? > > > Yes, it can work. Then is it worth to expose the bottom-up allocation > style beside for hotmovable purpose? Some architectures use bottom-up as a "compatability" mode with bootmem. And, I believe, powerpc and s390 use bottom-up to make some of the allocations close to the kernel. > Thanks, > Pingfan > > [1] http://lists.infradead.org/pipermail/kexec/2017-October/019571.html > > > > > Thanks > > > Baoquan > > > > > > > > > > > diff --git a/mm/memblock.c b/mm/memblock.c > > > > index 7df468c..d1b30b9 100644 > > > > --- a/mm/memblock.c > > > > +++ b/mm/memblock.c > > > > @@ -274,24 +274,14 @@ phys_addr_t __init_memblock memblock_find_in_range_node(phys_addr_t size, > > > > * try bottom-up allocation only when bottom-up mode > > > > * is set and @end is above the kernel image. > > > > */ > > > > - if (memblock_bottom_up() && end > kernel_end) { > > > > - phys_addr_t bottom_up_start; > > > > - > > > > - /* make sure we will allocate above the kernel */ > > > > - bottom_up_start = max(start, kernel_end); > > > > - > > > > + if (memblock_bottom_up()) { > > > > /* ok, try bottom-up allocation first */ > > > > - ret = __memblock_find_range_bottom_up(bottom_up_start, end, > > > > + ret = __memblock_find_range_bottom_up(start, end, > > > > size, align, nid, flags); > > > > if (ret) > > > > return ret; > > > > > > > > /* > > > > - * we always limit bottom-up allocation above the kernel, > > > > - * but top-down allocation doesn't have the limit, so > > > > - * retrying top-down allocation may succeed when bottom-up > > > > - * allocation failed. > > > > - * > > > > * bottom-up allocation is expected to be fail very rarely, > > > > * so we use WARN_ONCE() here to see the stack trace if > > > > * fail happens. > > > > > > > > [1] https://lore.kernel.org/lkml/1545966002-3075-3-git-send-email-kernelfans@gmail.com/ > > > > [2] https://lore.kernel.org/lkml/1545966002-3075-2-git-send-email-kernelfans@gmail.com/ > > > > > > > > > + > > > > > + return ret; > > > > > +} > > > > > + > > > > > /** > > > > > * __memblock_find_range_top_down - find free area utility, in top-down > > > > > * @start: start of candidate range > > > > > -- > > > > > 2.7.4 > > > > > > > > > > > > > -- > > > > Sincerely yours, > > > > Mike. > > > > > > > > > > > -- > > Sincerely yours, > > Mike. > > > -- Sincerely yours, Mike.