Re: [RFC] Prepend timestamp in msgbuf

2011-10-17 Thread Alexander Best
On Fri Oct 14 11, Arnaud Lacombe wrote:
 Hi,
 
 On Fri, Oct 14, 2011 at 8:52 AM, Nali Toja nalit...@gmail.com wrote:
  Alexander Best arun...@freebsd.org writes:
 
  On Fri Oct 14 11, Poul-Henning Kamp wrote:
   In message 20111014085609.ga3...@freebsd.org, Alexander Best writes:
  
   1) would it be possible to prepend those timestamps to the actual 
   console
   output and not only to the output of demsg? maybe via a sysctl toggle?
  
   The kernel does not know enough about timezones to emit anything
   but UTC timestamps.
 
  hmm ok.
 
  
   2) my dmesg output contains a lot of these entries: 118
  
   These are magic markers for syslogd(8) specifying priority.
 
  it would be nice, if their output could be turned off via a dmesg flag 
  imo.
 
  
   3) roughly the first 30 lines of my dmesg output have the timestamp 
   [1.0].
   would it be possible to have more accuracy there?
  
   No, because we don't know the time until we've found the RTC chip.
 
  maybe prepending the output with [??] instead of [1.0] would make more 
  sense,
  so users knows that those timestamps are bogus.
 
  maybe the granularity of the timestamps could be limited to a static 
  value? the
  following output doesn't really look pretty:
 
  [7.729516] 118/dev/ufs/varfs: clean, 879143 free (7407 frags, 108967 
  blocks, 0.7% fragmentation)
  [7.891512] 118Mounting local file systems:WARNING: TMPFS is considered 
  to be a highly experimental feature in FreeBSD.
  [8.33519] .
  [9.440514] 118Setting hostname: otaku.
  [9.744516] wlan0: Ethernet address: 00:0f:b5:82:07:c8
  [9.850516] 118Starting wpa_supplicant.
  [10.335514] 118Starting Network: lo0 ath0.
 
  so it would be nice, if trailing zeros got printed out, too.
 
  Why not make formatting similar to linux/xorg logs, e.g.
 
   [    31.897] (**) Option XkbLayout us
   [    31.897] (II) XINPUT: Adding extended input device default 
  keyboard (type: KEYBOARD, id 7)
   [ 11485.404] (II) 3rd Button detected: disabling emulate3Button
 
   [    0.00] Linux version 3.0-ARCH (tobias@T-POWA-LX) (gcc version 
  4.6.1 20110819 (prerelease) (GCC) ) #1 SMP PREEMPT Tue Aug 30 08:53:25 CEST 
  2011
   [    0.00] Command line: 
  root=/dev/disk/by-uuid/625db1f5-9b51-4d2d-acb7-6726f4d7e199 ro
   [...]
   [   15.096862] NET: Registered protocol family 10
   [   16.792594] [drm] nouveau :01:00.0: plugged DVI-I-2
   [   26.054186] eth0: no IPv6 routers present
 
  A way to convert those timestamps to localtime or time delta[1] post-mortem
  via dmesg(8) would be good, too.
 
 well, I do not care for the pretty side of the thing, however, this
 is just a matter length modifier in the string format; should be
 trivial to fix.

cc -c -O -pipe -march=core2 -std=c99 -g -Wall -Wredundant-decls 
-Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith 
-Winline -Wcast-qual -Wundef -Wno-pointer-sign -Wmissing-include-dirs -nostdinc 
 -I. -I/usr/git-freebsd-head/sys -I/usr/git-freebsd-head/sys/contrib/altq 
-D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h -fno-common 
-finline-limit=8000 --param inline-unit-growth=100 --param 
large-function-growth=1000  -fno-omit-frame-pointer -mno-sse -mcmodel=kernel 
-mno-red-zone -mno-mmx -msoft-float -fno-asynchronous-unwind-tables 
-ffreestanding -fformat-extensions -fdiagnostics-show-option -fstack-protector 
-Werror  /usr/git-freebsd-head/sys/kern/subr_msgbuf.c
cc1: warnings being treated as errors
/usr/git-freebsd-head/sys/kern/subr_msgbuf.c: In function 'msgbuf_do_addchar':
/usr/git-freebsd-head/sys/kern/subr_msgbuf.c:171: warning: format '%d' expects 
type 'int', but argument 4 has type 'time_t' [-Wformat]
*** Error code 1

Stop in /usr/obj/usr/git-freebsd-head/sys/ARUNDEL.
*** Error code 1

Stop in /usr/git-freebsd-head.
*** Error code 1

Stop in /usr/git-freebsd-head.

 
  - Arnaud
 
  [1] like in tcpdump -ttt
 
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: [RFC] Prepend timestamp in msgbuf

2011-10-17 Thread Arnaud Lacombe
Hi,

On Mon, Oct 17, 2011 at 2:01 PM, Alexander Best arun...@freebsd.org wrote:
 On Fri Oct 14 11, Arnaud Lacombe wrote:
 Hi,

 On Fri, Oct 14, 2011 at 8:52 AM, Nali Toja nalit...@gmail.com wrote:
  Alexander Best arun...@freebsd.org writes:
 
  On Fri Oct 14 11, Poul-Henning Kamp wrote:
   In message 20111014085609.ga3...@freebsd.org, Alexander Best writes:
  
   1) would it be possible to prepend those timestamps to the actual 
   console
   output and not only to the output of demsg? maybe via a sysctl toggle?
  
   The kernel does not know enough about timezones to emit anything
   but UTC timestamps.
 
  hmm ok.
 
  
   2) my dmesg output contains a lot of these entries: 118
  
   These are magic markers for syslogd(8) specifying priority.
 
  it would be nice, if their output could be turned off via a dmesg flag 
  imo.
 
  
   3) roughly the first 30 lines of my dmesg output have the timestamp 
   [1.0].
   would it be possible to have more accuracy there?
  
   No, because we don't know the time until we've found the RTC chip.
 
  maybe prepending the output with [??] instead of [1.0] would make more 
  sense,
  so users knows that those timestamps are bogus.
 
  maybe the granularity of the timestamps could be limited to a static 
  value? the
  following output doesn't really look pretty:
 
  [7.729516] 118/dev/ufs/varfs: clean, 879143 free (7407 frags, 108967 
  blocks, 0.7% fragmentation)
  [7.891512] 118Mounting local file systems:WARNING: TMPFS is considered 
  to be a highly experimental feature in FreeBSD.
  [8.33519] .
  [9.440514] 118Setting hostname: otaku.
  [9.744516] wlan0: Ethernet address: 00:0f:b5:82:07:c8
  [9.850516] 118Starting wpa_supplicant.
  [10.335514] 118Starting Network: lo0 ath0.
 
  so it would be nice, if trailing zeros got printed out, too.
 
  Why not make formatting similar to linux/xorg logs, e.g.
 
   [    31.897] (**) Option XkbLayout us
   [    31.897] (II) XINPUT: Adding extended input device default 
  keyboard (type: KEYBOARD, id 7)
   [ 11485.404] (II) 3rd Button detected: disabling emulate3Button
 
   [    0.00] Linux version 3.0-ARCH (tobias@T-POWA-LX) (gcc version 
  4.6.1 20110819 (prerelease) (GCC) ) #1 SMP PREEMPT Tue Aug 30 08:53:25 
  CEST 2011
   [    0.00] Command line: 
  root=/dev/disk/by-uuid/625db1f5-9b51-4d2d-acb7-6726f4d7e199 ro
   [...]
   [   15.096862] NET: Registered protocol family 10
   [   16.792594] [drm] nouveau :01:00.0: plugged DVI-I-2
   [   26.054186] eth0: no IPv6 routers present
 
  A way to convert those timestamps to localtime or time delta[1] post-mortem
  via dmesg(8) would be good, too.
 
 well, I do not care for the pretty side of the thing, however, this
 is just a matter length modifier in the string format; should be
 trivial to fix.

 cc -c -O -pipe -march=core2 -std=c99 -g -Wall -Wredundant-decls 
 -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith 
 -Winline -Wcast-qual -Wundef -Wno-pointer-sign -Wmissing-include-dirs 
 -nostdinc  -I. -I/usr/git-freebsd-head/sys 
 -I/usr/git-freebsd-head/sys/contrib/altq -D_KERNEL 
 -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h -fno-common 
 -finline-limit=8000 --param inline-unit-growth=100 --param 
 large-function-growth=1000  -fno-omit-frame-pointer -mno-sse -mcmodel=kernel 
 -mno-red-zone -mno-mmx -msoft-float -fno-asynchronous-unwind-tables 
 -ffreestanding -fformat-extensions -fdiagnostics-show-option 
 -fstack-protector -Werror  /usr/git-freebsd-head/sys/kern/subr_msgbuf.c
 cc1: warnings being treated as errors
 /usr/git-freebsd-head/sys/kern/subr_msgbuf.c: In function 'msgbuf_do_addchar':
 /usr/git-freebsd-head/sys/kern/subr_msgbuf.c:171: warning: format '%d' 
 expects type 'int', but argument 4 has type 'time_t' [-Wformat]
 *** Error code 1

 Stop in /usr/obj/usr/git-freebsd-head/sys/ARUNDEL.
 *** Error code 1

 Stop in /usr/git-freebsd-head.
 *** Error code 1

 Stop in /usr/git-freebsd-head.

