From patchwork Wed Dec 4 12:54:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13893713 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 5E08AE7716B for ; Wed, 4 Dec 2024 12:55:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 89F866B009E; Wed, 4 Dec 2024 07:55:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 828FA6B00A0; Wed, 4 Dec 2024 07:55:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 678DA6B00A2; Wed, 4 Dec 2024 07:55:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 47E5B6B009E for ; Wed, 4 Dec 2024 07:55:19 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id B0A6CC0FC1 for ; Wed, 4 Dec 2024 12:55:13 +0000 (UTC) X-FDA: 82857271644.21.E45EE6A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf22.hostedemail.com (Postfix) with ESMTP id D362FC0017 for ; Wed, 4 Dec 2024 12:54:55 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=cQUBjrHC; spf=pass (imf22.hostedemail.com: domain of dhildenb@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhildenb@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=1733316901; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=/hPjJFLUCb0ZdSDAqGVI3uh+hCPNkczr7XmzIQmCEzE=; b=YsBmkYYGAdUNLHwXkGTxOc+J0str3/w8NcymdAN4hx81cFIVsI/PAzvVWyD4oJ7qobxGl5 Bt40/V7oHGo35fXkARbtv30ti5UyjClRaAr41LvoBSfKuu8BSXbbVdlfQSYQYiPRqB5UO1 WRMI5bECVeIeHa31u7wB2phMhFGYKHI= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=cQUBjrHC; spf=pass (imf22.hostedemail.com: domain of dhildenb@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhildenb@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733316901; a=rsa-sha256; cv=none; b=Na4r8y1P/gXq4Maf7AN3jzhIGoTGnR+FfSfSiR81XJHmayY44UKYSahSjKQlbIWkbSANkS bZraMuBtbkLC2gNbRFXTXGMahhBcqoWyClLgSiIBvD/vgKdcEejFCVP0bOaCAUOEY86mWl m5SY4SLRv+s/CtiJaF5+lq34jhw33V4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1733316911; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/hPjJFLUCb0ZdSDAqGVI3uh+hCPNkczr7XmzIQmCEzE=; b=cQUBjrHC6vuua6YJh3h/w0XCrGusBAG31hO28IrWKXTd4iOjlDk08wjUFqtKMOZYhNoWPn Xu51WI2LXGXFKEID26X8TYgt54osLNucZs38bIBtskdHdIEKlxEtBbedI+bJv313Vkpf7G VstWXl2cUnPdSvxmIE0rmakzlBcJMWs= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-99-CX8u_T5BM6Wj1oeSMImkgw-1; Wed, 04 Dec 2024 07:55:09 -0500 X-MC-Unique: CX8u_T5BM6Wj1oeSMImkgw-1 X-Mimecast-MFC-AGG-ID: CX8u_T5BM6Wj1oeSMImkgw Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4349e97bfc4so62389435e9.3 for ; Wed, 04 Dec 2024 04:55:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733316909; x=1733921709; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/hPjJFLUCb0ZdSDAqGVI3uh+hCPNkczr7XmzIQmCEzE=; b=KARU309MKiNMZfcmiV9/E8hCUj1ZWdLfC7JPL75RPtRhH278MXukAc+2B3L18UPRAm wwGiZcc2qmcDmBxu7djPKSvjthhNgpv3NsilNsI/8N/OQLLJRa8SFytKSxT5ZTJoqz/4 gQT5aBXsBS4+bC/mDHttfzDlO1iyk6fTf+DR0KKd0yj2NQ8MOJTcLgWXqViKU6hvWI6l SoHtHFMjFXly2RA0LLNQU7Ftg1uviUDXhfc6bQbglst01y/0mX0+xKyB7rbdeWRpt1nk qpWZRaoRgT//TfYONXP8AK9XLwFlSMBA533BRlTzU+D0tUAiWUZTRoZtamaYHEKenYlJ kW5g== X-Gm-Message-State: AOJu0YzH4zYeikVqfSj/9WKEd2IZJJ2MNGYbl8yUDwlKZNWjSCA5m9KD 0IJsIsyv4BpsHZrx64rzXyIf/FkaRJWR8I5YN0xGYIImCyQMJ92Lv9JlCyL2L3Omwk+1EbovOJJ Uts0I+bBREf1UTSpelonD351kc0dZ/AUwfYaBysyxPuXPWJpd X-Gm-Gg: ASbGncstkMmMTz3ExZIGyTsmk/KDwdiWhr0CXcUc5UPqvWCI6oLLn7YbYRtOz3Eezu5 YkJGTCzX0zH8fos6/5As2p93qsZoeSKEYXDUPaQSe3ZwNmmKV6cfbaIM/9fspf9IQq/ujqj9m0m IRNmH0dtuBRJEWCUtb3BlPfu7AxV8ctt2xVoclFzMBlxvgx+kbzpOqNos1wm6javMYAuGQoxH3u Kh009D6RV2F41gX+w1SHgMoRxo298lvnPn7gyfmP9SVeOe6miepQdMCVX5jTz5BVmfDmHDvuyjs 7tOs55VaUoJxJjTurxig8C2TVyK3boW1WE4= X-Received: by 2002:a05:600c:1989:b0:431:6083:cd30 with SMTP id 5b1f17b1804b1-434d09b2a75mr60274915e9.6.1733316908761; Wed, 04 Dec 2024 04:55:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IFKlYOU/tZlshqWyJGjVsl03zkEzffSPE/+D71b9Tfd5+g4TqcfXtmwO5t6x/22DC/lF4E/bA== X-Received: by 2002:a05:600c:1989:b0:431:6083:cd30 with SMTP id 5b1f17b1804b1-434d09b2a75mr60274425e9.6.1733316908112; Wed, 04 Dec 2024 04:55:08 -0800 (PST) Received: from localhost (p200300cbc70be10038d68aa111b0a20a.dip0.t-ipconnect.de. [2003:cb:c70b:e100:38d6:8aa1:11b0:a20a]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-385db7f86dasm16267209f8f.66.2024.12.04.04.55.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 04 Dec 2024 04:55:06 -0800 (PST) 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 v2 07/12] fs/proc/vmcore: factor out freeing a list of vmcore ranges Date: Wed, 4 Dec 2024 13:54:38 +0100 Message-ID: <20241204125444.1734652-8-david@redhat.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241204125444.1734652-1-david@redhat.com> References: <20241204125444.1734652-1-david@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: RcgopBNDSGLMDfkA5n1L-9909PVr2M3DdDZfAxvtrI8_1733316909 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true X-Rspamd-Server: rspam05 X-Stat-Signature: d5h83z1bra81ktfnxxdumxg9cm6patqz X-Rspamd-Queue-Id: D362FC0017 X-Rspam-User: X-HE-Tag: 1733316895-864789 X-HE-Meta: U2FsdGVkX1+ANg8NBaNk5IHpOp64ee+qT1RqoXM3QGrcuoaWtTux4ranckLWExYMPn41QQW5M5Dqip4Jb4rccxgsLzgYOH5kGSBfzbt5s3onGSMkLmnGHy++64p0zmE11LnGR9w+6ZRN/ZD7LLsbUXTjf9ZWztbtFJLU33I8ekRo0N148vVYD8LLmYTiDrBU8mW8Vt/oAIllVdI1k06kzngvJ3pqD8CvQET89oOaC6F/tsEfXKQAvAbdYiTortN1LBvD+yvSdy6vSnJGJd3DZPFZeDSEONyyFuKFtAlEj8+JPbIhSsM4K7bEF5N1Lzs4Rv1AWTHOtwVsJNheNQ2zWNB06HO9ofAzpjHKZwtjzOt6mFK8HXnXTzatOYtCjPWEkZaw1fOwNIg9P6A9+05U6xAZ4MNxvc2NfoMlMGWy+HQbaEoOSMuWAx70VqQCcfpFkMRqzC3TAlUTGnLrprzjYZW/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-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. Acked-by: Baoquan He Signed-off-by: David Hildenbrand --- 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 9b72e255dd03..e7b3cde44890 100644 --- a/fs/proc/vmcore.c +++ b/fs/proc/vmcore.c @@ -1592,14 +1592,7 @@ void vmcore_cleanup(void) proc_vmcore = NULL; } - /* clear the vmcore list. */ - while (!list_empty(&vmcore_list)) { - struct vmcore_range *m; - - m = list_first_entry(&vmcore_list, struct vmcore_range, list); - list_del(&m->list); - kfree(m); - } + vmcore_free_ranges(&vmcore_list); free_elfcorebuf(); /* clear vmcore device dump list */ diff --git a/include/linux/crash_dump.h b/include/linux/crash_dump.h index 9717912ce4d1..5d61c7454fd6 100644 --- a/include/linux/crash_dump.h +++ b/include/linux/crash_dump.h @@ -135,6 +135,17 @@ static inline int vmcore_alloc_add_range(struct list_head *list, return 0; } +/* Free a list of vmcore ranges. */ +static inline void vmcore_free_ranges(struct list_head *list) +{ + struct vmcore_range *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 */