Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp4287949imc; Thu, 14 Mar 2019 17:44:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqxRKaMDTEU2E/47YIhCwvdTU1UGaC51IPlkenYtYEaKs8DR+JKl/n7QUd0eTf4M7rv8/fSX X-Received: by 2002:a17:902:9a95:: with SMTP id w21mr1221670plp.118.1552610656248; Thu, 14 Mar 2019 17:44:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552610656; cv=none; d=google.com; s=arc-20160816; b=hOQOkuVTh6dkbmio68p9e50D7JqgRoOhGXHaoj5otZVpl274w/DU+zrv8PL52MV8D9 i4Ha3m4IGWB6Q41p8AqUV+h/amSsw5et1wo0w3eiyvWFWzHvav/YaSRgu1ioIlHj3imm UOSGF8GkgxTbaRn2nT91BToB3U0BdwdQ2GrRbODp0Qx6D2cVFN098B7mtDkG+Vffqb8z KfM95aq+bilYf06vnwpU0sv3m4Ue+ibMdvHoN54MVVdEwX3L9u4JSwrEu8pg2zsIB/Iu kRJ1Ku5iBIuutOtX7hdJd08FD0lVIHiEaxxoY/KETQiKe9+Og7pOroivLYXoqwVBmwv9 Q85w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=JB9jscts8kzK4p600VjcsL8ub7M1GwE2+klmg+TlIf8=; b=RvgV1RVo9QeqIipAacwiHG5P63XlQ+bI/aopSJxM2Hjq/feRISdFLpkmt8OSzcIK11 IpMGh1KEhlMHW5QRUh9XClIbNp2BqAuw+cwB9cikZ0SyrAU+ANamBGjQQIAc7ClpZaX4 O7ziT1fWSdYnIBuLBYZIB6EfJXCipnOEQETx3JSsJG4Bgw1F3r+8Yn0ZO4cYAE3MGIqF chXO4I3oWyfWGuWVQI3eCBR+op7NbFluTVtnQ/9cjVnyr+kHcyQ087L1H24dkOIssUg+ /h2JEcdbq20r5QPWsDgcwRwzQt71LTP0z6ZL5xcSVZDBZRy/VRmVdHZaRPpJjiUojtzj +jMg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 34si364636plz.256.2019.03.14.17.43.59; Thu, 14 Mar 2019 17:44:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727642AbfCOAnW (ORCPT + 99 others); Thu, 14 Mar 2019 20:43:22 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:4683 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727254AbfCOAnV (ORCPT ); Thu, 14 Mar 2019 20:43:21 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 06BCC734732244197B04; Fri, 15 Mar 2019 08:43:19 +0800 (CST) Received: from [127.0.0.1] (10.184.38.59) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.408.0; Fri, 15 Mar 2019 08:43:08 +0800 Subject: Re: WARN ON at kernel/sched/deadline.c task_non_contending To: luca abeni CC: "linux-kernel@vger.kernel.org" , Li Bin , "Xiexiuqi (Xie XiuQi)" , , Peter Zijlstra , Juri Lelli References: <20190313154948.773427d6@luca64> From: "chengjian (D)" Message-ID: <0032cd53-05b4-002a-6860-62b51e9e8299@huawei.com> Date: Fri, 15 Mar 2019 08:43:00 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.5.2 MIME-Version: 1.0 In-Reply-To: <20190313154948.773427d6@luca64> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Originating-IP: [10.184.38.59] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019/3/13 22:49, luca abeni wrote: > Hi, > > After looking at the patch a little bit more and running some tests, > I suspect this solution might be racy: > when the timer is already active, (and hrtimer_start() fails), it > relies on its handler to decrease the running bw (by setting > dl_non_contending to 1)... But inactive_task_timer() might have > already checked dl_non_contending, finding it equal to 0 (so, it > ends up doing nothing and the running bw is not decreased). > > > So, I would prefer a different solution. I think this patch should work: > > diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c > index 6a73e41a2016..43901fa3f269 100644 > --- a/kernel/sched/deadline.c > +++ b/kernel/sched/deadline.c > @@ -252,7 +252,6 @@ static void task_non_contending(struct task_struct *p) > if (dl_entity_is_special(dl_se)) > return; > > - WARN_ON(hrtimer_active(&dl_se->inactive_timer)); > WARN_ON(dl_se->dl_non_contending); > > zerolag_time = dl_se->deadline - > @@ -269,7 +268,7 @@ static void task_non_contending(struct task_struct *p) > * If the "0-lag time" already passed, decrease the active > * utilization now, instead of starting a timer > */ > - if (zerolag_time < 0) { > + if ((zerolag_time < 0) || hrtimer_active(&dl_se->inactive_timer)) { > if (dl_task(p)) > sub_running_bw(dl_se, dl_rq); > if (!dl_task(p) || p->state == TASK_DEAD) { > > > The idea is that if the timer is active, we leave dl_non_contending set to > 0 (so that the timer handler does nothing), and we immediately decrease the > running bw. > I think this is OK, because this situation can happen only if the task > blocks, wakes up while the timer handler is running, and then immediately > blocks again - while the timer handler is still running. So, the "zero lag > time" cannot be too much in the future. > > > Thanks, > Luca > > . Yeah, it looks good. I can do some experiments with it , Do you have some testcases to help me with the test ? Thanks,     Cheng Jian.