Home | History | Annotate | Download | only in kern
History log of /src/sys/kern/subr_log.c
RevisionDateAuthorComments
 1.66  09-Apr-2025  rin logread: Stop reading msgbuf without log_lock being held

Idea taken from FreeBSD.

XXX
The size of temporal buffer on stack (== 128) is also taken from FreeBSD.
We are not very sure whether this value is optimal or not. But we don't
expect performance regression from this choice.

No new regression for full ATF run on amd64 with DIAGNOSTIC+LOCKDEBUG
kernel and rump kernel.

Authored by knakahara@.
 1.65  08-Apr-2025  rin logread: Use ulmin(9) for long v.s. size_t comparison

instead of uimin(9).

No real harm is expected IIUC.
 1.64  08-Apr-2025  rin logread: Drop unnecessary (int) cast for uiomove(9)'s count

which was changed to size_t back to 2002!
https://cvsweb.netbsd.org/bsdweb.cgi/src/sys/sys/systm.h#rev1.149

No practical problem is expected although.
 1.63  26-Oct-2022  riastradh branches: 1.63.2; 1.63.8;
kern/subr_log.c: log_lock is private; make it static, not extern.
 1.62  26-Sep-2021  thorpej logread_filtops is MPSAFE.
 1.61  26-Sep-2021  thorpej Change the kqueue filterops::f_isfd field to filterops::f_flags, and
define a flag FILTEROP_ISFD that has the meaning of the prior f_isfd.
Field and flag name aligned with OpenBSD.

This does not constitute a functional or ABI change, as the field location
and size, and the value placed in that field, are the same as the previous
code, but we're bumping __NetBSD_Version__ so 3rd-party module source code
can adapt, as needed.

NetBSD 9.99.89
 1.60  11-Dec-2020  thorpej Use sel{record,remove}_knote().
 1.59  03-Sep-2018  riastradh branches: 1.59.4; 1.59.12;
Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.58  01-Apr-2018  christos branches: 1.58.2;
Move the add char portion to its own function.
 1.57  31-Mar-2018  christos factor out some repeated code and simplify the logputchar function.
 1.56  25-Oct-2017  maya branches: 1.56.2;
Use C99 initializer for filterops

Mostly done with spatch with touchups for indentation

