From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D03893CDBD5 for ; Mon, 25 May 2026 08:47:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779698870; cv=none; b=Od4ikaAwVBv81USz6jQ5BkBLkJUXE/rZwyjAds/9XTl+ZZsBxLTrmQjYe+siyrQWYD/sc8qVQphkaqSk4LvMb7Jw6M7aN7WZcZy5i8vh+NcbbLtFpoYXgifAkryo+9SIDJJOgTqGdX3rgVWa3KBYbydkaOsm2o7u89SyjWhEhRY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779698870; c=relaxed/simple; bh=LbVJknQpNl4ambNq6Ee3GBo/kMDTef5deBiK6Zt8cBQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=us0E+6GXJrm58qECPX608ei90buowy1HOZ2ZcULq9yK5nT+ZM0xN7FGrziCpt+zrMFde+KwHQfkb4h8b4RsNbuyyy3HDwv8m6IYF+ScBHy9ZsxDTolYnmgRE+qugvTDL0e6IssdZEPtBuwliuhx0PKXAOKUFw5qwl91afITSmDU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=rF1bufAc; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="rF1bufAc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1779698866; bh=LbVJknQpNl4ambNq6Ee3GBo/kMDTef5deBiK6Zt8cBQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=rF1bufAcVWDpEqTqHof94d/WlJEcPD63Oufi6YBT8w4d22pra2DKb60gCBNooDlZR XzM9gzJvn/PCUH+WpF1+GqjwPSTebIgVIktwTzPihgzNOg463Bnd+Ek855kXH4hbw4 wnv6CDtfsy/tmZ7M7qWuMqjSFiUEhzCAYrT/IX1U= Date: Mon, 25 May 2026 10:47:46 +0200 From: Thomas =?utf-8?Q?Wei=C3=9Fschuh?= To: Petr Mladek Cc: Steven Rostedt , John Ogness , Sergey Senozhatsky , linux-kernel@vger.kernel.org Subject: Re: [QUESTION] printk: time namespaces and printk timestamps Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On 2026-05-25 10:37:40+0200, Petr Mladek wrote: > On Sat 2026-05-23 17:20:45, Thomas Weißschuh wrote: > > It looks like the monotonic timestamps of printk records do not take the > > callers time namespace into account when emitted through /dev/kmsg, > > /proc/kmsg and syslog(2). > > > > To me this looks like a bug. What do you think? Should it be changed? > > To be honest, I have never heard about time namespaces before ;-) > > So, you propose to use the timestamp with the namespace-specific > offset when a message is added from the given namespace, e.g. via: > > echo "This message is from another time space" > /dev/kmsg > > Do I get it correctly? My idea was rather to do the conversion when *reading* the message from a time namespaced user process. > I see two potential problems: > > 1. printk() historically used a monotonic clock. I am not sure if any > usespace application depends on it but there is a risk of breaking > something. >From the perspective of the namespaced process currently the timestamps from printk may in fact not be CLOCK_MONOTONIC. > Anyway, the printk messages are used to debug kernel problems. > And the order of events might be important. IMHO, messages with > random offsets might create confusion. That would not be an issue when doing the conversion during read. Each process sees the same order of events with the same relative time increments between them. Only the absolute values would change. Note: The offsets can never change for a given namespace or process. > 2. printk() has to work in any context, including NMI. It requires > a lockless way to get the timestamps. I am not sure if the > namespace timestamps might be read a lockless way and if > it would be worth the effort. As above. Thomas