FreeBSD has no time_t PRI... macros in any machine/_inttypes.h,
eventually cast it to `long'.

Btw, I appreciate the very clear message of yours, no Hi, no
signature, no idea what ARUNDEL is, and especially no details on
which architecture you are attempting to build, which should be, I
assume, LP64 ;-)

 - Arnaud
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: [RFC] Prepend timestamp in msgbuf

2011-10-17 Thread Garrett Cooper
On Mon, Oct 17, 2011 at 12:27 PM, Arnaud Lacombe lacom...@gmail.com wrote:
 Hi,

 On Mon, Oct 17, 2011 at 2:01 PM, Alexander Best arun...@freebsd.org wrote:
 On Fri Oct 14 11, Arnaud Lacombe wrote:
 Hi,

 On Fri, Oct 14, 2011 at 8:52 AM, Nali Toja nalit...@gmail.com wrote:
  Alexander Best arun...@freebsd.org writes:
 
  On Fri Oct 14 11, Poul-Henning Kamp wrote:
   In message 20111014085609.ga3...@freebsd.org, Alexander Best writes:
  
   1) would it be possible to prepend those timestamps to the actual 
   console
   output and not only to the output of demsg? maybe via a sysctl 
   toggle?
  
   The kernel does not know enough about timezones to emit anything
   but UTC timestamps.
 
  hmm ok.
 
  
   2) my dmesg output contains a lot of these entries: 118
  
   These are magic markers for syslogd(8) specifying priority.
 
  it would be nice, if their output could be turned off via a dmesg flag 
  imo.
 
  
   3) roughly the first 30 lines of my dmesg output have the timestamp 
   [1.0].
   would it be possible to have more accuracy there?
  
   No, because we don't know the time until we've found the RTC chip.
 
  maybe prepending the output with [??] instead of [1.0] would make more 
  sense,
  so users knows that those timestamps are bogus.
 
  maybe the granularity of the timestamps could be limited to a static 
  value? the
  following output doesn't really look pretty:
 
  [7.729516] 118/dev/ufs/varfs: clean, 879143 free (7407 frags, 108967 
  blocks, 0.7% fragmentation)
  [7.891512] 118Mounting local file systems:WARNING: TMPFS is considered 
  to be a highly experimental feature in FreeBSD.
  [8.33519] .
  [9.440514] 118Setting hostname: otaku.
  [9.744516] wlan0: Ethernet address: 00:0f:b5:82:07:c8
  [9.850516] 118Starting wpa_supplicant.
  [10.335514] 118Starting Network: lo0 ath0.
 
  so it would be nice, if trailing zeros got printed out, too.
 
  Why not make formatting similar to linux/xorg logs, e.g.
 
   [    31.897] (**) Option XkbLayout us
   [    31.897] (II) XINPUT: Adding extended input device default 
  keyboard (type: KEYBOARD, id 7)
   [ 11485.404] (II) 3rd Button detected: disabling emulate3Button
 
   [    0.00] Linux version 3.0-ARCH (tobias@T-POWA-LX) (gcc version 
  4.6.1 20110819 (prerelease) (GCC) ) #1 SMP PREEMPT Tue Aug 30 08:53:25 
  CEST 2011
   [    0.00] Command line: 
  root=/dev/disk/by-uuid/625db1f5-9b51-4d2d-acb7-6726f4d7e199 ro
   [...]
   [   15.096862] NET: Registered protocol family 10
   [   16.792594] [drm] nouveau :01:00.0: plugged DVI-I-2
   [   26.054186] eth0: no IPv6 routers present
 
  A way to convert those timestamps to localtime or time delta[1] 
  post-mortem
  via dmesg(8) would be good, too.
 
 well, I do not care for the pretty side of the thing, however, this
 is just a matter length modifier in the string format; should be
 trivial to fix.

 cc -c -O -pipe -march=core2 -std=c99 -g -Wall -Wredundant-decls 
 -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith 
 -Winline -Wcast-qual -Wundef -Wno-pointer-sign -Wmissing-include-dirs 
 -nostdinc  -I. -I/usr/git-freebsd-head/sys 
 -I/usr/git-freebsd-head/sys/contrib/altq -D_KERNEL 
 -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h -fno-common 
 -finline-limit=8000 --param inline-unit-growth=100 --param 
 large-function-growth=1000  -fno-omit-frame-pointer -mno-sse -mcmodel=kernel 
 -mno-red-zone -mno-mmx -msoft-float -fno-asynchronous-unwind-tables 
 -ffreestanding -fformat-extensions -fdiagnostics-show-option 
 -fstack-protector -Werror  /usr/git-freebsd-head/sys/kern/subr_msgbuf.c
 cc1: warnings being treated as errors
 /usr/git-freebsd-head/sys/kern/subr_msgbuf.c: In function 
 'msgbuf_do_addchar':
 /usr/git-freebsd-head/sys/kern/subr_msgbuf.c:171: warning: format '%d' 
 expects type 'int', but argument 4 has type 'time_t' [-Wformat]
 *** Error code 1

 Stop in /usr/obj/usr/git-freebsd-head/sys/ARUNDEL.
 *** Error code 1

 Stop in /usr/git-freebsd-head.
 *** Error code 1

 Stop in /usr/git-freebsd-head.

 FreeBSD has no time_t PRI... macros in any machine/_inttypes.h,
 eventually cast it to `long'.

 Btw, I appreciate the very clear message of yours, no Hi, no
 signature, no idea what ARUNDEL is, and especially no details on
 which architecture you are attempting to build, which should be, I
 assume, LP64 ;-)

time_t maps to int32_t on i386 and int64_t on amd64 (at least), so
you should be able to use %zd in the format string as the type is
variable width depending on the architecture.
Thanks,
-Garrett
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: [RFC] Prepend timestamp in msgbuf

2011-10-17 Thread Alexander Best
On Mon Oct 17 11, Arnaud Lacombe wrote:
 Hi,
 
 On Mon, Oct 17, 2011 at 2:01 PM, Alexander Best arun...@freebsd.org wrote:
  On Fri Oct 14 11, Arnaud Lacombe wrote:
  Hi,
 
  On Fri, Oct 14, 2011 at 8:52 AM, Nali Toja nalit...@gmail.com wrote:
   Alexander Best arun...@freebsd.org writes:
  
   On Fri Oct 14 11, Poul-Henning Kamp wrote:
