From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752761AbbDTXqA (ORCPT ); Mon, 20 Apr 2015 19:46:00 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:35519 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751712AbbDTXp7 (ORCPT ); Mon, 20 Apr 2015 19:45:59 -0400 Date: Tue, 21 Apr 2015 01:45:50 +0200 From: Peter Zijlstra To: Steven Rostedt Cc: Xunlei Pang , linux-kernel@vger.kernel.org, Juri Lelli , Xunlei Pang Subject: Re: [PATCH v6 2/3] sched/rt: Fix wrong SMP scheduler behavior for equal prio cases Message-ID: <20150420234550.GA3182@worktop.meeting.verilan.com> References: <1429518168-7965-1-git-send-email-xlpang@126.com> <1429518168-7965-2-git-send-email-xlpang@126.com> <20150420105228.461e103c@gandalf.local.home> <20150420172048.GZ27490@worktop.programming.kicks-ass.net> <20150420134803.5446e32d@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150420134803.5446e32d@gandalf.local.home> User-Agent: Mutt/1.5.22.1 (2013-10-16) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 20, 2015 at 01:48:03PM -0400, Steven Rostedt wrote: > On Mon, 20 Apr 2015 19:20:48 +0200 > Peter Zijlstra wrote: > > > > > + */ > > > > + if (preempt_count() & PREEMPT_ACTIVE) > > > > + enqueue_pushable_task_preempted(rq, p); > > > > + else > > > > + enqueue_pushable_task(rq, p); > > > > + } > > > > } > > > > This looks wrong, what do you want to find? _any_ preemption? In that > > case PREEMPT_ACTIVE is wrong. What you need to check is if the task is > > still on the RQ or not. > > > > If the task was put to sleep it got dequeued, if it was not dequeued, it > > got preempted. > > > > PREEMPT_ACTIVE is only ever set for forced kernel preemption, which is a > > special sub case only ever triggered with CONFIG_PREEMPT=y. > > Ah, you're right. I was thinking of just forced preemption, but, I > wasn't thinking about voluntary preemption (preemption points). We want > this behavior for that too (for kernel). > > And yes, if we preempt in user space, this isn't enough either. > > Actually, I think we only care if the state of the task is > TASK_RUNNING, if it is anything else, the task is probably going to > sleep anyway and we don't care about FIFO order then. Please don't try and be clever there :-) Task state can be misleading, you might get a wakeup before you're running again, in which case you never went to sleep. Please use task_on_rq_queued(p) like all other sites.