History log of /freebsd-current/usr.sbin/watchdogd/watchdogd.c
Revision Date Author Comments
# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix


# 1de7b4b8 27-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

various: general adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

No functional change intended.


# 97e832c1 27-Jun-2017 Xin LI <delphij@FreeBSD.org>

Chase malloc() change by removing lg_chunk malloc_conf settings.

In jemalloc 5, there are no longer chunks, and as configured on
FreeBSD (the "retain" option defaults to false), the mmap()
requests are precisely sized for the specific needs, which means
the virtual memory overhead should be lower for small applications.

Reviewed by: jasone, ian
Differential Revision: https://reviews.freebsd.org/D11366


# a18f2805 10-Nov-2016 Andriy Gapon <avg@FreeBSD.org>

fix a watchdogd regression introduced in r308040

The code assumed that 'timeout' and 'timeout_sec' are in sync
which they weren't if no '-t' option was passed to watchdogd.

Reported by: Olivier Smedts <olivier@gid0.org>,
Alex Deiter <alex.deiter@gmail.com>
Tested by: Olivier Smedts <olivier@gid0.org>,
Alex Deiter <alex.deiter@gmail.com>
MFC after: 5 days
X-MFC with: r308040


# 9cb44c5d 28-Oct-2016 Andriy Gapon <avg@FreeBSD.org>

nap time between pats is forced to be at most half of the timeout

Previously, if the timeout was less than 10 seconds, for example, about
8 seconds, then the watchdog timer would be let to expire before patting
the watchdog.

MFC after: 2 weeks


# 7b4a83b1 19-Aug-2015 Ian Lepore <ian@FreeBSD.org>

Add a new exit-timeout option to watchdogd.

Watchdogd currently disables the watchdog when it exits, such as during
rc.shutdown processing. That leaves the system vulnerable to getting hung
or deadlocked during the shutdown part of a reboot. For embedded systems
it's especially important that the hardware watchdog always be active. It
can also be useful for servers that are administered remotely.

The new -x <seconds> option tells watchdogd to program the watchdog with the
given timeout just before exiting. The -x value can be longer or shorter
than the -t normal time value, to allow for various exceptional conditions
at shutdown such as allowing extra time for buffer flushing.

The exit value is also used internally in the "failsafe" handling (which
used to just disable the watchdog), on the theory that if you're using this
option, "safe" means having the watchdog always running, not disabled.

The default is still to disable the watchdog on exit if -x is not specified.

Differential Revision: https://reviews.freebsd.org/D2556 (timed out)


# dad6df61 16-Nov-2014 Xin LI <delphij@FreeBSD.org>

Default to use 10 seconds as nap interval instead of 1.

Previously, we have a nap interval of 1 second while we have a timeout of
128 seconds by default, which could be an overkill, and for some hardware
the patting action may be expensive.

Note that the choice of nap interval is still arbitrary. We preferred
a safe value where even when the system is very heavily loaded, the
watchdog should not shoot the system down if it's not really hung.
According to the manual page of Linux's watchdog daemon, the nap interval
time of theirs is 10 seconds, which seems to be a reasonable value --
according to Intel documentation AP-725 (Document Number: 292273-001),
ICH5's maximum timeout is about 37.5 seconds, which the ichwd(4) driver
would set when we requested 128 seconds (although it should probably
feed back this as an error and do not set the timeout). Since that's
the shortest maximum value, 10 seconds seems to be a right choice for
us too.

Discussed with: alfred
MFC after: 1 month


# 907745a8 09-Aug-2013 Alfred Perlstein <alfred@FreeBSD.org>

Fix bug in r253719: fix command line watchdog disable.

r253719 disallowed watchdog(8) from disabling the watchdog
by breaking the ability to pass 0 as a timeout arg. Fix this.


# 22dbec3d 30-Jul-2013 John Baldwin <jhb@FreeBSD.org>

Apply a casting sledgehammer.

Submitted by: dhw


# 232b79f5 28-Jul-2013 Ian Lepore <ian@FreeBSD.org>

Fix printf of seconds for systems where time_t is 64 bits.


