* [PATCH 0/3] ratelimit: patchset focus on return value of __ratelimit()
@ 2010-03-17 2:58 Yong Zhang
2010-03-17 2:58 ` [PATCH 1/3] ratelimit: annotate ___ratelimit() Yong Zhang
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Yong Zhang @ 2010-03-17 2:58 UTC (permalink / raw)
To: linux-kernel; +Cc: mingo
When try to use the new API pr_*_ratelimited(), I got the opposite outcome.
After some checking, I find print_ratelimited() misunderstand the return
value of __ratelimit(). So I fix it in this patchset and also annotate
__ratelimit() for later user.
I mark patch 3 with RFC because I'm afraid I misunderstand the intention,
Ingo, can you please take a look at it? You know that change is introduced
by edaac8e3167501cda336231d00611bf59c164346.
Yong Zhang (3):
ratelimit: annotate ___ratelimit()
kernel.h: fix wrong usage of __ratelimit()
ratelimit: Fix return value when fail to get lock
include/linux/kernel.h | 2 +-
lib/ratelimit.c | 11 ++++++++---
2 files changed, 9 insertions(+), 4 deletions(-)
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH 1/3] ratelimit: annotate ___ratelimit()
2010-03-17 2:58 [PATCH 0/3] ratelimit: patchset focus on return value of __ratelimit() Yong Zhang
@ 2010-03-17 2:58 ` Yong Zhang
2010-03-17 2:58 ` [PATCH 2/3] kernel.h: fix wrong usage of __ratelimit() Yong Zhang
2010-03-17 2:58 ` [RFC PATCH 3/3] ratelimit: Fix return value when fail to get lock Yong Zhang
2 siblings, 0 replies; 5+ messages in thread
From: Yong Zhang @ 2010-03-17 2:58 UTC (permalink / raw)
To: linux-kernel; +Cc: mingo
Especially to prevent from wrong using of the return value.
Signed-off-by: Yong Zhang <yong.zhang@windriver.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Dave Young <hidave.darkstar@gmail.com>
---
lib/ratelimit.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/lib/ratelimit.c b/lib/ratelimit.c
index 09f5ce1..29a10b3 100644
--- a/lib/ratelimit.c
+++ b/lib/ratelimit.c
@@ -16,9 +16,14 @@
/*
* __ratelimit - rate limiting
* @rs: ratelimit_state data
+ * @func: name of calling function
*
- * This enforces a rate limit: not more than @rs->ratelimit_burst callbacks
- * in every @rs->ratelimit_jiffies
+ * This enforces a rate limit: not more than @rs->burst callbacks
+ * in every @rs->interval
+ *
+ * RETURNS:
+ * 0 means callbacks will be suppuressed.
+ * 1 means go ahead and do it.
*/
int ___ratelimit(struct ratelimit_state *rs, const char *func)
{
--
1.6.3.3
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 2/3] kernel.h: fix wrong usage of __ratelimit()
2010-03-17 2:58 [PATCH 0/3] ratelimit: patchset focus on return value of __ratelimit() Yong Zhang
2010-03-17 2:58 ` [PATCH 1/3] ratelimit: annotate ___ratelimit() Yong Zhang
@ 2010-03-17 2:58 ` Yong Zhang
2010-03-17 2:58 ` [RFC PATCH 3/3] ratelimit: Fix return value when fail to get lock Yong Zhang
2 siblings, 0 replies; 5+ messages in thread
From: Yong Zhang @ 2010-03-17 2:58 UTC (permalink / raw)
To: linux-kernel; +Cc: mingo
__ratelimit() rerurn 1 means we can go ahead.
Signed-off-by: Yong Zhang <yong.zhang@windriver.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Joe Perches <joe@perches.com>
---
include/linux/kernel.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 7f07074..9365227 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -426,7 +426,7 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
.burst = DEFAULT_RATELIMIT_BURST, \
}; \
\
- if (!__ratelimit(&_rs)) \
+ if (__ratelimit(&_rs)) \
printk(fmt, ##__VA_ARGS__); \
})
#else
--
1.6.3.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [RFC PATCH 3/3] ratelimit: Fix return value when fail to get lock
2010-03-17 2:58 [PATCH 0/3] ratelimit: patchset focus on return value of __ratelimit() Yong Zhang
2010-03-17 2:58 ` [PATCH 1/3] ratelimit: annotate ___ratelimit() Yong Zhang
2010-03-17 2:58 ` [PATCH 2/3] kernel.h: fix wrong usage of __ratelimit() Yong Zhang
@ 2010-03-17 2:58 ` Yong Zhang
2010-03-22 20:07 ` Andrew Morton
2 siblings, 1 reply; 5+ messages in thread
From: Yong Zhang @ 2010-03-17 2:58 UTC (permalink / raw)
To: linux-kernel; +Cc: mingo
>From log of commit edaac8e3167501cda336231d00611bf59c164346,
It seems that we want to suppress the callback when trylock
fails.
Signed-off-by: Yong Zhang <yong.zhang@windriver.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
---
lib/ratelimit.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/ratelimit.c b/lib/ratelimit.c
index 29a10b3..358638f 100644
--- a/lib/ratelimit.c
+++ b/lib/ratelimit.c
@@ -40,7 +40,7 @@ int ___ratelimit(struct ratelimit_state *rs, const char *func)
* the entity that is holding the lock already:
*/
if (!spin_trylock_irqsave(&rs->lock, flags))
- return 1;
+ return 0;
if (!rs->begin)
rs->begin = jiffies;
--
1.6.3.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [RFC PATCH 3/3] ratelimit: Fix return value when fail to get lock
2010-03-17 2:58 ` [RFC PATCH 3/3] ratelimit: Fix return value when fail to get lock Yong Zhang
@ 2010-03-22 20:07 ` Andrew Morton
0 siblings, 0 replies; 5+ messages in thread
From: Andrew Morton @ 2010-03-22 20:07 UTC (permalink / raw)
To: Yong Zhang; +Cc: linux-kernel, mingo
On Wed, 17 Mar 2010 10:58:44 +0800
Yong Zhang <yong.zhang@windriver.com> wrote:
> >From log of commit edaac8e3167501cda336231d00611bf59c164346,
> It seems that we want to suppress the callback when trylock
> fails.
>
> Signed-off-by: Yong Zhang <yong.zhang@windriver.com>
> Cc: Ingo Molnar <mingo@elte.hu>
> Cc: Christian Borntraeger <borntraeger@de.ibm.com>
> ---
> lib/ratelimit.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/lib/ratelimit.c b/lib/ratelimit.c
> index 29a10b3..358638f 100644
> --- a/lib/ratelimit.c
> +++ b/lib/ratelimit.c
> @@ -40,7 +40,7 @@ int ___ratelimit(struct ratelimit_state *rs, const char *func)
> * the entity that is holding the lock already:
> */
> if (!spin_trylock_irqsave(&rs->lock, flags))
> - return 1;
> + return 0;
>
> if (!rs->begin)
> rs->begin = jiffies;
Looks right to me. I queued all three patches for 2.6.34.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-03-22 20:08 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-17 2:58 [PATCH 0/3] ratelimit: patchset focus on return value of __ratelimit() Yong Zhang
2010-03-17 2:58 ` [PATCH 1/3] ratelimit: annotate ___ratelimit() Yong Zhang
2010-03-17 2:58 ` [PATCH 2/3] kernel.h: fix wrong usage of __ratelimit() Yong Zhang
2010-03-17 2:58 ` [RFC PATCH 3/3] ratelimit: Fix return value when fail to get lock Yong Zhang
2010-03-22 20:07 ` Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox