public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/3] workqueues: microoptimize set_wq_data()
@ 2010-02-24 20:20 Oleg Nesterov
  2010-02-25  3:10 ` Tejun Heo
  0 siblings, 1 reply; 5+ messages in thread
From: Oleg Nesterov @ 2010-02-24 20:20 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Dmitry Torokhov, Samu Onkalo, Tejun Heo, linux-kernel

The comment correctly states that the _PENDING bit must be set and
we even have the BUG_ON() check. But this means there is no need to
set WORK_STRUCT_PENDING explicitely and load work_data_bits() twice,
we can rely on WORK_STRUCT_FLAG_MASK which contains _PENDING.

Shaves 32 bytes from workqueue.o.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---

 kernel/workqueue.c |    7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

--- wq/kernel/workqueue.c~2_CLEANUP_SET_DATA	2010-02-24 20:55:53.000000000 +0100
+++ wq/kernel/workqueue.c	2010-02-24 20:58:37.000000000 +0100
@@ -220,12 +220,9 @@ struct cpu_workqueue_struct *wq_per_cpu(
 static inline void set_wq_data(struct work_struct *work,
 				struct cpu_workqueue_struct *cwq)
 {
-	unsigned long new;
-
-	BUG_ON(!work_pending(work));
-
-	new = (unsigned long) cwq | (1UL << WORK_STRUCT_PENDING);
+	unsigned long new = (unsigned long)cwq;
 	new |= WORK_STRUCT_FLAG_MASK & *work_data_bits(work);
+	BUG_ON(!(new & (1UL << WORK_STRUCT_PENDING)));
 	atomic_long_set(&work->data, new);
 }
 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/3] workqueues: microoptimize set_wq_data()
  2010-02-24 20:20 [PATCH 2/3] workqueues: microoptimize set_wq_data() Oleg Nesterov
@ 2010-02-25  3:10 ` Tejun Heo
  2010-02-25 10:27   ` Tejun Heo
  0 siblings, 1 reply; 5+ messages in thread
From: Tejun Heo @ 2010-02-25  3:10 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: Andrew Morton, Dmitry Torokhov, Samu Onkalo, linux-kernel

On 02/25/2010 05:20 AM, Oleg Nesterov wrote:
> The comment correctly states that the _PENDING bit must be set and
> we even have the BUG_ON() check. But this means there is no need to
> set WORK_STRUCT_PENDING explicitely and load work_data_bits() twice,
> we can rely on WORK_STRUCT_FLAG_MASK which contains _PENDING.
> 
> Shaves 32 bytes from workqueue.o.
> 
> Signed-off-by: Oleg Nesterov <oleg@redhat.com>
> ---
> 
>  kernel/workqueue.c |    7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> --- wq/kernel/workqueue.c~2_CLEANUP_SET_DATA	2010-02-24 20:55:53.000000000 +0100
> +++ wq/kernel/workqueue.c	2010-02-24 20:58:37.000000000 +0100
> @@ -220,12 +220,9 @@ struct cpu_workqueue_struct *wq_per_cpu(
>  static inline void set_wq_data(struct work_struct *work,
>  				struct cpu_workqueue_struct *cwq)
>  {
> -	unsigned long new;
> -
> -	BUG_ON(!work_pending(work));
> -
> -	new = (unsigned long) cwq | (1UL << WORK_STRUCT_PENDING);
> +	unsigned long new = (unsigned long)cwq;
>  	new |= WORK_STRUCT_FLAG_MASK & *work_data_bits(work);
> +	BUG_ON(!(new & (1UL << WORK_STRUCT_PENDING)));
>  	atomic_long_set(&work->data, new);

Will apply under cmwq patches for the next merge window.

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/3] workqueues: microoptimize set_wq_data()
  2010-02-25  3:10 ` Tejun Heo
@ 2010-02-25 10:27   ` Tejun Heo
  2010-02-25 13:55     ` Oleg Nesterov
  0 siblings, 1 reply; 5+ messages in thread
