Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp206753rdg; Thu, 12 Oct 2023 03:25:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFEUKbRXSoR6VQMoZ4mVichoOMc70L4EA1rTOhiTr+YAaNHvOdfFs21e2OLmtCDXZDwv/rI X-Received: by 2002:a05:6a00:2e10:b0:68e:41e9:10be with SMTP id fc16-20020a056a002e1000b0068e41e910bemr26335086pfb.20.1697106355307; Thu, 12 Oct 2023 03:25:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697106355; cv=none; d=google.com; s=arc-20160816; b=Sb4qOkIgHBI/w6ccsAFfnCN1QZk2MTZWV5T+QcH+jUvXmaELfSiExUAU+i2XDEnMXM pq8KRXi0wLQmjzSniHZzESqOnllcFJDJDAoQ7pZXXNnFoiK8gsdHOgSo64WXwzKLJ5Yd /KEEqouwjvfEV5K5IaO4wLN2UDt2G5m3Ot2uQBWDvVGPmW+Qz14tGyjKfwf/5QxjvVMN j7swETzGureJBHhKMoht+LY2b+kwOL7V5qyES0JHvR7f8+S90/lJgHSkcmgceKtq2dl9 a1GJrORiNOnHSP9/werAR+S/oh7TMhYV8gifbAMbsItHXX4mjM3040gNo7Cn1Ucxsw5T fzlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=k7ICXJkU98oSQJrBKC7mcojL9G7RN3hGsGY8b4JhLlQ=; fh=jABIjUGhIZjOxiJ3PElCxawbOLyk2aMf7MFpvfeX0TY=; b=kl+kNb52bMlmpoSq26HM4j9Sen32rRrp/cudDokj/LzTEd58/6trJ4dY8wTmSXqZn0 LdJEAZc7HWhGfbPig6bPZ9CuTxztO7z/Oxem8PHMHX/dMI9KrkLylULP0eJaD5mPpTsV 4shXRTsNTyH9ppRwbLVoKV64Gqv68s0OLVjWhX0ubXzXnxR+sgTj2ys67SKXZPXQv2f2 uhjgOVx+mDsYbLhctsCTgWw+zsGcUeo/fPmhy//5nscm+FXMp1gBzf0yMlmuQsxYcDgX eJsiaDPsGpCzXsaKTOjLNlvRfgRSvqV3yEd23BP5AS1bQ0ba992sTqK3gwQsNmlgqXeD uGeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b="D6MjR8/U"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id l125-20020a633e83000000b005a073e0cc99si2084505pga.333.2023.10.12.03.25.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 03:25:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b="D6MjR8/U"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 08F00809B756; Thu, 12 Oct 2023 03:25:36 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347120AbjJLKZX (ORCPT + 99 others); Thu, 12 Oct 2023 06:25:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235614AbjJLKZT (ORCPT ); Thu, 12 Oct 2023 06:25:19 -0400 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BDB490 for ; Thu, 12 Oct 2023 03:25:18 -0700 (PDT) Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-690ce3c55f1so634413b3a.0 for ; Thu, 12 Oct 2023 03:25:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1697106317; x=1697711117; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=k7ICXJkU98oSQJrBKC7mcojL9G7RN3hGsGY8b4JhLlQ=; b=D6MjR8/U7KwXdfuDydeoWIjfUkN1Q9uXnbtGv5JG0hzU4VHE6183QldC1ZJ2gN/FAO zVIb8win9X1WG7hIFDwKBOuUnTk/PkIMbczB+YKkeYetwvri+54KXjqUJMCsHCj7lOHX mXAfXfOLefjYsgud35TqdkmXJvwTxTTZt55xAiiluFCB094YjjsYAM56Zn5EA6/ljceQ usFHgzxDzD7X1JwmfOfBoXMsoYnzRUaxrsN/VAjcFLbN5Xn9ttCDi1udgkHpWQ1x9JPp D7SY8Y2QFu3jCqbKxUURZhvtCZVJcDDirjV0+rxMdbWLlj8hc0WDVQWs7zhRDnRY1O08 YV+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697106317; x=1697711117; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=k7ICXJkU98oSQJrBKC7mcojL9G7RN3hGsGY8b4JhLlQ=; b=onnP8A1jCR9Eo7RLXFdVLMc3CBgR4RYkGCTnJQhJn1wKgT7lcJSMqnLiq7CVtM6d6o 3nTHR/2ftlr240qYUn0akpr3qlMq9R3yO/IkV5/R2Rbk7eyyCX5T1XKoG46KHq3lJoVA 2v81pqCH/+p0xzukS3Lrz7mEyPevVDTwoYhXqDx9vaffbGcAAS2OFat8Es2pfbItmqEx O3nYlIje8NJ46sbuVg5YTlln0ygkf/NORZ76RPrxF00sMuymLLDcdp1sQS9HPzRU8MiL SvM5z4cw3BtjkFs9DRV2xiPPpvOG7qiOL6KnOpTVHmka4HFwCbmc/lX84rGeXnv4YMBJ 6vGA== X-Gm-Message-State: AOJu0YzN44ndkFPN6MR9V48/FHbgrq9YwSdatoUSllqVXJdi4BWCMqZD ap8uyN2trr1Lxy+KMsp33SCexg== X-Received: by 2002:a05:6a20:3c88:b0:14c:910d:972d with SMTP id b8-20020a056a203c8800b0014c910d972dmr25253157pzj.12.1697106317507; Thu, 12 Oct 2023 03:25:17 -0700 (PDT) Received: from [10.84.153.115] ([203.208.167.147]) by smtp.gmail.com with ESMTPSA id cv14-20020a17090afd0e00b00271c5811019sm1506246pjb.38.2023.10.12.03.25.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 12 Oct 2023 03:25:17 -0700 (PDT) Message-ID: <699cc8b1-f341-4af7-9c47-fee961c5c4b7@bytedance.com> Date: Thu, 12 Oct 2023 18:25:06 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Re: [PATCH] sched/fair: fix pick_eevdf to always find the correct se Content-Language: en-US To: Benjamin Segall Cc: Peter Zijlstra , mingo@kernel.org, vincent.guittot@linaro.org, linux-kernel@vger.kernel.org, juri.lelli@redhat.com, dietmar.eggemann@arm.com, rostedt@goodmis.org, mgorman@suse.de, bristot@redhat.com, corbet@lwn.net, qyousef@layalina.io, chris.hyser@oracle.com, patrick.bellasi@matbug.net, pjt@google.com, pavel@ucw.cz, qperret@google.com, tim.c.chen@linux.intel.com, joshdon@google.com, timj@gnu.org, kprateek.nayak@amd.com, yu.c.chen@intel.com, youssefesmat@chromium.org, joel@joelfernandes.org, efault@gmx.de, tglx@linutronix.de References: <20230531115839.089944915@infradead.org> <20230531124603.931005524@infradead.org> <6b606049-3412-437f-af25-a4c33139e2d8@bytedance.com> From: Abel Wu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Thu, 12 Oct 2023 03:25:36 -0700 (PDT) On 10/12/23 5:01 AM, Benjamin Segall Wrote: > Abel Wu writes: > >> On 9/30/23 8:09 AM, Benjamin Segall Wrote: >>> + /* >>> + * Now best_left and all of its children are eligible, and we are just >>> + * looking for deadline == min_deadline >>> + */ >>> + node = &best_left->run_node; >>> + while (node) { >>> + struct sched_entity *se = __node_2_se(node); >>> + >>> + /* min_deadline is the current node */ >>> + if (se->deadline == se->min_deadline) >>> + return se; >> >> IMHO it would be better tiebreak on vruntime by moving this hunk to .. >> >>> + >>> + /* min_deadline is in the left branch */ >>> if (node->rb_left && >>> __node_2_se(node->rb_left)->min_deadline == se->min_deadline) { >>> node = node->rb_left; >>> continue; >>> } >> >> .. here, thoughts? > > Yeah, that should work and be better on the tiebreak (and my test code > agrees). There's an argument that the tiebreak will never really come up > and it's better to avoid the potential one extra cache line from > "__node_2_se(node->rb_left)->min_deadline" though. I see. Then probably do the same thing in the first loop? > >> >>> + /* else min_deadline is in the right branch */ >>> node = node->rb_right; >>> } >>> + return NULL; >> >> Why not 'best'? Since .. > > The only time this can happen is if the tree is corrupt. We only reach > this case if best_left is set at all (and best_left's min_deadline is > better than "best"'s, which includes curr). In that case getting an > error message is good, and in general I wasn't worrying about it much. Right. > >> >>> +} >>> - if (!best || (curr && deadline_gt(deadline, best, curr))) >>> - best = curr; >>> +static struct sched_entity *pick_eevdf(struct cfs_rq *cfs_rq) >>> +{ >>> + struct sched_entity *se = __pick_eevdf(cfs_rq); >>> - if (unlikely(!best)) { >>> + if (!se) { >>> struct sched_entity *left = __pick_first_entity(cfs_rq); >> >> .. cfs_rq->curr isn't considered here. > > That said, we should probably consider curr here in the error-case > fallback, if just as a "if (!left) left = cfs_rq->curr;" I don't think so as there must be some bugs in the scheduler, replacing 'pr_err' with 'BUG()' would be more appropriate. > > > I've also attached my ugly userspace EEVDF tester as an attachment, > hopefully I attached it in a correct mode to go through lkml. Received. Thanks, Ben.