Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp1359227pxu; Sat, 24 Oct 2020 08:15:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfekZDBT4GwlYBzvafmMTyAFLjYEZpJ4fKWPZEO3PHLqqgOlqrlvJ4r/aRU1tvuXLRvG1s X-Received: by 2002:aa7:c717:: with SMTP id i23mr7378733edq.250.1603552510974; Sat, 24 Oct 2020 08:15:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603552510; cv=none; d=google.com; s=arc-20160816; b=gxD4uuuSc45j0p8aFL9EQVdJ8OzxVu5/eN6o+YMlsIvDtxvoVqxXjy/994+RNnJhc8 /Db25CCKPtG6H1FwYcZL0pMy66juCSgQcd+BjFmntlYVOo7er1kP/KBT3RCxj1Ctr1CR +2RqCWMaVfRN3E0UXNY2B+LpJFEUn2KTSVSIt3bhMLb1Iz+crFnpip6VVeUd9qDn6sw+ VWb1Zl7FBlp5I661k/uMMDyp9iu5Ya3DWAlk/XSwyxFolaRLQhZC/bx2/EE+/IBGhP30 8VUYRcLzFLxnRLbPOT0rMzrg0CzAo/5TYXsoCv9m09WzL5qw8EwE5TN3ui2iYjQ7mVFS YPLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:references:cc :to:from:subject:dkim-signature:dkim-filter; bh=qUKEiaaGFJQ56Nx5gaWkWp7EAEbVcuu2OEIi8+ZL+Rw=; b=dax1CiedCJ2PzgXzh4po/0kucjCS6+yC3p/Oifn5Joxzi7U+EMs8mSjZXLbvPw5BSg Mb0KT66Dqc44QMdQnJ6uBP9XWspDEAY9BTlI+4q8kXNkcB1cM46xU5w8xnaVgwOT/35Y Ow8qClfSMbgnSGrLr3ECfEucBM7R1PwuxREwbFnY3W7aYuC49qxRpgniPwJt6JtgQhka rbnu9+3g/nJdiMP40sintqIThL62xrOoPZ2OnMaqJ75+lWN/oq5fY0LHsbyhIxtQzOvD hZMr8d40asNV+ouKG6H40D+8yuuJzOcHWV/1U3s0+NOdd28RLbXj6LIHmy5QizXUxfFH f9VA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b="CzpV6K3/"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g25si3245115eds.336.2020.10.24.08.14.48; Sat, 24 Oct 2020 08:15:10 -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=@linux.microsoft.com header.s=default header.b="CzpV6K3/"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761375AbgJXM1Z (ORCPT + 99 others); Sat, 24 Oct 2020 08:27:25 -0400 Received: from linux.microsoft.com ([13.77.154.182]:50258 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761371AbgJXM1Y (ORCPT ); Sat, 24 Oct 2020 08:27:24 -0400 Received: from [192.168.86.211] (c-73-38-52-84.hsd1.vt.comcast.net [73.38.52.84]) by linux.microsoft.com (Postfix) with ESMTPSA id 426CD20B4905; Sat, 24 Oct 2020 05:27:18 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 426CD20B4905 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1603542443; bh=qUKEiaaGFJQ56Nx5gaWkWp7EAEbVcuu2OEIi8+ZL+Rw=; h=Subject:From:To:Cc:References:Date:In-Reply-To:From; b=CzpV6K3/ewCfh+99KHsZHKW7FFWPT8iHnnH9UgMNx+0IWV5W51O2JK9qQofq7xdu4 PEDYC5lDpjnX1x3WgaYTvUnpt5xavQcjGHjuSb+nUZoUc9ctIldbXFwq1S1IooTsKV TyrwQ1gQ6j/tqUlSRsaZ03rbiZ+oa/YLHJd7dUPg= Subject: Re: [PATCH v8 -tip 02/26] sched: Introduce sched_class::pick_task() From: Vineeth Pillai To: "Li, Aubrey" , Joel Fernandes Cc: Nishanth Aravamudan , Julien Desfossez , Peter Zijlstra , 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" 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> Message-ID: <8230ada7-839f-2335-9a55-b09f6a813e91@linux.microsoft.com> Date: Sat, 24 Oct 2020 08:27:16 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.3.2 MIME-Version: 1.0 In-Reply-To: <4241e5ac-ecdf-8634-fa0d-dd6759e477e1@linux.microsoft.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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'. So I think the above fix is appropriate when core scheduling is active. It could be cleaned up a bit though. Thanks, Vineeth