From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (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 E3B5A186A for ; Fri, 2 Jan 2026 15:31:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767367874; cv=none; b=Ej+DZ6nLDvsbRVr2awd1llOjcsL7CI0zyjQIilcM3A8b+0D2X6pD30ddMH4YgEuh3KVHDqSN4Mfg5IYvSVED0Km0bKyCalzs7cckEhnQA6F3pTsG1xJgSnchaIsrifNhP2LijRnfNcdOuQZGLrd0rgL6JEypMcO4EumZfvK8aXM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767367874; c=relaxed/simple; bh=F18ZHT6IqTNbfmjmDbSdJE8GBhF9H+y+hFS2fiEMDnI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=BWjf+MkEB75J78/m9SxLJz+2HR1DfGlhtJr4dw4RVe/KyhFh/YZQgNtjdyWvl3QperPZPLvxhcbictVelE6p+I76JhrcTTWfhnxCUR+sYqrDfNMWZjsN/FkI3K4d9ie2vHT3o9EUNh3QPOSHLC3OvBbaSs7Bl/QclpknyFW6568= 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=GNVux1Zs; arc=none smtp.client-ip=209.85.128.41 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="GNVux1Zs" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-4779ce2a624so94949485e9.2 for ; Fri, 02 Jan 2026 07:31:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767367871; x=1767972671; 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=w4uNqY5r0cWL7e4gE2mSIbtSpXgssK+f0V6w+g1HxwU=; b=GNVux1ZsxGXBzF9cBTtVa+vDQ8Px3FEY2FA2UGE9HBr0bSiI1R93OeTZ8bd5C4zxQy PvIOLk09xqmJUwv32R9j/zdR61+6V6iUoTzB9n0wdL25ZgAWfLGji8Ij4ICpvMA094B3 XZ38NVHakMOworor5/6PydJhQvHyqlJTlUwJjqsF8/fkJF4UgeoQ/+imPbjm3ykbzUMg axh405f04E3DdG59bkT1ZL6T4MEHxKWmxJ7N7poWhwE0gWupNydONE5uO2QoEILHJO5m Aifh/AvadBuQdEMgACEjmKito/usm9P4DKWU2xGsW066Ug9rqsaSgS6pv1nj2VThxAOs e/Lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767367871; x=1767972671; 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=w4uNqY5r0cWL7e4gE2mSIbtSpXgssK+f0V6w+g1HxwU=; b=PL18sYWgmGgipc6PD1nVy395QERfE6dSdyFY8LsDy1bzEe949yfY2/KaRa7Et8ntMy dX3w6wUzz1hNNUUHks4E35amOwblUK25tbW7rdPiI2VA7jvXZVjD4fXYtffd+ZWky/tA XCWi0vKyO0CSh7hVpAjUDA34d5Fu8BXSPyhDFomWPA61BLkL3rA7zyVkrCPWOLvAu/+n vLssJvRqC2PEB6D5Jho3ZK+qNMaKiv7aJKJ4vR0OmpGfJNsSaAIgitCgnlrou8bxitEz dWY0clhvlxu2GTW577IkZAZ1hYtOSSfKuZShaTsnIQSHwjfV+6gqIQntIxQI9v6jUewZ kVjg== X-Forwarded-Encrypted: i=1; AJvYcCUCgsRVfE3wz/qSKmf0ebwrICxL14z7LymWe5ADGys3JY4+7t0Rk5318pohYT3nPCMBqNOIbJwaZF69474=@vger.kernel.org X-Gm-Message-State: AOJu0YylG1lzcr3WAs2OpprSvywNWvzKH0rz/wuFWCypxp/113vMRCPO psZS+VaxOe1xRyacQTiSoC9teWq0ihc0Sl2uDO+07j327XnWGfGr9QUO X-Gm-Gg: AY/fxX70C/ohDqRGi9cDNCq8xaQB055mVhElCijzbbtQsmsHNYTzSRfdC09/DzOzXA8 zePOH5BJB/p5eoik0u8PWmMgG7HEe/H/VYqItqfw+5RuDeLqx315c0Mu92EXC+TWKy7TqMWMuOI XvK2wTJ0m8J7HJzYJlR5g4Y5RV8Ln9vi+L7qN9T53TN64KVLZmpI5wNU8boKzcIXyo3qiW181aE C+QIHNhUuF6L7tuFG64fO0G8tfwwAFkti59Ed8pWLxUiLvYgsTLhD4zakP79jPvYjkCrequ6tVr IDdUeeyDXRbwAScLSBk8nGNoqanqEeM7N23zQVNb3VCFmySwWaNCjeLR4vlam+WHeJR9cyCTEhR BQuYCkcgR8HGk0uNv++W3jEcl9c43U/R2i6CPzcsmxKFe5B6R1fGm5IFpQqMdmYXZ0jHG8+FjDF MZTTpc711PBXaj+H0uj1TTc9eg+xWQvDT0c5h4XYenmZK6feREBTK2ZghcExKvLvz/pXfmpbLfC 2EYGXEQNUNi X-Google-Smtp-Source: AGHT+IHBT9YlOVOXNiWvFipggdEYaegBM5I94nBU4m8bda8nrXYoAOcEMlAFzjbdkmpGlrMqkrvPEg== X-Received: by 2002:a05:600c:3146:b0:477:7c7d:d9b2 with SMTP id 5b1f17b1804b1-47d1959f776mr535335675e9.32.1767367870730; Fri, 02 Jan 2026 07:31:10 -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 5b1f17b1804b1-47d6ba40a50sm919985e9.7.2026.01.02.07.31.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 02 Jan 2026 07:31:10 -0800 (PST) Message-ID: <2bed4bbf-256a-4918-be53-1d4c6999a46b@gmail.com> Date: Fri, 2 Jan 2026 18:31:07 +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 Cc: Alexander Graf , Mike Rapoport , Pasha Tatashin , Pratyush Yadav , 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: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 02/01/2026 18:24, Breno Leitao wrote: > Hello Usama, > > On Fri, Jan 02, 2026 at 06:09:57PM +0300, Usama Arif wrote: >> >> 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; ? > > I don't think so. Basically we want to increment the counter in native > endianess and then convert to the Big Endian (FDT/DT are big endian > AFAIK) and then store (line below) to the DT. > > If we convert to big endian and then sum 1, it will mess with the > result. ack, Thanks for explaining, I didnt think of endianess! > >> + err |= fdt_property(root, PROP_KEXEC_COUNT, &kexec_count, >>> + sizeof(kexec_count)); > > Thanks for the review, > --breno