From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0C43C4338F for ; Mon, 23 Aug 2021 20:25:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C49D7613DB for ; Mon, 23 Aug 2021 20:25:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232517AbhHWU00 (ORCPT ); Mon, 23 Aug 2021 16:26:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231569AbhHWU0X (ORCPT ); Mon, 23 Aug 2021 16:26:23 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6F15C061575 for ; Mon, 23 Aug 2021 13:25:40 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id e5so11416460wrp.8 for ; Mon, 23 Aug 2021 13:25:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=XA/U7CbvSIHKK66o3nJxmSeGYBaHonHFImu9Oh5UX2A=; b=Savy0dtjx7o4Aqu7CBxxzc8ewmDn9EunBQaxTV4NbqlxfqCJeRB2lscks5obwevqWE Oa84PwV1s+eZtxZcICaa7Vk/6pLdFvoA2IQNJZPj9pcRZ70RTs7eLEvYo8S7F0TfjwQv 9Uv/bHtyyeRkEasrUlf9aP0aI5fGlPJWwe8aBbdyplJoCnG6h41PoOoZ58Ea6HHLdN+n 7k3cpIlO13/VaXzx2vW/MW8i6hVtcMgobFmPSueVrJObXb0mZZinwI7HtFvYBTU8svHc U+sQcWsdv8efpqYh2VS8zDHfZZo9GAOomihCEjrVO7pw9vA4wZBrrXhbyY1spwtE195S xkQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=XA/U7CbvSIHKK66o3nJxmSeGYBaHonHFImu9Oh5UX2A=; b=s6f+4lLU1+T9rzE+zAXpLVH8H0g7dOiwCAnDS/XZ3eAvZPCHBxSCBiVL2A0DUjiY0W 9EdcTvD1pLP/tBI7ed03tYoCduio3domMmDi82h94YE6vSUlYyr0sAqFo4crZbRnmHow Ah7089d0Ci4OOQkd2g8BaIqhae8wasaUVL+cnfVNUU3NUlZ6c8uFsEFj4B6tsDhqMeic UDepcXxB13UWPXkxF8Yoxdii2DO5BU5w65/L2zi3UnvROc6J5MnHQGecczQ2/Vft9qaF JeTeBcftDEoGjR4xdwgui1ctcNbZ4Y6RLQqg/V//Z6lucK+tsHnaWrfE+tdl48ufmZsO 9Iag== X-Gm-Message-State: AOAM532DWnqDDqtnrw04WDts2epk6V7GFNqT/iqUYsNmEF8kSevE6wag iboYb1jHjhMH6NGYdP/NImHPOozg407vM/n8HGA= X-Google-Smtp-Source: ABdhPJyNa4Lhm1KPbXEFf/bFRJxZKAu46GiYfOhGAEuvv8PN5HHbO365Vb1nUqKVFQ4BuYLk/jroKtWvh7NyYYQuoBQ= X-Received: by 2002:a5d:4d03:: with SMTP id z3mr15596912wrt.229.1629750339391; Mon, 23 Aug 2021 13:25:39 -0700 (PDT) MIME-Version: 1.0 References: <20210818005615.138527-1-joshdon@google.com> In-Reply-To: From: Vineeth Pillai Date: Mon, 23 Aug 2021 16:25:28 -0400 Message-ID: Subject: Re: [PATCH] sched/core: fix pick_next_task 'max' tracking To: Peter Zijlstra Cc: Josh Don , Ingo Molnar , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Joel Fernandes , linux-kernel@vger.kernel.org, tao.zhou@linux.dev Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Peter, > > 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. > > Going with the observation Tao made; how about we rewrite the whole lot > to not be mind-bending complicated :-) > > How's this? It seems to build and pass the core-sched selftest thingy > (so it must be perfect, right? :-) > Nice, the code is much simpler now :-). A minor suggestion down.. > - for_each_cpu(i, smt_mask) { > - struct rq *rq_i = cpu_rq(i); > - > + /* > + * For each thread: do the regular task pick and find the max prio task > + * amongst them. > + * > + * Tie-break prio towards the current CPU > + */ > + for_each_cpu_wrap(i, smt_mask, cpu) { > + rq_i = cpu_rq(i); > rq_i->core_pick = NULL; > > if (i != cpu) > update_rq_clock(rq_i); > + > + for_each_class(class) { > + p = rq_i->core_temp = class->pick_task(rq_i); I think we can use core_pick to store the pick here and core_temp might not be required. What do you feel? > + if (p) > + break; > + } > + > + if (!max || prio_less(max, p, fi_before)) > + max = p; Thanks, Vineeth