public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Shrink the held_lock struct by using bitfields.
@ 2007-01-02 23:35 Dave Jones
  2007-01-02 23:38 ` Dave Jones
  0 siblings, 1 reply; 5+ messages in thread
From: Dave Jones @ 2007-01-02 23:35 UTC (permalink / raw)
  To: mingo; +Cc: Linux Kernel

Shrink the held_lock struct by using bitfields.
This shrinks task_struct on lockdep enabled kernels by 480 bytes.

Signed-off-by: Dave Jones <davej@redhat.com>

diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h
index ea097dd..ba81cce 100644
--- a/include/linux/lockdep.h
+++ b/include/linux/lockdep.h
@@ -175,11 +175,11 @@ struct held_lock {
 	 * The following field is used to detect when we cross into an
 	 * interrupt context:
 	 */
-	int				irq_context;
-	int				trylock;
-	int				read;
-	int				check;
-	int				hardirqs_off;
+	unsigned char irq_context:1;
+	unsigned char trylock:1;
+	unsigned char read:1;
+	unsigned char check:1;
+	unsigned char hardirqs_off:1;
 };
 
 /*

-- 
http://www.codemonkey.org.uk

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

* Re: Shrink the held_lock struct by using bitfields.
  2007-01-02 23:35 Dave Jones
@ 2007-01-02 23:38 ` Dave Jones
  2007-01-14 18:45   ` Ingo Molnar
  0 siblings, 1 reply; 5+ messages in thread
From: Dave Jones @ 2007-01-02 23:38 UTC (permalink / raw)
  To: mingo, Linux Kernel

On Tue, Jan 02, 2007 at 06:35:58PM -0500, Dave Jones wrote:

Sent the wrong diff.  Here's the fixed version...



Shrink the held_lock struct by using bitfields.
This shrinks task_struct on lockdep enabled kernels by 480 bytes.

Signed-off-by: Dave Jones <davej@redhat.com>

diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h
index ea097dd..ba81cce 100644
--- a/include/linux/lockdep.h
+++ b/include/linux/lockdep.h
@@ -175,11 +175,11 @@ struct held_lock {
 	 * The following field is used to detect when we cross into an
 	 * interrupt context:
 	 */
-	int				irq_context;
-	int				trylock;
-	int				read;
-	int				check;
-	int				hardirqs_off;
+	unsigned char irq_context:1;
+	unsigned char trylock:1;
+	unsigned char read:2;
+	unsigned char check:1;
+	unsigned char hardirqs_off:1;
 };
 
 /*

-- 
http://www.codemonkey.org.uk

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

* Re: Shrink the held_lock struct by using bitfields.
       [not found] <7z1oG-6Jr-5@gated-at.bofh.it>
@ 2007-01-03  0:47 ` Bodo Eggert
  2007-01-03  1:06   ` Dave Jones
  0 siblings, 1 reply; 5+ messages in thread
From: Bodo Eggert @ 2007-01-03  0:47 UTC (permalink / raw)
  To: Dave Jones, mingo, Linux Kernel

Dave Jones <davej@redhat.com> wrote:

> Shrink the held_lock struct by using bitfields.
> This shrinks task_struct on lockdep enabled kernels by 480 bytes.

>  * The following field is used to detect when we cross into an
>  * interrupt context:
>  */
> -     int                             irq_context;
[...]
> +     unsigned char irq_context:1;
[...]

Can these fields be set by concurrent processes, e.g.:
CPU0        CPU1
load flags
            load flags
            flip bit
            store
flip bit
store

?
-- 
Ich danke GMX dafür, die Verwendung meiner Adressen mittels per SPF
verbreiteten Lügen zu sabotieren.

http://david.woodhou.se/why-not-spf.html

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

* Re: Shrink the held_lock struct by using bitfields.
  2007-01-03  0:47 ` Shrink the held_lock struct by using bitfields Bodo Eggert
@ 2007-01-03  1:06   ` Dave Jones
  0 siblings, 0 replies; 5+ messages in thread
From: Dave Jones @ 2007-01-03  1:06 UTC (permalink / raw)
  To: Bodo Eggert; +Cc: mingo, Linux Kernel

On Wed, Jan 03, 2007 at 01:47:36AM +0100, Bodo Eggert wrote:
 > Dave Jones <davej@redhat.com> wrote:
 > 
 > > Shrink the held_lock struct by using bitfields.
 > > This shrinks task_struct on lockdep enabled kernels by 480 bytes.
 > 
 > >  * The following field is used to detect when we cross into an
 > >  * interrupt context:
 > >  */
 > > -     int                             irq_context;
 > [...]
 > > +     unsigned char irq_context:1;
 > [...]
 > 
 > Can these fields be set by concurrent processes, e.g.:
 > CPU0        CPU1
 > load flags
 >             load flags
 >             flip bit
 >             store
 > flip bit
 > store

It's a per-process structure.

		Dave

-- 
http://www.codemonkey.org.uk

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

* Re: Shrink the held_lock struct by using bitfields.
  2007-01-02 23:38 ` Dave Jones
@ 2007-01-14 18:45   ` Ingo Molnar
  0 siblings, 0 replies; 5+ messages in thread
From: Ingo Molnar @ 2007-01-14 18:45 UTC (permalink / raw)
  To: Dave Jones; +Cc: Linux Kernel, mingo

On Tue, 2007-01-02 at 18:38 -0500, Dave Jones wrote:
> +       unsigned char irq_context:1;
> +       unsigned char trylock:1;
> +       unsigned char read:2;
> +       unsigned char check:1;
> +       unsigned char hardirqs_off:1; 

cool! I totally missed those. I'd even do this for 2.6.20, but it's
probably too late for that.

Acked-by: Ingo Molnar <mingo@redhat.com>

	Ingo


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

end of thread, other threads:[~2007-01-14 18:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <7z1oG-6Jr-5@gated-at.bofh.it>
2007-01-03  0:47 ` Shrink the held_lock struct by using bitfields Bodo Eggert
2007-01-03  1:06   ` Dave Jones
2007-01-02 23:35 Dave Jones
2007-01-02 23:38 ` Dave Jones
2007-01-14 18:45   ` Ingo Molnar

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