Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754066AbcDAMYE (ORCPT ); Fri, 1 Apr 2016 08:24:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51005 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753274AbcDAMYC (ORCPT ); Fri, 1 Apr 2016 08:24:02 -0400 Reply-To: xlpang@redhat.com Subject: Re: [PATCH] sched/deadline/rtmutex: Fix a PI crash for deadline tasks References: <1459508418-25577-1-git-send-email-xlpang@redhat.com> <20160401113827.GQ3430@twins.programming.kicks-ass.net> To: Peter Zijlstra , Xunlei Pang Cc: linux-kernel@vger.kernel.org, Juri Lelli , Ingo Molnar , Steven Rostedt From: Xunlei Pang Message-ID: <56FE685E.6080001@redhat.com> Date: Fri, 1 Apr 2016 20:23:58 +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: <20160401113827.GQ3430@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 Content-Length: 2185 Lines: 48 On 2016/04/01 at 19:38, Peter Zijlstra wrote: > On Fri, Apr 01, 2016 at 07:00:18PM +0800, Xunlei Pang wrote: >> I found a kernel crash while playing with deadline PI rtmutex. >> >> BUG: unable to handle kernel NULL pointer dereference at 0000000000000018 >> IP: [] rt_mutex_get_top_task+0x1f/0x30 >> PGD 232a75067 PUD 230947067 PMD 0 >> Oops: 0000 [#1] SMP >> CPU: 1 PID: 10994 Comm: a.out Not tainted >> >> Call Trace: >> [] ? enqueue_task_dl+0x2a/0x320 >> [] enqueue_task+0x2c/0x80 >> [] activate_task+0x23/0x30 >> [] pull_dl_task+0x1d5/0x260 >> [] pre_schedule_dl+0x16/0x20 >> [] __schedule+0xd3/0x900 >> [] schedule+0x29/0x70 >> [] __rt_mutex_slowlock+0x4b/0xc0 >> [] rt_mutex_slowlock+0xd1/0x190 >> [] rt_mutex_timed_lock+0x53/0x60 >> [] futex_lock_pi.isra.18+0x28c/0x390 >> [] ? enqueue_task_dl+0x195/0x320 >> [] ? prio_changed_dl+0x6c/0x90 >> [] do_futex+0x190/0x5b0 >> [] SyS_futex+0x80/0x180 >> [] system_call_fastpath+0x16/0x1b >> RIP [] rt_mutex_get_top_task+0x1f/0x30 >> >> This is because rt_mutex_enqueue_pi() and rt_mutex_dequeue_pi() >> are only protected by pi_lock when operating pi waiters, while >> rt_mutex_get_top_task() will access them with rq lock held but >> not holding pi_lock. >> >> It's hard for rt_mutex_get_top_task() to hold pi_lock, so the >> patch ensures rt_mutex_enqueue_pi() and rt_mutex_dequeue_pi() >> lock rq when operating "pi_waiters" and "pi_waiters_leftmost". >> We need this iff lock owner has the deadline priority. > How is this deadline specific, those functions you modify are > deadline/rt agnostic. I checked the code, currently only deadline accesses the pi_waiters/pi_waiters_leftmost without pi_lock held via rt_mutex_get_top_task(), other cases all have pi_lock held. So adding the condition. Regards, Xunlei