2013-03-18 23:20:56

by Davidlohr Bueso

[permalink] [raw]
Subject: [PATCH 1/3] rbtree_test: use pr_info for module prefix in messages

This provides nicer message output. Since it seems more appropriate
for the nature of this module, also use KERN_INFO instead of other
levels.

Signed-off-by: Davidlohr Bueso <[email protected]>
---
lib/rbtree_test.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/lib/rbtree_test.c b/lib/rbtree_test.c
index af38aed..66ca26d 100644
--- a/lib/rbtree_test.c
+++ b/lib/rbtree_test.c
@@ -1,3 +1,6 @@
+#define KMSG_COMPONENT "rbtree_test"
+#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
+
#include <linux/module.h>
#include <linux/rbtree_augmented.h>
#include <linux/random.h>
@@ -153,7 +156,7 @@ static int rbtree_test_init(void)
int i, j;
cycles_t time1, time2, time;

- printk(KERN_ALERT "rbtree testing");
+ pr_info("rbtree testing");

prandom_seed_state(&rnd, 3141592653589793238ULL);
init();
@@ -171,7 +174,7 @@ static int rbtree_test_init(void)
time = time2 - time1;

time = div_u64(time, PERF_LOOPS);
- printk(" -> %llu cycles\n", (unsigned long long)time);
+ pr_info(" -> %llu cycles\n", (unsigned long long)time);

for (i = 0; i < CHECK_LOOPS; i++) {
init();
@@ -186,7 +189,7 @@ static int rbtree_test_init(void)
check(0);
}

- printk(KERN_ALERT "augmented rbtree testing");
+ pr_info("augmented rbtree testing");

init();

@@ -203,7 +206,7 @@ static int rbtree_test_init(void)
time = time2 - time1;

time = div_u64(time, PERF_LOOPS);
- printk(" -> %llu cycles\n", (unsigned long long)time);
+ pr_info(" -> %llu cycles\n", (unsigned long long)time);

for (i = 0; i < CHECK_LOOPS; i++) {
init();
@@ -223,7 +226,7 @@ static int rbtree_test_init(void)

static void rbtree_test_exit(void)
{
- printk(KERN_ALERT "test exit\n");
+ pr_info("test exit\n");
}

module_init(rbtree_test_init)
--
1.7.11.7




2013-03-18 23:44:27

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH 1/3] rbtree_test: use pr_info for module prefix in messages

On Mon, 2013-03-18 at 16:20 -0700, Davidlohr Bueso wrote:
> This provides nicer message output. Since it seems more appropriate
> for the nature of this module, also use KERN_INFO instead of other
> levels.
[]
> diff --git a/lib/rbtree_test.c b/lib/rbtree_test.c
[]
> @@ -153,7 +156,7 @@ static int rbtree_test_init(void)
> int i, j;
> cycles_t time1, time2, time;
>
> - printk(KERN_ALERT "rbtree testing");
> + pr_info("rbtree testing");
>
> prandom_seed_state(&rnd, 3141592653589793238ULL);
> init();
> @@ -171,7 +174,7 @@ static int rbtree_test_init(void)
> time = time2 - time1;
>
> time = div_u64(time, PERF_LOOPS);
> - printk(" -> %llu cycles\n", (unsigned long long)time);
> + pr_info(" -> %llu cycles\n", (unsigned long long)time);

You change the output here by more than just adding a prefix.

The first printk didn't have a newline.

The old code would print:

"rbtree testing -> <foo> cycles"

The new code prints:

"rbtree_test: rbtree testing"
"rbtree_test: -> <foo> cycles"

btw: each pr_info should have a newline termination
or be followed by a some number of pr_cont/printk with
the last one having a terminating newline.

The first pr_info here doesn't have a newline
so it's possible (though unlikely) that another
thread could have its output appended/interleaved
on the same line.

2013-03-18 23:47:53

by Davidlohr Bueso

[permalink] [raw]
Subject: Re: [PATCH 1/3] rbtree_test: use pr_info for module prefix in messages