# 3d30404f 27-Jul-2013 Alfred Perlstein <alfred@FreeBSD.org>

Fix watchdog pretimeout.

The original API calls for pow2ns, however the new APIs from
Linux call for seconds.

We need to be able to convert to/from 2^Nns to seconds in both
userland and kernel to fix this and properly compare units.


# 5e49d30e 08-Apr-2013 Ed Schouten <ed@FreeBSD.org>

Mark the act_tbl static/const.

This table is only used within this source file and is only accessed
read-only.

MFC after: 1 week


# 8d7ad01f 26-Mar-2013 Mark Johnston <markj@FreeBSD.org>

Invert the meaning of -S (added in r247405) and document its meaning. Also,
don't carp about the watchdog command taking too long until after the
watchdog has been patted, and don't carp via warnx(3) unless -S is set
since syslog(3) already logs to standard error otherwise.

Discussed with: alfred
Reviewed by: alfred
Approved by: emaste (co-mentor)


# 4b9b732a 27-Feb-2013 Alfred Perlstein <alfred@FreeBSD.org>

watchdogd(8) and watchdog(4) enhancements.

The following support was added to watchdog(4):
- Support to query the outstanding timeout.
- Support to set a software pre-timeout function watchdog with an 'action'
- Support to set a software only watchdog with a configurable 'action'

'action' can be a mask specifying a single operation or a combination of:
log(9), printf(9), panic(9) and/or kdb_enter(9).

Support the following in watchdogged:
- Support to utilize the new additions to watchdog(4).
- Support to warn if a watchdog script runs for too long.
- Support for "dry run" where we do not actually arm the watchdog,
but only report on our timing.

Sponsored by: iXsystems, Inc.
MFC after: 1 month


# 3c5bfb58 26-Jan-2013 Ian Lepore <ian@FreeBSD.org>

Revert accidental regression to previous misspelling.

Approved by: cognet (mentor)


# e6af9f3a 26-Jan-2013 Ian Lepore <ian@FreeBSD.org>

Reduce watchdogd's memory footprint when running daemonized.

This uses the recently-added jemalloc(3) feature of setting the lg_chunk
tuning option to zero to request that memory be allocated in the smallest
chunks possible. Without this option, the default is to initally map 8MB,
and then the mlockall() call wires that entire allocation even though the
program only uses a few Kbytes of it at runtime.

PR: bin/173332
Approved by: cognet (mentor)


# b6473670 17-Jan-2013 Alfred Perlstein <alfred@FreeBSD.org>

Spelling: exitting -> exiting

MFC after: 2 weeks


# 652c4260 03-Nov-2012 Xin LI <delphij@FreeBSD.org>

Replace log(3) with flsll(3) for watchdogd(8) and drop libm dependency.

MFC after: 2 weeks


# 193e2b55 30-Aug-2012 Andrey Zonov <zont@FreeBSD.org>

- It's also need to lock current memory.

Approved by: kib (mentor)
MFC after: 1 week


# e489ac6c 28-Aug-2012 Andrey Zonov <zont@FreeBSD.org>

- Don't allow watchdogd(8) to be swapped out.
On machines with huge amount of swap and high IO activity,
watchdogd(8) may wait for a swap memory longer than timeout and
sometimes fires.

Approved by: kib (mentor)
MFC after: 1 week


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# f145c771 25-Sep-2010 Ed Maste <emaste@FreeBSD.org>

Protect the watchdog daemon against swap OOM killer. This is similar to
SVN r199804 which added protection to sshd, cron, syslogd, and inetd.


# d10d35b3 20-Jul-2010 Xin LI <delphij@FreeBSD.org>

Staticify local variables.

While I'm there also add a 'static' keyword for a function to make it
consistent with prototype.

Reviewed by: phk
MFC after: 3 months


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# 10bc3a7f 29-Dec-2009 Ed Schouten <ed@FreeBSD.org>

ANSIfy almost all applications that use WARNS=6.

I was considering committing all these patches one by one, but as
discussed with brooks@, there is no need to do this. If we ever
need/want to merge these changes back, it is still possible to do this
per application.


