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 Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B3CC5C61DC2 for ; Wed, 26 Aug 2026 09:26:18 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4hVK4t0qn4z3bwk; Wed, 26 Aug 2026 19:25:34 +1000 (AEST) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=113.46.200.221 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1787736334; cv=none; b=ZpQtNG5+3QwWw1drtcQrIlgy41rx4gWZ6dI8IHyLWMnJZCrylZZsbQeLPbFXO9mQIa9qg8AS9NCFWB61A9Ijx0O2pftNdt6C4wmhdRQhhPKD9B4fMzBxoxdhx08rgfUjs2C+TCTkDjRzOTmYXFmjf2XXXY7shUUXW0iIXugW8eWSY8a8R7Vzs1nqMGsBU26fkiyDuQS61v1JvNH8zpgYqPTq7qXLXfGf04WUKrNo7I+FNRqGuvDqdfBRc34GR64UWP8K0kgPyCSlP1JCZ51iCus3oMHttJV7IsVP3cLQquavoVgIRf5xI4SzEu3k/fvB/cXEn+wN+b9TxhHX6mR11g== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1787736334; c=relaxed/relaxed; bh=0gF1CX+SLowxFh9fJKRvX/sCOgXb1E06TJatahYgRnw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Z8q33cxPDKHd7+tq6hNouGjJpz9Il1UfQA9TLbQWnvS7/JJRBeJ9nxftFwpRm3UBBSzscTdo8Ag3v6QsqjH77Yi/uBsqvLR6pojnKXy50chHBSHJQyXNeVJR5Z8qpMwJRpJx/AOt8hfP2lKxKGI/Z2TFHl5aYuetRO/rbEza6RR3JRJIlIQsHkM8ql1AhnDQ6wd1FEG+gBIKuzCThnyTzinsnpKjzD5IzVBLlXyHOS/jPpFiWvCvp2GdJ/UxZLVJqYS2x3/5VVlDYxrT5pvR+URU0TDSz9C0av7d4DHf1yQS7uznQUbA//Moa/Me1ulP0GPuZymlpoJByr3cm+s9Xg== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; dkim=pass (1024-bit key; unprotected) header.d=huawei.com header.i=@huawei.com header.a=rsa-sha256 header.s=dkim header.b=JX+hJB4h; dkim-atps=neutral; spf=pass (client-ip=113.46.200.221; helo=canpmsgout06.his.huawei.com; envelope-from=ruanjinjie@huawei.com; receiver=lists.ozlabs.org) smtp.mailfrom=huawei.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=huawei.com header.i=@huawei.com header.a=rsa-sha256 header.s=dkim header.b=JX+hJB4h; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=huawei.com (client-ip=113.46.200.221; helo=canpmsgout06.his.huawei.com; envelope-from=ruanjinjie@huawei.com; receiver=lists.ozlabs.org) Received: from canpmsgout06.his.huawei.com (canpmsgout06.his.huawei.com [113.46.200.221]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4hVK4r1WWJz3bsT for ; Wed, 26 Aug 2026 19:25:32 +1000 (AEST) dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=0gF1CX+SLowxFh9fJKRvX/sCOgXb1E06TJatahYgRnw=; b=JX+hJB4hTDDgkqA1/sg50c8MkVgqGYd5+tQwQD3uhUYhWr5tSyj9b7DiiSZk+6f6uc8AIE9K+ ir0Lyq63+jQ7c35zwdyKfSwDnYHnSJCkKIb5GmhVr88An2gsqRKmbRDNYbe4sIKFnFBQ50Jwe6I os3GmFKja6Un1xAaUllqd0w= Received: from mail.maildlp.com (unknown [172.19.163.104]) by canpmsgout06.his.huawei.com (SkyGuard) with ESMTPS id 4hVJrN2SFjzRhrs; Wed, 26 Aug 2026 17:14:44 +0800 (CST) Received: from dggpemf500011.china.huawei.com (unknown [7.185.36.131]) by mail.maildlp.com (Postfix) with ESMTPS id 0BF314058C; Wed, 26 Aug 2026 17:25:28 +0800 (CST) Received: from huawei.com (10.90.53.73) 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; Wed, 26 Aug 2026 17:25:25 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: Subject: [PATCH v3 08/17] crash: Extract crash_get_memory_ranges() helper Date: Wed, 26 Aug 2026 17:25:32 +0800 Message-ID: <20260826092541.3905933-9-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260826092541.3905933-1-ruanjinjie@huawei.com> References: <20260826092541.3905933-1-ruanjinjie@huawei.com> X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , List-Unsubscribe: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: kwepems500002.china.huawei.com (7.221.188.17) To dggpemf500011.china.huawei.com (7.185.36.131) Factor out the crash memory range collection logic from crash_prepare_headers() into a separate function. This allows the memory hotplug path to obtain and modify the range list (e.g. remove offlined memory) before generating the elfcorehdr. Cc: Andrew Morton Cc: Baoquan He Cc: Mike Rapoport Cc: Pasha Tatashin Cc: Pratyush Yadav Cc: Dave Young Signed-off-by: Jinjie Ruan --- include/linux/crash_core.h | 1 + kernel/crash_core.c | 22 +++++++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/include/linux/crash_core.h b/include/linux/crash_core.h index bc087124cd78..619af312bd9a 100644 --- a/include/linux/crash_core.h +++ b/include/linux/crash_core.h @@ -62,6 +62,7 @@ extern int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_ma extern int crash_prepare_headers(int need_kernel_map, void **addr, unsigned long *sz, unsigned long *nr_mem_ranges); extern int crash_exclude_core_ranges(struct crash_mem **cmem); +extern int crash_get_memory_ranges(struct crash_mem **mem_ranges); struct kimage; struct kexec_segment; diff --git a/kernel/crash_core.c b/kernel/crash_core.c index d0bd2d0cf899..991d1599cf9a 100644 --- a/kernel/crash_core.c +++ b/kernel/crash_core.c @@ -317,8 +317,7 @@ int crash_exclude_core_ranges(struct crash_mem **cmem) return 0; } -int crash_prepare_headers(int need_kernel_map, void **addr, unsigned long *sz, - unsigned long *nr_mem_ranges) +int crash_get_memory_ranges(struct crash_mem **mem_ranges) { unsigned int max_nr_ranges; struct crash_mem *cmem; @@ -344,13 +343,30 @@ int crash_prepare_headers(int need_kernel_map, void **addr, unsigned long *sz, if (ret) goto out; + *mem_ranges = cmem; + return 0; + +out: + kvfree(cmem); + return ret; +} + +int crash_prepare_headers(int need_kernel_map, void **addr, unsigned long *sz, + unsigned long *nr_mem_ranges) +{ + struct crash_mem *cmem = NULL; + int ret; + + ret = crash_get_memory_ranges(&cmem); + if (ret) + return ret; + /* Return the computed number of memory ranges, for hotplug usage */ if (nr_mem_ranges) *nr_mem_ranges = cmem->nr_ranges; ret = crash_prepare_elf64_headers(cmem, need_kernel_map, addr, sz); -out: kvfree(cmem); return ret; } -- 2.34.1