In message 20111014085609.ga3...@freebsd.org, Alexander Best 
writes:
   
1) would it be possible to prepend those timestamps to the actual 
console
output and not only to the output of demsg? maybe via a sysctl 
toggle?
   
The kernel does not know enough about timezones to emit anything
but UTC timestamps.
  
   hmm ok.
  
   
2) my dmesg output contains a lot of these entries: 118
   
These are magic markers for syslogd(8) specifying priority.
  
   it would be nice, if their output could be turned off via a dmesg flag 
   imo.
  
   
3) roughly the first 30 lines of my dmesg output have the timestamp 
[1.0].
would it be possible to have more accuracy there?
   
No, because we don't know the time until we've found the RTC chip.
  
   maybe prepending the output with [??] instead of [1.0] would make more 
   sense,
   so users knows that those timestamps are bogus.
  
   maybe the granularity of the timestamps could be limited to a static 
   value? the
   following output doesn't really look pretty:
  
   [7.729516] 118/dev/ufs/varfs: clean, 879143 free (7407 frags, 108967 
   blocks, 0.7% fragmentation)
   [7.891512] 118Mounting local file systems:WARNING: TMPFS is 
   considered to be a highly experimental feature in FreeBSD.
   [8.33519] .
   [9.440514] 118Setting hostname: otaku.
   [9.744516] wlan0: Ethernet address: 00:0f:b5:82:07:c8
   [9.850516] 118Starting wpa_supplicant.
   [10.335514] 118Starting Network: lo0 ath0.
  
   so it would be nice, if trailing zeros got printed out, too.
  
   Why not make formatting similar to linux/xorg logs, e.g.
  
    [    31.897] (**) Option XkbLayout us
    [    31.897] (II) XINPUT: Adding extended input device default 
   keyboard (type: KEYBOARD, id 7)
    [ 11485.404] (II) 3rd Button detected: disabling emulate3Button
  
    [    0.00] Linux version 3.0-ARCH (tobias@T-POWA-LX) (gcc version 
   4.6.1 20110819 (prerelease) (GCC) ) #1 SMP PREEMPT Tue Aug 30 08:53:25 
   CEST 2011
    [    0.00] Command line: 
   root=/dev/disk/by-uuid/625db1f5-9b51-4d2d-acb7-6726f4d7e199 ro
    [...]
    [   15.096862] NET: Registered protocol family 10
    [   16.792594] [drm] nouveau :01:00.0: plugged DVI-I-2
    [   26.054186] eth0: no IPv6 routers present
  
   A way to convert those timestamps to localtime or time delta[1] 
   post-mortem
   via dmesg(8) would be good, too.
  
  well, I do not care for the pretty side of the thing, however, this
  is just a matter length modifier in the string format; should be
  trivial to fix.
 
  cc -c -O -pipe -march=core2 -std=c99 -g -Wall -Wredundant-decls 
  -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith 
  -Winline -Wcast-qual -Wundef -Wno-pointer-sign -Wmissing-include-dirs 
  -nostdinc  -I. -I/usr/git-freebsd-head/sys 
  -I/usr/git-freebsd-head/sys/contrib/altq -D_KERNEL 
  -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h -fno-common 
  -finline-limit=8000 --param inline-unit-growth=100 --param 
  large-function-growth=1000  -fno-omit-frame-pointer -mno-sse 
  -mcmodel=kernel -mno-red-zone -mno-mmx -msoft-float 
  -fno-asynchronous-unwind-tables -ffreestanding -fformat-extensions 
  -fdiagnostics-show-option -fstack-protector -Werror  
  /usr/git-freebsd-head/sys/kern/subr_msgbuf.c
  cc1: warnings being treated as errors
  /usr/git-freebsd-head/sys/kern/subr_msgbuf.c: In function 
  'msgbuf_do_addchar':
  /usr/git-freebsd-head/sys/kern/subr_msgbuf.c:171: warning: format '%d' 
  expects type 'int', but argument 4 has type 'time_t' [-Wformat]
  *** Error code 1
 
  Stop in /usr/obj/usr/git-freebsd-head/sys/ARUNDEL.
  *** Error code 1
 
  Stop in /usr/git-freebsd-head.
  *** Error code 1
 
  Stop in /usr/git-freebsd-head.
 
 FreeBSD has no time_t PRI... macros in any machine/_inttypes.h,
 eventually cast it to `long'.

just wanted to tell you that your patch causes buildkernel to fail on certain
archs (amd64 in my case) and that it appears you didn't run
'make universe-kernels' to check, whether your patch breaks anything.

i'll leave the details to you.

cheers.
alex

 
 Btw, I appreciate the very clear message of yours, no Hi, no
 signature, no idea what ARUNDEL is, and especially no details on
 which architecture you are attempting to build, which should be, I
 assume, LP64 ;-)
 
  - Arnaud
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: [RFC] Prepend timestamp in msgbuf

2011-10-17 Thread Arnaud Lacombe
Hi,

On Mon, Oct 17, 2011 at 3:44 PM, Alexander Best arun...@freebsd.org wrote:
 On Mon Oct 17 11, Arnaud Lacombe wrote:
 Hi,

 On Mon, Oct 17, 2011 at 2:01 PM, Alexander Best arun...@freebsd.org wrote:
  On Fri Oct 14 11, Arnaud Lacombe wrote:
  Hi,
 
  On Fri, Oct 14, 2011 at 8:52 AM, Nali Toja nalit...@gmail.com wrote:
   Alexander Best arun...@freebsd.org writes:
  
   On Fri Oct 14 11, Poul-Henning Kamp wrote:
In message 20111014085609.ga3...@freebsd.org, Alexander Best 
writes:
   
1) would it be possible to prepend those timestamps to the actual 
console
output and not only to the output of demsg? maybe via a sysctl 
toggle?
   
The kernel does not know enough about timezones to emit anything
but UTC timestamps.
  
   hmm ok.
  
   
2) my dmesg output contains a lot of these entries: 118
   
These are magic markers for syslogd(8) specifying priority.
  
   it would be nice, if their output could be turned off via a dmesg 
   flag imo.
  
   
3) roughly the first 30 lines of my dmesg output have the 
timestamp [1.0].
would it be possible to have more accuracy there?
   
No, because we don't know the time until we've found the RTC chip.
  
   maybe prepending the output with [??] instead of [1.0] would make 
   more sense,
   so users knows that those timestamps are bogus.
  
   maybe the granularity of the timestamps could be limited to a static 
   value? the
   following output doesn't really look pretty:
  
   [7.729516] 118/dev/ufs/varfs: clean, 879143 free (7407 frags, 108967 
   blocks, 0.7% fragmentation)
   [7.891512] 118Mounting local file systems:WARNING: TMPFS is 
   considered to be a highly experimental feature in FreeBSD.
   [8.33519] .
   [9.440514] 118Setting hostname: otaku.
   [9.744516] wlan0: Ethernet address: 00:0f:b5:82:07:c8
   [9.850516] 118Starting wpa_supplicant.
   [10.335514] 118Starting Network: lo0 ath0.
  
   so it would be nice, if trailing zeros got printed out, too.
  
   Why not make formatting similar to linux/xorg logs, e.g.
  
    [    31.897] (**) Option XkbLayout us
    [    31.897] (II) XINPUT: Adding extended input device default 
   keyboard (type: KEYBOARD, id 7)
    [ 11485.404] (II) 3rd Button detected: disabling emulate3Button
  
    [    0.00] Linux version 3.0-ARCH (tobias@T-POWA-LX) (gcc version 
   4.6.1 20110819 (prerelease) (GCC) ) #1 SMP PREEMPT Tue Aug 30 08:53:25 
   CEST 2011
    [    0.00] Command line: 
   root=/dev/disk/by-uuid/625db1f5-9b51-4d2d-acb7-6726f4d7e199 ro
    [...]
    [   15.096862] NET: Registered protocol family 10
    [   16.792594] [drm] nouveau :01:00.0: plugged DVI-I-2
    [   26.054186] eth0: no IPv6 routers present
  
   A way to convert those timestamps to localtime or time delta[1] 
   post-mortem
   via dmesg(8) would be good, too.
  
  well, I do not care for the pretty side of the thing, however, this
  is just a matter length modifier in the string format; should be
  trivial to fix.
 
  cc -c -O -pipe -march=core2 -std=c99 -g -Wall -Wredundant-decls 
  -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith 
  -Winline -Wcast-qual -Wundef -Wno-pointer-sign -Wmissing-include-dirs 
  -nostdinc  -I. -I/usr/git-freebsd-head/sys 
  -I/usr/git-freebsd-head/sys/contrib/altq -D_KERNEL 
  -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h -fno-common 
  -finline-limit=8000 --param inline-unit-growth=100 --param 
  large-function-growth=1000  -fno-omit-frame-pointer -mno-sse 
  -mcmodel=kernel -mno-red-zone -mno-mmx -msoft-float 
  -fno-asynchronous-unwind-tables -ffreestanding -fformat-extensions 
  -fdiagnostics-show-option -fstack-protector -Werror  
  /usr/git-freebsd-head/sys/kern/subr_msgbuf.c
  cc1: warnings being treated as errors
  /usr/git-freebsd-head/sys/kern/subr_msgbuf.c: In function 
  'msgbuf_do_addchar':
  /usr/git-freebsd-head/sys/kern/subr_msgbuf.c:171: warning: format '%d' 
  expects type 'int', but argument 4 has type 'time_t' [-Wformat]
  *** Error code 1
 
  Stop in /usr/obj/usr/git-freebsd-head/sys/ARUNDEL.
  *** Error code 1
 
  Stop in /usr/git-freebsd-head.
  *** Error code 1
 
  Stop in /usr/git-freebsd-head.
 
 FreeBSD has no time_t PRI... macros in any machine/_inttypes.h,
 eventually cast it to `long'.

 just wanted to tell you that your patch causes buildkernel to fail on certain
 archs (amd64 in my case) and that it appears you didn't run
 'make universe-kernels' to check, whether your patch breaks anything.

 i'll leave the details to you.
