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=-2.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no 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 6DA94C54E4B for ; Mon, 11 May 2020 11:28:09 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2CF8D20722 for ; Mon, 11 May 2020 11:28:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="bBzvX/oP" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2CF8D20722 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 D4C4F900034; Mon, 11 May 2020 07:28:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CFCD4900006; Mon, 11 May 2020 07:28:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BEBC5900034; Mon, 11 May 2020 07:28:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0233.hostedemail.com [216.40.44.233]) by kanga.kvack.org (Postfix) with ESMTP id A4DAE900006 for ; Mon, 11 May 2020 07:28:08 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 66F23181AEF09 for ; Mon, 11 May 2020 11:28:08 +0000 (UTC) X-FDA: 76804214256.01.mask28_47004cfb8e42b X-HE-Tag: mask28_47004cfb8e42b X-Filterd-Recvd-Size: 5233 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by imf11.hostedemail.com (Postfix) with ESMTP for ; Mon, 11 May 2020 11:28:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589196487; 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: in-reply-to:in-reply-to:references:references; bh=s7GIl9tuMpK1VOwRBY9ihebUTptjwd7riGoyjLY7P6Q=; b=bBzvX/oPYT1oCLX14LlAvVS81ECQ4JdLUpLRIZg6t/bLywV3raC7c2mQmfRnW2n5aOhgPA waa781UPPdG2TwVQdMlrJOC+rlxyQmMDVNN78+hWBBRj874hlD5m//JVueLuQrbH3iZ/ap ymVzqlMYIcUFBGlS0P7xPUnH7qW1/d4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-472-CMeEOkNMNLSPh_fWphzpMw-1; Mon, 11 May 2020 07:28:05 -0400 X-MC-Unique: CMeEOkNMNLSPh_fWphzpMw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 56C89107ACF5; Mon, 11 May 2020 11:28:04 +0000 (UTC) Received: from localhost (ovpn-12-129.pek2.redhat.com [10.72.12.129]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EA737610AF; Mon, 11 May 2020 11:27:58 +0000 (UTC) Date: Mon, 11 May 2020 19:27:55 +0800 From: Baoquan He To: David Hildenbrand Cc: "Eric W. Biederman" , James Morse , kexec@lists.infradead.org, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, Dave Young Subject: Re: [PATCH] kexec: Discard loaded image on memory hotplug Message-ID: <20200511112755.GB4922@MiWiFi-R3L-srv> References: <20200501165701.24587-1-james.morse@arm.com> <40b07632-b044-d1cd-96a2-81eec3da93e7@redhat.com> <8736892l92.fsf@x220.int.ebiederm.org> MIME-Version: 1.0 In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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: On 05/11/20 at 10:19am, David Hildenbrand wrote: > On 09.05.20 17:14, Eric W. Biederman wrote: > >>> + * If the memory layout changes, any loaded kexec image should be evicted > >>> + * as it may contain a copy of the (now stale) memory map. This also means > >>> + * we don't need to check the memory is still present when re-assembling the > >>> + * new kernel at machine_kexec() time. > >>> + */ > >> > >> Onlining/offlining is not a change of the memory map. > > > > Phrasing it that way is non-sense. What is important is memory > > available in the system. A memory map is just a reflection upon that, > > a memory map is not the definition of truth. > > > > So if this notifier reflects when memory is coming and going on the > > system this is a reasonable approach. > > > > Do these notifiers might fire for special kinds of memory that should > > only be used for very special purposes? > > > > This change with the addition of some filters say to limit taking action > > to MEM_ONLINE and MEM_OFFLINE looks reasonable to me. Probably also > > filtering out special kinds of memory that is not gernally useful. > > There are cases, where this notifier will not get called (e.g., hotplug > a DIMM and don't online it) or will get called, although nothing changed > (offline+re-online to a different zone triggered by user space). AFAIK, > nothing in kexec (*besides kdump) cares about online vs. offline memory. > This is why this feels wrong. > > add_memory()/try_remove_memory() is the place where: > - Memblocks are created/deleted (if the memblock allocator is still > alive) > - Memory resources are created/deleted (e.g., reflected in /proc/iomem) > - Firmware memmap entries are created/deleted (/sys/firmware/memmap) > > My idea would be to add something like > kexec_map_add()/kexec_map_remove() where we have > firmware_map_add_hotplug()/firmware_map_remove(). From there, we can > unload the kexec image like done in this patch. Hi David, I may miss some details, do you know why we have to unload the kexec image when add/remove memory? If this is applied, even kexec_file_load is also affected. As we discussed, kexec_file_load is not impacted by kinds of memory adding/removing at all. Besides, if unload image in casae memory added/removed, we will accept that the later 'kexec -e' is actually rebooting? Thanks Baoquan > > And these callbacks might come in handy for fixing up the kexec initial > memmap in case of kexec_file_load(). AFAIKS on x86_64: > - Hotplugging a DIMM will not add that memory to > e820_table_kexec > - Hotunplugging a DIMM will not remove that memory from e820_table_kexec > > Maybe we have similar things to handle on other architectures. > > -- > Thanks, > > David / dhildenb > >