From nobody Sat May 07 15:34:37 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 66B611ABE163; Sat, 7 May 2022 15:34:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KwWhF75kQz3qrw; Sat, 7 May 2022 15:34:37 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651937678; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=XTP3iRcHuP9tzyK9SDZgfjG5X5W8scDKSiyWh7ctauc=; b=Lkrwn8+e9iOvqIga/284ZYHThwZWyU3wfCyF3cj197GcQLj8CEwTg548sgkafKqpu5sUqw QCv2ty9WDEjbaIGiOtQkb3bLlIMTW8VOz7GtJmBgoZuhmEWFyNMdXpQyvNHnGpB5KdQDgc dJG/MusALOG2V0N67PX72m4nbNDuxpoOUdnu0yHphoFzBiGaaekEIbq7jFZ5uhcVCjUzB1 fTz2/UiO76WNwFFrp2P9M4rP3XxLTecP9EhHs3w2/qc0v4LEpwweDvYg0wsewxlrk85WIM eOWWtTpavPg3zhDdDue7ESWYsZSvL7yg7JktWq3YgaZpf09nxWum2tuW/2r+mQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B1E0C131AE; Sat, 7 May 2022 15:34:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 247FYbha087925; Sat, 7 May 2022 15:34:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 247FYbju087924; Sat, 7 May 2022 15:34:37 GMT (envelope-from git) Date: Sat, 7 May 2022 15:34:37 GMT Message-Id: <202205071534.247FYbju087924@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 45ae223ac654 - main - msgbuf: Allow microsecond granularity timestamps List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 45ae223ac654c0ab6cdc4eaacca693244802383e Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651937678; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=XTP3iRcHuP9tzyK9SDZgfjG5X5W8scDKSiyWh7ctauc=; b=mVSgJn7/of38i89GELSQ7+tK9a5b2kHRTpSPxGfx+6qmB++el9MUeHUCT4/opdgJj9FCe2 fOUt/h+gvbCOc0QG91IvnIPFWIigxZn6kiUyQvcz4OkBpfmQjPWVWJgP2e3FfAp/uFI58w mNwWfvmsRZ58VcQ1D8tXCuO70ITmI74GiGpdfSMgOoNQFNaEVN1UQt0tc/SJTdd/D2djVv 7TE9qDpv8DsPQmDNVHsSgmONXenlps9B+7dhbVZl1hvGWlComFJWntVfttHTPbL1W9eR83 fLCsNxiU1gKHlY23EneyD9jUDj3APByO6ccb9AG8mciRfZwO0gG6Hmg/5qhbvQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1651937678; a=rsa-sha256; cv=none; b=VHmB7eihkHTNdaTlbS4om+MCWbP8pDijJDydOw3cXiyoeK52NzUaovCxXlbRFUxiN7h6Qh Y9FL/RRDnN2YvArxSfZwSZmW9uHtBvcI3LoN1dOUuwq4ABTRRbW/pxhQK7c+wAuZaCFBsI i4KQH54Sdb3cQByxDirloyMi9jnWSj9piEFDMQCUPHr7JKw5LSykgXOCFWjM8gtPw1XO0v o+3Y7h5F8hnS3wYzMnCPY4bjhnDld7Aqyz2889e+Qlg4+VMFhuG/FGXgZWDMPlsDCYNBzv 5CDvgzip2Uy2L9MM9U/sgD52mLC533gDa0rQa626c9dBLYGDbt09tNi9rrhJdg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=45ae223ac654c0ab6cdc4eaacca693244802383e commit 45ae223ac654c0ab6cdc4eaacca693244802383e Author: Warner Losh AuthorDate: 2022-05-06 17:31:18 +0000 Commit: Warner Losh CommitDate: 2022-05-07 15:32:22 +0000 msgbuf: Allow microsecond granularity timestamps Today, kern.msgbuf_show_timestamp=1 will give 1 second granularity timestamps on dmesg lines. When kern.msgbuf_show_timestamp=2, we'll produce microsecond level graunlarity. For example: old (== 1): [13] Dual Console: Video Primary, Serial Secondary [14] lo0: link state changed to UP [15] bxe0: NIC Link is Up, 10000 Mbps full duplex, Flow control: ON - receive & transmit [15] bxe0: link state changed to UP new (== 2): [13.807015] Dual Console: Video Primary, Serial Secondary [14.544150] lo0: link state changed to UP [15.272044] bxe0: NIC Link is Up, 10000 Mbps full duplex, Flow control: ON - receive & transmit [15.272052] bxe0: link state changed to UP Sponsored by: Netflix --- sbin/dmesg/dmesg.8 | 5 ++++- sys/kern/subr_msgbuf.c | 12 ++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/sbin/dmesg/dmesg.8 b/sbin/dmesg/dmesg.8 index 13101baf7e78..a924549264cd 100644 --- a/sbin/dmesg/dmesg.8 +++ b/sbin/dmesg/dmesg.8 @@ -78,7 +78,10 @@ the message buffer: The default value is shown next to each variable. .Bl -tag -width indent .It kern.msgbuf_show_timestamp : No 0 -If set to 1, then a timestamp will be added to most lines in the message buffer. +If set to 0, no timetamps are added. +If set to 1, then a 1-second granularity timestamp will be added to most lines +in the message buffer. +If set to 2, then a microsecond granularity timestamp will be added. This may also be set as a boot .Xr loader 8 tunable. diff --git a/sys/kern/subr_msgbuf.c b/sys/kern/subr_msgbuf.c index b41e78dd886e..4664e742c5fb 100644 --- a/sys/kern/subr_msgbuf.c +++ b/sys/kern/subr_msgbuf.c @@ -234,8 +234,16 @@ msgbuf_addstr(struct msgbuf *mbp, int pri, const char *str, int filter_cr) if (msgbuf_show_timestamp && needtime == 1 && (mbp->msg_flags & MSGBUF_NEEDNL) == 0) { - snprintf(buf, sizeof(buf), "[%jd] ", - (intmax_t)time_uptime); + if (msgbuf_show_timestamp == 1) { + snprintf(buf, sizeof(buf), "[%jd] ", + (intmax_t)time_uptime); + } else { + struct timeval tv; + + microuptime(&tv); + snprintf(buf, sizeof(buf), "[%jd.%06d] ", + (intmax_t)tv.tv_sec, (int)tv.tv_usec); + } for (j = 0; buf[j] != '\0'; j++) msgbuf_do_addchar(mbp, buf[j]); needtime = 0;