From patchwork Fri Oct 25 15:11:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13850939 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id ECC73D0BB56 for ; Fri, 25 Oct 2024 15:12:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 871066B0099; Fri, 25 Oct 2024 11:12:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8201E6B009B; Fri, 25 Oct 2024 11:12:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 70E946B009C; Fri, 25 Oct 2024 11:12:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 53DB56B0099 for ; Fri, 25 Oct 2024 11:12:45 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 32642140D6B for ; Fri, 25 Oct 2024 15:12:24 +0000 (UTC) X-FDA: 82712465304.17.837D59C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf10.hostedemail.com (Postfix) with ESMTP id 27531C000C for ; Fri, 25 Oct 2024 15:12:34 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=PgzS1vUx; spf=pass (imf10.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729869085; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=gIFNVFgavkgVE76rylQBcYDoA1k/9BPXcVZSMfOlsww=; b=dKRJEaOUfIQ/y4jxvTKigK5ys4+Ac83q436ZkWFGnDpp5LMydt+PX6IcE2BKmm1lfacrfg c5RIUkcXgo7jhidU7efqRq4dMI7SDz8aKodQ0o7uzDZtqTjlmVH1L9NtVUv2iT9UC0uofI S7tkmYUilrjzX27gbS8yBlV8KAE2jE0= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=PgzS1vUx; spf=pass (imf10.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729869085; a=rsa-sha256; cv=none; b=6ePrOpLCTQTw/a2m7SGGQTh85SY+U/tTNXqHBa3JyKYvL6XU4dTJ0Pc5Lec2NUY3BdSl8v raQGhH0ezRnW7fdQFf/vuHt0Q7Mf71HfBL+BLxD2C/GcqaQsJdOBWm+YU6fVOPOtPTlVR9 wTgl4J/SSUZcS8n14TEjPOFAXEPMSpI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729869162; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gIFNVFgavkgVE76rylQBcYDoA1k/9BPXcVZSMfOlsww=; b=PgzS1vUxZ0uddPT3LqJA+CNRyxkp9Tbpx+Xt+jQ8yrdWsKmhvJxY1KyijuTnBLaqt08YFW 1VR+vh3k0mfD0CUPXsiiFgcR9BWt8L6uNAY/j5BnL2awlch0596Tly6qm3cqV+g5yxagzo OarSny9Ss4VLiQZVw+I7Fd3DP4kS0so= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-271-KbkSjjO5MweDNtywRObLgg-1; Fri, 25 Oct 2024 11:12:38 -0400 X-MC-Unique: KbkSjjO5MweDNtywRObLgg-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B1FBE1955F25; Fri, 25 Oct 2024 15:12:36 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.22.65.27]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2F05A300018D; Fri, 25 Oct 2024 15:12:27 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-s390@vger.kernel.org, virtualization@lists.linux.dev, kvm@vger.kernel.org, linux-fsdevel@vger.kernel.org, kexec@lists.infradead.org, David Hildenbrand , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?utf-8?q?Eugenio_P=C3=A9rez?= , Baoquan He , Vivek Goyal , Dave Young , Thomas Huth , Cornelia Huck , Janosch Frank , Claudio Imbrenda , Eric Farman , Andrew Morton Subject: [PATCH v1 06/11] fs/proc/vmcore: factor out freeing a list of vmcore ranges Date: Fri, 25 Oct 2024 17:11:28 +0200 Message-ID: <20241025151134.1275575-7-david@redhat.com> In-Reply-To: <20241025151134.1275575-1-david@redhat.com> References: <20241025151134.1275575-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 27531C000C X-Stat-Signature: kbdempww4rp9bqgqzohx5udxawrjxmsk X-HE-Tag: 1729869154-364377 X-HE-Meta: U2FsdGVkX18olD1NER8aUYs14OtCTvuLt5qmthcyjmBkWX1l1hTRFwqb5OXPgeAn6E4kUepHZABffAwSolYfvw7clfGMXGg+gOZ7tuMTfMVyjNkvadw+QPTrPdumj+tOrwqD7rOF7C5yeK2EsUfcaVDNPbXBQTVbqoTwdm3wr9GOpeyko4+Or+cGoPgFamV48faoFMuPqnrVT3/aLdEbUyp+Ii4zE3ATl7dzZV3AIT6rvEiOwPMdDZyxm1qPnpMQm55RwmK45RnE6TDKd6uOd45wU65w6hFPXgNESwr8RipJSE/wn+ND125SBGs2Z+OsHId3G9wzVfxP/kOwXZ8574bZNvf49oaq/o40C9sDBZrikP5Hkb+5Nkau4PEgcM5xxWz30nZFkWTbI6E+thO0FmFrw/e72quTKFv3R49zpUDqbkq7Gu+IzzxQWqJdWrX0fI90DCF9xjJvZe3G7mefqQ2+zFj/w3NfV02U60gA8aa++eqMLQgVDcXHTcbnwqTSfw+UHxLemnQ4prwVD8DMzYRpJ2zjfEtYWrP9wflsvIyZ3/bSLOlEaRSbhyPpDAsoE2mHT4MzDetH11+OkB3OR4oSGBzLJ2JgIevxmUuPwtICJCBzDXB+ylkSynfWb6Ei9RpGSsC9grmzL0a1pj92ggTjLHoPGjDcfb9EiOur5AKznfpUcTbpwZWJLRqKT4ceBXx5eKlx7X+aloS9QQXkMR6glFwgZFZZANfGjDPMcwIPTLvnwf6ukpBRwwmHvV8nDMGjpLN0y1YY2ltmBfKgx4RseUUQDJ4m4QYFiAGYYI6pGrqcNfNbziYbYuvdvftIhdmNykJCXbVUMJOFnjfgGFf99bep0ZaolBqKfknpc9rboCcv07pMssgW2zFjylEbo7/YjA76acWqkltKDM87WNiuwvc5RWFe/5524rg1o2vPpccc0MrY+EADRFrZUlEUQoSdQuosJ0u4C5dAJ8U wDhnnTwp 1oz+A8nthOdFmPUb6KDs9m8HJfcftCXUgJ+O5tkaQAhQRvG4T9AgLVT5iDFXT82m2zfMvfN1MgXyC1RK7LGv/WBOMVcCNU6fsryh3EeFBPjkQl+NlOEfdsoDrhd5LBt+v/NgE9IBeacBUrQ1Y2CWGA42fneDnE1xognPfJ4byaY5IcCK59CtCZ0uVZKaXVRTN6RvFxexuIN21Am7ZFS2m8oI2NCrpsIeIvhOHKa6hy/5WlnhXyi3jAwmFaWvbuZh3rBHFngV9JzNzGjQHrC6jfyvkSpsdN1wxwXh3VqhIkF0NfR9rI3wm5x9PEwZX5GC8T+4aOOPgqOKy2d8= 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: List-Subscribe: List-Unsubscribe: Let's factor it out into include/linux/crash_dump.h, from where we can use it also outside of vmcore.c later. Signed-off-by: David Hildenbrand Acked-by: Baoquan He --- fs/proc/vmcore.c | 9 +-------- include/linux/crash_dump.h | 11 +++++++++++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c index 76fdc3fb8c0e..3e90416ee54e 100644 --- a/fs/proc/vmcore.c +++ b/fs/proc/vmcore.c @@ -1568,14 +1568,7 @@ void vmcore_cleanup(void) proc_vmcore = NULL; } - /* clear the vmcore list. */ - while (!list_empty(&vmcore_list)) { - struct vmcore_mem_node *m; - - m = list_first_entry(&vmcore_list, struct vmcore_mem_node, list); - list_del(&m->list); - kfree(m); - } + vmcore_free_mem_nodes(&vmcore_list); free_elfcorebuf(); /* clear vmcore device dump list */ diff --git a/include/linux/crash_dump.h b/include/linux/crash_dump.h index ae77049fc023..722dbcff7371 100644 --- a/include/linux/crash_dump.h +++ b/include/linux/crash_dump.h @@ -135,6 +135,17 @@ static inline int vmcore_alloc_add_mem_node(struct list_head *list, return 0; } +/* Free a list of vmcore memory nodes. */ +static inline void vmcore_free_mem_nodes(struct list_head *list) +{ + struct vmcore_mem_node *m, *tmp; + + list_for_each_entry_safe(m, tmp, list, list) { + list_del(&m->list); + kfree(m); + } +} + #else /* !CONFIG_CRASH_DUMP */ static inline bool is_kdump_kernel(void) { return false; } #endif /* CONFIG_CRASH_DUMP */