Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2160078pxb; Mon, 23 Aug 2021 13:29:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxsx1XBDiB03JsoVERswGJ7KosW2dXx367IhDPQKN1OJ24fr9PrZUgKIFI51jV/r/jauP7 X-Received: by 2002:a17:907:2989:: with SMTP id eu9mr36823376ejc.89.1629750581598; Mon, 23 Aug 2021 13:29:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629750581; cv=none; d=google.com; s=arc-20160816; b=WQjTc7Z7a6n5SdzKljxrdT3wnwC986Ax6hfC10X+IOKQnr0TvQqaKXejdWd2L1WhdW B0k4gvtoN1Sl6n67Hl+ZstzlkNDw3zPgi2nyiJ/SvEtN1z8DTmiAXt/Djn5aWZEVIX9E MV+J1eXaKTEjLYNspfiId5Cx7Kj4EXyFLrYMUfg+3skRje/er6rVaMVYlKC1Vl8BpwZ/ oT/JchQTRNIpj+8LBGgqDP0aDVSdBvJjgZ222zbF1uqSWXBoFaf+Vl+j+bhd3WCaMa7M qOvJDqmSL0qNWmd/P8abcyl9tsIiKsm7FfvqWS9DEFgtL9Nie7eWOCEQ0Ohy6EGkGmbg GywQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=XA/U7CbvSIHKK66o3nJxmSeGYBaHonHFImu9Oh5UX2A=; b=J6FuFDe/RieFoeUqieVXZPOI1WbmrEOsIhL6veCTEt6teUaG1TQMYMolcLRv0BHmc6 UUQlLAiw8uRC1sATkjnrQs+8ekwY4qWFw80Sceqw3aoL1kM+armnmhR2fcYIHl+F7PxC UbReVgnMNZJvhjhuRJfGIO9mPgc25Is8Dn9obA/T7Xh+3HFW2+GpqunmunPPMsQR9Mxe 8j1EsvoMThCIVZs0spe/9EflazUnX4IGSzsjlKy0tCn0GxuIg7wOcRcg88BAnPIdNMAw tabTCPvTsfYoTwHKqMZmdoTMvqV3NbrsGh3FE/nbjr93lwuSTd9zeBBMrF/ISuE9ocIs X8og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Savy0dtj; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o10si15898483edw.236.2021.08.23.13.29.18; Mon, 23 Aug 2021 13:29:41 -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=@gmail.com header.s=20161025 header.b=Savy0dtj; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232404AbhHWU0Z (ORCPT + 99 others); Mon, 23 Aug 2021 16:26:25 -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-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