From patchwork Tue Jun 18 15:41:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 13702528 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 213DBC2BA18 for ; Tue, 18 Jun 2024 15:41:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=wnHyax3WjIX/aTzAT9Wm9Aa6ZC1whYa8v13L9CGfOrw=; b=2Yg6XRDUa3Y221RXAABINqXUdo EZasOsrknVBaTuiYBoyupfQql/T+g05muGmZ2WtXBlm946QzROO+tva2qfkWdKbTIl7Nzvv5Aq36g oRuRdRwFIifp9qvHMIF22wjiiseh0vZRqU9F0wBZ9ZYaI0LW0AVoX9ju4/2T3AI6lWDE/9V1m0Xw6 N2kYfW0XTACy88emQOf/OVMzPgfoZq5B37Z8yCi7OMkJL2tRiBEve0h8FL72IVWzwLkL73O1WuJx7 hkRYnY7pABb/v2/FsaTpq6F4+ESk9QPhpVRrbM8TI8u40P3g6sVrjlCy/X5V+C0RoCKu41RYkZqjC CKE4IiBw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJaxj-0000000Feda-1hR8; Tue, 18 Jun 2024 15:41:35 +0000 Received: from smtpout.efficios.com ([2607:5300:203:b2ee::31e5]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJaxf-0000000FeaA-1WjK for linux-arm-kernel@lists.infradead.org; Tue, 18 Jun 2024 15:41:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1718725285; bh=z68f1glzn8W2C+bMjjEW4ShrQhXTjCIJIGeZFccSLPY=; h=From:To:Cc:Subject:Date:From; b=ruPl0PEK6sazyyfliImMeV4N/RZ2w8trQpW+3BuxpBgfY74vvT/HTIXHFg/jkFBQc /uBO2xX+9egDFU5OrOj2KpijQr4ZUW5T+4hy6xikS7DNQecF40c7bVg/Cxc/LZoDSp DYjYYdqNCSUbc0Rz4MVpOFUjPlXBIuXLohSoA+4D5d95W41rtitl5ImkDQZdJfEjkB hSBVD6dG4LDuD+4rA29R9WFRnnKK6gQKolTmEr5i3euC7TvREsV86F0zeU99zuak82 vZQ07ATaYtykem/C52Uzhjjt2JgKx769WJm5J/bFWPMniHwGcaJojALjUvaobuC0+Z oS+lXuzA5GT4A== Received: from thinkos.internal.efficios.com (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4W3WFK0rrfz16Vj; Tue, 18 Jun 2024 11:41:25 -0400 (EDT) From: Mathieu Desnoyers To: Dan Williams , Steven Rostedt Cc: linux-kernel@vger.kernel.org, Mathieu Desnoyers , Vishal Verma , Dave Jiang , Ira Weiny , nvdimm@lists.linux.dev, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org Subject: [RFC PATCH 0/4] Flush nvdimm/pmem to memory before machine restart Date: Tue, 18 Jun 2024 11:41:53 -0400 Message-Id: <20240618154157.334602-1-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240618_084131_646668_ED10A367 X-CRM114-Status: GOOD ( 11.14 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Introduce a new pre_restart notifier chain for callbacks that need to be executed after the system has been made quiescent with syscore_shutdown(), before machine restart. Register pre-restart notifiers to flush pmem areas from CPU data cache to memory on reboot, immediately before restarting the machine. This ensures all other CPUs are quiescent before the pmem data is flushed to memory. The use-case for this new notifier chain is to preserve tracing data within pmem areas on systems where the BIOS does not clear memory across warm reboots. I did an earlier POC that flushed caches on panic/die oops notifiers [1], but it did not cover the reboot case. I've been made aware that some distribution vendors have started shipping their own modified version of my earlier POC patch. This makes a strong argument for upstreaming this work. Link: https://lore.kernel.org/linux-kernel/f6067e3e-a2bc-483d-b214-6e3fe6691279@efficios.com/ [1] Cc: Vishal Verma Cc: Dave Jiang Cc: Ira Weiny Cc: nvdimm@lists.linux.dev Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: Dave Hansen Cc: x86@kernel.org Cc: "H. Peter Anvin" Cc: Catalin Marinas Cc: Will Deacon Cc: linux-arm-kernel@lists.infradead.org Mathieu Desnoyers (4): kernel/reboot: Introduce pre_restart notifiers nvdimm/pmem: Flush to memory before machine restart arm64: Invoke pre_restart notifiers x86: Invoke pre_restart notifiers arch/arm64/kernel/process.c | 2 ++ arch/x86/kernel/reboot.c | 7 +++-- drivers/nvdimm/pmem.c | 29 ++++++++++++++++++++- drivers/nvdimm/pmem.h | 2 ++ include/linux/reboot.h | 4 +++ kernel/reboot.c | 51 +++++++++++++++++++++++++++++++++++++ 6 files changed, 92 insertions(+), 3 deletions(-)