Re: [PATCH 1/6] Free up pf flag PF_KSOFTIRQD
From: Venkatesh Pallipadi
Date: Thu Oct 21 2010 - 10:36:57 EST
On Wed, Oct 20, 2010 at 10:23 PM, Eric Dumazet <eric.dumazet@xxxxxxxxx> wrote:
> Le mercredi 20 octobre 2010 à 15:48 -0700, Venkatesh Pallipadi a écrit :
>> +int is_ksoftirqd_context(void)
>> +{
>> + return (current == __get_cpu_var(ksoftirqd));
>> +}
>
> "return (X == Y);" should be "return X == Y;"
>
> I believe this function should be inlined, and use this_cpu_read()
> You probably can pass 'current' as a pointer.
>
> static inline bool is_ksoftirq(struct task_struct *p)
> {
> return p == this_cpu_read(ksoftirqd);
> }
Yes. I thought about static inline part. The reason I did not make
this static inline was because ksoftirqd was declared static in
softirq.c and this function was getting called from sched.c.
I did not know that this_cpu_read existed though. I guess I should be
looking at using that elsewhere in the patchset too.
Also, part of the overhead you see below I think is coming from
DEBUG_PREEMPT. That would be making every smp_processor_id() call more
expensive. No?
Thanks,
Venki
>
> Your version is a bit expensive :
>
> <is_ksoftirqd_context>:
> 55 push %rbp
> 48 89 e5 mov %rsp,%rbp
> 48 83 ec 10 sub $0x10,%rsp
> 48 89 1c 24 mov %rbx,(%rsp)
> 4c 89 64 24 08 mov %r12,0x8(%rsp)
> 48 c7 c3 40 03 01 00 mov $0x10340,%rbx
> e8 93 e5 24 00 callq ffffffff812aeab0 <debug_smp_processor_id>
> 89 c0 mov %eax,%eax
> 48 8b 04 c5 a0 b8 b5 mov -0x7e4a4760(,%rax,8),%rax
> 81
> 65 4c 8b 24 25 00 cc mov %gs:0xcc00,%r12
> 00 00
> 4c 39 24 18 cmp %r12,(%rax,%rbx,1)
> 48 8b 1c 24 mov (%rsp),%rbx
> 4c 8b 64 24 08 mov 0x8(%rsp),%r12
> c9 leaveq
> 0f 94 c0 sete %al
> 0f b6 c0 movzbl %al,%eax
> c3 retq
>
> While alternate version :
>
> cmp %gs:0x10340,%rdi
>
> (So it should be as fast as previous flag based test)
>
> Thanks
>
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/