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=-6.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS 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 E63E4C3F68F for ; Mon, 13 Jan 2020 08:57:17 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8F61420678 for ; Mon, 13 Jan 2020 08:57:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="BlbT9jlP" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8F61420678 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2C5F18E0006; Mon, 13 Jan 2020 03:57:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 29C4B8E0001; Mon, 13 Jan 2020 03:57:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1B2898E0006; Mon, 13 Jan 2020 03:57:17 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0100.hostedemail.com [216.40.44.100]) by kanga.kvack.org (Postfix) with ESMTP id 03F648E0001 for ; Mon, 13 Jan 2020 03:57:17 -0500 (EST) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id 881F3180AD80F for ; Mon, 13 Jan 2020 08:57:16 +0000 (UTC) X-FDA: 76372006872.05.peace33_79947d4d0b62f X-HE-Tag: peace33_79947d4d0b62f X-Filterd-Recvd-Size: 11354 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by imf17.hostedemail.com (Postfix) with ESMTP for ; Mon, 13 Jan 2020 08:57:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578905834; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kSZRjJfw93Ipkr3yobm8XvNBZBNIgi3AuZ4c4CpTNeU=; b=BlbT9jlPOyTUyZmMX1FuhCzbKfKLZy7RGGCZWeazp4WPqfjbE/yfXHoVMljHLBcB264pF7 zI3Kjt2faNK0oQ0/mjboVZByidXBtMMRs75MJBccP0fZJ5qF5UPQ3SsLawlIU9cnUq1yZQ fEOOvZHhQTEnrTqOX4JLTyPiJb2MALY= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-26-DimlMSTvOTq6WJ1zNX1yeg-1; Mon, 13 Jan 2020 03:57:13 -0500 Received: by mail-wr1-f71.google.com with SMTP id h30so4687207wrh.5 for ; Mon, 13 Jan 2020 00:57:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:content-transfer-encoding:from:mime-version :subject:date:message-id:references:cc:in-reply-to:to; bh=/8jjd0naK5yUfMwY72nPxcwXV/oe8/+GoHM6O1vObkI=; b=leh+yjL3Ofo/nI9huzgWI4/HjuR3wPs0gan7kR9rRTaHsQcJmkZBImNOihur10hAd2 4HDr7NUTPBg3poGEdd2XqRYueh0ipZq4EttJnMjttHXzkrDGl7ct2N6hie2QMm4zf1do pV3XejZQAWPGNt9Dcc12llsWIq4WZk6mlD1h/u3q23rIiSNrM6vVX2zpnGaMaqQQtU9m 8sr1nbDPhSncKSIDOFDn2cyljxTdo891ijOhH+O11DDIubD8h4wGbxHhD+LNM7h6OzA/ kF+VmeiiHjlfzJfxbPoGPOK8nU4ujVKC4luk5gdeOSkXPeSWim+FRytEkNTvKcneiT0f lFXQ== X-Gm-Message-State: APjAAAUfur5MFAhq3E7yjtho/ymImrCzILs0+Gg5n5cODwA+9tkmkhzo 4QFuneqbRVz4L8mUfDgSUfLVge4NcsJfhOm7D1QlZ9XNX1VsDeIqY3eQY35+7OvMh/6xExZyJ4S U8lclekiVdtw= X-Received: by 2002:adf:e6d2:: with SMTP id y18mr17811312wrm.262.1578905831899; Mon, 13 Jan 2020 00:57:11 -0800 (PST) X-Google-Smtp-Source: APXvYqwF0kUnrNLDD5EzuOc11BAoE/EIsGFlPEyEanuIV9dNnJKSOmjB0O8bGGRRL5aTmJgHXY6KaQ== X-Received: by 2002:adf:e6d2:: with SMTP id y18mr17811261wrm.262.1578905831571; Mon, 13 Jan 2020 00:57:11 -0800 (PST) Received: from ?IPv6:2a01:598:a803:c918:91cf:ba30:dbb0:f19? ([2a01:598:a803:c918:91cf:ba30:dbb0:f19]) by smtp.gmail.com with ESMTPSA id b18sm14133777wru.50.2020.01.13.00.57.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 13 Jan 2020 00:57:11 -0800 (PST) From: David Hildenbrand Mime-Version: 1.0 (1.0) Subject: Re: [PATCH V11 2/5] mm/memblock: Introduce MEMBLOCK_BOOT flag Date: Mon, 13 Jan 2020 09:57:09 +0100 Message-Id: <12BCAD36-D99C-4AC0-B466-06E1A02DDD72@redhat.com> References: <08a2f82a-3201-055a-316a-a2f11c7ff7a5@arm.com> Cc: Mike Rapoport , mark.rutland@arm.com, david@redhat.com, catalin.marinas@arm.com, linux-mm@kvack.org, arunks@codeaurora.org, cpandya@codeaurora.org, will@kernel.org, ira.weiny@intel.com, steven.price@arm.com, valentin.schneider@arm.com, suzuki.poulose@arm.com, robin.murphy@arm.com, broonie@kernel.org, cai@lca.pw, ard.biesheuvel@arm.com, dan.j.williams@intel.com, linux-arm-kernel@lists.infradead.org, osalvador@suse.de, steve.capper@arm.com, logang@deltatee.com, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, mgorman@techsingularity.net In-Reply-To: <08a2f82a-3201-055a-316a-a2f11c7ff7a5@arm.com> To: Anshuman Khandual X-Mailer: iPhone Mail (17C54) X-MC-Unique: DimlMSTvOTq6WJ1zNX1yeg-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: > Am 13.01.2020 um 09:41 schrieb Anshuman Khandual : >=20 > =EF=BB=BF >=20 >> On 01/13/2020 01:07 PM, Mike Rapoport wrote: >>> On Fri, Jan 10, 2020 at 08:39:12AM +0530, Anshuman Khandual wrote: >>> On arm64 platform boot memory should never be hot removed due to certai= n >>> platform specific constraints. Hence the platform would like to overrid= e >>> earlier added arch call back arch_memory_removable() for this purpose. = In >>> order to reject boot memory hot removal request, it needs to first trac= k >>> them at runtime. In the future, there might be other platforms requirin= g >>> runtime boot memory enumeration. Hence lets expand the existing generic >>> memblock framework for this purpose rather then creating one just for >>> arm64 platforms. >>>=20 >>> This introduces a new memblock flag MEMBLOCK_BOOT along with helpers wh= ich >>> can be marked by given platform on all memory regions discovered during >>> boot. >>=20 >> We already have MEMBLOCK_HOTPLUG to mark hotpluggable region. Can't we u= se >> it for your use-case? >=20 > At present MEMBLOCK_HOTPLUG flag helps in identifying parts of boot memor= y > as hotpluggable as indicated by the firmware. This information is then us= ed > to avoid those regions during standard memblock_alloc_*() API requests an= d > later marking them as ZONE_MOVABLE when buddy gets initialized. >=20 > Memory hot remove does not check for MEMBLOCK_HOTPLUG flag as a requireme= nt > before initiating the process. We could probably use this flag if generic > hot remove can be changed to check for MEMBLOCK_HOTPLUG as a prerequisite > which will require changes to memblock handling (boot and runtime) on all > existing platforms currently supporting hot remove. But what about handli= ng > the movable boot memory created with movablecore/kernelcore command line, > should generic MM update their memblock regions with MEMBLOCK_HOTPLUG ? As I said in my other mail, just disallow offlining of the affected (boot) = memory blocks using a memory notifier and you should be good to go. No chan= ges in memory unplug code required. >=20 >>=20 >>> Cc: Mike Rapoport >>> Cc: Andrew Morton >>> Signed-off-by: Anshuman Khandual >>> --- >>> include/linux/memblock.h | 10 ++++++++++ >>> mm/memblock.c | 37 +++++++++++++++++++++++++++++++++++++ >>> 2 files changed, 47 insertions(+) >>>=20 >>> diff --git a/include/linux/memblock.h b/include/linux/memblock.h >>> index b38bbef..fb04c87 100644 >>> --- a/include/linux/memblock.h >>> +++ b/include/linux/memblock.h >>> @@ -31,12 +31,14 @@ extern unsigned long long max_possible_pfn; >>> * @MEMBLOCK_HOTPLUG: hotpluggable region >>> * @MEMBLOCK_MIRROR: mirrored region >>> * @MEMBLOCK_NOMAP: don't add to kernel direct mapping >>> + * @MEMBLOCK_BOOT: memory received from firmware during boot >>> */ >>> enum memblock_flags { >>> MEMBLOCK_NONE =3D 0x0, /* No special request */ >>> MEMBLOCK_HOTPLUG =3D 0x1, /* hotpluggable region */ >>> MEMBLOCK_MIRROR =3D 0x2, /* mirrored region */ >>> MEMBLOCK_NOMAP =3D 0x4, /* don't add to kernel direct mapp= ing */ >>> + MEMBLOCK_BOOT =3D 0x8, /* memory received from firmware = during boot */ >>> }; >>>=20 >>> /** >>> @@ -116,6 +118,8 @@ int memblock_reserve(phys_addr_t base, phys_addr_t = size); >>> void memblock_trim_memory(phys_addr_t align); >>> bool memblock_overlaps_region(struct memblock_type *type, >>> phys_addr_t base, phys_addr_t size); >>> +int memblock_mark_boot(phys_addr_t base, phys_addr_t size); >>> +int memblock_clear_boot(phys_addr_t base, phys_addr_t size); >>> int memblock_mark_hotplug(phys_addr_t base, phys_addr_t size); >>> int memblock_clear_hotplug(phys_addr_t base, phys_addr_t size); >>> int memblock_mark_mirror(phys_addr_t base, phys_addr_t size); >>> @@ -216,6 +220,11 @@ static inline bool memblock_is_nomap(struct memblo= ck_region *m) >>> return m->flags & MEMBLOCK_NOMAP; >>> } >>>=20 >>> +static inline bool memblock_is_boot(struct memblock_region *m) >>> +{ >>> + return m->flags & MEMBLOCK_BOOT; >>> +} >>> + >>> #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP >>> int memblock_search_pfn_nid(unsigned long pfn, unsigned long *start_pfn= , >>> unsigned long *end_pfn); >>> @@ -449,6 +458,7 @@ void memblock_cap_memory_range(phys_addr_t base, ph= ys_addr_t size); >>> void memblock_mem_limit_remove_map(phys_addr_t limit); >>> bool memblock_is_memory(phys_addr_t addr); >>> bool memblock_is_map_memory(phys_addr_t addr); >>> +bool memblock_is_boot_memory(phys_addr_t addr); >>> bool memblock_is_region_memory(phys_addr_t base, phys_addr_t size); >>> bool memblock_is_reserved(phys_addr_t addr); >>> bool memblock_is_region_reserved(phys_addr_t base, phys_addr_t size); >>> diff --git a/mm/memblock.c b/mm/memblock.c >>> index 4bc2c7d..e10207f 100644 >>> --- a/mm/memblock.c >>> +++ b/mm/memblock.c >>> @@ -865,6 +865,30 @@ static int __init_memblock memblock_setclr_flag(ph= ys_addr_t base, >>> } >>>=20 >>> /** >>> + * memblock_mark_bootmem - Mark boot memory with flag MEMBLOCK_BOOT. >>> + * @base: the base phys addr of the region >>> + * @size: the size of the region >>> + * >>> + * Return: 0 on success, -errno on failure. >>> + */ >>> +int __init_memblock memblock_mark_boot(phys_addr_t base, phys_addr_t s= ize) >>> +{ >>> + return memblock_setclr_flag(base, size, 1, MEMBLOCK_BOOT); >>> +} >>> + >>> +/** >>> + * memblock_clear_bootmem - Clear flag MEMBLOCK_BOOT for a specified r= egion. >>> + * @base: the base phys addr of the region >>> + * @size: the size of the region >>> + * >>> + * Return: 0 on success, -errno on failure. >>> + */ >>> +int __init_memblock memblock_clear_boot(phys_addr_t base, phys_addr_t = size) >>> +{ >>> + return memblock_setclr_flag(base, size, 0, MEMBLOCK_BOOT); >>> +} >>> + >>> +/** >>> * memblock_mark_hotplug - Mark hotpluggable memory with flag MEMBLOCK_= HOTPLUG. >>> * @base: the base phys addr of the region >>> * @size: the size of the region >>> @@ -974,6 +998,10 @@ static bool should_skip_region(struct memblock_reg= ion *m, int nid, int flags) >>> if ((flags & MEMBLOCK_MIRROR) && !memblock_is_mirror(m)) >>> return true; >>>=20 >>> + /* if we want boot memory skip non-boot memory regions */ >>> + if ((flags & MEMBLOCK_BOOT) && !memblock_is_boot(m)) >>> + return true; >>> + >>> /* skip nomap memory unless we were asked for it explicitly */ >>> if (!(flags & MEMBLOCK_NOMAP) && memblock_is_nomap(m)) >>> return true; >>> @@ -1785,6 +1813,15 @@ bool __init_memblock memblock_is_map_memory(phys= _addr_t addr) >>> return !memblock_is_nomap(&memblock.memory.regions[i]); >>> } >>>=20 >>> +bool __init_memblock memblock_is_boot_memory(phys_addr_t addr) >>> +{ >>> + int i =3D memblock_search(&memblock.memory, addr); >>> + >>> + if (i =3D=3D -1) >>> + return false; >>> + return memblock_is_boot(&memblock.memory.regions[i]); >>> +} >>> + >>> #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP >>> int __init_memblock memblock_search_pfn_nid(unsigned long pfn, >>> unsigned long *start_pfn, unsigned long *end_pfn) >>> --=20 >>> 2.7.4 >>>=20 >>=20 >=20