From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751993AbbKIN3W (ORCPT ); Mon, 9 Nov 2015 08:29:22 -0500 Received: from casper.infradead.org ([85.118.1.10]:46927 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751168AbbKIN3T (ORCPT ); Mon, 9 Nov 2015 08:29:19 -0500 Date: Mon, 9 Nov 2015 14:29:14 +0100 From: Peter Zijlstra To: byungchul.park@lge.com Cc: mingo@kernel.org, linux-kernel@vger.kernel.org, yuyang.du@intel.com, pjt@google.com, efault@gmx.de, tglx@linutronix.de Subject: Re: [PATCH v4 3/3] sched: optimize migration by forcing rmb() and updating to be called once Message-ID: <20151109132914.GK17308@twins.programming.kicks-ass.net> References: <1445616981-29904-1-git-send-email-byungchul.park@lge.com> <1445616981-29904-4-git-send-email-byungchul.park@lge.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1445616981-29904-4-git-send-email-byungchul.park@lge.com> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Oct 24, 2015 at 01:16:21AM +0900, byungchul.park@lge.com wrote: > +++ b/kernel/sched/core.c > @@ -1264,6 +1264,8 @@ EXPORT_SYMBOL_GPL(set_cpus_allowed_ptr); > > void set_task_cpu(struct task_struct *p, unsigned int new_cpu) > { > + unsigned int prev_cpu = task_cpu(p); > + > #ifdef CONFIG_SCHED_DEBUG > /* > * We should never call set_task_cpu() on a blocked task, > @@ -1289,15 +1291,14 @@ void set_task_cpu(struct task_struct *p, unsigned int new_cpu) > #endif > > trace_sched_migrate_task(p, new_cpu); > + __set_task_cpu(p, new_cpu); > > - if (task_cpu(p) != new_cpu) { > + if (prev_cpu != new_cpu) { > if (p->sched_class->migrate_task_rq) > - p->sched_class->migrate_task_rq(p, new_cpu); > + p->sched_class->migrate_task_rq(p, prev_cpu); > p->se.nr_migrations++; > perf_event_task_migrate(p); > } > - > - __set_task_cpu(p, new_cpu); > } I don't think this is safe, see the comment in __set_task_cpu(). We want that to be last.