From owner-svn-src-all@freebsd.org Thu Mar 23 15:44:51 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DEC78D182E3; Thu, 23 Mar 2017 15:44:51 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: from mail-wr0-f177.google.com (mail-wr0-f177.google.com [209.85.128.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7FB801B37; Thu, 23 Mar 2017 15:44:51 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: by mail-wr0-f177.google.com with SMTP id y90so32601066wrb.0; Thu, 23 Mar 2017 08:44:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:reply-to:in-reply-to:references :from:date:message-id:subject:to:cc; bh=//zf2ZU/SehNHT2vLFRMmva5OkObUllZWCXTYcWLF5A=; b=tSbxFwyPdPzgTliR5aoZ1hBdC7/1hf11Hqe5gNU+2rxuQ/t+Y/4iQVE+m6iOlhoNDK 8gl4h9TDqnmTJR1zM7fAyth6CL65YcAko0XNw57ms0xUJlmyAaCTEfo4iNq+ffHUScfk R2yNsZw63QUM2kLfTQQ6BarjMDFEHdhXxIssxBjMYKV1dgD0H9wK/FynI52M3WbMRGMy qmHzSj3JypkcmR52v6IoQ1+ItumDIEiZSLFevvCBTex/5o03r/QuykC98fEc7JjQL9BW HJ86xOA/Gv0BfbY28iXGziGMHj8Qf2WyyGZ3T/DEviQkrqDoxqwk9/ZZK9jCU9os4mYu DkQA== X-Gm-Message-State: AFeK/H3STln3EAekDajSTge2Tnfc4AtE/9XK0rNwPm8MBdPzRaCqJQ7veMkPnsAOYCuZ9A== X-Received: by 10.223.161.156 with SMTP id u28mr3055475wru.203.1490282483457; Thu, 23 Mar 2017 08:21:23 -0700 (PDT) Received: from mail-wr0-f176.google.com (mail-wr0-f176.google.com. [209.85.128.176]) by smtp.gmail.com with ESMTPSA id p38sm2121518wrb.46.2017.03.23.08.21.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Mar 2017 08:21:23 -0700 (PDT) Received: by mail-wr0-f176.google.com with SMTP id u108so149755267wrb.3; Thu, 23 Mar 2017 08:21:23 -0700 (PDT) X-Received: by 10.223.160.243 with SMTP id n48mr3357852wrn.198.1490282483163; Thu, 23 Mar 2017 08:21:23 -0700 (PDT) MIME-Version: 1.0 Reply-To: cem@freebsd.org Received: by 10.80.169.4 with HTTP; Thu, 23 Mar 2017 08:21:22 -0700 (PDT) In-Reply-To: <201703231048.v2NAmAFU056867@repo.freebsd.org> References: <201703231048.v2NAmAFU056867@repo.freebsd.org> From: Conrad Meyer Date: Thu, 23 Mar 2017 08:21:22 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r315856 - in head/sys/compat/linuxkpi/common: include/linux src To: Hans Petter Selasky Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Mar 2017 15:44:52 -0000 On Thu, Mar 23, 2017 at 3:48 AM, Hans Petter Selasky 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