Date: Thu, 23 Mar 2017 08:21:22 -0700 From: Conrad Meyer <cem@freebsd.org> To: Hans Petter Selasky <hselasky@freebsd.org> Cc: src-committers <src-committers@freebsd.org>, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r315856 - in head/sys/compat/linuxkpi/common: include/linux src Message-ID: <CAG6CVpWehJSm-Fyhh0dmfTNdonLFFWg%2BokFTZDygjtOSKQ3s=g@mail.gmail.com> In-Reply-To: <201703231048.v2NAmAFU056867@repo.freebsd.org> References: <201703231048.v2NAmAFU056867@repo.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Mar 23, 2017 at 3:48 AM, Hans Petter Selasky <hselasky@freebsd.org> wrote: > Author: hselasky > Date: Thu Mar 23 10:48:10 2017 > New Revision: 315856 > URL: https://svnweb.freebsd.org/changeset/base/315856 > > Log: > Add support for ratelimited printouts in the LinuxKPI. > > ... --- head/sys/compat/linuxkpi/common/include/linux/kernel.h Thu Mar 23 10:43:29 2017 (r315855) > +++ head/sys/compat/linuxkpi/common/include/linux/kernel.h Thu Mar 23 10:48:10 2017 (r315856) > @@ -224,6 +224,11 @@ scnprintf(char *buf, size_t size, const > log_once(LOG_INFO, pr_fmt(fmt), ##__VA_ARGS__) > #define pr_cont(fmt, ...) \ > printk(KERN_CONT fmt, ##__VA_ARGS__) > +#define pr_warn_ratelimited(...) do { \ > + static time_t __ratelimited; \ > + if (linux_ratelimited(&__ratelimited)) \ > + pr_warning(__VA_ARGS__); \ > +} while (0) > > #ifndef WARN > #define WARN(condition, ...) ({ \ > @@ -331,4 +336,6 @@ abs64(int64_t x) > return (x < 0 ? -x : x); > } > > +extern bool linux_ratelimited(time_t *); > + > #endif /* _LINUX_KERNEL_H_ */ > > Modified: head/sys/compat/linuxkpi/common/src/linux_compat.c > ============================================================================== > --- head/sys/compat/linuxkpi/common/src/linux_compat.c Thu Mar 23 10:43:29 2017 (r315855) > +++ head/sys/compat/linuxkpi/common/src/linux_compat.c Thu Mar 23 10:48:10 2017 (r315856) > @@ -1484,6 +1484,20 @@ __unregister_chrdev(unsigned int major, > bool linux_cpu_has_clflush; > #endif > > +bool > +linux_ratelimited(time_t *ptime) > +{ > + /* make sure uptime is not zero by OR'ing bit 31 */ > + time_t curr = time_uptime | (1U << 31); > + > + /* check if one or more seconds have passed */ > + if (*ptime != curr) { > + *ptime = curr; > + return (1); > + } > + return (0); > +} > + Hi Hans, Is there any reason to use this hand-rolled thing to limit ratelimited logging instead of ppsratecheck()? Best, Conrad
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAG6CVpWehJSm-Fyhh0dmfTNdonLFFWg%2BokFTZDygjtOSKQ3s=g>