From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752673AbbKPMyE (ORCPT ); Mon, 16 Nov 2015 07:54:04 -0500 Received: from casper.infradead.org ([85.118.1.10]:59910 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751697AbbKPMyA (ORCPT ); Mon, 16 Nov 2015 07:54:00 -0500 Date: Mon, 16 Nov 2015 13:53:51 +0100 From: Peter Zijlstra To: Byungchul Park 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: <20151116125351.GT17308@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> <20151109132914.GK17308@twins.programming.kicks-ass.net> <20151110010905.GD4164@byungchulpark-X58A-UD3R> <20151110121647.GZ17308@twins.programming.kicks-ass.net> <20151110235147.GE4164@byungchulpark-X58A-UD3R> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20151110235147.GE4164@byungchulpark-X58A-UD3R> 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 Wed, Nov 11, 2015 at 08:51:47AM +0900, Byungchul Park wrote: > On Tue, Nov 10, 2015 at 01:16:47PM +0100, Peter Zijlstra wrote: > > So the problem is that as soon as that ->cpu store comes through, the > > other rq->lock can happen, even though we might still hold a rq->lock > > thinking we're serialized. > > > > Take for instance move_queued_tasks(), it does: > > > > dequeue_task(rq, p, 0); > > p->on_rq = TASK_ON_RQ_MIGRATING; > > set_task_cpu(p, new_cpu) { > > __set_task_cpu(); > > > > ^^^ here holding rq->lock is insufficient and the below: > > > > p->sched_class->migrate_task_rq() > > Thank you for explaning in detail, but this's why i asked you. > Yes, rq->lock is insufficient in this place as you said, but > should migrate_task_rq() be serialized by rq->lock? I might have > agreed with you if the migrate_task_rq() should be serialized by > rq->lock, but I think it's not the case. I think it would be of > if task->pi_lock can work correcly within *if statement* in > set_task_cpu(). Wrong? So currently, set_task_cpu() is serialized by: - p->pi_lock; on wakeup - rq->lock; otherwise (see the #ifdef CONFIG_LOCKDEP comment in set_task_cpu()) This means that sched_class::migrate_task() cannot indeed rely on rq->lock for full serialization, however it still means that task_rq_lock() will fully serialize against the thing. By changing this, it no longer will. Even without that; I think such a change, if correct, is very fragile and prone to creating problems later on, and sets bad precedent.