From patchwork Mon Jun 19 05:59:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 10954 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2801154vqr; Sun, 18 Jun 2023 23:12:46 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4LntwzVaf6xFw3q80naYOM/aw7jQHyFmD5VQF7/39bxRtY1tF0DIib4gcgXx+l8qAXf7QC X-Received: by 2002:a05:6a20:12d1:b0:121:b440:2820 with SMTP id v17-20020a056a2012d100b00121b4402820mr3086855pzg.19.1687155166541; Sun, 18 Jun 2023 23:12:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687155166; cv=none; d=google.com; s=arc-20160816; b=V46/Cks/FzQedN8hmKmd7QMw+axop45rUFgczzcHxG0GYpCNuzse8XyDxzzTbrD59t CN3E8zAa7/Qev6ipG7bpHeU1WkxYR9zXeQ0ZYt/gUseLHTMlICYIXBPTHvUu6pQjKu0R iXJ3RCI0QPUiuxAGJlvdjzP6a5UlKG6Pcc7ewJpR8NxSaL1gQtmhNK7m/+dE9yrSwERA 1D7CdnSq9mtDGLBeGGXm0tEDy9KL0gAyDkhtFv7lFXsJK0X2xJLRE2oRzGASOwrC6GMr 5JGdVvdycH0pwKnyRGGLq8nIoddAC5AKAw1n7fhkYbTu/fA7vbEIarjUitV0yJcJDKhK 4+gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=1Z+NO+U3mF4VkZPV3TiZ9hDCsNGYkiNE2A8dRovLHfw=; b=RoJvSgRJzATLjpFiFHh1Yhx6NVerlSqEKrl3Rtr62leXLyf3OTLYYpAB5seXhrI1NT 1UKSicoDJO59N3b/NM0eLDucNay9jgxcs4oQGtUAHGqT9emWe2MAeFi/umLFCDL3c2G/ Q4AvB/EzRBbh6mqSqTPYhJnhgtWNZGWcdQLxYUjJsgrhW3En2pK2fFQaW9rV0JyX60Sk iuZ0P5xhiEqsV7sg0a06CiFyQ7OazntF90qv4DiplR6BCY3aP4F9nzh/WIsvEebsxy5/ jKrH+d6x4o9el3+OvwqxEd8Xs2PM8ZZ1RfIAB9lbFfcAcQepCm50OMNd3/hei0GtKip+ PL8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KFCHLeaN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h23-20020a633857000000b0054ffd92af2bsi8864349pgn.506.2023.06.18.23.12.33; Sun, 18 Jun 2023 23:12:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KFCHLeaN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229765AbjFSGA5 (ORCPT + 99 others); Mon, 19 Jun 2023 02:00:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229456AbjFSGAz (ORCPT ); Mon, 19 Jun 2023 02:00:55 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D3E91A6 for ; Sun, 18 Jun 2023 23:00:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687154407; 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; bh=1Z+NO+U3mF4VkZPV3TiZ9hDCsNGYkiNE2A8dRovLHfw=; b=KFCHLeaNT+RfLyBxagPhlw5qcoabJ0e2DM2HtXEi3t4MV62idz/VJF/3YuSKGih9T9B9je WsYQze4my65b9jgHAY6HVsq111K6dRqjhSQVpXan3I7vUHCF8M5Ax2jyd/ZO4BT196CNT3 K1SoXXZ6OQgI1tTcluCQ5XGBnMj8oiM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-384-e-TQ8zTVO1GPjKCn5TdD5g-1; Mon, 19 Jun 2023 02:00:01 -0400 X-MC-Unique: e-TQ8zTVO1GPjKCn5TdD5g-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0B2E3800888; Mon, 19 Jun 2023 06:00:01 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-194.pek2.redhat.com [10.72.12.194]) by smtp.corp.redhat.com (Postfix) with ESMTP id 20987112132C; Mon, 19 Jun 2023 05:59:54 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: catalin.marinas@arm.com, thunder.leizhen@huawei.com, John.p.donnelly@oracle.com, kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, horms@kernel.org, chenjiahao16@huawei.com, linux-riscv@lists.infradead.org, x86@kernel.org, bp@alien8.de, Baoquan He Subject: [RFC PATCH 0/4] kdump: add generic functions to simplify crashkernel crashkernel in architecture Date: Mon, 19 Jun 2023 13:59:47 +0800 Message-Id: <20230619055951.45620-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769110415632083599?= X-GMAIL-MSGID: =?utf-8?q?1769110415632083599?= In the current arm64, crashkernel=,high support has been finished after several rounds of posting and careful reviewing. The code in arm64 which parses crashkernel kernel parameters firstly, then reserve memory can be a good example for other ARCH to refer to. Whereas in x86_64, the code mixing crashkernel parameter parsing and memory reserving is twisted, and looks messy. Refactoring the code to make it more readable maintainable is necessary. Here, try to abstract the crashkernel parameter parsing code into a generic function parse_crashkernel_generic(), and the crashkernel memory reserving code into a generic function reserve_crashkernel_generic(). Then, in ARCH which crashkernel=,high support is needed, a simple arch_reserve_crashkernel() can be added to call above two generic functions. This can remove the duplicated implmentation code in each ARCH, like arm64, x86_64. I only change the arm64 and x86_64 implementation to make use of the generic functions to simplify code. Risc-v can be done very easily refer to the steps in arm64 and x86_64. I leave this to Jiahao or other risc-v developer since Jiahao have posted a patchset to add crashkernel=,high support to risc-v. This patchset is based on the latest linus's tree, and on top of below patch: arm64: kdump: simplify the reservation behaviour of crashkernel=,high https://git.kernel.org/arm64/c/6c4dcaddbd36 Baoquan He (4): kdump: rename parse_crashkernel() to parse_crashkernel_common() kdump: add generic functions to parse crashkernel and do reservation arm64: kdump: use generic interfaces to simplify crashkernel reservation code x86: kdump: use generic interfaces to simplify crashkernel reservation code arch/arm/kernel/setup.c | 4 +- arch/arm64/Kconfig | 3 + arch/arm64/include/asm/kexec.h | 8 ++ arch/arm64/mm/init.c | 141 ++---------------------- arch/ia64/kernel/setup.c | 4 +- arch/loongarch/kernel/setup.c | 3 +- arch/mips/cavium-octeon/setup.c | 2 +- arch/mips/kernel/setup.c | 4 +- arch/powerpc/kernel/fadump.c | 5 +- arch/powerpc/kexec/core.c | 4 +- arch/powerpc/mm/nohash/kaslr_booke.c | 4 +- arch/riscv/mm/init.c | 5 +- arch/s390/kernel/setup.c | 4 +- arch/sh/kernel/machine_kexec.c | 5 +- arch/x86/Kconfig | 3 + arch/x86/include/asm/kexec.h | 32 ++++++ arch/x86/kernel/setup.c | 141 +++--------------------- include/linux/crash_core.h | 33 +++++- kernel/crash_core.c | 158 +++++++++++++++++++++++++-- 19 files changed, 274 insertions(+), 289 deletions(-)