I have no interest testing architectures/kernels I have no interest
in. Of course, this statement only apply as long as I have no full
control over the future of the feature.

 - Arnaud
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: [RFC] Prepend timestamp in msgbuf

2011-10-17 Thread Arnaud Lacombe
Hi,

On Mon, Oct 17, 2011 at 3:38 PM, Garrett Cooper yaneg...@gmail.com wrote:
 On Mon, Oct 17, 2011 at 12:27 PM, Arnaud Lacombe lacom...@gmail.com wrote:
 Hi,

 On Mon, Oct 17, 2011 at 2:01 PM, Alexander Best arun...@freebsd.org wrote:
 On Fri Oct 14 11, Arnaud Lacombe wrote:
 [...]

 cc -c -O -pipe -march=core2 -std=c99 -g -Wall -Wredundant-decls 
 -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith 
 -Winline -Wcast-qual -Wundef -Wno-pointer-sign -Wmissing-include-dirs 
 -nostdinc  -I. -I/usr/git-freebsd-head/sys 
 -I/usr/git-freebsd-head/sys/contrib/altq -D_KERNEL 
 -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h -fno-common 
 -finline-limit=8000 --param inline-unit-growth=100 --param 
 large-function-growth=1000  -fno-omit-frame-pointer -mno-sse 
 -mcmodel=kernel -mno-red-zone -mno-mmx -msoft-float 
 -fno-asynchronous-unwind-tables -ffreestanding -fformat-extensions 
 -fdiagnostics-show-option -fstack-protector -Werror  
 /usr/git-freebsd-head/sys/kern/subr_msgbuf.c
 cc1: warnings being treated as errors
 /usr/git-freebsd-head/sys/kern/subr_msgbuf.c: In function 
 'msgbuf_do_addchar':
 /usr/git-freebsd-head/sys/kern/subr_msgbuf.c:171: warning: format '%d' 
 expects type 'int', but argument 4 has type 'time_t' [-Wformat]
 *** Error code 1

 Stop in /usr/obj/usr/git-freebsd-head/sys/ARUNDEL.
 *** Error code 1

 Stop in /usr/git-freebsd-head.
 *** Error code 1

 Stop in /usr/git-freebsd-head.

 FreeBSD has no time_t PRI... macros in any machine/_inttypes.h,
 eventually cast it to `long'.

 Btw, I appreciate the very clear message of yours, no Hi, no
 signature, no idea what ARUNDEL is, and especially no details on
 which architecture you are attempting to build, which should be, I
 assume, LP64 ;-)

    time_t maps to int32_t on i386 and int64_t on amd64 (at least), so
 you should be able to use %zd in the format string as the type is
 variable width depending on the architecture.

make sense.

Thanks,
 - Arnaud
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: [RFC] Prepend timestamp in msgbuf

2011-10-17 Thread Alexander Best
On Mon Oct 17 11, Arnaud Lacombe wrote:
 Hi,
 
 On Mon, Oct 17, 2011 at 3:44 PM, Alexander Best arun...@freebsd.org wrote:
  On Mon Oct 17 11, Arnaud Lacombe wrote:
  Hi,
 
  On Mon, Oct 17, 2011 at 2:01 PM, Alexander Best arun...@freebsd.org 
  wrote:
   On Fri Oct 14 11, Arnaud Lacombe wrote:
   Hi,
  
   On Fri, Oct 14, 2011 at 8:52 AM, Nali Toja nalit...@gmail.com wrote:
Alexander Best arun...@freebsd.org writes:
   
On Fri Oct 14 11, Poul-Henning Kamp wrote:
 In message 20111014085609.ga3...@freebsd.org, Alexander Best 
 writes:

 1) would it be possible to prepend those timestamps to the 
 actual console
 output and not only to the output of demsg? maybe via a sysctl 
 toggle?

 The kernel does not know enough about timezones to emit anything
 but UTC timestamps.
   
hmm ok.
   

 2) my dmesg output contains a lot of these entries: 118

 These are magic markers for syslogd(8) specifying priority.
   
it would be nice, if their output could be turned off via a dmesg 
flag imo.
   

 3) roughly the first 30 lines of my dmesg output have the 
 timestamp [1.0].
 would it be possible to have more accuracy there?

 No, because we don't know the time until we've found the RTC chip.
   
maybe prepending the output with [??] instead of [1.0] would make 
more sense,
so users knows that those timestamps are bogus.
   
maybe the granularity of the timestamps could be limited to a static 
value? the
following output doesn't really look pretty:
   
[7.729516] 118/dev/ufs/varfs: clean, 879143 free (7407 frags, 
108967 blocks, 0.7% fragmentation)
[7.891512] 118Mounting local file systems:WARNING: TMPFS is 
considered to be a highly experimental feature in FreeBSD.
[8.33519] .
[9.440514] 118Setting hostname: otaku.
[9.744516] wlan0: Ethernet address: 00:0f:b5:82:07:c8
[9.850516] 118Starting wpa_supplicant.
[10.335514] 118Starting Network: lo0 ath0.
   
so it would be nice, if trailing zeros got printed out, too.
   
Why not make formatting similar to linux/xorg logs, e.g.
   
 [    31.897] (**) Option XkbLayout us
 [    31.897] (II) XINPUT: Adding extended input device default 
keyboard (type: KEYBOARD, id 7)
 [ 11485.404] (II) 3rd Button detected: disabling emulate3Button
   
 [    0.00] Linux version 3.0-ARCH (tobias@T-POWA-LX) (gcc 
version 4.6.1 20110819 (prerelease) (GCC) ) #1 SMP PREEMPT Tue Aug 30 
08:53:25 CEST 2011
 [    0.00] Command line: 
root=/dev/disk/by-uuid/625db1f5-9b51-4d2d-acb7-6726f4d7e199 ro
 [...]
 [   15.096862] NET: Registered protocol family 10
 [   16.792594] [drm] nouveau :01:00.0: plugged DVI-I-2
 [   26.054186] eth0: no IPv6 routers present
   
A way to convert those timestamps to localtime or time delta[1] 
post-mortem
via dmesg(8) would be good, too.
   
   well, I do not care for the pretty side of the thing, however, this
   is just a matter length modifier in the string format; should be
   trivial to fix.
  
   cc -c -O -pipe -march=core2 -std=c99 -g -Wall -Wredundant-decls 
   -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes 
   -Wpointer-arith -Winline -Wcast-qual -Wundef -Wno-pointer-sign 
   -Wmissing-include-dirs -nostdinc  -I. -I/usr/git-freebsd-head/sys 
   -I/usr/git-freebsd-head/sys/contrib/altq -D_KERNEL 
   -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h -fno-common 
   -finline-limit=8000 --param inline-unit-growth=100 --param 
   large-function-growth=1000  -fno-omit-frame-pointer -mno-sse 
   -mcmodel=kernel -mno-red-zone -mno-mmx -msoft-float 
   -fno-asynchronous-unwind-tables -ffreestanding -fformat-extensions 
   -fdiagnostics-show-option -fstack-protector -Werror  
   /usr/git-freebsd-head/sys/kern/subr_msgbuf.c
   cc1: warnings being treated as errors
   /usr/git-freebsd-head/sys/kern/subr_msgbuf.c: In function 
   'msgbuf_do_addchar':
   /usr/git-freebsd-head/sys/kern/subr_msgbuf.c:171: warning: format '%d' 
   expects type 'int', but argument 4 has type 'time_t' [-Wformat]
   *** Error code 1
  
   Stop in /usr/obj/usr/git-freebsd-head/sys/ARUNDEL.
   *** Error code 1
  
   Stop in /usr/git-freebsd-head.
   *** Error code 1
  
   Stop in /usr/git-freebsd-head.
  
  FreeBSD has no time_t PRI... macros in any machine/_inttypes.h,
  eventually cast it to `long'.
 
  just wanted to tell you that your patch causes buildkernel to fail on 
  certain
  archs (amd64 in my case) and that it appears you didn't run
  'make universe-kernels' to check, whether your patch breaks anything.
 
  i'll leave the details to you.
 I have no interest testing architectures/kernels I have no interest
 in. Of course, this statement only apply as long as I have no full
 control over the future of the feature.