From: Tejun Heo @ 2010-02-25 10:27 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: Andrew Morton, Dmitry Torokhov, Samu Onkalo, linux-kernel

Hello, again.

On 02/25/2010 12:10 PM, Tejun Heo wrote:
>> @@ -220,12 +220,9 @@ struct cpu_workqueue_struct *wq_per_cpu(
>>  static inline void set_wq_data(struct work_struct *work,
>>  				struct cpu_workqueue_struct *cwq)
>>  {
>> -	unsigned long new;
>> -
>> -	BUG_ON(!work_pending(work));
>> -
>> -	new = (unsigned long) cwq | (1UL << WORK_STRUCT_PENDING);
>> +	unsigned long new = (unsigned long)cwq;
>>  	new |= WORK_STRUCT_FLAG_MASK & *work_data_bits(work);
>> +	BUG_ON(!(new & (1UL << WORK_STRUCT_PENDING)));
>>  	atomic_long_set(&work->data, new);
> 
> Will apply under cmwq patches for the next merge window.

Turns out I already have a patch which kills the second
work_data_bits() dereferencing in the series.  The first one is now in
the cmwq series which is about to be posted again.

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/3] workqueues: microoptimize set_wq_data()
  2010-02-25 10:27   ` Tejun Heo
@ 2010-02-25 13:55     ` Oleg Nesterov
  2010-02-25 15:16       ` Tejun Heo
  0 siblings, 1 reply; 5+ messages in thread
From: Oleg Nesterov @ 2010-02-25 13:55 UTC (permalink / raw)
  To: Tejun Heo; +Cc: Andrew Morton, Dmitry Torokhov, Samu Onkalo, linux-kernel

Hi,

On 02/25, Tejun Heo wrote:
>
> Hello, again.
>
> On 02/25/2010 12:10 PM, Tejun Heo wrote:
> >> @@ -220,12 +220,9 @@ struct cpu_workqueue_struct *wq_per_cpu(
> >>  static inline void set_wq_data(struct work_struct *work,
> >>  				struct cpu_workqueue_struct *cwq)
> >>  {
> >> -	unsigned long new;
> >> -
> >> -	BUG_ON(!work_pending(work));
> >> -
> >> -	new = (unsigned long) cwq | (1UL << WORK_STRUCT_PENDING);
> >> +	unsigned long new = (unsigned long)cwq;
> >>  	new |= WORK_STRUCT_FLAG_MASK & *work_data_bits(work);
> >> +	BUG_ON(!(new & (1UL << WORK_STRUCT_PENDING)));
> >>  	atomic_long_set(&work->data, new);
> >
> > Will apply under cmwq patches for the next merge window.
>
> Turns out I already have a patch which kills the second
> work_data_bits() dereferencing in the series.  The first one is now in
> the cmwq series which is about to be posted again.

OK, good.

Tejun, where can I find your cmwq patches? I'd like to take a look.

Thanks,

Oleg.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/3] workqueues: microoptimize set_wq_data()
  2010-02-25 13:55     ` Oleg Nesterov
@ 2010-02-25 15:16       ` Tejun Heo
  0 siblings, 0 replies; 5+ messages in thread
From: Tejun Heo @ 2010-02-25 15:16 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: Andrew Morton, Dmitry Torokhov, Samu Onkalo, linux-kernel

Hello,

On 02/25/2010 10:55 PM, Oleg Nesterov wrote:
>> Turns out I already have a patch which kills the second
>> work_data_bits() dereferencing in the series.  The first one is now in
>> the cmwq series which is about to be posted again.
> 
> OK, good.
> 
> Tejun, where can I find your cmwq patches? I'd like to take a look.

The third take was about a month ago.

  http://thread.gmane.org/gmane.linux.kernel/939353

The fourth take is just around the corner.

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-02-25 15:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-24 20:20 [PATCH 2/3] workqueues: microoptimize set_wq_data() Oleg Nesterov
2010-02-25  3:10 ` Tejun Heo
2010-02-25 10:27   ` Tejun Heo
2010-02-25 13:55     ` Oleg Nesterov
2010-02-25 15:16       ` Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox