Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp184963pxu; Sat, 24 Oct 2020 20:33:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxj3XEfVAz/xQQ0LH+3L6ApP3Ow/ojyI2KUzBG8lV9e8HRzXvRipgTj3s1xXjDLJVvw4it8 X-Received: by 2002:a17:906:b1d6:: with SMTP id bv22mr9214303ejb.60.1603596831108; Sat, 24 Oct 2020 20:33:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603596831; cv=none; d=google.com; s=arc-20160816; b=KtL4JswFiMvFCxI1Fw5zE0xpBe/tR832UowWMLdmBzU87/X+cuIYpTc9RiPAgc+K/L B7p+ea2OXv+Sj2wvGNodh3O9IOPCgRmpNUBIVT1J6GG+elGetIer4tC3gsNS9/SE9edv swkMGpGNaLQjXux2bod/wyWtIj001+7KGwE/tfVNL6Jh/+13myCTZbGYE8dwBCPJdeYB OKf8y79rMiN7y2iEH5DVctOxILZFeRYEAcB6BmhYzPNFWsWgZYrKIOc3DFNxR9MxXUtP vK704CUsmg8HpIVsSRozsmHX9LJhPlPWjm8iZzPR8yIXCt/qFsTwKzjVd7GLgYbeTSN9 hnEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:ironport-sdr:ironport-sdr; bh=3R3EH+O3LcXyAzzzzUZNtaDTvy1obtvVEn6t6pbIdEQ=; b=dV4KXObTlXAeGJ+n5cXrYlXC+1CBLVvd8KPhdkqR9M1/ANZFvl3u3WgTIq3Fyf/DLK nXzVrUFkPP+vG8dC1C21rWNAlPGncGtXiu5ybYn0r21yPeVweJsXP6KpNCk3ksQum5ud 8OgohCkcV9/nLY2RPvd+ecEVldioJYqGDmQceX9D4evGf8mFqd05hpjzsWs2QeXw07sx XTJ+dye5Y7X8ML8TQuwXKitZthEs+cd5SjfsfboIHAvkmmfDHPHgXV6aqFf/qYTTwtgY tc6KLkr340bdaIiSwveioels89zazfnC+7NoW6IrcJY9bjwwDv6YTjNrjhJ+LWHNFjQo LKLA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c24si4361296edy.580.2020.10.24.20.33.28; Sat, 24 Oct 2020 20:33:51 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1762951AbgJXXs0 (ORCPT + 99 others); Sat, 24 Oct 2020 19:48:26 -0400 Received: from mga17.intel.com ([192.55.52.151]:53563 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1762947AbgJXXsZ (ORCPT ); Sat, 24 Oct 2020 19:48:25 -0400 IronPort-SDR: 5lSh1QuHkwxj78K0TXPgr1SclDNltvlXgGkY9t5VHCNvMZ44pE0QgU1bCSuvW2a+fMY/CCoUNf g4EgoiHeQ7Iw== X-IronPort-AV: E=McAfee;i="6000,8403,9784"; a="147658470" X-IronPort-AV: E=Sophos;i="5.77,414,1596524400"; d="scan'208";a="147658470" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Oct 2020 16:48:25 -0700 IronPort-SDR: Al+Y29xVYP57ZqmLV5lsi8j+5v3ZGZkxYUCkSAlynZv4loScP/cPagJgjK/FC5AQD9OJfV0uHy PEwk8mH+QNwA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,414,1596524400"; d="scan'208";a="360606597" Received: from cli6-desk1.ccr.corp.intel.com (HELO [10.239.161.135]) ([10.239.161.135]) by orsmga007.jf.intel.com with ESMTP; 24 Oct 2020 16:48:16 -0700 Subject: Re: [PATCH v8 -tip 02/26] sched: Introduce sched_class::pick_task() To: Vineeth Pillai , 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> <8230ada7-839f-2335-9a55-b09f6a813e91@linux.microsoft.com> From: "Li, Aubrey" Message-ID: Date: Sun, 25 Oct 2020 07:48:15 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <8230ada7-839f-2335-9a55-b09f6a813e91@linux.microsoft.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/10/24 20:27, 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'. So I think the > above fix is appropriate when core scheduling is active. It could be > cleaned up a bit though. This patch works, thanks Vineeth for the quick fix!