get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/2195907/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2195907,
    "url": "http://patchwork.ozlabs.org/api/patches/2195907/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20260212101001.343158-2-ruanjinjie@huawei.com/",
    "project": {
        "id": 2,
        "url": "http://patchwork.ozlabs.org/api/projects/2/?format=api",
        "name": "Linux PPC development",
        "link_name": "linuxppc-dev",
        "list_id": "linuxppc-dev.lists.ozlabs.org",
        "list_email": "linuxppc-dev@lists.ozlabs.org",
        "web_url": "https://github.com/linuxppc/wiki/wiki",
        "scm_url": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git",
        "webscm_url": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/",
        "list_archive_url": "https://lore.kernel.org/linuxppc-dev/",
        "list_archive_url_format": "https://lore.kernel.org/linuxppc-dev/{}/",
        "commit_url_format": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?id={}"
    },
    "msgid": "<20260212101001.343158-2-ruanjinjie@huawei.com>",
    "list_archive_url": "https://lore.kernel.org/linuxppc-dev/20260212101001.343158-2-ruanjinjie@huawei.com/",
    "date": "2026-02-12T10:09:58",
    "name": "[v5,1/4] powerpc/crash: sort crash memory ranges before preparing elfcorehdr",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "f8563bbfbf202cb3389326ffe75d0d12c515d860",
    "submitter": {
        "id": 84791,
        "url": "http://patchwork.ozlabs.org/api/people/84791/?format=api",
        "name": "Jinjie Ruan",
        "email": "ruanjinjie@huawei.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20260212101001.343158-2-ruanjinjie@huawei.com/mbox/",
    "series": [
        {
            "id": 491953,
            "url": "http://patchwork.ozlabs.org/api/series/491953/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=491953",
            "date": "2026-02-12T10:09:57",
            "name": "arm64/riscv: Add support for crashkernel CMA reservation",
            "version": 5,
            "mbox": "http://patchwork.ozlabs.org/series/491953/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2195907/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2195907/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "\n <linuxppc-dev+bounces-16838-incoming=patchwork.ozlabs.org@lists.ozlabs.org>",
        "X-Original-To": [
            "incoming@patchwork.ozlabs.org",
            "linuxppc-dev@lists.ozlabs.org"
        ],
        "Delivered-To": "patchwork-incoming@legolas.ozlabs.org",
        "Authentication-Results": [
            "legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=huawei.com header.i=@huawei.com header.a=rsa-sha256\n header.s=dkim header.b=pV5q7TUN;\n\tdkim-atps=neutral",
            "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org\n (client-ip=2404:9400:21b9:f100::1; helo=lists.ozlabs.org;\n envelope-from=linuxppc-dev+bounces-16838-incoming=patchwork.ozlabs.org@lists.ozlabs.org;\n receiver=patchwork.ozlabs.org)",
            "lists.ozlabs.org;\n arc=none smtp.remote-ip=113.46.200.222",
            "lists.ozlabs.org;\n dmarc=pass (p=quarantine dis=none) header.from=huawei.com",
            "lists.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=huawei.com header.i=@huawei.com header.a=rsa-sha256\n header.s=dkim header.b=pV5q7TUN;\n\tdkim-atps=neutral",
            "lists.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=huawei.com\n (client-ip=113.46.200.222; helo=canpmsgout07.his.huawei.com;\n envelope-from=ruanjinjie@huawei.com; receiver=lists.ozlabs.org)"
        ],
        "Received": [
            "from lists.ozlabs.org (lists.ozlabs.org\n [IPv6:2404:9400:21b9:f100::1])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fBWHX54T4z1xpY\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 12 Feb 2026 21:09:28 +1100 (AEDT)",
            "from boromir.ozlabs.org (localhost [127.0.0.1])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 4fBWHN6nyJz3bfV;\n\tThu, 12 Feb 2026 21:09:20 +1100 (AEDT)",
            "from canpmsgout07.his.huawei.com (canpmsgout07.his.huawei.com\n [113.46.200.222])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n\t(No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 4fBWHL2ktLz2yLH\n\tfor <linuxppc-dev@lists.ozlabs.org>; Thu, 12 Feb 2026 21:09:17 +1100 (AEDT)",
            "from mail.maildlp.com (unknown [172.19.163.15])\n\tby canpmsgout07.his.huawei.com (SkyGuard) with ESMTPS id 4fBW9r1K0QzLlW6;\n\tThu, 12 Feb 2026 18:04:32 +0800 (CST)",
            "from dggpemf500011.china.huawei.com (unknown [7.185.36.131])\n\tby mail.maildlp.com (Postfix) with ESMTPS id ECECB4056D;\n\tThu, 12 Feb 2026 18:09:10 +0800 (CST)",
            "from huawei.com (10.90.53.73) by dggpemf500011.china.huawei.com\n (7.185.36.131) with Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 12 Feb\n 2026 18:09:08 +0800"
        ],
        "ARC-Seal": "i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1770890960;\n\tcv=none;\n b=MaAJfljP2ztk0Tnq78Qq8wIRGSeTJ4yZvAqBmwLCHmaGidGvdFKGp5NvjIbeaJaibDfAiaM02MYlz1qVBmzGc9/fuC5WJBk39fQZFmlGdSjk8Fv6IsArV5gQXlgS6QS6cS9gGn5Gld3gtIST0XIjvF+mkJ04PTToUqjOWZtBDZpp4B6UC3tKqD4lj4zGFipaZMqIOdkK0fHLSVG1dFVr4+s5e+bEr8d96VKcYTUfhoGZtdgTgvpu1YqoP9Zq79aLWI0YnlGMr6hAM4au6aTXNX2+AgD+W81Aw2xykqrU4Rb4kl/omGrORtEtdgGsn6TYVJkm6ktqPqIxQ1zz0rPDFA==",
        "ARC-Message-Signature": "i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707;\n\tt=1770890960; c=relaxed/relaxed;\n\tbh=N5U6UgKBkjgYe5hwRHaVlDPTsZ0XGPihvgAIy47lkjU=;\n\th=From:To:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version:Content-Type;\n b=Khw54mPKhW5L7GiySiUR3cFlwG13JXd9Wk4NzIiJrM3KzHnQKQ0MDcSC5Hgx3y9WCkhReaaeY24n8qxuVQ3guMIg0OhHLDjAUm+BA5WKG/ClAsmfq6Bh5yLbs92CDPnOyJGkYGnrHeE6SfIeocU3AovHQEnvm9qJqJzR+DW1JxAzns2ttMmGe+rUQQw6KMDIUG4uu5Zic55HRpBlhPoLuogOqjRbex3jeAchGf8MKNj+WQGReJcaakscNN5AJdxzbSPyIlgqxyW3atjAcePZHtbRPwv3MR5Tng+36TPTqnXGaBr0lgvHuMkNmQLiw4k83FzUiC/j0ziOA4gciyE7oA==",
        "ARC-Authentication-Results": "i=1; lists.ozlabs.org;\n dmarc=pass (p=quarantine dis=none) header.from=huawei.com;\n dkim=pass (1024-bit key;\n unprotected) header.d=huawei.com header.i=@huawei.com header.a=rsa-sha256\n header.s=dkim header.b=pV5q7TUN; dkim-atps=neutral;\n spf=pass (client-ip=113.46.200.222; helo=canpmsgout07.his.huawei.com;\n envelope-from=ruanjinjie@huawei.com;\n receiver=lists.ozlabs.org) smtp.mailfrom=huawei.com",
        "dkim-signature": "v=1; a=rsa-sha256; d=huawei.com; s=dkim;\n\tc=relaxed/relaxed; q=dns/txt;\n\th=From;\n\tbh=N5U6UgKBkjgYe5hwRHaVlDPTsZ0XGPihvgAIy47lkjU=;\n\tb=pV5q7TUN92Ds+psPyaIUXw5pu5dPevyzBBFcm9I6uplX/qnoYdVryXadfkNqFjU+6EJZemlsQ\n\t9c968myFEowMGocTU+K6TwGn3lEzgEyzpS7I+GVtbcZK6wax4N1yVHOqvmWy8oqYF980tqzGs3w\n\txqJqBNPog82y4QzWia5K+rs=",
        "From": "Jinjie Ruan <ruanjinjie@huawei.com>",
        "To": "<corbet@lwn.net>, <skhan@linuxfoundation.org>, <catalin.marinas@arm.com>,\n\t<will@kernel.org>, <chenhuacai@kernel.org>, <kernel@xen0n.name>,\n\t<maddy@linux.ibm.com>, <mpe@ellerman.id.au>, <npiggin@gmail.com>,\n\t<chleroy@kernel.org>, <pjw@kernel.org>, <palmer@dabbelt.com>,\n\t<aou@eecs.berkeley.edu>, <alex@ghiti.fr>, <tglx@kernel.org>,\n\t<mingo@redhat.com>, <bp@alien8.de>, <dave.hansen@linux.intel.com>,\n\t<hpa@zytor.com>, <akpm@linux-foundation.org>, <bhe@redhat.com>,\n\t<vgoyal@redhat.com>, <dyoung@redhat.com>, <rdunlap@infradead.org>,\n\t<kees@kernel.org>, <elver@google.com>, <paulmck@kernel.org>, <arnd@arndb.de>,\n\t<ruanjinjie@huawei.com>, <fvdl@google.com>, <thuth@redhat.com>,\n\t<ardb@kernel.org>, <leitao@debian.org>, <rppt@kernel.org>, <osandov@fb.com>,\n\t<cfsworks@gmail.com>, <sourabhjain@linux.ibm.com>, <ryan.roberts@arm.com>,\n\t<tangyouling@kylinos.cn>, <eajames@linux.ibm.com>, <hbathini@linux.ibm.com>,\n\t<ritesh.list@gmail.com>, <songshuaishuai@tinylab.org>, <bjorn@rivosinc.com>,\n\t<samuel.holland@sifive.com>, <kevin.brodsky@arm.com>,\n\t<junhui.liu@pigmoral.tech>, <vishal.moola@gmail.com>, <dwmw@amazon.co.uk>,\n\t<pbonzini@redhat.com>, <kai.huang@intel.com>, <ubizjak@gmail.com>,\n\t<coxu@redhat.com>, <fuqiang.wang@easystack.cn>, <liaoyuanhong@vivo.com>,\n\t<brgerst@gmail.com>, <jbohac@suse.cz>, <x86@kernel.org>,\n\t<linux-doc@vger.kernel.org>, <linux-kernel@vger.kernel.org>,\n\t<linux-arm-kernel@lists.infradead.org>, <loongarch@lists.linux.dev>,\n\t<linuxppc-dev@lists.ozlabs.org>, <linux-riscv@lists.infradead.org>,\n\t<kexec@lists.infradead.org>",
        "Subject": "[PATCH v5 1/4] powerpc/crash: sort crash memory ranges before\n preparing elfcorehdr",
        "Date": "Thu, 12 Feb 2026 18:09:58 +0800",
        "Message-ID": "<20260212101001.343158-2-ruanjinjie@huawei.com>",
        "X-Mailer": "git-send-email 2.34.1",
        "In-Reply-To": "<20260212101001.343158-1-ruanjinjie@huawei.com>",
        "References": "<20260212101001.343158-1-ruanjinjie@huawei.com>",
        "X-Mailing-List": "linuxppc-dev@lists.ozlabs.org",
        "List-Id": "<linuxppc-dev.lists.ozlabs.org>",
        "List-Help": "<mailto:linuxppc-dev+help@lists.ozlabs.org>",
        "List-Owner": "<mailto:linuxppc-dev+owner@lists.ozlabs.org>",
        "List-Post": "<mailto:linuxppc-dev@lists.ozlabs.org>",
        "List-Archive": "<https://lore.kernel.org/linuxppc-dev/>,\n  <https://lists.ozlabs.org/pipermail/linuxppc-dev/>",
        "List-Subscribe": "<mailto:linuxppc-dev+subscribe@lists.ozlabs.org>,\n  <mailto:linuxppc-dev+subscribe-digest@lists.ozlabs.org>,\n  <mailto:linuxppc-dev+subscribe-nomail@lists.ozlabs.org>",
        "List-Unsubscribe": "<mailto:linuxppc-dev+unsubscribe@lists.ozlabs.org>",
        "Precedence": "list",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain",
        "X-Originating-IP": "[10.90.53.73]",
        "X-ClientProxiedBy": "kwepems200002.china.huawei.com (7.221.188.68) To\n dggpemf500011.china.huawei.com (7.185.36.131)",
        "X-Spam-Status": "No, score=-0.2 required=3.0 tests=DKIM_SIGNED,DKIM_VALID,\n\tDKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled\n\tversion=4.0.1 OzLabs 8",
        "X-Spam-Checker-Version": "SpamAssassin 4.0.1 (2024-03-25) on lists.ozlabs.org"
    },
    "content": "From: Sourabh Jain <sourabhjain@linux.ibm.com>\n\nDuring a memory hot-remove event, the elfcorehdr is rebuilt to exclude\nthe removed memory. While updating the crash memory ranges for this\noperation, the crash memory ranges array can become unsorted. This\nhappens because remove_mem_range() may split a memory range into two\nparts and append the higher-address part as a separate range at the end\nof the array.\n\nSo far, no issues have been observed due to the unsorted crash memory\nranges. However, this could lead to problems once crash memory range\nremoval is handled by generic code, as introduced in the upcoming\npatches in this series.\n\nCurrently, powerpc uses a platform-specific function,\nremove_mem_range(), to exclude hot-removed memory from the crash memory\nranges. This function performs the same task as the generic\ncrash_exclude_mem_range() in crash_core.c. The generic helper also\nensures that the crash memory ranges remain sorted. So remove the\nredundant powerpc-specific implementation and instead call\ncrash_exclude_mem_range_guarded() (which internally calls\ncrash_exclude_mem_range()) to exclude the hot-removed memory ranges.\n\nCc: Andrew Morton <akpm@linux-foundation.org>\nCc: Baoquan he <bhe@redhat.com>\nCc: Jinjie Ruan <ruanjinjie@huawei.com>\nCc: Hari Bathini <hbathini@linux.ibm.com>\nCc: Madhavan Srinivasan <maddy@linux.ibm.com>\nCc: Mahesh Salgaonkar <mahesh@linux.ibm.com>\nCc: Michael Ellerman <mpe@ellerman.id.au>\nCc: Ritesh Harjani (IBM) <ritesh.list@gmail.com>\nCc: Shivang Upadhyay <shivangu@linux.ibm.com>\nCc: linux-kernel@vger.kernel.org\nSigned-off-by: Sourabh Jain <sourabhjain@linux.ibm.com>\n---\n arch/powerpc/include/asm/kexec_ranges.h |  4 +-\n arch/powerpc/kexec/crash.c              |  5 +-\n arch/powerpc/kexec/ranges.c             | 87 +------------------------\n 3 files changed, 7 insertions(+), 89 deletions(-)",
    "diff": "diff --git a/arch/powerpc/include/asm/kexec_ranges.h b/arch/powerpc/include/asm/kexec_ranges.h\nindex 14055896cbcb..ad95e3792d10 100644\n--- a/arch/powerpc/include/asm/kexec_ranges.h\n+++ b/arch/powerpc/include/asm/kexec_ranges.h\n@@ -7,7 +7,9 @@\n void sort_memory_ranges(struct crash_mem *mrngs, bool merge);\n struct crash_mem *realloc_mem_ranges(struct crash_mem **mem_ranges);\n int add_mem_range(struct crash_mem **mem_ranges, u64 base, u64 size);\n-int remove_mem_range(struct crash_mem **mem_ranges, u64 base, u64 size);\n+int crash_exclude_mem_range_guarded(struct crash_mem **mem_ranges,\n+\t\t\t\t    unsigned long long mstart,\n+\t\t\t\t    unsigned long long mend);\n int get_exclude_memory_ranges(struct crash_mem **mem_ranges);\n int get_reserved_memory_ranges(struct crash_mem **mem_ranges);\n int get_crash_memory_ranges(struct crash_mem **mem_ranges);\ndiff --git a/arch/powerpc/kexec/crash.c b/arch/powerpc/kexec/crash.c\nindex a325c1c02f96..898742a5205c 100644\n--- a/arch/powerpc/kexec/crash.c\n+++ b/arch/powerpc/kexec/crash.c\n@@ -431,7 +431,7 @@ static void update_crash_elfcorehdr(struct kimage *image, struct memory_notify *\n \tstruct crash_mem *cmem = NULL;\n \tstruct kexec_segment *ksegment;\n \tvoid *ptr, *mem, *elfbuf = NULL;\n-\tunsigned long elfsz, memsz, base_addr, size;\n+\tunsigned long elfsz, memsz, base_addr, size, end;\n \n \tksegment = &image->segment[image->elfcorehdr_index];\n \tmem = (void *) ksegment->mem;\n@@ -450,7 +450,8 @@ static void update_crash_elfcorehdr(struct kimage *image, struct memory_notify *\n \tif (image->hp_action == KEXEC_CRASH_HP_REMOVE_MEMORY) {\n \t\tbase_addr = PFN_PHYS(mn->start_pfn);\n \t\tsize = mn->nr_pages * PAGE_SIZE;\n-\t\tret = remove_mem_range(&cmem, base_addr, size);\n+\t\tend = base_addr + size - 1;\n+\t\tret = crash_exclude_mem_range_guarded(&cmem, base_addr, end);\n \t\tif (ret) {\n \t\t\tpr_err(\"Failed to remove hot-unplugged memory from crash memory ranges\\n\");\n \t\t\tgoto out;\ndiff --git a/arch/powerpc/kexec/ranges.c b/arch/powerpc/kexec/ranges.c\nindex 867135560e5c..6c58bcc3e130 100644\n--- a/arch/powerpc/kexec/ranges.c\n+++ b/arch/powerpc/kexec/ranges.c\n@@ -553,7 +553,7 @@ int get_usable_memory_ranges(struct crash_mem **mem_ranges)\n #endif /* CONFIG_KEXEC_FILE */\n \n #ifdef CONFIG_CRASH_DUMP\n-static int crash_exclude_mem_range_guarded(struct crash_mem **mem_ranges,\n+int crash_exclude_mem_range_guarded(struct crash_mem **mem_ranges,\n \t\t\t\t\t   unsigned long long mstart,\n \t\t\t\t\t   unsigned long long mend)\n {\n@@ -641,89 +641,4 @@ int get_crash_memory_ranges(struct crash_mem **mem_ranges)\n \t\tpr_err(\"Failed to setup crash memory ranges\\n\");\n \treturn ret;\n }\n-\n-/**\n- * remove_mem_range - Removes the given memory range from the range list.\n- * @mem_ranges:    Range list to remove the memory range to.\n- * @base:          Base address of the range to remove.\n- * @size:          Size of the memory range to remove.\n- *\n- * (Re)allocates memory, if needed.\n- *\n- * Returns 0 on success, negative errno on error.\n- */\n-int remove_mem_range(struct crash_mem **mem_ranges, u64 base, u64 size)\n-{\n-\tu64 end;\n-\tint ret = 0;\n-\tunsigned int i;\n-\tu64 mstart, mend;\n-\tstruct crash_mem *mem_rngs = *mem_ranges;\n-\n-\tif (!size)\n-\t\treturn 0;\n-\n-\t/*\n-\t * Memory range are stored as start and end address, use\n-\t * the same format to do remove operation.\n-\t */\n-\tend = base + size - 1;\n-\n-\tfor (i = 0; i < mem_rngs->nr_ranges; i++) {\n-\t\tmstart = mem_rngs->ranges[i].start;\n-\t\tmend = mem_rngs->ranges[i].end;\n-\n-\t\t/*\n-\t\t * Memory range to remove is not part of this range entry\n-\t\t * in the memory range list\n-\t\t */\n-\t\tif (!(base >= mstart && end <= mend))\n-\t\t\tcontinue;\n-\n-\t\t/*\n-\t\t * Memory range to remove is equivalent to this entry in the\n-\t\t * memory range list. Remove the range entry from the list.\n-\t\t */\n-\t\tif (base == mstart && end == mend) {\n-\t\t\tfor (; i < mem_rngs->nr_ranges - 1; i++) {\n-\t\t\t\tmem_rngs->ranges[i].start = mem_rngs->ranges[i+1].start;\n-\t\t\t\tmem_rngs->ranges[i].end = mem_rngs->ranges[i+1].end;\n-\t\t\t}\n-\t\t\tmem_rngs->nr_ranges--;\n-\t\t\tgoto out;\n-\t\t}\n-\t\t/*\n-\t\t * Start address of the memory range to remove and the\n-\t\t * current memory range entry in the list is same. Just\n-\t\t * move the start address of the current memory range\n-\t\t * entry in the list to end + 1.\n-\t\t */\n-\t\telse if (base == mstart) {\n-\t\t\tmem_rngs->ranges[i].start = end + 1;\n-\t\t\tgoto out;\n-\t\t}\n-\t\t/*\n-\t\t * End address of the memory range to remove and the\n-\t\t * current memory range entry in the list is same.\n-\t\t * Just move the end address of the current memory\n-\t\t * range entry in the list to base - 1.\n-\t\t */\n-\t\telse if (end == mend)  {\n-\t\t\tmem_rngs->ranges[i].end = base - 1;\n-\t\t\tgoto out;\n-\t\t}\n-\t\t/*\n-\t\t * Memory range to remove is not at the edge of current\n-\t\t * memory range entry. Split the current memory entry into\n-\t\t * two half.\n-\t\t */\n-\t\telse {\n-\t\t\tsize = mem_rngs->ranges[i].end - end + 1;\n-\t\t\tmem_rngs->ranges[i].end = base - 1;\n-\t\t\tret = add_mem_range(mem_ranges, end + 1, size);\n-\t\t}\n-\t}\n-out:\n-\treturn ret;\n-}\n #endif /* CONFIG_CRASH_DUMP */\n",
    "prefixes": [
        "v5",
        "1/4"
    ]
}