From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C4F5524A05D for ; Fri, 2 Jan 2026 15:10:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767366605; cv=none; b=EPQMFot8nKR25UiQ05AOMFuvwiT5hFlPYcSHMlIFh6gYgXRkm7k+wkxS+CO45xhytb7l5vsvIvQ+8FbUggeEc7q8FR9hYhLtpzNLuQubsJ5qyIn3f77kG1WM6OGdb7nX/MXH31MYd1t7TbJusBs9VO6m3DZkkHc5mg5PkEUriv4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767366605; c=relaxed/simple; bh=oreu//ovKvInbKfmnQGhKW8r0b58aJlYO4iSyIHPkRY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=YWfAXEDk80YrFV8XBhjb54kKdSd4uV7SC+y2Ltx8F9ODIuBCBTeEDakKzdPAuDyoxihxxDXIQYf/SvU58DYycaYgDAo87cFL7HXbp35oYWUQVNVJqfNFJrN7Jri2qYAGRoNFDYY+P5IMfvtiv97XOmgkHhhQ1a/xBGJRQ2Rgz3I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ALkmzmEt; arc=none smtp.client-ip=209.85.128.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ALkmzmEt" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-4775895d69cso51545435e9.0 for ; Fri, 02 Jan 2026 07:10:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767366601; x=1767971401; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=y1eJCz3IMCVzaPFR9n+LpYQ3cFp/Gh9wDP5j0bwatno=; b=ALkmzmEtBm6V0ItsR3iAerrJ6a+V7eqNescA/a8bF04jlXRF/AMRhc19jjVqY9dyzJ +0IBZrmtLCOpc0wnhH6Lax38nw10dgdLsKuTZKdbsWeTA7zbE7HtEHHFT9/JNkv3gK2Z q6gXycGw7L2UZFaoLluvOK8TZ4/kHZUySHUB0iKtj/fhmanUbag3341MeGtPR1VUdjXN OxhMdZdfEHeqQ7DzykR3e3RmYqbelF5cKiSYEva+HP5LCxwbWCu2+STc7P4zgFAbOpuV 7UejkxU2WRV2sATCCBHyvr8PyyA/93fwFhmpld2AMD6wy1A7ju8C31O0W1RGNkpuCEBg bh/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767366601; x=1767971401; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=y1eJCz3IMCVzaPFR9n+LpYQ3cFp/Gh9wDP5j0bwatno=; b=U+jUVT1TQ2eK9LkRZV8C9gcbdDfbDoG1gyuLxLAgaHoSkqV5mw6e84+esLFgXOP0xr Kc+CZ8qM77C6sJhwkTekFGRPyg0fOOkSr63vMI/hV48IUXGpB2mHlJzahxeH/oReIhiM mmUvAVAN3nuUtncRcd2fjoDYZkujErDamcQOxhgqOVi1JN0unVkHVpP/SXfQjuGxjazA XU8hTCx+KxHs1wdDlD/BgzTXXnvLGzcn7H7QzpH/IR7UtpyTsiUaHl5dhD6gjRGLIIjB G5i1MKgku4H57aMCulD1v72gGv4kR+C/Fg+uHTnu0IDZNqQmwATdBP8CU0P4ULyZ8IOH 1ulQ== X-Gm-Message-State: AOJu0Yz9HkyxrprmsMrCD1P5byRG8PvXtZIYt0ObDuWJlWRaxECm6NBu ME09fBArOzoXnMuP5b0gFwx8V8qG6r+8ti+7KXUlKS74IZY2M2Hreub6 X-Gm-Gg: AY/fxX7F+stMEhW0cO7Mbr7j52em+8iYDon6lLFFhohaJrNdFD9v+0qKMxtWrn+DFn3 LGs4YOJB4q502yUNP6q2oW28MPD+EQr5208rfBHFYck4yCd9qhomUbuJCvjBPVgqDAL6dpyXVMJ 1G5fbC7rmUU9+HgG0xO7QImV7JKhVDXAfwvgqceSDrfmg/ff4hgJeCbV271FJylGC9Q1pAVZSGf 0MpAUjNJKQj02xLUovITd7eV5syS8wQ8I4+R4HAtcfDL52lwcAVuNF5S7qgDaMo0j7LWol0ac3K tXzbikLFNBU8RcPI//F0IPUhsv2FMcE/F8lEUd/XAvB2AVoNMv514+52/N7DXCGJ+W3ZFNbIaQi japIIDLPXZPADbfH6qw0q594y0icsTNBTCx6fq6wJgrBfrpd+8k5iovqIVCQ2WOwDqcliMxuGW8 ANREcueG2g/jYhUPoIWRP8MxIxJeh5XGYDMFp5iLQcoD/qSFJQa2CWb7kDZYWmX8IggQSeQs6HA ie2HJmGf3Df X-Google-Smtp-Source: AGHT+IH3RpKWczLY+gkhjq2AtrhL06nZ1EdBricEWM1SCBl/FAK+3Z835dNOj1erlKquHw/1w2TN/Q== X-Received: by 2002:a05:600c:4f4f:b0:46f:d682:3c3d with SMTP id 5b1f17b1804b1-47d1955187fmr636047545e9.13.1767366600834; Fri, 02 Jan 2026 07:10:00 -0800 (PST) Received: from ?IPV6:2001:16a2:c8d2:2b00:183a:1350:d3a4:d89? ([2001:16a2:c8d2:2b00:183a:1350:d3a4:d89]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4324ea226d1sm87195021f8f.13.2026.01.02.07.09.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 02 Jan 2026 07:10:00 -0800 (PST) Message-ID: Date: Fri, 2 Jan 2026 18:09:57 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 2/2] kexec: history: track kexec boot counter Content-Language: en-GB To: Breno Leitao , Alexander Graf , Mike Rapoport , Pasha Tatashin , Pratyush Yadav Cc: linux-kernel@vger.kernel.org, kexec@lists.infradead.org, linux-mm@kvack.org, rmikey@meta.com, clm@fb.com, riel@surriel.com, kernel-team@meta.com References: <20260102-kho-v2-0-1747b1a3a1d6@debian.org> <20260102-kho-v2-2-1747b1a3a1d6@debian.org> From: Usama Arif In-Reply-To: <20260102-kho-v2-2-1747b1a3a1d6@debian.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 02/01/2026 17:53, Breno Leitao wrote: > Track and display the number of kexec boots since the last cold reboot > when CONFIG_KEXEC_HISTORY is enabled. > > This extends the previous kernel release tracking feature by adding > a counter that increments with each kexec boot. The counter provides > visibility into the kexec chain depth, which is useful for understanding > boot history in production environments. > > Add a new property, "kexec-count" in KHO FDT alongside the existing > "previous-release" property. The counter is: > > - Initialized to 0 when kho_in is instantiated. > - Incremented by 1 on each subsequent kexec. > - Printed alongside the previous kernel release version. > > The counter is stored as a 32-bit unsigned integer in FDT format and is > only active when CONFIG_KEXEC_HISTORY is enabled. > > Signed-off-by: Breno Leitao > Suggested-by: Pasha Tatashin > --- > kernel/liveupdate/kexec_handover.c | 25 +++++++++++++++++++++++-- > 1 file changed, 23 insertions(+), 2 deletions(-) > > diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_handover.c > index 06d99627bb3c..fe5a2c5c4c86 100644 > --- a/kernel/liveupdate/kexec_handover.c > +++ b/kernel/liveupdate/kexec_handover.c > @@ -38,6 +38,7 @@ > #define PROP_PRESERVED_MEMORY_MAP "preserved-memory-map" > #define PROP_SUB_FDT "fdt" > #define PROP_PREVIOUS_RELEASE "previous-release" > +#define PROP_KEXEC_COUNT "kexec-count" > > #define KHO_PAGE_MAGIC 0x4b484f50U /* ASCII for 'KHOP' */ > > @@ -1257,6 +1258,7 @@ struct kho_in { > phys_addr_t scratch_phys; > #ifdef CONFIG_KEXEC_HISTORY > char previous_release[__NEW_UTS_LEN + 1]; > + u32 kexec_count; > #endif > struct kho_debugfs dbg; > }; > @@ -1330,6 +1332,9 @@ static __init int kho_out_fdt_setup(void) > void *root = kho_out.fdt; > u64 empty_mem_map = 0; > int err; > +#ifdef CONFIG_KEXEC_HISTORY > + u32 kexec_count; > +#endif > > err = fdt_create(root, PAGE_SIZE); > err |= fdt_finish_reservemap(root); > @@ -1340,6 +1345,10 @@ static __init int kho_out_fdt_setup(void) > #ifdef CONFIG_KEXEC_HISTORY > err |= fdt_property_string(root, PROP_PREVIOUS_RELEASE, > init_uts_ns.name.release); > + /* kho_in.kexec_count is set to 0 on cold boot */ > + kexec_count = cpu_to_fdt32(kho_in.kexec_count + 1); Should this be kexec_count = cpu_to_fdt32(kho_in.kexec_count) + 1; ? > + err |= fdt_property(root, PROP_KEXEC_COUNT, &kexec_count, > + sizeof(kexec_count)); > #endif > err |= fdt_end_node(root); > err |= fdt_finish(root); > @@ -1468,6 +1477,7 @@ void __init kho_memory_init(void) > static void __init kho_print_previous_kernel(const void *fdt) > { > const char *prev_release; > + const u32 *count_ptr; > int len; > > prev_release = fdt_getprop(fdt, 0, PROP_PREVIOUS_RELEASE, &len); > @@ -1476,8 +1486,19 @@ static void __init kho_print_previous_kernel(const void *fdt) > > strscpy(kho_in.previous_release, prev_release, > sizeof(kho_in.previous_release)); > - pr_info("This kernel was kexec'ed from kernel release: %s\n", > - kho_in.previous_release); > + > + /* Read the kexec count from the previous kernel */ > + count_ptr = fdt_getprop(fdt, 0, PROP_KEXEC_COUNT, &len); > + if (WARN_ON_ONCE(!count_ptr || len <= 0)) > + /* > + * PROP_KEXEC_COUNT should exist if PROP_PREVIOUS_RELEASE > + * exists. > + */ > + return; > + kho_in.kexec_count = fdt32_to_cpu(*count_ptr); > + > + pr_info("This kernel was kexec'ed from kernel release: %s (kexec count: %u)\n", > + kho_in.previous_release, kho_in.kexec_count); > } > #else > static void __init kho_print_previous_kernel(const void *fdt) { } >