lkml.org 
[lkml]   [2009]   [Dec]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [mmotm][PATCH 2/5] mm : avoid false sharing on mm_counter
On Tue, 15 Dec 2009, KAMEZAWA Hiroyuki wrote:

> #if USE_SPLIT_PTLOCKS
> +#define SPLIT_RSS_COUNTING
> struct mm_rss_stat {
> atomic_long_t count[NR_MM_COUNTERS];
> };
> +/* per-thread cached information, */
> +struct task_rss_stat {
> + int events; /* for synchronization threshold */

Why count events? Just always increment the task counters and fold them
at appropriate points into mm_struct. Or get rid of the mm_struct counters
and only sum them up on the fly if needed?

Add a pointer to thread rss_stat structure to mm_struct and remove the
counters? If the task has only one thread then the pointer points to the
accurate data (most frequent case). Otherwise it can be NULL and then we
calculate it on the fly?

> +static void add_mm_counter_fast(struct mm_struct *mm, int member, int val)
> +{
> + struct task_struct *task = current;
> +
> + if (likely(task->mm == mm))
> + task->rss_stat.count[member] += val;
> + else
> + add_mm_counter(mm, member, val);
> +}
> +#define inc_mm_counter_fast(mm, member) add_mm_counter_fast(mm, member,1)
> +#define dec_mm_counter_fast(mm, member) add_mm_counter_fast(mm, member,-1)
> +

Code will be much simpler if you always increment the task counts.



\
 
 \ /
  Last update: 2009-12-15 16:27    [W:0.301 / U:0.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site