@@
expression a;
identifier b,c,d;
identifier p;
@@
const struct filterops p =
- { a, b, c, d
+ {
+ .f_isfd = a,
+ .f_attach = b,
+ .f_detach = c,
+ .f_event = d,
};
 1.55  20-May-2015  pooka Don't log kern.msgbuf* sysctls. it's rather pointless, nobody can
unload subr_log.c
 1.54  20-May-2015  pooka group msgbuf sysctls with the msgbuf code
(init_sysctl.c -> subr_log.c)
 1.53  25-Jul-2014  dholland branches: 1.53.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.
 1.52  27-May-2014  msaitoh Move forward read pointer to the next line in the buffer
to prevent corrupting the most old line.
 1.51  16-Mar-2014  dholland branches: 1.51.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.
 1.50  28-Apr-2008  martin branches: 1.50.34; 1.50.44; 1.50.50;
Remove clause 3 and 4 from TNF licenses
 1.49  21-Mar-2008  ad branches: 1.49.2; 1.49.4;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
 1.48  01-Mar-2008  rmind Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>
 1.47  05-Jan-2008  ad branches: 1.47.2; 1.47.6;
Export log_lock.
 1.46  02-Jan-2008  ad Merge vmlocking2 to head.
 1.45  25-Dec-2007  ad Wups, the log softint can't be mpsafe yet.
 1.44  05-Dec-2007  pooka branches: 1.44.4;
Do not "return 1" from kqfilter for errors. That value is passed
directly to the userland caller and results in a mysterious EPERM.
Instead, return EINVAL or something else sensible depending on the
case.
 1.43  05-Dec-2007  ad Match the docs: MUTEX_DRIVER/SPIN are now only for porting code written
for Solaris.
 1.42  07-Nov-2007  ad branches: 1.42.2;
Merge from vmlocking.
 1.41  17-May-2007  yamt branches: 1.41.6; 1.41.8; 1.41.12; 1.41.14;
merge yamt-idlelwp branch. asked by core@. some ports still needs work.

from doc/BRANCHES:

idle lwp, and some changes depending on it.

1. separate context switching and thread scheduling.
(cf. gmcgarry_ctxsw)
2. implement idle lwp.
3. clean up related MD/MI interfaces.
4. make scheduler(s) modular.
 1.40  04-Mar-2007  christos branches: 1.40.2; 1.40.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.39  01-Nov-2006  yamt branches: 1.39.4;
remove some __unused from function parameters.
 1.38  12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.37  03-Sep-2006  christos branches: 1.37.2; 1.37.4;
add missing initializer
 1.36  11-Dec-2005  christos branches: 1.36.4; 1.36.8;
merge ktrace-lwp.
 1.35  23-Jun-2005  thorpej branches: 1.35.2;
Use ANSI function decls.
 1.34  29-May-2005  christos - add const.
- remove unnecessary casts.
- add __UNCONST casts and mark them with XXXUNCONST as necessary.
 1.33  22-Sep-2003  christos - pass signo to fownsignal [ok by jd]
- make urg signal handling use fownsignal
- remove out of band detection in sowakeup
 1.32  21-Sep-2003  jdolecek cleanup & uniform descriptor owner handling:
* introduce fsetown(), fgetown(), fownsignal() - this sets/retrieves/signals
the owner of descriptor, according to appropriate sematics
of TIOCSPGRP/FIOSETOWN/SIOCSPGRP/TIOCGPGRP/FIOGETOWN/SIOCGPGRP ioctl; use
these routines instead of custom code where appropriate
* make every place handling TIOCSPGRP/TIOCGPGRP handle also FIOSETOWN/FIOGETOWN
properly, and remove the translation of FIO[SG]OWN to TIOC[SG]PGRP
in sys_ioctl() & sys_fcntl()
* also remove the socket-specific hack in sys_ioctl()/sys_fcntl() and
pass the ioctls down to soo_ioctl() as any other ioctl

change discussed on tech-kern@
 1.31  07-Sep-2003  jdolecek one more sc_pgid change
 1.30  07-Sep-2003  jdolecek for logsoftc.sc_pgid, use negative value for process group and positive
for process ID, to match e.g. how socket code sets things up
 1.29  07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.28  29-Jun-2003  fvdl branches: 1.28.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.27  28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.26  13-Mar-2003  dsl Ensure that the pgid arg to TIOCSPGRP is in the current session.
Correctly treat a +ve value as a pgid and a -ve one as a pid.
 1.25  26-Nov-2002  christos si_ -> sel_ to avoid conflicts with siginfo.
 1.24  23-Oct-2002  jdolecek merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe
 1.23  06-Sep-2002  gehenna Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.
 1.22  28-Apr-2002  enami branches: 1.22.2;
Fix the return value of logioctl() for unhandled ioctl; return EPASSTHROUGH
instead of -1. Fix suggested by Andrew Brown.
 1.21  12-Nov-2001  lukem add RCSIDs
 1.20  28-May-2000  jhawk branches: 1.20.4; 1.20.6; 1.20.8; 1.20.10;
brain-oh in last. test logsoftc.sc_pgid, not p.
 1.19  28-May-2000  jhawk Ensure that all callers of pfind() can deal with pfind(0) returning
a real procp* rather than NULL.
 1.18  30-Mar-2000  augustss branches: 1.18.2;
Get rid of register declarations.
 1.17  18-Aug-1998  thorpej branches: 1.17.12;
Add some braces to make egcs happy (ambiguous else warning).
 1.16  04-Aug-1998  perry Abolition of bcopy, ovbcopy, bcmp, and bzero, phase one.
bcopy(x, y, z) -> memcpy(y, x, z)
ovbcopy(x, y, z) -> memmove(y, x, z)
bcmp(x, y, z) -> memcmp(x, y, z)
bzero(x, y) -> memset(x, 0, y)
 1.15  01-Mar-1998  fvdl Merge with Lite2 + local changes
 1.14  28-Jan-1998  thorpej Use offsetof() from libkern.h
 1.13  19-Sep-1997  leo Implement the kernel part of pr-1891. This allows for a more flexible sized
msgbuf. Note that old 'dmesg' and 'syslogd' binaries will continue running,
though old 'dmesg' binaries will output a few bytes of junk at the start of
the buffer, and will miss a few bytes at the end of the buffer.
 1.12  07-Sep-1996  mycroft branches: 1.12.10;
Implement poll(2).
 1.11  30-Mar-1996  christos Eliminate kern_conf.h
 1.10  09-Feb-1996  christos More proto fixes
 1.9  04-Feb-1996  christos First pass at prototyping
 1.8  30-Oct-1994  cgd be more careful with types, also pull in headers where necessary.
 1.7  29-Jun-1994  cgd New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'
 1.6  19-May-1994  cgd update to 4.4-Lite, with some local changes
 1.5  12-Apr-1994  deraadt FIONREAD returns int, not off_t
 1.4  18-Dec-1993  mycroft Canonicalize all #includes.
 1.3  27-Jun-1993  andrew branches: 1.3.4;
ANSIfications - removed all implicit function return types and argument
definitions. Ensured that all files include "systm.h" to gain access to
general prototypes. Casts where necessary.
 1.2  18-May-1993  cgd make kernel select interface be one-stop shopping & clean it all up.
 1.1  21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3  01-Mar-1998  fvdl Import 4.4BSD-Lite2
 1.1.1.2  01-Mar-1998  fvdl Import 4.4BSD-Lite for reference
 1.1.1.1  21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.3.4.2  14-Nov-1993  mycroft Canonicalize all #includes.
 1.3.4.1  24-Sep-1993  mycroft Make all files using spl*() #include cpu.h. Changes from trunk.
init_main.c: New method of pseudo-device of initialization.
kern_clock.c: hardclock() and softclock() now take a pointer to a clockframe.
softclock() only does callouts.
kern_synch.c: Remove spurious declaration of endtsleep(). Adjust uses of
averunnable for new struct loadav.
subr_prf.c: Allow printf() formats in panic().
tty.c: averunnable changes.
vfs_subr.c: va_size and va_bytes are now quads.
 1.12.10.1  22-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.17.12.1  20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.18.2.1  22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.20.10.1  12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.20.8.1  07-Sep-2001  thorpej Commit my "devvp" changes to the thorpej-devvp branch. This
replaces the use of dev_t in most places with a struct vnode *.

This will form the basic infrastructure for real cloning device
support (besides being architecurally cleaner -- it'll be good
to get away from using numbers to represent objects).
 1.20.6.4  10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.20.6.3  23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.20.6.2  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.20.6.1  08-Sep-2001  thorpej Add kqueue support.
 1.20.4.5  11-Dec-2002  thorpej Sync with HEAD.
 1.20.4.4  11-Nov-2002  nathanw Catch up to -current
 1.20.4.3  17-Sep-2002  nathanw Catch up to -current.
 1.20.4.2  20-Jun-2002  nathanw Catch up to -current.
 1.20.4.1  14-Nov-2001  nathanw Catch up to -current.
 1.22.2.1  16-May-2002  gehenna Add the character device switch.
 1.28.2.5  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.28.2.4  21-Sep-2004  skrll Fix the sync with head I botched.
 1.28.2.3  18-Sep-2004  skrll Sync with HEAD.
 1.28.2.2  03-Aug-2004  skrll Sync with HEAD
 1.28.2.1  02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.35.2.8  24-Mar-2008  yamt sync with head.
 1.35.2.7  17-Mar-2008  yamt sync with head.
 1.35.2.6  21-Jan-2008  yamt sync with head
 1.35.2.5  07-Dec-2007  yamt sync with head
 1.35.2.4  15-Nov-2007  yamt sync with head.
 1.35.2.3  03-Sep-2007  yamt sync with head.
 1.35.2.2  30-Dec-2006  yamt sync with head.
 1.35.2.1  21-Jun-2006  yamt sync with head.
 1.36.8.1  03-Sep-2006  yamt sync with head.
 1.36.4.1  09-Sep-2006  rpaulo sync with head
 1.37.4.2  10-Dec-2006  yamt sync with head.
 1.37.4.1  22-Oct-2006  yamt sync with head
 1.37.2.1  18-Nov-2006  ad Sync with head.
 1.39.4.2  24-Mar-2007  ad Don't sleep at splhigh, use splsched instead.
 1.39.4.1  12-Mar-2007  rmind Sync with HEAD.
 1.40.4.1  11-Jul-2007  mjf Sync with head.
 1.40.2.2  28-Oct-2007  ad /dev/klog:

- Put locking around it since it's used by printf().
- Mark it MPSAFE.
 1.40.2.1  08-Jun-2007  ad Sync with head.
 1.41.14.3  18-Feb-2008  mjf Sync with HEAD.
 1.41.14.2  08-Dec-2007  mjf Sync with HEAD.
 1.41.14.1  19-Nov-2007  mjf Sync with HEAD.
 1.41.12.1  13-Nov-2007  bouyer Sync with HEAD
 1.41.8.3  23-Mar-2008  matt sync with HEAD
 1.41.8.2  09-Jan-2008  matt sync with HEAD
 1.41.8.1  08-Nov-2007  matt sync with -HEAD
 1.41.6.2  09-Dec-2007  jmcneill Sync with HEAD.
 1.41.6.1  11-Nov-2007  joerg Sync with HEAD.
 1.42.2.1  08-Dec-2007  ad Sync with head.
 1.44.4.1  08-Jan-2008  bouyer Sync with HEAD
 1.47.6.2  02-Jun-2008  mjf Sync with HEAD.
 1.47.6.1  03-Apr-2008  mjf Sync with HEAD.
 1.47.2.1  24-Mar-2008  keiichi sync with head.
 1.49.4.1  16-May-2008  yamt sync with head.
 1.49.2.1  18-May-2008  yamt sync with head.
 1.50.50.1  18-May-2014  rmind sync with head
 1.50.44.2  03-Dec-2017  jdolecek update from HEAD
 1.50.44.1  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.50.34.1  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.51.2.1  10-Aug-2014  tls Rebase.
 1.53.4.1  06-Jun-2015  skrll Sync with HEAD
 1.56.2.2  06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.56.2.1  07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.58.2.1  10-Jun-2019  christos Sync with HEAD
 1.59.12.1  14-Dec-2020  thorpej Sync w/ HEAD.
 1.59.4.1  12-Apr-2025  martin Pull up following revision(s) (requested by rin in ticket #1939):

sys/kern/subr_log.c: revision 1.64
sys/kern/subr_log.c: revision 1.65
sys/kern/subr_log.c: revision 1.66

logread: Drop unnecessary (int) cast for uiomove(9)'s count
which was changed to size_t back to 2002!
https://cvsweb.netbsd.org/bsdweb.cgi/src/sys/sys/systm.h#rev1.149

No practical problem is expected although.

logread: Use ulmin(9) for long v.s. size_t comparison
instead of uimin(9).
No real harm is expected IIUC.

logread: Stop reading msgbuf without log_lock being held
Idea taken from FreeBSD.

XXX
The size of temporal buffer on stack (== 128) is also taken from FreeBSD.
We are not very sure whether this value is optimal or not. But we don't
expect performance regression from this choice.

No new regression for full ATF run on amd64 with DIAGNOSTIC+LOCKDEBUG
kernel and rump kernel.

Authored by knakahara@.
 1.63.8.1  02-Aug-2025  perseant Sync with HEAD
 1.63.2.1  12-Apr-2025  martin Pull up following revision(s) (requested by rin in ticket #1092):

sys/kern/subr_log.c: revision 1.64
sys/kern/subr_log.c: revision 1.65
sys/kern/subr_log.c: revision 1.66

logread: Drop unnecessary (int) cast for uiomove(9)'s count
which was changed to size_t back to 2002!
https://cvsweb.netbsd.org/bsdweb.cgi/src/sys/sys/systm.h#rev1.149

No practical problem is expected although.

logread: Use ulmin(9) for long v.s. size_t comparison
instead of uimin(9).
No real harm is expected IIUC.

logread: Stop reading msgbuf without log_lock being held
Idea taken from FreeBSD.

XXX
The size of temporal buffer on stack (== 128) is also taken from FreeBSD.
We are not very sure whether this value is optimal or not. But we don't
expect performance regression from this choice.

No new regression for full ATF run on amd64 with DIAGNOSTIC+LOCKDEBUG
kernel and rump kernel.

Authored by knakahara@.

RSS XML Feed