Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8540657imu; Fri, 28 Dec 2018 21:36:18 -0800 (PST) X-Google-Smtp-Source: ALg8bN79i/Bbae+q/GG8eFfgNTge5yxaqwiflgaC8JifKoiFxX6gnS1gLi0JG+mbfq+D3t0IrefX X-Received: by 2002:a17:902:2862:: with SMTP id e89mr30532695plb.158.1546061777953; Fri, 28 Dec 2018 21:36:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546061777; cv=none; d=google.com; s=arc-20160816; b=WbW1wdDU4OoZgod5ZKtp3ThDDoT/lrY8gEb6mVHt1bA295RLayr8SjaMNw0Mh9IeEf 6mzN3Pr33e9gM4abrL8qz6l9aU4EDcXZDvvvjSbtt6Zk1tiggzYS3msHVbPmt00foZCa 473YmlEIgykr25pHprCukSpoVA/2y4nW5KuWsiyymmfMwDYVIDjUlNOlttXCU+9idiuC lKj5O5MtkJsjSEjgptaqFvtkQLEypS/XH+qWKCYqKuB6u5cRwwiDsT3hI4EPWx7hm05X 3wSoPJDe5g7r6uGbMrs/V+Gu+/MDfJpjTxPXCI2UPo5TL1/IuczaQID1xaEdX3O8C5FB mPoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=F7PYXEbho+iDCU0XXTHdMZCs4YKxu18fFx+s5fS54DI=; b=Y5ok07xaofSUw116fjj50IXlm/C2hAvvNeD0Sp45qv8rL39SZSPjsYijAPizLNXxAW lvaH97oQmgsjikkpkkGdNGadmfLg8wyTptismheZiiVHti3m3q+bS8YsqP3a/HR6HW7Z paECD1yGSb87qmjYuyU61kDZOuqsIpecOg9JBUEkywQa+VTKrsfRYdZzpbZb3/5E9ZG2 FiKhH8QgnqIfxHm82Me7lORJCH+4pFoU8PrPAp1v7sAVs/0DD4sqSLRJKcF6ZLY0zc1C HdBCkomMT/xlcvw7Vgd3mAxWMtxJ+//S+w2zzgWbFCz7mg3S3fqxTrcz6Y5zJxHa6Rnt utaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QH3jHzzv; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n2si27407932pgr.67.2018.12.28.21.36.02; Fri, 28 Dec 2018 21:36:17 -0800 (PST) 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; dkim=pass header.i=@linaro.org header.s=google header.b=QH3jHzzv; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387520AbeL1RZu (ORCPT + 99 others); Fri, 28 Dec 2018 12:25:50 -0500 Received: from mail-it1-f193.google.com ([209.85.166.193]:39704 "EHLO mail-it1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726830AbeL1RZt (ORCPT ); Fri, 28 Dec 2018 12:25:49 -0500 Received: by mail-it1-f193.google.com with SMTP id a6so27740563itl.4 for ; Fri, 28 Dec 2018 09:25:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=F7PYXEbho+iDCU0XXTHdMZCs4YKxu18fFx+s5fS54DI=; b=QH3jHzzvXCKp8rIxup+C6z5Mhy6iZowKiMDVdAveunTabeE6Kgjk/wGUnQCDI2WUwe rGGG84Fwm7JeISMDbO+ROpCKorY5+AJ3ddt3UHupAsDgqXCkLcVSa4dewVcPrQ2PPHmf K2lvQH2LN/r5JSgDpcKCEw4TeymVoFuAxW/sQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=F7PYXEbho+iDCU0XXTHdMZCs4YKxu18fFx+s5fS54DI=; b=D/v+PK0czhhejX9xsUdrIgiwd90AgI/Ry5bQE6qEWa5SBplQfJK+wXEzx7UNUFVVsF Qjcc9sHUDPN7a5ppTML676blJpjzix74lpxZ0qPwbMAK12RkXjcZt6pPPZROtZnwi0tE kAai6rAAGLT/wEvtvJ1V3AigFG1sBnpveQhIJ3XWCpPLIqup5P7qUruByuK+RBf8xjQG YG57L1bGtYtRaO+rKwfW58MziU4KyAfBA3LKLoSzciL37ut3aZwx8xKKhje20MZ20Fxn rZ64fUQUoZfJRzguNKLNVUM6CSPLfstxbvHNUtLd0igjdNUVdSCUdwtitkFTQWXAehDF OUKA== X-Gm-Message-State: AA+aEWZLuX6eFgiguOqGVYYuWI+va4TkgZfMiQNpDaWyXz2FQQ1hU+N1 lYGUZPFSohsckvWjxmr/mH3uZDgRKIHtXFtEP29wFA== X-Received: by 2002:a05:660c:a8f:: with SMTP id m15mr17901041itk.114.1546017948472; Fri, 28 Dec 2018 09:25:48 -0800 (PST) MIME-Version: 1.0 References: <20181227102107.GA21156@linaro.org> <20181228011524.GF2509588@devbig004.ftw2.facebook.com> <20181228015352.GG2509588@devbig004.ftw2.facebook.com> <20181228020243.GH2509588@devbig004.ftw2.facebook.com> <20181228165451.GJ2509588@devbig004.ftw2.facebook.com> In-Reply-To: <20181228165451.GJ2509588@devbig004.ftw2.facebook.com> From: Vincent Guittot Date: Fri, 28 Dec 2018 18:25:37 +0100 Message-ID: Subject: Re: [PATCH] sched: fix infinity loop in update_blocked_averages To: Tejun Heo Cc: Linus Torvalds , Sargun Dhillon , Xie XiuQi , Ingo Molnar , Peter Zijlstra , xiezhipeng1@huawei.com, huawei.libin@huawei.com, linux-kernel , Dmitry Adamushko , Rik van Riel Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 28 Dec 2018 at 17:54, Tejun Heo wrote: > > Hello, > > On Fri, Dec 28, 2018 at 10:30:07AM +0100, Vincent Guittot wrote: > > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > > > index d1907506318a..88b9118b5191 100644 > > > --- a/kernel/sched/fair.c > > > +++ b/kernel/sched/fair.c > > > @@ -7698,7 +7698,8 @@ static void update_blocked_averages(int cpu) > > > * There can be a lot of idle CPU cgroups. Don't let fully > > > * decayed cfs_rqs linger on the list. > > > */ > > > - if (cfs_rq_is_decayed(cfs_rq)) > > > + if (cfs_rq_is_decayed(cfs_rq) && > > > + rq->tmp_alone_branch == &rq->leaf_cfs_rq_list) > > > list_del_leaf_cfs_rq(cfs_rq); > > > > This patch reduces the cases but I don't thinks it's enough because it > > doesn't cover the case of unregister_fair_sched_group() > > And we can still break the ordering of the cfs_rq > > So, if unregister_fair_sched_group() can corrupt list, the bug is > there regardless of a9e7f6544b9ce, right? I don't think so because without a9e7f6544b9ce, the insertion in the list is done only once and we can't call unregister_fair_sched_group while an enqueue is ongoing so tmp_alone_branch always point to rq->leaf_cfs_rq_list. a9e7f6544b9ce enables to have tmp_alone_branch not pointing to rq->leaf_cfs_rq_list > > Is there a reason why we're building a dedicated list for avg > propagation? AFAICS, it's just doing depth first walk, which can be we have this list of sched group of the rq to update the load of each cfs_rq and as a result the load of the task group. This is then used to compute the share of a task group between CPUs. This list must be ordered to correctly propagate the updates from leafs to root. > done without extra space as long as each node has the parent pointer, > which they do. Is the dedicated list an optimization? It prevents to parse and walk all task group struct every time. Instead, you just have to follow a linked list Regards, Vincent > > Thanks. > > -- > tejun