Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp9208004rwd; Wed, 21 Jun 2023 04:39:36 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5yVoX2qauNm3jczJAzZdKnAkWnXj3dYsRoRRpzn4gYmPnSVImlFbNvGu98vXYbJmnzKAtA X-Received: by 2002:a05:6a20:258c:b0:123:6bd8:90d5 with SMTP id k12-20020a056a20258c00b001236bd890d5mr516072pzd.36.1687347576174; Wed, 21 Jun 2023 04:39:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687347576; cv=none; d=google.com; s=arc-20160816; b=DMbssYmFQXS47fGGcE1vT3Ex51xv1k1csPwYKI2S/qJYssJo81frwfMbfsrEToUY2W sj5ywL7oJEKuewPDnT0fS1MBJBXvGRqL/d2KRVEbpVvYhanNfeyMCKsSVBqtsE4ZTG5n gv7xeub7b1UpLjjM+QMxhPcTwqfe9RSvfLtje+YyNyDH6PRg3TgCEaxCrGlT3mEwZF9M FkgkuyFNJpzTbRWKEma0HZirOfIIdwdrQCXjOM5tcjx9k66jtF8WBNlAylcNOLEvJD0w /phbMfpvY7NFgY9K5dYBhEOemi7Tcf08hPpIsGsvhi7CEH9q715WkFm5rLVhAurMrTru Mg8Q== 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=NTnjGZKBu9TEe19lHWWEX9W303Dh2DKZfeOIZZMKAR8=; b=waa7IH9pZh1sy3ENoBntyPU6CrGa9anrybFOI5ToqiUTyREkDmw08BJeocP6WITtuH JKxRw0DvJt2LwHMvj/kLoffeAVkXmLiSO7Q8kGGNxLCjNiOxCKQuxqsAEaM3vrI2M3PE SdfBGYuwG5aQdiwjqHxpHZKXvt27fTx+H8dPmhl1uG5xDsgWBttv3m3yAhNzP4jN6uTM wsSXNG0Be2r4fItn4xdr64O+lIZmNfa/ohyX8KftnADmIv8ACzNn6khDAM97r5sJS61Z c1eXzadcL2tw/hhW1qWwy3nHmeCjdqgqikE8HXkdxy7YP53nmQa3TqqP+Z9Px2dQheHm XjSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=V4RocZfX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y1-20020a170902b48100b001aafe3f409asi3711739plr.205.2023.06.21.04.39.21; Wed, 21 Jun 2023 04:39:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=V4RocZfX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232405AbjFULTK (ORCPT + 99 others); Wed, 21 Jun 2023 07:19:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232298AbjFULSY (ORCPT ); Wed, 21 Jun 2023 07:18:24 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 868381BC for ; Wed, 21 Jun 2023 04:18:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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=NTnjGZKBu9TEe19lHWWEX9W303Dh2DKZfeOIZZMKAR8=; b=V4RocZfXblFLdVojirHUgpuHi4 BN1wr42TI+yB6elo4QjVPFiE4NVSB8EPLpY+O/UpCdm9191ekTVUl+Zzrj/+5iP8U2y2RqjnG11CB u6dW7ZcQf5dExDGUQ4RKUVeXj891ZOlyJEmHdRIMPA4IMpMmPwCKJH41sylyibSYJfoFT1J5HL6N7 bFXOKgaj6E6997w+mHKUQxe+fcOEOJpJR53MUb1Pqq0RvuyvHfg2X54g8P7JJOSybAvUKt8fgREQG InNLoM4Z2wQvgKRcgDwK6NQHkVY7bid5WSAjGBr922WqqW4Oqn6aDRceT6XHFZl8w2HXPDbkBihSW /KhKKBOw==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qBvq0-00HOeE-1k; Wed, 21 Jun 2023 11:17:24 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 65ED23002F0; Wed, 21 Jun 2023 13:17:21 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 4CF22246D37FC; Wed, 21 Jun 2023 13:17:21 +0200 (CEST) Date: Wed, 21 Jun 2023 13:17:21 +0200 From: Peter Zijlstra To: Chen Yu Cc: Vincent Guittot , Ingo Molnar , Juri Lelli , Tim Chen , Mel Gorman , Dietmar Eggemann , K Prateek Nayak , Abel Wu , "Gautham R . Shenoy" , Len Brown , Chen Yu , Yicong Yang , linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH 3/4] sched/fair: Calculate the scan depth for idle balance based on system utilization Message-ID: <20230621111721.GA2053369@hirez.programming.kicks-ass.net> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 13, 2023 at 12:18:57AM +0800, Chen Yu wrote: > When CPU is about to enter idle, it invokes newidle_balance() to pull > some tasks from other runqueues. Although there is per domain > max_newidle_lb_cost to throttle the newidle_balance(), it would be > good to further limit the scan based on overall system utilization. > The reason is that there is no limitation for newidle_balance() to > launch this balance simultaneously on multiple CPUs. Since each > newidle_balance() has to traverse all the CPUs to calculate the > statistics one by one, this total time cost on newidle_balance() > could be O(n^2). This is not good for performance or power saving. Another possible solution is to keep struct sg_lb_stats in sd->child->shared (below the NUMA domains) and put a lock around it. Then have update_sd_lb_stats() do something like: struct sg_lb_stats *sgs = &sds->sgs; if (raw_spin_trylock(&sds->sg_lock)) { struct sg_lb_stats tmp; ... collect tmp sds->sgs = tmp; raw_spin_unlock(&sds->sg_lock); } ... use sgs Then you know you've always got a 'recent' copy but avoid the concurrent updates.