sorry i was under the impression that this feature was a candidate to make it
into HEAD.

 
  - Arnaud

Re: [RFC] Prepend timestamp in msgbuf

2011-10-17 Thread Ed Schouten
* Garrett Cooper yaneg...@gmail.com, 20111017 21:38:
 time_t maps to int32_t on i386 and int64_t on amd64 (at least), so
 you should be able to use %zd in the format string as the type is
 variable width depending on the architecture.

Yuck. Why not cast it to intmax_t and print it using %jd?

-- 
 Ed Schouten e...@80386.nl
 WWW: http://80386.nl/


pgpgMKrnZfrX8.pgp
Description: PGP signature


Re: [RFC] Prepend timestamp in msgbuf

2011-10-14 Thread Nikolay Denev

On Oct 13, 2011, at 9:40 PM, Arnaud Lacombe wrote:

 Hi,
 
 On Thu, Oct 13, 2011 at 2:00 PM,  lacom...@gmail.com wrote:
 From: Arnaud Lacombe lacom...@gmail.com
 
 Hi folks,
 
 There is many case recently when I really wished timestamp were present in 
 the
 post-mortem msgbuf. Such situation could be when userland application 
 segfault
 potentially triggering a panic/crash, or have information about the time-wise
 location of a given message (kernel or userland).
 
 Attached patch is available in the git repository at:
  git://github.com/lacombar/freebsd.git master/topic/msgbuf-timestamp
 
 Arnaud Lacombe (3):
  msgbuf(4): convert `msg_needsnl' to a bit flag
  msgbuf(4): add logic to prepend timestamp on new line
  msgbuf(4): add a sysctl to toggle timestamp prepend
 
  sys/kern/subr_msgbuf.c |   53 
 ---
  sys/sys/msgbuf.h   |4 ++-
  2 files changed, 48 insertions(+), 9 deletions(-)
 

Cool!

I've dreamt for something like this for a long time, it can be very useful.

Regards,
Nikolay

___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: [RFC] Prepend timestamp in msgbuf

2011-10-14 Thread Alexander Best
On Fri Oct 14 11, Nikolay Denev wrote:
 
 On Oct 13, 2011, at 9:40 PM, Arnaud Lacombe wrote:
 
  Hi,
  
  On Thu, Oct 13, 2011 at 2:00 PM,  lacom...@gmail.com wrote:
  From: Arnaud Lacombe lacom...@gmail.com
  
  Hi folks,
  
  There is many case recently when I really wished timestamp were present in 
  the
  post-mortem msgbuf. Such situation could be when userland application 
  segfault
  potentially triggering a panic/crash, or have information about the 
  time-wise
  location of a given message (kernel or userland).
  
  Attached patch is available in the git repository at:
   git://github.com/lacombar/freebsd.git master/topic/msgbuf-timestamp
  
  Arnaud Lacombe (3):
   msgbuf(4): convert `msg_needsnl' to a bit flag
   msgbuf(4): add logic to prepend timestamp on new line
   msgbuf(4): add a sysctl to toggle timestamp prepend
  
   sys/kern/subr_msgbuf.c |   53 
  ---
   sys/sys/msgbuf.h   |4 ++-
   2 files changed, 48 insertions(+), 9 deletions(-)
  
 
 Cool!
 
 I've dreamt for something like this for a long time, it can be very useful.

great work! a have a few comments however:

1) would it be possible to prepend those timestamps to the actual console
output and not only to the output of demsg? maybe via a sysctl toggle?

2) my dmesg output contains a lot of these entries: 118

3) roughly the first 30 lines of my dmesg output have the timestamp [1.0].
would it be possible to have more accuracy there?

4) maybe a new dmesg flag would be a good idea to suppress timestamps.

cheers.
alex

 
 Regards,
 Nikolay
 
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: [RFC] Prepend timestamp in msgbuf

2011-10-14 Thread Poul-Henning Kamp
In message 20111014085609.ga3...@freebsd.org, Alexander Best writes:

1) would it be possible to prepend those timestamps to the actual console
output and not only to the output of demsg? maybe via a sysctl toggle?

The kernel does not know enough about timezones to emit anything
but UTC timestamps.

2) my dmesg output contains a lot of these entries: 118

These are magic markers for syslogd(8) specifying priority.

3) roughly the first 30 lines of my dmesg output have the timestamp [1.0].
would it be possible to have more accuracy there?

No, because we don't know the time until we've found the RTC chip.

-- 
Poul-Henning Kamp   | UNIX since Zilog Zeus 3.20
p...@freebsd.org | TCP/IP since RFC 956
FreeBSD committer   | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: [RFC] Prepend timestamp in msgbuf

2011-10-14 Thread Alexander Best
On Fri Oct 14 11, Poul-Henning Kamp wrote:
 In message 20111014085609.ga3...@freebsd.org, Alexander Best writes:
 
 1) would it be possible to prepend those timestamps to the actual console
 output and not only to the output of demsg? maybe via a sysctl toggle?
 
 The kernel does not know enough about timezones to emit anything
 but UTC timestamps.

hmm ok.

 
 2) my dmesg output contains a lot of these entries: 118
 
 These are magic markers for syslogd(8) specifying priority.

