From nobody Mon Nov 25 19:25:06 2024 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 5836F217468 for ; Fri, 25 Oct 2024 15:12:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729869165; cv=none; b=r9Qk8Npmyl0raScLaRxn1STGb6wmUzHtf3YA2sDuuLEUXU5d0MPcN0tSUNYWWOWzYIR0Nsw1PAg32k2rN61N8vFGK0m402mAQ+cJSuvqKbjbGrHPDaDVW0Pj/BzSe2rhCuyhmgo0caDTw2JHf1sSdNFh048TyfPzz9Pg4j78EYU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729869165; c=relaxed/simple; bh=XgE5h5JSsM45B+HHXH3XDv6/wR/fgvzuwnpVaJQjZ6c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZFU8Ob7RH2S8zz0jlqrXrZoTSB1GEgFhvaMjKCcznzI2p5If5GNar7DxjS6k0ydB/Hy+F8Vv3vTvi/FwixYVgnsFPv32itrcHlNiLMEO3gPZEP97OPoXtuc17ZVv4Ne9tcMNl2nJR/IMjCDriesB6vj04YT1FWl9S1lZ8N7is/U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=PgzS1vUx; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="PgzS1vUx" 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=20P=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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Content-Type: text/plain; charset="utf-8" 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 =3D NULL; } =20 - /* clear the vmcore list. */ - while (!list_empty(&vmcore_list)) { - struct vmcore_mem_node *m; - - m =3D list_first_entry(&vmcore_list, struct vmcore_mem_node, list); - list_del(&m->list); - kfree(m); - } + vmcore_free_mem_nodes(&vmcore_list); free_elfcorebuf(); =20 /* 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 lis= t_head *list, return 0; } =20 +/* 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 */ --=20 2.46.1