linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Move mostly read variables to __read_mostly section.
@ 2011-10-23 18:23 Eial Czerwacki
  2011-10-24  4:47 ` Andi Kleen
  0 siblings, 1 reply; 3+ messages in thread
From: Eial Czerwacki @ 2011-10-23 18:23 UTC (permalink / raw)
  To: linux-kernel; +Cc: Shai Fultheim (Shai@ScaleMP.com)


Move mostly read variables to __read_mostly section.

Signed-off-by: Eial Czerwacki<eial@ScaleMP.com>
Signed-off-by: Shai Fultheim<Shai@ScaleMP.com>
---

--- a/fs/buffer.c	2010-05-12 14:59:32.000000000 -0700
+++ b/fs/buffer.c	2010-05-24 11:56:32.000000000 -0700
@@ -3233,7 +3233,7 @@ SYSCALL_DEFINE2(bdflush, int, func, long
  /*
   * Buffer-head allocation
   */
-static struct kmem_cache *bh_cachep;
+static struct kmem_cache __read_mostly *bh_cachep;

  /*
   * Once the number of bh's in the machine exceeds this level, we start
--- a/kernel/time/timekeeping.c	2010-05-12 14:59:32.000000000 -0700
+++ b/kernel/time/timekeeping.c	2010-05-24 11:56:32.000000000 -0700
@@ -154,7 +154,7 @@ __cacheline_aligned_in_smp DEFINE_SEQLOC
   * used instead.
   */
  static struct timespec xtime __attribute__ ((aligned (16)));
-static struct timespec wall_to_monotonic __attribute__ ((aligned (16)));
+static struct timespec wall_to_monotonic __attribute__ ((aligned (16))) __read_mostly;
  static struct timespec total_sleep_time;

  /*




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

* Re: [PATCH] Move mostly read variables to __read_mostly section.
  2011-10-23 18:23 [PATCH] Move mostly read variables to __read_mostly section Eial Czerwacki
@ 2011-10-24  4:47 ` Andi Kleen
  2011-10-25  7:25   ` Eial Czerwacki
  0 siblings, 1 reply; 3+ messages in thread
From: Andi Kleen @ 2011-10-24  4:47 UTC (permalink / raw)
  To: Eial Czerwacki; +Cc: linux-kernel, Shai Fultheim (Shai@ScaleMP.com)

Eial Czerwacki <eial@scalemp.com> writes:
>   * Once the number of bh's in the machine exceeds this level, we start
> --- a/kernel/time/timekeeping.c	2010-05-12 14:59:32.000000000 -0700
> +++ b/kernel/time/timekeeping.c	2010-05-24 11:56:32.000000000 -0700
> @@ -154,7 +154,7 @@ __cacheline_aligned_in_smp DEFINE_SEQLOC
>   * used instead.
>   */
>  static struct timespec xtime __attribute__ ((aligned (16)));
> -static struct timespec wall_to_monotonic __attribute__ ((aligned (16)));
> +static struct timespec wall_to_monotonic __attribute__ ((aligned
>   (16))) __read_mostly;

That means that a common time fetch/update call will usually have to fetch two
cachelines now instead of one, because it needs xtime and
wall_to_monotonic. Usually those end up nearby.

On the other hand it's rare to fetch wall_to_monotonic without xtime.

So if anything all those variables should be grouped together in a
single cacheline, but definitely not split like you do.

The other changes in your patch are fine for me.

-Andi
-- 
ak@linux.intel.com -- Speaking for myself only

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

* Re: [PATCH] Move mostly read variables to __read_mostly section.
  2011-10-24  4:47 ` Andi Kleen
@ 2011-10-25  7:25   ` Eial Czerwacki
  0 siblings, 0 replies; 3+ messages in thread
From: Eial Czerwacki @ 2011-10-25  7:25 UTC (permalink / raw)
  To: Andi Kleen; +Cc: linux-kernel, Shai Fultheim (Shai@ScaleMP.com)

On 10/24/2011 06:47 AM, Andi Kleen wrote:
> Eial Czerwacki<eial@scalemp.com>  writes:
>>    * Once the number of bh's in the machine exceeds this level, we start
>> --- a/kernel/time/timekeeping.c	2010-05-12 14:59:32.000000000 -0700
>> +++ b/kernel/time/timekeeping.c	2010-05-24 11:56:32.000000000 -0700
>> @@ -154,7 +154,7 @@ __cacheline_aligned_in_smp DEFINE_SEQLOC
>>    * used instead.
>>    */
>>   static struct timespec xtime __attribute__ ((aligned (16)));
>> -static struct timespec wall_to_monotonic __attribute__ ((aligned (16)));
>> +static struct timespec wall_to_monotonic __attribute__ ((aligned
>>    (16))) __read_mostly;
>
> That means that a common time fetch/update call will usually have to fetch two
> cachelines now instead of one, because it needs xtime and
> wall_to_monotonic. Usually those end up nearby.
>
> On the other hand it's rare to fetch wall_to_monotonic without xtime.
>
> So if anything all those variables should be grouped together in a
> single cacheline, but definitely not split like you do.
>
> The other changes in your patch are fine for me.
>
> -Andi
Hello Andi,

Thanks for the input, we've removed the mentioned above section from the 
patch and it will be handled in a different patch.

the new patch is as follows:

Signed-off-by: Eial Czerwacki<eial@ScaleMP.com>
Signed-off-by: Shai Fultheim<Shai@ScaleMP.com>
---

--- a/fs/buffer.c	2010-05-12 14:59:32.000000000 -0700
+++ b/fs/buffer.c	2010-05-24 11:56:32.000000000 -0700
@@ -3233,7 +3233,7 @@ SYSCALL_DEFINE2(bdflush, int, func, long
  /*
   * Buffer-head allocation
   */
-static struct kmem_cache *bh_cachep;
+static struct kmem_cache __read_mostly *bh_cachep;

  /*
   * Once the number of bh's in the machine exceeds this level, we start



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

end of thread, other threads:[~2011-10-25  7:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-23 18:23 [PATCH] Move mostly read variables to __read_mostly section Eial Czerwacki
2011-10-24  4:47 ` Andi Kleen
2011-10-25  7:25   ` Eial Czerwacki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).