From mboxrd@z Thu Jan 1 00:00:00 1970 From: Glauber Costa Subject: Re: [patch 06/16] sched: add notifier for cross-cpu migrations Date: Thu, 1 Nov 2012 18:08:58 +0400 Message-ID: <5092827A.7040903@parallels.com> References: <20121031224656.417434866@redhat.com> <20121031224824.098925573@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit Cc: , , , , , , , Peter Zijlstra To: Marcelo Tosatti Return-path: Received: from mx2.parallels.com ([64.131.90.16]:55753 "EHLO mx2.parallels.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756011Ab2KAOJI (ORCPT ); Thu, 1 Nov 2012 10:09:08 -0400 In-Reply-To: <20121031224824.098925573@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 11/01/2012 02:47 AM, Marcelo Tosatti wrote: > Originally from Jeremy Fitzhardinge. > > Signed-off-by: Marcelo Tosatti > Please collect peterz's ack for this one. > Index: vsyscall/include/linux/sched.h > =================================================================== > --- vsyscall.orig/include/linux/sched.h > +++ vsyscall/include/linux/sched.h > @@ -107,6 +107,14 @@ extern unsigned long this_cpu_load(void) > extern void calc_global_load(unsigned long ticks); > extern void update_cpu_load_nohz(void); > > +/* Notifier for when a task gets migrated to a new CPU */ > +struct task_migration_notifier { > + struct task_struct *task; > + int from_cpu; > + int to_cpu; > +}; > +extern void register_task_migration_notifier(struct notifier_block *n); > + > extern unsigned long get_parent_ip(unsigned long addr); > > struct seq_file; > Index: vsyscall/kernel/sched/core.c > =================================================================== > --- vsyscall.orig/kernel/sched/core.c > +++ vsyscall/kernel/sched/core.c > @@ -922,6 +922,13 @@ void check_preempt_curr(struct rq *rq, s > rq->skip_clock_update = 1; > } > > +static ATOMIC_NOTIFIER_HEAD(task_migration_notifier); > + > +void register_task_migration_notifier(struct notifier_block *n) > +{ > + atomic_notifier_chain_register(&task_migration_notifier, n); > +} > + > #ifdef CONFIG_SMP > void set_task_cpu(struct task_struct *p, unsigned int new_cpu) > { > @@ -952,8 +959,16 @@ void set_task_cpu(struct task_struct *p, > trace_sched_migrate_task(p, new_cpu); > > if (task_cpu(p) != new_cpu) { > + struct task_migration_notifier tmn; > + > p->se.nr_migrations++; > perf_sw_event(PERF_COUNT_SW_CPU_MIGRATIONS, 1, NULL, 0); > + > + tmn.task = p; > + tmn.from_cpu = task_cpu(p); > + tmn.to_cpu = new_cpu; > + > + atomic_notifier_call_chain(&task_migration_notifier, 0, &tmn); > } > > __set_task_cpu(p, new_cpu); > >