On Mon, 2013-03-18 at 16:44 -0700, Joe Perches wrote:
> On Mon, 2013-03-18 at 16:20 -0700, Davidlohr Bueso wrote:
> > This provides nicer message output. Since it seems more appropriate
> > for the nature of this module, also use KERN_INFO instead of other
> > levels.
> []
> > diff --git a/lib/rbtree_test.c b/lib/rbtree_test.c
> []
> > @@ -153,7 +156,7 @@ static int rbtree_test_init(void)
> > int i, j;
> > cycles_t time1, time2, time;
> >
> > - printk(KERN_ALERT "rbtree testing");
> > + pr_info("rbtree testing");
> >
> > prandom_seed_state(&rnd, 3141592653589793238ULL);
> > init();
> > @@ -171,7 +174,7 @@ static int rbtree_test_init(void)
> > time = time2 - time1;
> >
> > time = div_u64(time, PERF_LOOPS);
> > - printk(" -> %llu cycles\n", (unsigned long long)time);
> > + pr_info(" -> %llu cycles\n", (unsigned long long)time);
>
> You change the output here by more than just adding a prefix.
>
> The first printk didn't have a newline.
>
> The old code would print:
>
> "rbtree testing -> <foo> cycles"
>
> The new code prints:
>
> "rbtree_test: rbtree testing"
> "rbtree_test: -> <foo> cycles"
>

Ah, I see. This is actually the first time I'm using pr_* calls. I
actually don't mind the new format, it looked
ok, but if others don't agree, I can always resend it.

> btw: each pr_info should have a newline termination
> or be followed by a some number of pr_cont/printk with
> the last one having a terminating newline.
>
> The first pr_info here doesn't have a newline
> so it's possible (though unlikely) that another
> thread could have its output appended/interleaved
> on the same line.
>
>

2013-03-19 00:29:42

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH 1/3] rbtree_test: use pr_info for module prefix in messages

On Mon, 2013-03-18 at 16:47 -0700, Davidlohr Bueso wrote:
> On Mon, 2013-03-18 at 16:44 -0700, Joe Perches wrote:
> > On Mon, 2013-03-18 at 16:20 -0700, Davidlohr Bueso wrote:
> > > This provides nicer message output. Since it seems more appropriate
> > > for the nature of this module, also use KERN_INFO instead of other
> > > levels.
> > []
> > > diff --git a/lib/rbtree_test.c b/lib/rbtree_test.c
> > []
> > > @@ -153,7 +156,7 @@ static int rbtree_test_init(void)
> > > int i, j;
> > > cycles_t time1, time2, time;
> > >
> > > - printk(KERN_ALERT "rbtree testing");
> > > + pr_info("rbtree testing");
> > >
> > > prandom_seed_state(&rnd, 3141592653589793238ULL);
> > > init();
> > > @@ -171,7 +174,7 @@ static int rbtree_test_init(void)
> > > time = time2 - time1;
> > >
> > > time = div_u64(time, PERF_LOOPS);
> > > - printk(" -> %llu cycles\n", (unsigned long long)time);
> > > + pr_info(" -> %llu cycles\n", (unsigned long long)time);
> >
> > You change the output here by more than just adding a prefix.
> >
> > The first printk didn't have a newline.
> >
> > The old code would print:
> >
> > "rbtree testing -> <foo> cycles"
> >
> > The new code prints:
> >
> > "rbtree_test: rbtree testing"
> > "rbtree_test: -> <foo> cycles"
> >
>
> Ah, I see. This is actually the first time I'm using pr_* calls. I
> actually don't mind the new format, it looked
> ok, but if others don't agree, I can always resend it.

Your choice. I don't prefer one over the other.

I do prefer you add an explicit newline to the first
format though instead of relying on the implicit
newline the printk subsystem will emit during the next
pr_<level> call.

cheers, Joe

2013-03-19 16:29:11

by Shuah Khan

[permalink] [raw]
Subject: Re: [PATCH 1/3] rbtree_test: use pr_info for module prefix in messages

On Mon, Mar 18, 2013 at 5:20 PM, Davidlohr Bueso <[email protected]> wrote:
> This provides nicer message output. Since it seems more appropriate
> for the nature of this module, also use KERN_INFO instead of other
> levels.

Why are you changing the ALERTs to INFO?

>
> Signed-off-by: Davidlohr Bueso <[email protected]>
> ---
> lib/rbtree_test.c | 13 ++++++++-----
> 1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/lib/rbtree_test.c b/lib/rbtree_test.c
> index af38aed..66ca26d 100644
> --- a/lib/rbtree_test.c
> +++ b/lib/rbtree_test.c
> @@ -1,3 +1,6 @@
> +#define KMSG_COMPONENT "rbtree_test"
> +#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
> +
> #include <linux/module.h>
> #include <linux/rbtree_augmented.h>
> #include <linux/random.h>
> @@ -153,7 +156,7 @@ static int rbtree_test_init(void)
> int i, j;
> cycles_t time1, time2, time;
>
> - printk(KERN_ALERT "rbtree testing");
> + pr_info("rbtree testing");

