Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp474769rdg; Thu, 12 Oct 2023 10:51:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFbQJwq7fSGnUyRx22dQXri9MMHT+nZjAEtY7PDeR08SINzW9TQUq9mdyXueHuXU1zUjDTT X-Received: by 2002:a05:6358:52c5:b0:135:85ec:a080 with SMTP id z5-20020a05635852c500b0013585eca080mr30157509rwz.32.1697133099660; Thu, 12 Oct 2023 10:51:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697133099; cv=none; d=google.com; s=arc-20160816; b=tu3GCdyyqNlsVqeBhN9f/WgozrdbCT0QXuIj5+0VfFstdCcv4K4h/pXo3Cxd1HYBRw gbyI6cdIEXNmGvZb1L9r9LF/VRsnSPlyDg6qBQiiH5k7Yv0L6FAMf8FSThgh3VbyEf9y 6hbxU7TdEz4CPk6boE4FFJIUl3mkcEixGYD4cHuFR6qHERlnFB3SVwwjfvis5mSOM6UA OBUrB5Hw96WVJEfnmvkLOjS8rMjCYAcRQ9KPNxQUqCXzrZc0HclhmyZTiJkixlpgdQMo 8nQHzfDmScQ4ScjCecNjHQU7jNgcAb5MfgVmvOcnEtkbnGLkdeOUroRd7+oN3oVefoBv EUmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:dkim-signature; bh=L4c9PxVdvDkaT2ILkkxYtn5SSd3e0yFpozDooEzbzQY=; fh=pAnqtrSw9fLXVGAy/ygKn7iKrJuyvwPlHhLZDIlZIQA=; b=GyNtU8UzKMxZYNqIhnP28M5oY425lEu6iFc37L3nObYHhYeCVs6Mky4iUjubH2ZjaA 3ZVnEgxsj7gpTZ3HIkvauuK1oflHnzO5wDjLlqc4sArL3Ys39RGsLo+Ta0uvsCsd86Q4 roau7eCcnRH7aNA7fe1YQMVUY+dV24kHWGDqiJ25xlJ+9sy6VFav7LxsQkN9Qa/omp75 oyGNPLXddx1QSzEiO3S50M6c25HaCpNkd7WBDaL7ERn8o5ikarhcyZHO50xSO8fO4gAZ U/ygt/arz/1jPEcBc7dEpAl92lnw96H7p6rHRDu/XMrd1429/Xc14TiXQioCTW1zGprd wmyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=OpUpWRlf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id n3-20020a6546c3000000b00577475ee5f6si2613132pgr.618.2023.10.12.10.51.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 10:51:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=OpUpWRlf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id BDF64828D015; Thu, 12 Oct 2023 10:51:36 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1441854AbjJLRva (ORCPT + 99 others); Thu, 12 Oct 2023 13:51:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344076AbjJLRv2 (ORCPT ); Thu, 12 Oct 2023 13:51:28 -0400 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F47AB8 for ; Thu, 12 Oct 2023 10:51:26 -0700 (PDT) Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1c9b70b9671so13665ad.1 for ; Thu, 12 Oct 2023 10:51:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1697133085; x=1697737885; darn=vger.kernel.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=L4c9PxVdvDkaT2ILkkxYtn5SSd3e0yFpozDooEzbzQY=; b=OpUpWRlfwa3dKx1B8Q6hV/FHslyyjw+Eojg0AT9cL3xVC7dQq8UR1sf7T4JwngUrq6 7C7TwLaUQbtASACzIcoCNobmDatORNrFhbURPFEZkx02idKPWxfOGbDUsAhtTcCspYCF EMciRZ2BJr7jC0UR2NmDGpq8HDDznqTQSMeyKui8wgcM3rj0XskgCHGzTAZB3HlzJLXF UzYTPZvDVOsv/NEJRxmA10PZVFNJgTUKKB7Egx7EuMkZk0gFxqLmW6lv1LQht8KUSaSx aLgCWA6kafUd8Wr7ANshdSCunX+yogiE53oAlQ3McIcddJi+MVH6rTrMcnpq91Te45RT jZjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697133085; x=1697737885; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=L4c9PxVdvDkaT2ILkkxYtn5SSd3e0yFpozDooEzbzQY=; b=OdpKcHkRZz4lxP8uMuRoNtW8VLMWofaA9tcNtefRxejPd8URxFk2WScqS/Ex+NK41z rqctvJRU6ogzjfoeN07kxNYWKGSnqnplP8iftfijLvuLoS3U9PjOMBnLMhCbbn9UFRCc V1orZ0xsQL0L/2zniEa7reR6i4KnhOYtP66SuZKdZu20KuTRWa+32FwBf7/gO7cmbl60 Bg43v8AXmqEXRSDA4ybgLvTRx/OC7o7NE+CrnsLWw8xxG6hWFUwBV0isvIrvwQDD8Xuq 5Dopcv+4e7mS7uangAH2UBH9l0A79IoGCgm7Kddyvx/YHBiYCOrQQFF+fI8/hSh7K0HX J9xQ== X-Gm-Message-State: AOJu0YyqE1VrIfFkdG0DEWDk4vuIFcIOAbMfqWiv8M67XDXmwFoNiXjM 0gUehe4zR4h6YcM5kfUhL/1rLw== X-Received: by 2002:a17:902:e952:b0:1c1:efe5:cce5 with SMTP id b18-20020a170902e95200b001c1efe5cce5mr3634pll.3.1697133085284; Thu, 12 Oct 2023 10:51:25 -0700 (PDT) Received: from bsegall-linux.svl.corp.google.com.localhost ([2620:15c:2a3:200:5aa:bf1b:3872:9fec]) by smtp.gmail.com with ESMTPSA id c4-20020a62e804000000b00690c9fda0fesm12045027pfi.169.2023.10.12.10.51.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 10:51:24 -0700 (PDT) From: Benjamin Segall To: Abel Wu 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 Subject: Re: [PATCH] sched/fair: fix pick_eevdf to always find the correct se In-Reply-To: <699cc8b1-f341-4af7-9c47-fee961c5c4b7@bytedance.com> (Abel Wu's message of "Thu, 12 Oct 2023 18:25:06 +0800") References: <20230531115839.089944915@infradead.org> <20230531124603.931005524@infradead.org> <6b606049-3412-437f-af25-a4c33139e2d8@bytedance.com> <699cc8b1-f341-4af7-9c47-fee961c5c4b7@bytedance.com> Date: Thu, 12 Oct 2023 10:51:22 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Thu, 12 Oct 2023 10:51:36 -0700 (PDT) Abel Wu writes: > 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? > We effectively do that already sorta by accident almost always - computing best and best_left via deadline_gt rather than gte prioritizes earlier elements, which always have a better vruntime. Then when we do the best_left->min_deadline vs best->deadline computation, we prioritize best_left, which is the one case it can be wrong, we'd need an additional "if (se->min_deadline == best->deadline && (s64)(se->vruntime - best->vruntime) > 0) return best;" check at the end of the second loop. (Though again I don't know how much this sort of never-going-to-happen slight fairness improvement is worth compared to the extra bit of overhead)