From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753910AbcDTNpc (ORCPT ); Wed, 20 Apr 2016 09:45:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49643 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751520AbcDTNpb (ORCPT ); Wed, 20 Apr 2016 09:45:31 -0400 Reply-To: xlpang@redhat.com Subject: Re: [PATCH v3 5/6] sched/deadline/rtmutex: Fix unprotected PI access in enqueue_task_dl() References: <1460633827-345-1-git-send-email-xlpang@redhat.com> <1460633827-345-6-git-send-email-xlpang@redhat.com> <20160414153111.GC2975@worktop.cust.blueprintrf.com> <57104ADB.20402@redhat.com> <57104FA0.4090509@redhat.com> <20160420122552.GY3430@twins.programming.kicks-ass.net> <57177D70.10504@redhat.com> <20160420131737.GB3430@twins.programming.kicks-ass.net> To: Peter Zijlstra , xlpang@redhat.com Cc: linux-kernel@vger.kernel.org, Thomas Gleixner , Juri Lelli , Ingo Molnar , Steven Rostedt From: Xunlei Pang Message-ID: <571787F7.3020609@redhat.com> Date: Wed, 20 Apr 2016 21:45:27 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <20160420131737.GB3430@twins.programming.kicks-ass.net> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2016/04/20 at 21:17, Peter Zijlstra wrote: > On Wed, Apr 20, 2016 at 09:00:32PM +0800, Xunlei Pang wrote: > >>> But what happens? How is it changed when it is blocked? >> The top waiter's policy can be changed by other tasks through sched_setattr() syscall during it was blocked. >> I created another thread doing the following thing: >> while (1) { >> change the waiter to cfs >> do something >> change the waiter to deadline >> } > Indeed; so why didn't you say that? That is the single most important > thing in the Changelog -- the _actual_ problem, and you left it out. Sorry, the changelog mentioned a little, I should describe it in detail. > > I'm not quite sure how to go fix that best, but copying the state is not > right. That precludes being able to change the state. The patch updates the copy everytime the waiter's policy/runtime/period are changed. The calling path is rt_mutex_setprio()->rt_mutex_update_copy(), so it can change very soon after __sched_setscheduler()->rt_mutex_adjust_pi() is made, also PATCH6 forces to make the update for deadline cases. This is not acceptable? Regards, Xunlei > > There's two (obvious but) rather ugly solutions: > > - delay the __sched_setscheduler() call until such a time that the task > is no longer the top waiter. > > - deboost + __sched_setscheduler() + boost > > Both have a different set of problems, but both keep the p->pi_task > pointer and its state 'stable'. > >