This is changing the output from KERN_ALERT to KERN_INFO. Why is this
necessary? Should this be pr_alert() instead?


>
> prandom_seed_state(&rnd, 3141592653589793238ULL);
> init();
> @@ -171,7 +174,7 @@ static int rbtree_test_init(void)
> time = time2 - time1;
>
> time = div_u64(time, PERF_LOOPS);
> - printk(" -> %llu cycles\n", (unsigned long long)time);
> + pr_info(" -> %llu cycles\n", (unsigned long long)time);
>
> for (i = 0; i < CHECK_LOOPS; i++) {
> init();
> @@ -186,7 +189,7 @@ static int rbtree_test_init(void)
> check(0);
> }
>
> - printk(KERN_ALERT "augmented rbtree testing");
> + pr_info("augmented rbtree testing");

This is changing the output from KERN_ALERT to KERN_INFO. Why is this
necessary? Should this be pr_alert() instead?

>
> init();
>
> @@ -203,7 +206,7 @@ static int rbtree_test_init(void)
> time = time2 - time1;
>
> time = div_u64(time, PERF_LOOPS);
> - printk(" -> %llu cycles\n", (unsigned long long)time);
> + pr_info(" -> %llu cycles\n", (unsigned long long)time);
>
> for (i = 0; i < CHECK_LOOPS; i++) {
> init();
> @@ -223,7 +226,7 @@ static int rbtree_test_init(void)
>
> static void rbtree_test_exit(void)
> {
> - printk(KERN_ALERT "test exit\n");
> + pr_info("test exit\n");

This is changing the output from KERN_ALERT to KERN_INFO. Why is this
necessary? Should this be pr_alert() instead?

> }
>
> module_init(rbtree_test_init)
> --
> 1.7.11.7
>
>
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/

2013-03-19 17:14:44

by Davidlohr Bueso

[permalink] [raw]
Subject: Re: [PATCH 1/3] rbtree_test: use pr_info for module prefix in messages

On Tue, 2013-03-19 at 10:29 -0600, Shuah Khan wrote:
> On Mon, Mar 18, 2013 at 5:20 PM, Davidlohr Bueso <[email protected]> wrote:
> > This provides nicer message output. Since it seems more appropriate
> > for the nature of this module, also use KERN_INFO instead of other
> > levels.
>
> Why are you changing the ALERTs to INFO?

Because of the nature of the messages. They don't justify having a
KERN_ALERT level (requiring immediate attention), and it seems a lot
more suitable to use INFO instead.

>
> >
> > Signed-off-by: Davidlohr Bueso <[email protected]>
> > ---
> > lib/rbtree_test.c | 13 ++++++++-----
> > 1 file changed, 8 insertions(+), 5 deletions(-)
> >
> > diff --git a/lib/rbtree_test.c b/lib/rbtree_test.c
> > index af38aed..66ca26d 100644
> > --- a/lib/rbtree_test.c
> > +++ b/lib/rbtree_test.c
> > @@ -1,3 +1,6 @@
> > +#define KMSG_COMPONENT "rbtree_test"
> > +#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
> > +
> > #include <linux/module.h>
> > #include <linux/rbtree_augmented.h>
> > #include <linux/random.h>
> > @@ -153,7 +156,7 @@ static int rbtree_test_init(void)
> > int i, j;
> > cycles_t time1, time2, time;
> >
> > - printk(KERN_ALERT "rbtree testing");
> > + pr_info("rbtree testing");
>
> This is changing the output from KERN_ALERT to KERN_INFO. Why is this
> necessary? Should this be pr_alert() instead?
>
>
> >
> > prandom_seed_state(&rnd, 3141592653589793238ULL);
> > init();
> > @@ -171,7 +174,7 @@ static int rbtree_test_init(void)
> > time = time2 - time1;
> >
> > time = div_u64(time, PERF_LOOPS);
> > - printk(" -> %llu cycles\n", (unsigned long long)time);
> > + pr_info(" -> %llu cycles\n", (unsigned long long)time);
> >
> > for (i = 0; i < CHECK_LOOPS; i++) {
> > init();
> > @@ -186,7 +189,7 @@ static int rbtree_test_init(void)
> > check(0);
> > }
> >
> > - printk(KERN_ALERT "augmented rbtree testing");
> > + pr_info("augmented rbtree testing");
>
> This is changing the output from KERN_ALERT to KERN_INFO. Why is this
> necessary? Should this be pr_alert() instead?
>
> >
> > init();
> >
> > @@ -203,7 +206,7 @@ static int rbtree_test_init(void)
> > time = time2 - time1;
> >
> > time = div_u64(time, PERF_LOOPS);
> > - printk(" -> %llu cycles\n", (unsigned long long)time);
> > + pr_info(" -> %llu cycles\n", (unsigned long long)time);
> >
> > for (i = 0; i < CHECK_LOOPS; i++) {
> > init();
> > @@ -223,7 +226,7 @@ static int rbtree_test_init(void)
> >
> > static void rbtree_test_exit(void)
> > {
> > - printk(KERN_ALERT "test exit\n");
> > + pr_info("test exit\n");
>
> This is changing the output from KERN_ALERT to KERN_INFO. Why is this
> necessary? Should this be pr_alert() instead?
>
> > }
> >
> > module_init(rbtree_test_init)
> > --
> > 1.7.11.7
> >
> >
> >
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> > the body of a message to [email protected]
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
> > Please read the FAQ at http://www.tux.org/lkml/

2013-03-19 17:54:18

by Shuah Khan

[permalink] [raw]
Subject: Re: [PATCH 1/3] rbtree_test: use pr_info for module prefix in messages

On Tue, Mar 19, 2013 at 11:14 AM, Davidlohr Bueso
<[email protected]> wrote:
> On Tue, 2013-03-19 at 10:29 -0600, Shuah Khan wrote:
>> On Mon, Mar 18, 2013 at 5:20 PM, Davidlohr Bueso <[email protected]> wrote:
>> > This provides nicer message output. Since it seems more appropriate
>> > for the nature of this module, also use KERN_INFO instead of other
>> > levels.
>>
>> Why are you changing the ALERTs to INFO?
>
> Because of the nature of the messages. They don't justify having a
> KERN_ALERT level (requiring immediate attention), and it seems a lot
> more suitable to use INFO instead.
>

Hmm. I see interval_tree_test using the same alerts. It almost looks
like the start and end of a test are meant to be alerts. I am not
saying it shouldn't be changed, however looking for a stronger reason
than "it seems a lot more suitable to use INFO instead". Are there any
use-cases in which KERN_ALERTs cause problems?

-- Shuah

2013-03-22 02:51:32

by Davidlohr Bueso

[permalink] [raw]
Subject: Re: [PATCH 1/3] rbtree_test: use pr_info for module prefix in messages

On Tue, 2013-03-19 at 11:54 -0600, Shuah Khan wrote:
> On Tue, Mar 19, 2013 at 11:14 AM, Davidlohr Bueso
> <[email protected]> wrote:
> > On Tue, 2013-03-19 at 10:29 -0600, Shuah Khan wrote:
> >> On Mon, Mar 18, 2013 at 5:20 PM, Davidlohr Bueso <[email protected]> wrote:
> >> > This provides nicer message output. Since it seems more appropriate
> >> > for the nature of this module, also use KERN_INFO instead of other
> >> > levels.
> >>
> >> Why are you changing the ALERTs to INFO?
> >
> > Because of the nature of the messages. They don't justify having a
> > KERN_ALERT level (requiring immediate attention), and it seems a lot
> > more suitable to use INFO instead.
> >
>
> Hmm. I see interval_tree_test using the same alerts. It almost looks
> like the start and end of a test are meant to be alerts. I am not
> saying it shouldn't be changed, however looking for a stronger reason
> than "it seems a lot more suitable to use INFO instead". Are there any
> use-cases in which KERN_ALERTs cause problems?
>

No 'issue' particularly, just common sense. In any case I have no
problem reverting the changes back to KERN_ALERT, no big deal.

Andrew, Michel, do you have any preferences? I'm mostly interested in
patch 3/3, do you have any objections?

Thanks,
Davidlohr

2013-03-22 03:29:09

by Michel Lespinasse

[permalink] [raw]
Subject: Re: [PATCH 1/3] rbtree_test: use pr_info for module prefix in messages

On Thu, Mar 21, 2013 at 7:51 PM, Davidlohr Bueso <[email protected]> wrote:
> On Tue, 2013-03-19 at 11:54 -0600, Shuah Khan wrote:
>> On Tue, Mar 19, 2013 at 11:14 AM, Davidlohr Bueso
>> <[email protected]> wrote:
>> > On Tue, 2013-03-19 at 10:29 -0600, Shuah Khan wrote:
>> >> On Mon, Mar 18, 2013 at 5:20 PM, Davidlohr Bueso <[email protected]> wrote:
>> >> > This provides nicer message output. Since it seems more appropriate
>> >> > for the nature of this module, also use KERN_INFO instead of other
>> >> > levels.
>> >>
>> >> Why are you changing the ALERTs to INFO?
>> >
>> > Because of the nature of the messages. They don't justify having a
>> > KERN_ALERT level (requiring immediate attention), and it seems a lot
>> > more suitable to use INFO instead.
>> >
>>
>> Hmm. I see interval_tree_test using the same alerts. It almost looks
>> like the start and end of a test are meant to be alerts. I am not
>> saying it shouldn't be changed, however looking for a stronger reason
>> than "it seems a lot more suitable to use INFO instead". Are there any
>> use-cases in which KERN_ALERTs cause problems?
>>
>
> No 'issue' particularly, just common sense. In any case I have no
> problem reverting the changes back to KERN_ALERT, no big deal.
>
> Andrew, Michel, do you have any preferences? I'm mostly interested in
> patch 3/3, do you have any objections?

Sorry for the late reply - I have a lot of upstream email to catch up to.

No objection to the change but I also have to say I'm not quite sure
what's the motivation - it'd be easier if you had a 0/3 mail to
explain the issue. In particular, I'm not sure if you've been trying
to use the test compiled in rather than as a module (which is all I've
ever built it as myself :)

--
Michel "Walken" Lespinasse
A program is never fully debugged until the last user dies.

2013-03-22 23:06:17

by Davidlohr Bueso

[permalink] [raw]
Subject: Re: [PATCH 1/3] rbtree_test: use pr_info for module prefix in messages

On Thu, 2013-03-21 at 20:29 -0700, Michel Lespinasse wrote:
> On Thu, Mar 21, 2013 at 7:51 PM, Davidlohr Bueso <[email protected]> wrote:
> > On Tue, 2013-03-19 at 11:54 -0600, Shuah Khan wrote:
> >> On Tue, Mar 19, 2013 at 11:14 AM, Davidlohr Bueso
> >> <[email protected]> wrote:
> >> > On Tue, 2013-03-19 at 10:29 -0600, Shuah Khan wrote:
> >> >> On Mon, Mar 18, 2013 at 5:20 PM, Davidlohr Bueso <[email protected]> wrote:
> >> >> > This provides nicer message output. Since it seems more appropriate
> >> >> > for the nature of this module, also use KERN_INFO instead of other
> >> >> > levels.
> >> >>
> >> >> Why are you changing the ALERTs to INFO?
> >> >
> >> > Because of the nature of the messages. They don't justify having a
> >> > KERN_ALERT level (requiring immediate attention), and it seems a lot
> >> > more suitable to use INFO instead.
> >> >
> >>
> >> Hmm. I see interval_tree_test using the same alerts. It almost looks
> >> like the start and end of a test are meant to be alerts. I am not
> >> saying it shouldn't be changed, however looking for a stronger reason
> >> than "it seems a lot more suitable to use INFO instead". Are there any
> >> use-cases in which KERN_ALERTs cause problems?
> >>
> >
> > No 'issue' particularly, just common sense. In any case I have no
> > problem reverting the changes back to KERN_ALERT, no big deal.
> >
> > Andrew, Michel, do you have any preferences? I'm mostly interested in
> > patch 3/3, do you have any objections?
>
> Sorry for the late reply - I have a lot of upstream email to catch up to.
>
> No objection to the change but I also have to say I'm not quite sure
> what's the motivation - it'd be easier if you had a 0/3 mail to
> explain the issue. In particular, I'm not sure if you've been trying
> to use the test compiled in rather than as a module (which is all I've
> ever built it as myself :)
>

Yeah, since it was a small and straightforward patchset I chose not to
send a 0/3 explaining the motivation. I was basically going through your
augmented rbtree work and noticed some property checks missing. FWIW I
only used it as a module as well.

Thanks,
Davidlohr