Page MenuHomeFreeBSD

Expand sbufs to be able to output directly to the log+console interface
ClosedPublic

Authored by scottl on Feb 14 2017, 10:45 PM.
Tags
None
Referenced Files
Unknown Object (File)
Jun 27 2025, 1:28 PM
Unknown Object (File)
Jun 25 2025, 7:41 AM
Unknown Object (File)
Jun 22 2025, 1:21 AM
Unknown Object (File)
Jun 21 2025, 8:48 AM
Unknown Object (File)
Jun 17 2025, 10:47 AM
Unknown Object (File)
Jun 17 2025, 6:19 AM
Unknown Object (File)
Jun 16 2025, 3:04 PM
Unknown Object (File)
Jun 6 2025, 4:04 PM
Subscribers

Details

Reviewers
ken
imp
Group Reviewers
manpages
Summary

Refactor putbuf() so that it can be used as a generic output sink. Add
sbuf_putbuf() to utilize this. This allows buffers to be written
atomically without bouncing through the buffer length limitations of
printf() and PRINTF_BUFR_SIZE.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 7782
Build 7929: arc lint + arc unit

Event Timeline

scottl retitled this revision from to Expand sbufs to be able to output directly to the log+console interface.
scottl updated this object.
scottl edited the test plan for this revision. (Show Details)
scottl added reviewers: ken, imp.
imp edited edge metadata.

Looks reasonable, assuming the code cut and paste into prf_putbuf was correct to start with.

This revision is now accepted and ready to land.Feb 16 2017, 7:32 AM
ken edited edge metadata.

I think this looks good, but we should also look at what it would take to put a drain mode in as well.

scottl edited edge metadata.

Update patch to provide a kernel version and userland version
of sbuf_putbuf()

This revision now requires review to proceed.Feb 27 2017, 10:23 PM

Need input on naming. sbuf_putbuf() was named since it wraps putbuf(). Is this the best name, though? Also, should it be kernel only, and the userland be something else that suggests printing to stdout vs stderr vs some other file descriptor?

imp edited edge metadata.

I can't think of a better name....

This revision is now accepted and ready to land.Feb 27 2017, 11:22 PM
In D9601#202724, @imp wrote:

I can't think of a better name....

dj_mc_sbuf_putbuff_iii_this_time_its_personal_esq is the obvious choice.

Please remember to bump .Dd, and credit me in the comments for the name.

Committed

commit 388f3ce6c3fb0c2eeeeebe1e0af6d72f840de7fc
Author: Scott Long <scottl@FreeBSD.org>
Date:   Tue Feb 28 18:25:06 2017 +0000

  Implement sbuf_prf(), which takes an sbuf and outputs it
  to stdout in the non-kernel case and to the console+log
  in the kernel case.  For the kernel case it hooks the
  putbuf() machinery underneath printf(9) so that the buffer
  is written completely atomically and without a copy into
  another temporary buffer.  This is useful for fixing
  compound console/log messages that become broken and
  interleaved when multiple threads are competing for the
  console.

  Reviewed by:    ken, imp
  Sponsored by:   Netflix

Notes:
  svn path=/head/; revision=314397