Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp117703pxx; Mon, 26 Oct 2020 04:54:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjnqF4cP4WeT+m6D3g7CqM1CCZD5E0qaP4NT706UCmrlzS5qXFUFdtoFamD3ESgUGcTZ+j X-Received: by 2002:a17:906:bc4b:: with SMTP id s11mr15745617ejv.437.1603713297535; Mon, 26 Oct 2020 04:54:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603713297; cv=none; d=google.com; s=arc-20160816; b=Lf3nfjpMx7wLHVrHmpIxI6bjWW9ePQb+hlPM7AHZ+DV63yH05oPmSWSLQt9mm6eA3S dGFwkWL2WZALKw8gqV7fXt/nADr04Z1ooJIUS7Yy0JXfmdpfEA/ikebaVcFt3nGShF6m 6phjOqVak+2DaathcZ1yz1cXC9y/uZ2WlFAPotIf41DAKpbXpTKLrJlz9x5nqyf+6y3T ox4VDfTSNJotvJ2Xh5GjjmI7jZzF3b1sKOaI5NxBJF1nrzH+MvNQCRX5lnxDUV2TQZso DXAjNOXW/QPNYvaGReidxp8yr8o+uUbvG58InuUVUOlJltu7vBh3b1PxPNjTi67c59Yf Fh3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=hjU0dz1YRwgCa86yg6lyx1HVln+GtR/AZJQmgFsXaoY=; b=RhdUpzi+InAjEC0xBGjXP0yOOb2dS53nzXHKxeBkH2Yw0eDWgQ1gLosCWyWnuHdyg8 50Aqbj2l0jkSKIQSEw3LzFz7SnsaKKBQLcqdyyqDuGmd44BqTnepCz7t1h87HCCVB/b+ JbTCeQ1V0Qrimg+cG+OGrfRLkw1eXECJOW1bAC10kWzN8LxPSeUbS63pSak9uUUALH0p 5pcvdqH0/vhtMexGRJYKk4HAzsEycJAwao8OLo1tCELMAMMcxc0ECu/qN50qwFyoLLdH ZZmRcGLq+23wdH33vgMldKobHY4onSCniuB+DzT24Q56nuewzwS3aCdU/RdCEu9Zupoe nlPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=merlin.20170209 header.b=drNaglO3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c21si6708623edw.472.2020.10.26.04.54.35; Mon, 26 Oct 2020 04:54:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=merlin.20170209 header.b=drNaglO3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1772497AbgJZJCl (ORCPT + 99 others); Mon, 26 Oct 2020 05:02:41 -0400 Received: from merlin.infradead.org ([205.233.59.134]:56258 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1772481AbgJZJCi (ORCPT ); Mon, 26 Oct 2020 05:02:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=hjU0dz1YRwgCa86yg6lyx1HVln+GtR/AZJQmgFsXaoY=; b=drNaglO3mdMrT6pn0m9aO2nOTf oyJQ2zZgCO/dMraCZHb5IdMROd3LSPfbiRth7VcaoFqq/T09KQ6n5FWRnpyqrPEtnJJ1OKvVd3CjG vbolK5x8ovRPS0GbX9uEXnolbOB+3+0kLIKQmv9tkwN5LNHeiA1zLBLkBvEwh5R4ESnlQwYCPjG4A kz4hDJIWfOBzVIGm20EfqBvGdR4X9+xwMqmuzs7XKP8a0R2aX1twpBNIvYbrZQyJgbfR4BOBHeqD7 Fmo0R9cpLjqThn1fEXiywagBERca4t02gDIBAoRDZLJ51rrvTGKW6XVgyt3L0TQrR8etzKi600Fa/ HVnuaQCA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kWyNi-0005zM-N3; Mon, 26 Oct 2020 09:01:35 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 775BA305815; Mon, 26 Oct 2020 10:01:31 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 5E01720325EC8; Mon, 26 Oct 2020 10:01:31 +0100 (CET) Date: Mon, 26 Oct 2020 10:01:31 +0100 From: Peter Zijlstra To: Vineeth Pillai Cc: "Li, Aubrey" , Joel Fernandes , Nishanth Aravamudan , Julien Desfossez , Tim Chen , Aaron Lu , Aubrey Li , Thomas Glexiner , LKML , Ingo Molnar , Linus Torvalds , Frederic Weisbecker , Kees Cook , Greg Kerr , Phil Auld , Valentin Schneider , Mel Gorman , Pawan Gupta , Paolo Bonzini , vineeth@bitbyteword.org, Chen Yu , Christian Brauner , Agata Gruza , Antonio Gomez Iglesias , graf@amazon.com, konrad.wilk@oracle.com, Dario Faggioli , Paul Turner , Steven Rostedt , Patrick Bellasi , =?utf-8?B?YmVuYmppYW5nKOiSi+W9qik=?= , Alexandre Chartre , James.Bottomley@hansenpartnership.com, OWeisse@umich.edu, Dhaval Giani , Junaid Shahid , Jesse Barnes , "Hyser,Chris" , "Paul E. McKenney" , Tim Chen , "Ning, Hongyu" Subject: Re: [PATCH v8 -tip 02/26] sched: Introduce sched_class::pick_task() Message-ID: <20201026090131.GE2628@hirez.programming.kicks-ass.net> References: <20201020014336.2076526-1-joel@joelfernandes.org> <20201020014336.2076526-3-joel@joelfernandes.org> <8ea1aa61-4a1c-2687-9f15-1062d37606c7@linux.intel.com> <20201023214702.GA3603399@google.com> <4241e5ac-ecdf-8634-fa0d-dd6759e477e1@linux.microsoft.com> <8230ada7-839f-2335-9a55-b09f6a813e91@linux.microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <8230ada7-839f-2335-9a55-b09f6a813e91@linux.microsoft.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Oct 24, 2020 at 08:27:16AM -0400, Vineeth Pillai wrote: > > > On 10/24/20 7:10 AM, Vineeth Pillai wrote: > > > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > > index 93a3b874077d..4cae5ac48b60 100644 > > --- a/kernel/sched/fair.c > > +++ b/kernel/sched/fair.c > > @@ -4428,12 +4428,14 @@ pick_next_entity(struct cfs_rq *cfs_rq, struct > > sched_entity *curr) > > ??????????????????????? se = second; > > ??????? } > > > > -?????? if (cfs_rq->next && wakeup_preempt_entity(cfs_rq->next, left) < > > 1) { > > +?????? if (left && cfs_rq->next && > > +?????????????????????? wakeup_preempt_entity(cfs_rq->next, left) < 1) { > > ??????????????? /* > > ???????????????? * Someone really wants this to run. If it's not unfair, > > run it. > > ???????????????? */ > > ??????????????? se = cfs_rq->next; > > -?????? } else if (cfs_rq->last && wakeup_preempt_entity(cfs_rq->last, > > left) < 1) { > > +?????? } else if (left && cfs_rq->last && > > +?????????????????????? wakeup_preempt_entity(cfs_rq->last, left) < 1) { > > ??????????????? /* > > ???????????????? * Prefer last buddy, try to return the CPU to a > > preempted task. > > > > > > There reason for left being NULL needs to be investigated. This was > > there from v1 and we did not yet get to it. I shall try to debug later > > this week. > > Thinking more about it and looking at the crash, I think that > 'left == NULL' can happen in pick_next_entity for core scheduling. > If a cfs_rq has only one task that is running, then it will be > dequeued and 'left = __pick_first_entity()' will be NULL as the > cfs_rq will be empty. This would not happen outside of coresched > because we never call pick_tack() before put_prev_task() which > will enqueue the task back. > > With core scheduling, a cpu can call pick_task() for its sibling while > the sibling is still running the active task and put_prev_task has yet > not been called. This can result in 'left == NULL'. Quite correct. Hurmph.. the reason we do this is because... we do the update_curr() the wrong way around. And I can't seem to remember why we do that (it was in my original patches). Something like so seems the obvious thing to do, but I can't seem to remember why we're not doing it :-( --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6950,15 +6950,10 @@ static struct task_struct *pick_task_fai do { struct sched_entity *curr = cfs_rq->curr; - se = pick_next_entity(cfs_rq, NULL); + if (curr && curr->on_rq) + update_curr(cfs_rq); - if (curr) { - if (se && curr->on_rq) - update_curr(cfs_rq); - - if (!se || entity_before(curr, se)) - se = curr; - } + se = pick_next_entity(cfs_rq, curr); cfs_rq = group_cfs_rq(se); } while (cfs_rq);