# c409ce41 21-Dec-2009 Ruslan Ermilov <ru@FreeBSD.org>

Don't hide an error if the initial attempt to program a watchdog from
within watchdogd(8) fails. This is also consistent with watchdog(8).


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# 0f71a1cb 15-Dec-2006 Nick Hibma <n_hibma@FreeBSD.org>

Don't exit from watchdogd on receiving a signal if we cannot stop the watchdog.
That'll require -KILL. This avoids resetting your system on one of the
watchdogs that you cannot disable.


# 5c272530 06-Mar-2006 Poul-Henning Kamp <phk@FreeBSD.org>

Fix usage().

Submitted by: Adrian Steinmann <ast@marabu.ch>


# 2a5f59b2 30-Sep-2005 Poul-Henning Kamp <phk@FreeBSD.org>

Report any errors we might see when disabling the watchdog.

Complain about extra arguments so people don't get surprised
if they type "watchdog 0"


# 8b28aef2 16-Sep-2005 Pawel Jakub Dawidek <pjd@FreeBSD.org>

Pidfiles should be created with permission preventing users from opening
them for reading. When user can open file for reading, he can also
flock(2) it, which can lead to confusions.

Pointed out by: green


# 0ea90af0 24-Aug-2005 Pawel Jakub Dawidek <pjd@FreeBSD.org>

Use pidfile(3) in watchdogd(8).


# bdd466ff 18-Mar-2005 Marius Strobl <marius@FreeBSD.org>

When disarming a watchdog by using an interval of WD_TO_NEVER a non-zero
return value of the ioctl doesn't indicate that the command has failed
so don't let watchdog(8) return an error in this case.

MFC after: 3 days


# a693939e 28-Jul-2004 Brian Feldman <green@FreeBSD.org>

Disable memory locking that could keep watchdogd from deadlocking itself
if the swap subsystem failed.

Requested by: phk


# 5e60838b 23-Jul-2004 Brian Feldman <green@FreeBSD.org>

Now that mlockall(2) is unbroken, use it to keep watchdogd(8) permanently
out of swap.


# 670c8a8c 03-May-2004 Sean Kelly <smkelly@FreeBSD.org>

Bump the copyright year since I forgot last time.


# 459336c4 28-Apr-2004 Sean Kelly <smkelly@FreeBSD.org>

Update comments to reflect changes made by phk. Also no longer need
<sys/sysctl.h>.


# 4103b765 28-Feb-2004 Poul-Henning Kamp <phk@FreeBSD.org>

Rename the WATCHDOG option to SW_WATCHDOG and make it use the
generic watchdoc(9) interface.

Make watchdogd(8) perform as watchdog(8) as well, and make it
possible to specify a check command to run, timeout and sleep
periods.

Update watchdog(4) to talk about the generic interface and add
new watchdog(8) page.


# bc8b0878 02-Jul-2003 Sean Kelly <smkelly@FreeBSD.org>

o style(9) fixes
- Reordered #includes
- Only include <sys/types.h>, not it and <sys/cdefs.h>
o style.Makefile(5) fixes
- No SRCS= line when only one src file with same name as program
o Use warn()/errx() instead of fprintf()
- Integrated patch from Philippe Charnier <charnier@xp11.frmug.org>

Approved by: jeff (mentor)


# 055d177f 26-Jun-2003 Sean Kelly <smkelly@FreeBSD.org>

Unbreak this for alpha and friends.

Double pointy hat to me, or something.


# e931de40 26-Jun-2003 Maxim Konovalov <maxim@FreeBSD.org>

o Fix typo.

Submitted by: smkelly


# 370c3cb5 26-Jun-2003 Sean Kelly <smkelly@FreeBSD.org>

- Add a software watchdog facility.

This commit has two pieces. One half is the watchdog kernel code which lives
primarily in hardclock() in sys/kern/kern_clock.c. The other half is a userland
daemon which, when run, will keep the watchdog from firing while the userland
is intact and functioning.

Approved by: jeff (mentor)