Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp18276pxb; Tue, 17 Aug 2021 17:58:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy6lMTGjl1GkN9toNcTLYa2PmbHXfDkznsct/g8zoaW4vuDPvag3amzABDM0XTWEnanJeox X-Received: by 2002:a05:6e02:15c8:: with SMTP id q8mr4336746ilu.285.1629248299092; Tue, 17 Aug 2021 17:58:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629248299; cv=none; d=google.com; s=arc-20160816; b=sMRoQgZNWv6HvmBJCv89wVekhGgju4IFg7M3fSSuwpwf7hV9QTWq/liHMiry3DUXv0 pNSmIcwjYk57WX9tG5m6d/7JDWhUYEmUq0QCwbGQHMhnSnAg3jNteItjxhEuUHyJxPx6 OWVL56dME7bxGCkN715BZ6qTasftWKoNuOMKfrdhKJ3n96tapiTWfCYDqt+xac3Xv7RZ kqmQoV07B69ZxjnwYVYGo4+MYbWwju/4BqaZ1DcvdcQNRc7FbNowf4MZ22814Ab781uo IfDz5d4ygNyzwRmdNN+gDIhjqs5yGYSuZMCyO4R2TMj75zzLQXZvT6NKZji9eeMhjJjv dRnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :dkim-signature; bh=kPhI44KGUm7/8eTG3gY7/tZXObx8TawisVJaeXRWoBI=; b=ZNdojzmcjGP55KYQ+m3PX35ecxucoRhliZ/scINYU5RM8sf5F57KK5N27pWNvnPhlK eRFMp+0xurOKsx75ykbXDiPF7EO+Xo//MzePmq9FRsaXAU82LwFeeVcbX0xqqshqXM5t 1kV347CFZ2uCN4UUqqdfaTXoKOvJ+/aPHcKlLKu4f1pxSa5czcM1+8erwdtJTpdVGBsA hsXYiBVB734imjhfLvOI+CgKoyxyo5mfWzDNf0uoAOkYMB40Ys/X7Var/eBs7WQkWriu U3YHAlNTCQuxSGUuK5X1YpL9B3rDC2YexF1R4So9ivxq6btPae2kcFWPYTO+/csfkxFx i8GQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=tpLYcVsK; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i13si4723279ilm.90.2021.08.17.17.58.08; Tue, 17 Aug 2021 17:58:19 -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=@google.com header.s=20161025 header.b=tpLYcVsK; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235645AbhHRA5E (ORCPT + 99 others); Tue, 17 Aug 2021 20:57:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234789AbhHRA5D (ORCPT ); Tue, 17 Aug 2021 20:57:03 -0400 Received: from mail-qk1-x749.google.com (mail-qk1-x749.google.com [IPv6:2607:f8b0:4864:20::749]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0864EC061764 for ; Tue, 17 Aug 2021 17:56:30 -0700 (PDT) Received: by mail-qk1-x749.google.com with SMTP id y185-20020a3764c20000b02903d2c78226ceso593372qkb.6 for ; Tue, 17 Aug 2021 17:56:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=kPhI44KGUm7/8eTG3gY7/tZXObx8TawisVJaeXRWoBI=; b=tpLYcVsKnU/TlaQgjIZeDx43Brjgw8Ld3uV8bjbsqHjo5HJjjJxIjuVvPH5j9HAHr3 UTyMNG96+Fu10AxK2l5kFPXDJ78FxtG0F3jJJfWSrItdMA6g82/N187s7hPbpyr1igDn v8wSl6VBunCCEgBgwghc74+icMtW633p1mYcWuQVHfPUGbnC+MBZcJnaF2NGIZkWVco8 P8fev9SpUEx17b5kIqaoGNBcLF7nxEtbuJX7BsggwBasOiyphArB/2gTLzIod031m41u DFH1j/aR9B4iwVooopPm4S699wKe1HYP1v4i+18QWt+veXtjxGnaHsixca01Ipzu7JVn e6Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=kPhI44KGUm7/8eTG3gY7/tZXObx8TawisVJaeXRWoBI=; b=czCX29N9kprwgeDPCTQeFVnJShl5sBX9eo4WgMelo7VyqB27zYOg+TybKYSdnMkIdi NTaamIKGE3TOEAECstIcF8XmoeJm4uryvaIMez4Eh22ajXeG4xzdJoJWTstoEE41OOCP HFIssDfgFqNtEzrJXWvH6BIr3E+oKmPTd0XvjDWG/hkQocwXqRDwWp6oVpYVOsSOGB4U TxteoB5OItFxkGAhceFPQtWiSjJzgo4ShzvQcfI4LGUYs3RfWCpt+Pcd7Yt1qMo/vFhb kHeqwsGEk8aOhBWTkxDr2vNlq2Q1EtWWEDqb0PMOzmTgLFoUVh3y/vuTxvD3UYbo/keg Hy7Q== X-Gm-Message-State: AOAM530tA8JzoHVMJTX0Ee1MjW6UdtK3jzdy15qYENbKp28lWzW6Ue0f y9NUeRvR4tf/z6nIHMTkXSYVOFf29CRR X-Received: from joshdon.svl.corp.google.com ([2620:15c:2cd:202:2f5f:84e3:5bc7:d6a0]) (user=joshdon job=sendgmr) by 2002:a05:6214:1c47:: with SMTP id if7mr6334685qvb.6.1629248189161; Tue, 17 Aug 2021 17:56:29 -0700 (PDT) Date: Tue, 17 Aug 2021 17:56:15 -0700 Message-Id: <20210818005615.138527-1-joshdon@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.33.0.rc1.237.g0d66db33f3-goog Subject: [PATCH] sched/core: fix pick_next_task 'max' tracking From: Josh Don To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot Cc: Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Joel Fernandes , Vineeth Pillai , linux-kernel@vger.kernel.org, Josh Don Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For core-sched, pick_next_task will update the 'max' task if there is a cookie mismatch (since in this case the new task must be of higher priority than the current max). However, we fail to update 'max' if we've found a task with a matching cookie and higher priority than 'max'. This can result in extra iterations on SMT-X machines, where X > 2. As an example, on a machine with SMT=3, on core 0, SMT-0 might pick the following, in order: - SMT-0: p1, with cookie A, and priority 10 (max = p1) - SMT-1: p2, with cookie A, and priority 30 (max not updated here) - SMT-2: p3, with cookie B, and priority 20 (max = p2) > invalidate the other picks and retry Here, we should have instead updated 'max' when picking for SMT-1. Note that this code would eventually have righted itself, since the retry loop would re-pick p2, and update 'max' accordingly. However, this patch avoids the extra round-trip. Signed-off-by: Josh Don --- kernel/sched/core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 3431939699dc..110ea7582a33 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -5623,6 +5623,8 @@ pick_next_task(struct rq *rq, struct task_struct *prev, struct rq_flags *rf) occ = 1; goto again; } + } else if (prio_less(max, p, fi_before)) { + max = p; } } } -- 2.33.0.rc1.237.g0d66db33f3-goog