Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3381789pxb; Sat, 9 Oct 2021 08:57:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyRUpJBBh2PjMY09Ngm0xpe/FlhMKw7ASjN1pFXKatXExPvxcs3x0tXgzhTFYwIUy7yCvd2 X-Received: by 2002:aa7:cd99:: with SMTP id x25mr24490615edv.266.1633795044531; Sat, 09 Oct 2021 08:57:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633795044; cv=none; d=google.com; s=arc-20160816; b=0SBg6qlB4cy7QWzJ8Q2AjO+DXcjDLZ3kQeKO2P3867snqPYA3KSA/gFMsQzr6WatAs qPEoH2CsXY/X4ihmdAXvg4P5JUPAX/Aen5cPoMg9uTOwriX1UBm1sgAlJuroR2y7DQGR YHIJ73QQYwmwJ9USIiQOj5GzQU0hnH1IdPDbeZEPdn1HRzQNFU2NuhWgNY8L7v1Si/vS dw+HZWeLKn1kt/sdXNApF9GUoPbwUs8dHwTENGLfelFNbQpnX+LEzIMli4jtOewQSCRt Pa23wpGP46EY4L7HJi9K3OoPmCynjbCw15Lm1RZq4GrM4w+Mmw7vnfa7xpG8XMuAZuU1 Bc2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=BaJAUCjClYecxQc1UPNq1ARwrAK2TC7OhEGmPGg48ss=; b=HXEZFELIdrdno+G4UeooXOzloXa5ORbnuUtYunnAjmXDhsEz5OYoXc7dtzY96TPRIK r6sERKipmUva0cj5e5ENmfmu5a3KOZaZf1vmXWkDY1aHarqjKEKNptY65BceEMnk1ecd kZcmsjr4TWbB9FUHnkufkY1EiJcDUVuLMIp8v2W4tQSd1C+ChwGyBk5LYFARSOUIEYst AehnNLwPobbu7Gczurnjpl8I5KrPXVetP9jitV66oANBO6F1nHbKuOTYigpQ5M4M9Xk/ tQblOtTQOuNQQ7/WTV+msD9A2ec0RgJciCrt4NP0embeFfUtDpIHlaUHj2fbGzSOw2N5 PgCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=fwh7dIO1; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i8si992368edx.406.2021.10.09.08.56.59; Sat, 09 Oct 2021 08:57:24 -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=@infradead.org header.s=casper.20170209 header.b=fwh7dIO1; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234695AbhJIP5b (ORCPT + 99 others); Sat, 9 Oct 2021 11:57:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234428AbhJIP5a (ORCPT ); Sat, 9 Oct 2021 11:57:30 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CEA03C061570 for ; Sat, 9 Oct 2021 08:55:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=BaJAUCjClYecxQc1UPNq1ARwrAK2TC7OhEGmPGg48ss=; b=fwh7dIO1KZWEgTkxAbewra7U4Z Uf5ppxbr3wf/egJnDn6+s2A4LdN5F4LiJJvQ/bG8gMt4oiB7tWQ8VvFKD8YoPC/BsuKg8dVbNoLRA mUgKnYHPZEXFIMtq9im+/WwZDSC95ROUGrxEKq9jIMpCJdrfjNkLVGBXdjVscUXu3gbXBWJAyh23N 6Dg++F6PWKdWFY5pEN+H06Frj1GTIAPAuwj7HIrTHPWck5diUm/KSKsMRn2KfwWdhYTXcVh9sFGkn DH8bMH7UuDXdgHa0KKlzkjvjX8KGYLlDPKAQ6p2HBL3TG6UQhf9v7fKVboF5KzTvhe06rUNRd99r5 9Zt7oFmA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mZEgF-004FDD-JP; Sat, 09 Oct 2021 15:54:41 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id 2FB2D9811D4; Sat, 9 Oct 2021 17:54:35 +0200 (CEST) Date: Sat, 9 Oct 2021 17:54:35 +0200 From: Peter Zijlstra To: Josh Don Cc: Ingo Molnar , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Joel Fernandes , Vineeth Pillai , Hao Luo , linux-kernel@vger.kernel.org Subject: Re: [PATCH] sched/core: forced idle accounting Message-ID: <20211009155435.GW174703@worktop.programming.kicks-ass.net> References: <20211008000825.1364224-1-joshdon@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211008000825.1364224-1-joshdon@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 07, 2021 at 05:08:25PM -0700, Josh Don wrote: > Adds accounting for "forced idle" time, which is time where a cookie'd > task forces its SMT sibling to idle, despite the presence of runnable > tasks. > > Forced idle time is one means to measure the cost of enabling core > scheduling (ie. the capacity lost due to the need to force idle). It seems an excessive amount of code for what it says to do. > + smt_count = cpumask_weight(smt_mask); That's a fairly expensive operation to find a number that's going the be to same over and over and over... > + if (smt_count > 2) { > + unsigned int nr_forced_idle = 0, nr_running = 0; > + > + for_each_cpu(i, smt_mask) { > + rq_i = cpu_rq(i); > + p = rq_i->core_pick ?: rq_i->curr; > + > + if (p != rq_i->idle) > + nr_running++; > + else if (rq_i->nr_running) > + nr_forced_idle++; > + } > + > + if (WARN_ON_ONCE(!nr_running)) { > + /* can't be forced idle without a running task */ > + } else { > + delta *= nr_forced_idle; > + delta /= nr_running; > + } Now the comment sayeth: > + /* > + * For larger SMT configurations, we need to scale the charged > + * forced idle amount since there can be more than one forced idle > + * sibling and more than one running cookied task. > + */ But why? > + } > + > + for_each_cpu(i, smt_mask) { > + rq_i = cpu_rq(i); > + p = rq_i->core_pick ?: rq_i->curr; > + > + if (!p->core_cookie) > + continue; > + > + p->core_forceidle_sum += delta; > + > + /* Optimize for common case. */ > + if (smt_count == 2) > + break; > + } > +}