Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp158354rdf; Mon, 20 Nov 2023 21:09:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IFinFOF0JHBqe+5247TFjCC67ASXiy3jM6/223TGDinJNsQ15KNagkvJqevE6Jd4iuesAsB X-Received: by 2002:a05:6808:28e:b0:3a4:6b13:b721 with SMTP id z14-20020a056808028e00b003a46b13b721mr9548700oic.46.1700543368978; Mon, 20 Nov 2023 21:09:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700543368; cv=none; d=google.com; s=arc-20160816; b=aI1eXK900aZn77ApKHIUiA7akUFcZ+XBPJOtoPJdt2M1GRjOe3X6LoPun5LUNFCbDy I9UYYQvOtH9P68VWlf1mWcoN8kUpzYCp/Cv3PKB5ozB2+fC5O+/ZZUHkGv/h7mTCyCFt vNDCAFCJiKvs1K2lovTbauonPUpDRu2HS1uaDyKtt6xCTk1Hbf8pbvd+MRynVjdMSS2l X17sF9aJM22dcOxGDqpbQB4TlT6LizniEfqQ7y2dKu6sRMnh+C7Evujuz0wfGSlD20xi FF8GK2uWA9Uxw78Po7qI13yHPH9azS+xznMOTIMbtXyij8TqelvwIM4wcbegBAjeVz3b riZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=0qLSUmFxKYTTBBAoYkylVM+B9mW+ZB3Zjl8Q8XAnhUc=; fh=mrWNDRsrpgyoyE5HZuP1Ris3UB5hGD93qWh8ZsUrP5g=; b=tMJeeWvYVrkB4Po2drlULIe9E/EoydOBQJq+blkT+GfDYkdirvbX6hJVtuHpfFXdtm Hq7dhO3hw3ngfQMtAhh66wAsksOnz2NWPB59Akt7+DetQDbBZvYIm0K0idIeT15iK4hy t7KJsVf9vzfe6xaKo9upudLRCutxqjqi8+CfaIwACRNlJ4XTGsjEXu26KXgV4zjiNaq2 ukhigl9e6Y0vjEo1nFVN2C5hksOCrT2ffvFTJRjfJy5TFQ1KrBcojDEJy6qKUgn3o7bM OF9bKfDWGdI5+Wzn8ZDf9Pa1JbOGLIQA1yqsJRqcPrp6PZdPY7xFJgDfXPahAAVdwcjO 5SpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=gWSQjuZK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id e36-20020a631e24000000b005b8ebaa2937si9761482pge.47.2023.11.20.21.09.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 21:09:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=gWSQjuZK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id C9CCD80B8151; Mon, 20 Nov 2023 21:09:13 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233399AbjKUFJA (ORCPT + 99 others); Tue, 21 Nov 2023 00:09:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233333AbjKUFI6 (ORCPT ); Tue, 21 Nov 2023 00:08:58 -0500 Received: from mail-oa1-x2d.google.com (mail-oa1-x2d.google.com [IPv6:2001:4860:4864:20::2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75D8DFA for ; Mon, 20 Nov 2023 21:08:54 -0800 (PST) Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-1f066fc2a2aso2396740fac.0 for ; Mon, 20 Nov 2023 21:08:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700543333; x=1701148133; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=0qLSUmFxKYTTBBAoYkylVM+B9mW+ZB3Zjl8Q8XAnhUc=; b=gWSQjuZKMt8glacIc5TJKBo3SDZpmp5CxWgTYXI5QEwn7JzoSw078/XJm1RJd0Lj4Q +LOaI0T3MzX9bCn8G0fwHw2ZDm4NLA21D7my9Fm/IUOwh9gjWLZx4aXqJyxWAPwy8wAj N0S4K6EDTAtqwfpoVlZZwtxmdnHcyYVbU+8BFVQm3MthxHwT5AEr0+8YufWMkkJNcc2Z ywFJXtExE7Ex48TG0g7Q8xnYvpYr67uEXu8zadxlJnheuTeP/Hg4CyF1+RPi7xdQGLVh M5s76b3ZmBm8ZcPmCpEd0ZhbL9QyQo6k50nLzz4w7r3k1trduMnEKU2gJLiKzy2UMLpv Ps+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700543333; x=1701148133; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0qLSUmFxKYTTBBAoYkylVM+B9mW+ZB3Zjl8Q8XAnhUc=; b=kI5ykB06CFXAfmGAigLsjq97cp44YrxH/wLM3AY3qlmp3WrrYFA7n6bY4aRNtkZFHc txEONTZo+YZViieHZtRY7RV2r2B5a9PXE6erDVdn0O3R5NBEk3V+urQIbFvKqQfDtsP+ CN9JIUbOf376acaGI18gzlP92a3JxhOLDIqs7ExHvrlxnj9lVN2XVfoMWASCV6Pmm0jA 7shIdde/2CN86unGYLL4TtWOqAwAud9H2LQJmXTeO8simlx8Q29hvARBG3ejccFfy2H9 6RKoCtQv0QZytpW3ig/Oy1OLZyJ8tZKpYvP3KmpUOHdY0jPDsm5JubF7s3hrQch0qrP9 8nEQ== X-Gm-Message-State: AOJu0YybIW1SxZg2AtViRZBo+Iiwi/RXhu9jjrKN2RD+qVSYRa3JYbaD TayLagrlSaWuHpBG/TJIslShawn7IU0qbsguGzM= X-Received: by 2002:a05:6871:5211:b0:1f9:6962:b06c with SMTP id ht17-20020a056871521100b001f96962b06cmr1127983oac.53.1700543333479; Mon, 20 Nov 2023 21:08:53 -0800 (PST) MIME-Version: 1.0 References: <20231120073821.1304-1-xuewen.yan@unisoc.com> <7c223b0c-d39a-4d53-8f00-7fbec6b49b6e@bytedance.com> In-Reply-To: <7c223b0c-d39a-4d53-8f00-7fbec6b49b6e@bytedance.com> From: Xuewen Yan Date: Tue, 21 Nov 2023 13:08:42 +0800 Message-ID: Subject: Re: [PATCH] sched/eevdf: Avoid NULL in pick_eevdf To: Abel Wu Cc: Xuewen Yan , mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, linux-kernel@vger.kernel.org, ke.wang@unisoc.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 20 Nov 2023 21:09:13 -0800 (PST) On Mon, Nov 20, 2023 at 4:49=E2=80=AFPM Abel Wu = wrote: > > Hi Xuewen, the pick part has been re-worked, would you please re-test > with the newest branch? Okay, Thanks! > > Thanks, > Abel > > https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/?h=3Dsched%2F= core > > On 11/20/23 3:38 PM, Xuewen Yan Wrote: > > Now in pick_eevdf function, add the pick_first_entity to prevent > > picking null when using eevdf, however, the leftmost may be null. > > As a result, it would cause oops because the se is NULL. > > > > Fix this by compare the curr and left, if the left is null, set > > the se be curr. > > > > Fixes: 147f3efaa241 ("sched/fair: Implement an EEVDF-like scheduling po= licy") > > Signed-off-by: Xuewen Yan > > --- > > kernel/sched/fair.c | 18 +++++++++++++++++- > > 1 file changed, 17 insertions(+), 1 deletion(-) > > > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > > index d7a3c63a2171..10916f6778ac 100644 > > --- a/kernel/sched/fair.c > > +++ b/kernel/sched/fair.c > > @@ -951,12 +951,28 @@ static struct sched_entity *__pick_eevdf(struct c= fs_rq *cfs_rq) > > return NULL; > > } > > > > +/* Just simply choose the se with the smallest vruntime */ > > +static struct sched_entity *__pick_cfs(struct cfs_rq *cfs_rq) > > +{ > > + struct sched_entity *curr =3D cfs_rq->curr; > > + struct sched_entity *left =3D __pick_first_entity(cfs_rq); > > + > > + /* > > + * If curr is set we have to see if its left of the leftmost enti= ty > > + * still in the tree, provided there was anything in the tree at = all. > > + */ > > + if (!left || (curr && entity_before(curr, left))) > > + left =3D curr; > > + > > + return left; > > +} > > + > > static struct sched_entity *pick_eevdf(struct cfs_rq *cfs_rq) > > { > > struct sched_entity *se =3D __pick_eevdf(cfs_rq); > > > > if (!se) { > > - struct sched_entity *left =3D __pick_first_entity(cfs_rq)= ; > > + struct sched_entity *left =3D __pick_cfs(cfs_rq); > > if (left) { > > pr_err("EEVDF scheduling fail, picking leftmost\n= "); > > return left;