it would be nice, if their output could be turned off via a dmesg flag imo.

 
 3) roughly the first 30 lines of my dmesg output have the timestamp [1.0].
 would it be possible to have more accuracy there?
 
 No, because we don't know the time until we've found the RTC chip.

maybe prepending the output with [??] instead of [1.0] would make more sense,
so users knows that those timestamps are bogus.

cheers.
alex

 
 -- 
 Poul-Henning Kamp   | UNIX since Zilog Zeus 3.20
 p...@freebsd.org | TCP/IP since RFC 956
 FreeBSD committer   | BSD since 4.3-tahoe
 Never attribute to malice what can adequately be explained by incompetence.
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: [RFC] Prepend timestamp in msgbuf

2011-10-14 Thread Alexander Best
On Fri Oct 14 11, Alexander Best wrote:
 On Fri Oct 14 11, Poul-Henning Kamp wrote:
  In message 20111014085609.ga3...@freebsd.org, Alexander Best writes:
  
  1) would it be possible to prepend those timestamps to the actual console
  output and not only to the output of demsg? maybe via a sysctl toggle?
  
  The kernel does not know enough about timezones to emit anything
  but UTC timestamps.
 
 hmm ok.
 
  
  2) my dmesg output contains a lot of these entries: 118
  
  These are magic markers for syslogd(8) specifying priority.
 
 it would be nice, if their output could be turned off via a dmesg flag imo.
 
  
  3) roughly the first 30 lines of my dmesg output have the timestamp 
  [1.0].
  would it be possible to have more accuracy there?
  
  No, because we don't know the time until we've found the RTC chip.
 
 maybe prepending the output with [??] instead of [1.0] would make more sense,
 so users knows that those timestamps are bogus.

maybe the granularity of the timestamps could be limited to a static value? the
following output doesn't really look pretty:

[7.729516] 118/dev/ufs/varfs: clean, 879143 free (7407 frags, 108967 blocks, 
0.7% fragmentation)
[7.891512] 118Mounting local file systems:WARNING: TMPFS is considered to be 
a highly experimental feature in FreeBSD.
[8.33519] .
[9.440514] 118Setting hostname: otaku.
[9.744516] wlan0: Ethernet address: 00:0f:b5:82:07:c8
[9.850516] 118Starting wpa_supplicant.
[10.335514] 118Starting Network: lo0 ath0.

so it would be nice, if trailing zeros got printed out, too.

cheers.
alex

 
 cheers.
 alex
 
  
  -- 
  Poul-Henning Kamp   | UNIX since Zilog Zeus 3.20
  p...@freebsd.org | TCP/IP since RFC 956
  FreeBSD committer   | BSD since 4.3-tahoe
  Never attribute to malice what can adequately be explained by incompetence.
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: [RFC] Prepend timestamp in msgbuf

2011-10-14 Thread Alexander Best
On Fri Oct 14 11, Alexander Best wrote:
 On Fri Oct 14 11, Poul-Henning Kamp wrote:
  In message 20111014085609.ga3...@freebsd.org, Alexander Best writes:
  
  1) would it be possible to prepend those timestamps to the actual console
  output and not only to the output of demsg? maybe via a sysctl toggle?
  
  The kernel does not know enough about timezones to emit anything
  but UTC timestamps.
 
 hmm ok.
 
  
  2) my dmesg output contains a lot of these entries: 118
  
  These are magic markers for syslogd(8) specifying priority.
 
 it would be nice, if their output could be turned off via a dmesg flag imo.
 
  
  3) roughly the first 30 lines of my dmesg output have the timestamp 
  [1.0].
  would it be possible to have more accuracy there?
  
  No, because we don't know the time until we've found the RTC chip.
 
 maybe prepending the output with [??] instead of [1.0] would make more sense,
 so users knows that those timestamps are bogus.

or even better: if timestamp == 1.0 then simply don't ouput it at all.

 
 cheers.
 alex
 
  
  -- 
  Poul-Henning Kamp   | UNIX since Zilog Zeus 3.20
  p...@freebsd.org | TCP/IP since RFC 956
  FreeBSD committer   | BSD since 4.3-tahoe
  Never attribute to malice what can adequately be explained by incompetence.
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: [RFC] Prepend timestamp in msgbuf

2011-10-14 Thread Nali Toja
Alexander Best arun...@freebsd.org writes:

 On Fri Oct 14 11, Poul-Henning Kamp wrote:
  In message 20111014085609.ga3...@freebsd.org, Alexander Best writes:
  
  1) would it be possible to prepend those timestamps to the actual console
  output and not only to the output of demsg? maybe via a sysctl toggle?
  
  The kernel does not know enough about timezones to emit anything
  but UTC timestamps.
 
 hmm ok.
 
  
  2) my dmesg output contains a lot of these entries: 118
  
  These are magic markers for syslogd(8) specifying priority.
 
 it would be nice, if their output could be turned off via a dmesg flag imo.
 
  
  3) roughly the first 30 lines of my dmesg output have the timestamp 
  [1.0].
  would it be possible to have more accuracy there?
  
  No, because we don't know the time until we've found the RTC chip.
 
 maybe prepending the output with [??] instead of [1.0] would make more sense,
 so users knows that those timestamps are bogus.

 maybe the granularity of the timestamps could be limited to a static value? 
 the
 following output doesn't really look pretty:

 [7.729516] 118/dev/ufs/varfs: clean, 879143 free (7407 frags, 108967 
 blocks, 0.7% fragmentation)
 [7.891512] 118Mounting local file systems:WARNING: TMPFS is considered to 
 be a highly experimental feature in FreeBSD.
 [8.33519] .
 [9.440514] 118Setting hostname: otaku.
 [9.744516] wlan0: Ethernet address: 00:0f:b5:82:07:c8
 [9.850516] 118Starting wpa_supplicant.
 [10.335514] 118Starting Network: lo0 ath0.

 so it would be nice, if trailing zeros got printed out, too.

Why not make formatting similar to linux/xorg logs, e.g.

  [31.897] (**) Option XkbLayout us
  [31.897] (II) XINPUT: Adding extended input device default keyboard 
(type: KEYBOARD, id 7)
  [ 11485.404] (II) 3rd Button detected: disabling emulate3Button

  [0.00] Linux version 3.0-ARCH (tobias@T-POWA-LX) (gcc version 4.6.1 
20110819 (prerelease) (GCC) ) #1 SMP PREEMPT Tue Aug 30 08:53:25 CEST 2011
  [0.00] Command line: 
root=/dev/disk/by-uuid/625db1f5-9b51-4d2d-acb7-6726f4d7e199 ro
  [...]
  [   15.096862] NET: Registered protocol family 10
  [   16.792594] [drm] nouveau :01:00.0: plugged DVI-I-2
  [   26.054186] eth0: no IPv6 routers present

A way to convert those timestamps to localtime or time delta[1] post-mortem
via dmesg(8) would be good, too.

[1] like in tcpdump -ttt
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: [RFC] Prepend timestamp in msgbuf

2011-10-14 Thread Arnaud Lacombe
Hi,

