From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from canpmsgout02.his.huawei.com (canpmsgout02.his.huawei.com [113.46.200.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1926C3ED3C4 for ; Mon, 17 Aug 2026 10:45:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.217 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786963549; cv=none; b=CDTF1ekHg0aOo79YfyzhYHuSFcfteKSWThQYuxd3c3NmtDsDjhJaBlHSqGQz8MdhUT+kZDc0/zIBJlIafp8L+Ai5DKbHHk0Kh8Jqhqy9hFim+e5ZBIFaH6+Z86XqjnpN56ct7ekj48g0cDFBQUpLrTumsmnI1LJ70MR5rrqwDgs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786963549; c=relaxed/simple; bh=vmcwScc6hF/Qx1vEahKTmwln2zyEHJLSJRCKnIXIcxY=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=aWxZxbZMVQuS/nLWZeaYKCy5WHOXBy+AGBJuT7WkQtHYZPqiv5ifA4HNfVtmo0WYAQl3VkLo5+qfJI9FSoiamB+ScPpkmz2ET6meHDkuHmM0XxmZgVkeZCXmdE2+3M3TiaVmMrIbGrZOJkJ7vcwdsMxItbuhRsVux6Fesxesxug= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=BMVVaj1T; arc=none smtp.client-ip=113.46.200.217 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="BMVVaj1T" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=zvCm+OYu+HXm7z1snfmD5E2E44f/n02MTod4Pvfjj44=; b=BMVVaj1TlTcvAO97yhiftu6cLaZm1WU583Ib9pBTHVzdqZyUhA0lYazOeZxhhDxb2qvD7vCVQ FzFrvcY0iU/2/lv/BMEdCkUqEhEF3hPQw/wIcsO1DO51XouQIxSPJ8yJrmpLCUFIcKlxBG6DMMB yp9zBBwo1ZikZVrb5doRDS0= Received: from mail.maildlp.com (unknown [172.19.162.144]) by canpmsgout02.his.huawei.com (SkyGuard) with ESMTPS id 4hNq3Z6cxqzcb0T; Mon, 17 Aug 2026 18:35:22 +0800 (CST) Received: from dggpemf500011.china.huawei.com (unknown [7.185.36.131]) by mail.maildlp.com (Postfix) with ESMTPS id 61E8D40538; Mon, 17 Aug 2026 18:45:39 +0800 (CST) Received: from [10.67.109.254] (10.67.109.254) by dggpemf500011.china.huawei.com (7.185.36.131) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 17 Aug 2026 18:45:37 +0800 Message-ID: Date: Mon, 17 Aug 2026 18:45:36 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 5/5] arm64: crash: Add crash hotplug support To: Catalin Marinas CC: , , , , , , , , , , , , , , , , , , , , , , , , , References: <20260729031235.2840255-1-ruanjinjie@huawei.com> <20260729031235.2840255-6-ruanjinjie@huawei.com> From: Jinjie Ruan In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-ClientProxiedBy: kwepems500002.china.huawei.com (7.221.188.17) To dggpemf500011.china.huawei.com (7.185.36.131) 在 2026/8/14 0:05, Catalin Marinas 写道: > Hi Jinjie, > > On Wed, Jul 29, 2026 at 11:12:35AM +0800, Jinjie Ruan wrote: >> +/** >> + * update_crash_elfcorehdr() - Recreate the elfcorehdr and replace it with old >> + * elfcorehdr in the kexec segment array. >> + * @image: the active struct kimage >> + */ >> +static void update_crash_elfcorehdr(struct kimage *image) >> +{ >> + void *elfbuf = NULL, *old_elfcorehdr; >> + unsigned long mem, memsz; >> + unsigned long elfsz = 0; >> + >> + /* >> + * Create the new elfcorehdr reflecting the changes to CPU and/or >> + * memory resources. >> + */ >> + if (crash_prepare_headers(true, &elfbuf, &elfsz, NULL)) { >> + pr_err("unable to create new elfcorehdr"); >> + goto out; >> + } >> + >> + /* >> + * Obtain address and size of the elfcorehdr segment, and >> + * check it against the new elfcorehdr buffer. >> + */ >> + mem = image->segment[image->elfcorehdr_index].mem; >> + memsz = image->segment[image->elfcorehdr_index].memsz; >> + if (elfsz > memsz) { >> + pr_err("update elfcorehdr elfsz %lu > memsz %lu", >> + elfsz, memsz); >> + goto out; >> + } >> + >> + /* >> + * Copy new elfcorehdr over the old elfcorehdr at destination. >> + */ >> + old_elfcorehdr = phys_to_virt(mem); >> + >> + /* >> + * Temporarily invalidate the crash image while the >> + * elfcorehdr is updated. >> + */ >> + xchg(&kexec_crash_image, NULL); >> + memcpy(old_elfcorehdr, elfbuf, elfsz); >> + dcache_clean_inval_poc((unsigned long)old_elfcorehdr, >> + (unsigned long)(old_elfcorehdr + elfsz)); >> + xchg(&kexec_crash_image, image); >> + pr_debug("updated elfcorehdr\n"); >> + >> +out: >> + vfree(elfbuf); >> +} >> + >> +/** >> + * arch_crash_handle_hotplug_event() - Handle hotplug elfcorehdr changes >> + * @image: a pointer to kexec_crash_image >> + * @arg: struct memory_notify handler for memory hotplug case and >> + * NULL for CPU hotplug case. >> + * >> + * Update the kdump image based on the type of hotplug event: >> + * - CPU add and remove: No action is needed. >> + * - Memory add/remove: Update the elfcorehdr to reflect the current memory layout. >> + * >> + * Prepare the new elfcorehdr and replace the existing elfcorehdr. >> + */ >> +void arch_crash_handle_hotplug_event(struct kimage *image, void *arg) >> +{ >> + if (image->hp_action == KEXEC_CRASH_HP_ADD_CPU || >> + image->hp_action == KEXEC_CRASH_HP_REMOVE_CPU) >> + return; >> + >> + update_crash_elfcorehdr(image); >> +} > > Looking at powerpc, they pass the arg down to update_crash_elfcorehdr() > to handle the memory hot-unplug case. It looks like the notifier is > called before the memblock_remove(), so the update above will still > count the memory being removed. Hi Catalin, After delving into the code flow, I believe you are correct. We need to manually remove the hot-unplug memory here, just like in the PowerPC case. Will update the code sooner. > > There are a few Sashiko comments as well, though some might be about > existing issues (it would be nice to have them fixed ;)). Thank you! I will take a close look and try to fix them later. Best regards, Jinjie >