On Fri, Oct 14, 2011 at 8:52 AM, Nali Toja nalit...@gmail.com wrote:
 Alexander Best arun...@freebsd.org writes:

 On Fri Oct 14 11, Poul-Henning Kamp wrote:
  In message 20111014085609.ga3...@freebsd.org, Alexander Best writes:
 
  1) would it be possible to prepend those timestamps to the actual console
  output and not only to the output of demsg? maybe via a sysctl toggle?
 
  The kernel does not know enough about timezones to emit anything
  but UTC timestamps.

 hmm ok.

 
  2) my dmesg output contains a lot of these entries: 118
 
  These are magic markers for syslogd(8) specifying priority.

 it would be nice, if their output could be turned off via a dmesg flag imo.

 
  3) roughly the first 30 lines of my dmesg output have the timestamp 
  [1.0].
  would it be possible to have more accuracy there?
 
  No, because we don't know the time until we've found the RTC chip.

 maybe prepending the output with [??] instead of [1.0] would make more 
 sense,
 so users knows that those timestamps are bogus.

 maybe the granularity of the timestamps could be limited to a static value? 
 the
 following output doesn't really look pretty:

 [7.729516] 118/dev/ufs/varfs: clean, 879143 free (7407 frags, 108967 
 blocks, 0.7% fragmentation)
 [7.891512] 118Mounting local file systems:WARNING: TMPFS is considered to 
 be a highly experimental feature in FreeBSD.
 [8.33519] .
 [9.440514] 118Setting hostname: otaku.
 [9.744516] wlan0: Ethernet address: 00:0f:b5:82:07:c8
 [9.850516] 118Starting wpa_supplicant.
 [10.335514] 118Starting Network: lo0 ath0.

 so it would be nice, if trailing zeros got printed out, too.

 Why not make formatting similar to linux/xorg logs, e.g.

  [    31.897] (**) Option XkbLayout us
  [    31.897] (II) XINPUT: Adding extended input device default keyboard 
 (type: KEYBOARD, id 7)
  [ 11485.404] (II) 3rd Button detected: disabling emulate3Button

  [    0.00] Linux version 3.0-ARCH (tobias@T-POWA-LX) (gcc version 4.6.1 
 20110819 (prerelease) (GCC) ) #1 SMP PREEMPT Tue Aug 30 08:53:25 CEST 2011
  [    0.00] Command line: 
 root=/dev/disk/by-uuid/625db1f5-9b51-4d2d-acb7-6726f4d7e199 ro
  [...]
  [   15.096862] NET: Registered protocol family 10
  [   16.792594] [drm] nouveau :01:00.0: plugged DVI-I-2
  [   26.054186] eth0: no IPv6 routers present

 A way to convert those timestamps to localtime or time delta[1] post-mortem
 via dmesg(8) would be good, too.

well, I do not care for the pretty side of the thing, however, this
is just a matter length modifier in the string format; should be
trivial to fix.

 - Arnaud

 [1] like in tcpdump -ttt

___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


[RFC] Prepend timestamp in msgbuf

2011-10-13 Thread lacombar
From: Arnaud Lacombe lacom...@gmail.com

Hi folks,

There is many case recently when I really wished timestamp were present in the
post-mortem msgbuf. Such situation could be when userland application segfault
potentially triggering a panic/crash, or have information about the time-wise
location of a given message (kernel or userland).

Attached patch is available in the git repository at:
  git://github.com/lacombar/freebsd.git master/topic/msgbuf-timestamp

Arnaud Lacombe (3):
  msgbuf(4): convert `msg_needsnl' to a bit flag
  msgbuf(4): add logic to prepend timestamp on new line
  msgbuf(4): add a sysctl to toggle timestamp prepend

 sys/kern/subr_msgbuf.c |   53 ---
 sys/sys/msgbuf.h   |4 ++-
 2 files changed, 48 insertions(+), 9 deletions(-)

diff --git a/sys/kern/subr_msgbuf.c b/sys/kern/subr_msgbuf.c
index cd9c551..b2f0e1a 100644
--- a/sys/kern/subr_msgbuf.c
+++ b/sys/kern/subr_msgbuf.c
@@ -34,6 +34,7 @@
 #include sys/lock.h
 #include sys/mutex.h
 #include sys/msgbuf.h
+#include sys/sysctl.h
 
 /*
  * Maximum number conversion buffer length: uintmax_t in base 2, plus 
@@ -47,6 +48,13 @@
 static u_int msgbuf_cksum(struct msgbuf *mbp);
 
 /*
+ *
+ */
+static int msgbuf_show_timestamp = 1;
+SYSCTL_INT(_kern, OID_AUTO, msgbuf_show_timestamp, CTLFLAG_RW,
+msgbuf_show_timestamp, 0, Show timestamp in msgbuf);
+
+/*
  * Initialize a message buffer of the specified size at the specified
  * location. This also zeros the buffer area.
  */
@@ -60,7 +68,7 @@ msgbuf_init(struct msgbuf *mbp, void *ptr, int size)
msgbuf_clear(mbp);
mbp-msg_magic = MSG_MAGIC;
mbp-msg_lastpri = -1;
-   mbp-msg_needsnl = 0;
+   mbp-msg_flags = 0;
bzero(mbp-msg_lock, sizeof(mbp-msg_lock));
mtx_init(mbp-msg_lock, msgbuf, NULL, MTX_SPIN);
 }
@@ -95,7 +103,7 @@ msgbuf_reinit(struct msgbuf *mbp, void *ptr, int size)
 
mbp-msg_lastpri = -1;
/* Assume that the old message buffer didn't end in a newline. */
-   mbp-msg_needsnl = 1;
+   mbp-msg_flags |= MSGBUF_NEEDNL;
bzero(mbp-msg_lock, sizeof(mbp-msg_lock));
mtx_init(mbp-msg_lock, msgbuf, NULL, MTX_SPIN);
 }
@@ -134,7 +142,7 @@ msgbuf_getcount(struct msgbuf *mbp)
  * The caller should hold the message buffer spinlock.
  */
 static inline void
-msgbuf_do_addchar(struct msgbuf *mbp, u_int *seq, int c)
+__msgbuf_do_addchar(struct msgbuf *mbp, u_int *seq, int c)
 {
u_int pos;
 
@@ -149,6 +157,34 @@ msgbuf_do_addchar(struct msgbuf *mbp, u_int *seq, int c)
*seq = MSGBUF_SEQNORM(mbp, *seq + 1);
 }
 
+static inline void
+msgbuf_do_addchar(struct msgbuf *mbp, u_int *seq, int c)
+{
+
+   if (msgbuf_show_timestamp  mbp-msg_flags  MSGBUF_NEXT_NEW_LINE) {
+   char buf[32], *bufp;
+   struct timespec ts;
+   int err;
+
+   buf[0] = '\0';
+   getnanouptime(ts);
+   err = snprintf(buf, sizeof buf, [%d.%ld] , ts.tv_sec, 
ts.tv_nsec / 1000);
+
+   bufp = buf;
+   while (*bufp != '\0') {
+   __msgbuf_do_addchar(mbp, seq, *bufp);
+   bufp++;
+   }
+
+   mbp-msg_flags = ~MSGBUF_NEXT_NEW_LINE;
+   }
+
+   __msgbuf_do_addchar(mbp, seq, c);
+
+   if (c == '\n')
+   mbp-msg_flags |= MSGBUF_NEXT_NEW_LINE;
+}
+
 /*
  * Append a character to a message buffer.
  */
@@ -207,10 +243,10 @@ msgbuf_addstr(struct msgbuf *mbp, int pri, char *str, int 
filter_cr)
 * did not end with a newline.  If that is the case, we need to
 * insert a newline before this string.
 */
-   if (mbp-msg_lastpri != pri  mbp-msg_needsnl != 0) {
+   if (mbp-msg_lastpri != pri  (mbp-msg_flags  MSGBUF_NEEDNL) != 0) {
 
msgbuf_do_addchar(mbp, seq, '\n');
-   mbp-msg_needsnl = 0;
+   mbp-msg_flags = ~MSGBUF_NEEDNL;
}
 
for (i = 0; i  len; i++) {
@@ -219,7 +255,7 @@ msgbuf_addstr(struct msgbuf *mbp, int pri, char *str, int 
filter_cr)
 * (and therefore prefix_len != 0), then we need a priority
 * prefix for this line.
 */
-   if (mbp-msg_needsnl == 0  prefix_len != 0) {
+   if ((mbp-msg_flags  MSGBUF_NEEDNL) == 0  prefix_len != 0) {
int j;
 
for (j = 0; j  prefix_len; j++)
@@ -242,9 +278,9 @@ msgbuf_addstr(struct msgbuf *mbp, int pri, char *str, int 
filter_cr)
 * we need to insert a new prefix or insert a newline later.
 */
if (str[i] == '\n')
-   mbp-msg_needsnl = 0;
+   mbp-msg_flags = ~MSGBUF_NEEDNL;
else
-   mbp-msg_needsnl = 1;
+   mbp-msg_flags |= MSGBUF_NEEDNL;
 
msgbuf_do_addchar(mbp, seq, str[i]);
}
@@ -395,3 +431,4 @@ 

Re: [RFC] Prepend timestamp in msgbuf

2011-10-13 Thread Arnaud Lacombe
Hi,

On Thu, Oct 13, 2011 at 2:00 PM,  lacom...@gmail.com wrote:
 From: Arnaud Lacombe lacom...@gmail.com

 Hi folks,

 There is many case recently when I really wished timestamp were present in the
 post-mortem msgbuf. Such situation could be when userland application segfault
 potentially triggering a panic/crash, or have information about the time-wise
 location of a given message (kernel or userland).

 Attached patch is available in the git repository at:
  git://github.com/lacombar/freebsd.git master/topic/msgbuf-timestamp

 Arnaud Lacombe (3):
      msgbuf(4): convert `msg_needsnl' to a bit flag
      msgbuf(4): add logic to prepend timestamp on new line
      msgbuf(4): add a sysctl to toggle timestamp prepend

  sys/kern/subr_msgbuf.c |   53 ---
  sys/sys/msgbuf.h       |    4 ++-
  2 files changed, 48 insertions(+), 9 deletions(-)

also tracked as:

http://www.freebsd.org/cgi/query-pr.cgi?pr=161553

 - Arnaud

 diff --git a/sys/kern/subr_msgbuf.c b/sys/kern/subr_msgbuf.c
 index cd9c551..b2f0e1a 100644
 --- a/sys/kern/subr_msgbuf.c
 +++ b/sys/kern/subr_msgbuf.c
 @@ -34,6 +34,7 @@
  #include sys/lock.h
  #include sys/mutex.h
  #include sys/msgbuf.h
 +#include sys/sysctl.h

  /*
  * Maximum number conversion buffer length: uintmax_t in base 2, plus 
 @@ -47,6 +48,13 @@
  static u_int msgbuf_cksum(struct msgbuf *mbp);

  /*
 + *
 + */
 +static int msgbuf_show_timestamp = 1;
 +SYSCTL_INT(_kern, OID_AUTO, msgbuf_show_timestamp, CTLFLAG_RW,
 +    msgbuf_show_timestamp, 0, Show timestamp in msgbuf);
 +
 +/*
  * Initialize a message buffer of the specified size at the specified
  * location. This also zeros the buffer area.
  */
 @@ -60,7 +68,7 @@ msgbuf_init(struct msgbuf *mbp, void *ptr, int size)
        msgbuf_clear(mbp);
        mbp-msg_magic = MSG_MAGIC;
        mbp-msg_lastpri = -1;
 -       mbp-msg_needsnl = 0;
 +       mbp-msg_flags = 0;
        bzero(mbp-msg_lock, sizeof(mbp-msg_lock));
        mtx_init(mbp-msg_lock, msgbuf, NULL, MTX_SPIN);
  }
 @@ -95,7 +103,7 @@ msgbuf_reinit(struct msgbuf *mbp, void *ptr, int size)

        mbp-msg_lastpri = -1;
        /* Assume that the old message buffer didn't end in a newline. */
 -       mbp-msg_needsnl = 1;
 +       mbp-msg_flags |= MSGBUF_NEEDNL;
        bzero(mbp-msg_lock, sizeof(mbp-msg_lock));
        mtx_init(mbp-msg_lock, msgbuf, NULL, MTX_SPIN);
  }
 @@ -134,7 +142,7 @@ msgbuf_getcount(struct msgbuf *mbp)
  * The caller should hold the message buffer spinlock.
  */
  static inline void
 -msgbuf_do_addchar(struct msgbuf *mbp, u_int *seq, int c)
 +__msgbuf_do_addchar(struct msgbuf *mbp, u_int *seq, int c)
  {
        u_int pos;

 @@ -149,6 +157,34 @@ msgbuf_do_addchar(struct msgbuf *mbp, u_int *seq, int c)
        *seq = MSGBUF_SEQNORM(mbp, *seq + 1);
  }

 +static inline void
 +msgbuf_do_addchar(struct msgbuf *mbp, u_int *seq, int c)
 +{
 +
 +       if (msgbuf_show_timestamp  mbp-msg_flags  MSGBUF_NEXT_NEW_LINE) {
 +               char buf[32], *bufp;
 +               struct timespec ts;
 +               int err;
 +
 +               buf[0] = '\0';
 +               getnanouptime(ts);
 +               err = snprintf(buf, sizeof buf, [%d.%ld] , ts.tv_sec, 
 ts.tv_nsec / 1000);
 +
 +               bufp = buf;
 +               while (*bufp != '\0') {
 +                       __msgbuf_do_addchar(mbp, seq, *bufp);
 +                       bufp++;
 +               }
 +
 +               mbp-msg_flags = ~MSGBUF_NEXT_NEW_LINE;
 +       }
 +
 +       __msgbuf_do_addchar(mbp, seq, c);
 +
 +       if (c == '\n')
 +               mbp-msg_flags |= MSGBUF_NEXT_NEW_LINE;
 +}
 +
  /*
  * Append a character to a message buffer.
  */
 @@ -207,10 +243,10 @@ msgbuf_addstr(struct msgbuf *mbp, int pri, char *str, 
 int filter_cr)
         * did not end with a newline.  If that is the case, we need to
         * insert a newline before this string.
         */
 -       if (mbp-msg_lastpri != pri  mbp-msg_needsnl != 0) {
 +       if (mbp-msg_lastpri != pri  (mbp-msg_flags  MSGBUF_NEEDNL) != 0) 
 {

                msgbuf_do_addchar(mbp, seq, '\n');
 -               mbp-msg_needsnl = 0;
 +               mbp-msg_flags = ~MSGBUF_NEEDNL;
        }

        for (i = 0; i  len; i++) {
 @@ -219,7 +255,7 @@ msgbuf_addstr(struct msgbuf *mbp, int pri, char *str, int 
 filter_cr)
                 * (and therefore prefix_len != 0), then we need a priority
                 * prefix for this line.
                 */
 -               if (mbp-msg_needsnl == 0  prefix_len != 0) {
 +               if ((mbp-msg_flags  MSGBUF_NEEDNL) == 0  prefix_len != 0) 
 {
                        int j;

                        for (j = 0; j  prefix_len; j++)
 @@ -242,9 +278,9 @@ msgbuf_addstr(struct msgbuf *mbp, int pri, char *str, int 
 filter_cr)
                 * we need to insert a new prefix or insert a newline later.
                 */
                if (str[i] == '\n')
 -                       mbp-msg_needsnl = 0;
 +                       

Re: [RFC] Prepend timestamp in msgbuf

2011-10-13 Thread Adrian Chadd
On 14 October 2011 02:40, Arnaud Lacombe lacom...@gmail.com wrote:
 Hi,

 On Thu, Oct 13, 2011 at 2:00 PM,  lacom...@gmail.com wrote:
 From: Arnaud Lacombe lacom...@gmail.com

 Hi folks,

 There is many case recently when I really wished timestamp were present in 
 the
 post-mortem msgbuf. Such situation could be when userland application 
 segfault
 potentially triggering a panic/crash, or have information about the time-wise
 location of a given message (kernel or userland).


Nice! Once the -head dust settles and 9.0-rel makes it out the door,
I'd like to see this make an appearance.



Adrian
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org