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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 81796C433C1 for ; Mon, 22 Mar 2021 11:14:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5B06C60C3D for ; Mon, 22 Mar 2021 11:14:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230248AbhCVLNz (ORCPT ); Mon, 22 Mar 2021 07:13:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230215AbhCVLNr (ORCPT ); Mon, 22 Mar 2021 07:13:47 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0C16C061574 for ; Mon, 22 Mar 2021 04:13:46 -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=IIIw13O8cplkzyhExasOFLMgFkr0z+hZIs3WQKQ9yFU=; b=v40pu7Sjgj89k9iH9TmwhRiPVb IUzOsxkrh1STZqx7Mkg4kso7yqoj5EMssEHesSQcVr+G1oG3YeKVRGP3JSG4bYTEFvG7Pbt3Ek6ah H5/lSs+Pr9WBphU2wBsbbyIPaB4LAlBTFUxfaLiwr1O4Y99WP1/HuiTJtZjqeUSp5mo0/VU10bZLf B7oQDbbe1caKiV3MUUvT2AJcuO/hW97DijP+cEu37vxRPSDqOHTqEcBhBWtb//XHsDPtevbI0+0b4 IH22PhfFp2Fza/T1q8iPmvEg9am+7C4vboLibIJ4sJWMe9eqtQnj1dQDL1lvAcj7ruiaK5YSLHVgd +9TEO5dg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1lOIQl-008OfY-PJ; Mon, 22 Mar 2021 11:09:27 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 0021930377D; Mon, 22 Mar 2021 12:09:05 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id D4B902BCFBDAD; Mon, 22 Mar 2021 12:09:05 +0100 (CET) Date: Mon, 22 Mar 2021 12:09:05 +0100 From: Peter Zijlstra To: Barry Song Cc: vincent.guittot@linaro.org, mingo@redhat.com, juri.lelli@redhat.com, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, valentin.schneider@arm.com, aubrey.li@linux.intel.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, xuwei5@huawei.com, prime.zeng@hisilicon.com, guodong.xu@linaro.org, yangyicong@huawei.com, liguozhu@hisilicon.com, linuxarm@openeuler.org Subject: Re: [PATCH] sched/fair: remove redundant test_idle_cores for non-smt Message-ID: References: <20210320221432.924-1-song.bao.hua@hisilicon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210320221432.924-1-song.bao.hua@hisilicon.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Mar 21, 2021 at 11:14:32AM +1300, Barry Song wrote: > update_idle_core() is only done for the case of sched_smt_present. > but test_idle_cores() is done for all machines even those without > smt. > this could contribute to up 8%+ hackbench performance loss on a > machine like kunpeng 920 which has no smt. this patch removes the > redundant test_idle_cores() for non-smt machines. > > we run the below hackbench with different -g parameter from 2 to > 14, for each different g, we run the command 10 times and get the > average time: > $ numactl -N 0 hackbench -p -T -l 20000 -g $1 > > hackbench will report the time which is needed to complete a certain > number of messages transmissions between a certain number of tasks, > for example: > $ numactl -N 0 hackbench -p -T -l 20000 -g 10 > Running in threaded mode with 10 groups using 40 file descriptors each > (== 400 tasks) > Each sender will pass 20000 messages of 100 bytes > > The below is the result of hackbench w/ and w/o this patch: > g= 2 4 6 8 10 12 14 > w/o: 1.8151 3.8499 5.5142 7.2491 9.0340 10.7345 12.0929 > w/ : 1.8428 3.7436 5.4501 6.9522 8.2882 9.9535 11.3367 > +4.1% +8.3% +7.3% +6.3% > The patch looks obvious, but the Changelog and Subject needed a lot of help. I've changed it like so: --- Subject: sched/fair: Optimize test_idle_cores() for !SMT From: Barry Song Date: Sun, 21 Mar 2021 11:14:32 +1300 From: Barry Song update_idle_core() is only done for the case of sched_smt_present. but test_idle_cores() is done for all machines even those without SMT. This can contribute to up 8%+ hackbench performance loss on a machine like kunpeng 920 which has no SMT. This patch removes the redundant test_idle_cores() for !SMT machines. Hackbench is ran with -g {2..14}, for each g it is ran 10 times to get an average. $ numactl -N 0 hackbench -p -T -l 20000 -g $1 The below is the result of hackbench w/ and w/o this patch: g= 2 4 6 8 10 12 14 w/o: 1.8151 3.8499 5.5142 7.2491 9.0340 10.7345 12.0929 w/ : 1.8428 3.7436 5.4501 6.9522 8.2882 9.9535 11.3367 +4.1% +8.3% +7.3% +6.3% Signed-off-by: Barry Song Signed-off-by: Peter Zijlstra (Intel) Acked-by: Mel Gorman Link: https://lkml.kernel.org/r/20210320221432.924-1-song.bao.hua@hisilicon.com --- kernel/sched/fair.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6038,9 +6038,11 @@ static inline bool test_idle_cores(int c { struct sched_domain_shared *sds; - sds = rcu_dereference(per_cpu(sd_llc_shared, cpu)); - if (sds) - return READ_ONCE(sds->has_idle_cores); + if (static_branch_likely(&sched_smt_present)) { + sds = rcu_dereference(per_cpu(sd_llc_shared, cpu)); + if (sds) + return READ_ONCE(sds->has_idle_cores); + } return def; } 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=-14.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 EAF88C433DB for ; Mon, 22 Mar 2021 11:12:07 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8A4F961984 for ; Mon, 22 Mar 2021 11:12:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8A4F961984 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=XBFDXRvXMKfhppcrCGy85k80qgVIsQE4lctGzipikiI=; b=SrGmskRhzr2bkCOD3obqi5cFu n+WnHLdWX6gArqxSV/Vt84M0dTKKGsEkDs7ORT9VB063K2npek0bj6kU5ZD4j9apqfbAqi0R8zQdB uR03+4/IdPZc3v/CRY1zlF4bCAunnal/vLUyp4w7sfGMnzoZC4+IM7f3UxLaQWQFhA5T86Gs4PlR0 k2lWjsCRHzkuiYeAJwyYgpyAfrfQuXtTlE1cBO3xNLH4UpcAVhcwYangb5IyqgCeFChr9EzKICUhu XJVTwtVYqTg3FByAKxL1etf6LNI6RXSp3S9GsmxDv02RBWEaPxciB18LD7XaO2P0MwBgnqadj+JXI /LWv1etDw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lOIRz-00BPsU-N1; Mon, 22 Mar 2021 11:10:23 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lOIRv-00BPsG-Uo for linux-arm-kernel@desiato.infradead.org; Mon, 22 Mar 2021 11:10:21 +0000 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=IIIw13O8cplkzyhExasOFLMgFkr0z+hZIs3WQKQ9yFU=; b=v40pu7Sjgj89k9iH9TmwhRiPVb IUzOsxkrh1STZqx7Mkg4kso7yqoj5EMssEHesSQcVr+G1oG3YeKVRGP3JSG4bYTEFvG7Pbt3Ek6ah H5/lSs+Pr9WBphU2wBsbbyIPaB4LAlBTFUxfaLiwr1O4Y99WP1/HuiTJtZjqeUSp5mo0/VU10bZLf B7oQDbbe1caKiV3MUUvT2AJcuO/hW97DijP+cEu37vxRPSDqOHTqEcBhBWtb//XHsDPtevbI0+0b4 IH22PhfFp2Fza/T1q8iPmvEg9am+7C4vboLibIJ4sJWMe9eqtQnj1dQDL1lvAcj7ruiaK5YSLHVgd +9TEO5dg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1lOIQl-008OfY-PJ; Mon, 22 Mar 2021 11:09:27 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 0021930377D; Mon, 22 Mar 2021 12:09:05 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id D4B902BCFBDAD; Mon, 22 Mar 2021 12:09:05 +0100 (CET) Date: Mon, 22 Mar 2021 12:09:05 +0100 From: Peter Zijlstra To: Barry Song Cc: vincent.guittot@linaro.org, mingo@redhat.com, juri.lelli@redhat.com, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, valentin.schneider@arm.com, aubrey.li@linux.intel.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, xuwei5@huawei.com, prime.zeng@hisilicon.com, guodong.xu@linaro.org, yangyicong@huawei.com, liguozhu@hisilicon.com, linuxarm@openeuler.org Subject: Re: [PATCH] sched/fair: remove redundant test_idle_cores for non-smt Message-ID: References: <20210320221432.924-1-song.bao.hua@hisilicon.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210320221432.924-1-song.bao.hua@hisilicon.com> X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Sun, Mar 21, 2021 at 11:14:32AM +1300, Barry Song wrote: > update_idle_core() is only done for the case of sched_smt_present. > but test_idle_cores() is done for all machines even those without > smt. > this could contribute to up 8%+ hackbench performance loss on a > machine like kunpeng 920 which has no smt. this patch removes the > redundant test_idle_cores() for non-smt machines. > > we run the below hackbench with different -g parameter from 2 to > 14, for each different g, we run the command 10 times and get the > average time: > $ numactl -N 0 hackbench -p -T -l 20000 -g $1 > > hackbench will report the time which is needed to complete a certain > number of messages transmissions between a certain number of tasks, > for example: > $ numactl -N 0 hackbench -p -T -l 20000 -g 10 > Running in threaded mode with 10 groups using 40 file descriptors each > (== 400 tasks) > Each sender will pass 20000 messages of 100 bytes > > The below is the result of hackbench w/ and w/o this patch: > g= 2 4 6 8 10 12 14 > w/o: 1.8151 3.8499 5.5142 7.2491 9.0340 10.7345 12.0929 > w/ : 1.8428 3.7436 5.4501 6.9522 8.2882 9.9535 11.3367 > +4.1% +8.3% +7.3% +6.3% > The patch looks obvious, but the Changelog and Subject needed a lot of help. I've changed it like so: --- Subject: sched/fair: Optimize test_idle_cores() for !SMT From: Barry Song Date: Sun, 21 Mar 2021 11:14:32 +1300 From: Barry Song update_idle_core() is only done for the case of sched_smt_present. but test_idle_cores() is done for all machines even those without SMT. This can contribute to up 8%+ hackbench performance loss on a machine like kunpeng 920 which has no SMT. This patch removes the redundant test_idle_cores() for !SMT machines. Hackbench is ran with -g {2..14}, for each g it is ran 10 times to get an average. $ numactl -N 0 hackbench -p -T -l 20000 -g $1 The below is the result of hackbench w/ and w/o this patch: g= 2 4 6 8 10 12 14 w/o: 1.8151 3.8499 5.5142 7.2491 9.0340 10.7345 12.0929 w/ : 1.8428 3.7436 5.4501 6.9522 8.2882 9.9535 11.3367 +4.1% +8.3% +7.3% +6.3% Signed-off-by: Barry Song Signed-off-by: Peter Zijlstra (Intel) Acked-by: Mel Gorman Link: https://lkml.kernel.org/r/20210320221432.924-1-song.bao.hua@hisilicon.com --- kernel/sched/fair.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6038,9 +6038,11 @@ static inline bool test_idle_cores(int c { struct sched_domain_shared *sds; - sds = rcu_dereference(per_cpu(sd_llc_shared, cpu)); - if (sds) - return READ_ONCE(sds->has_idle_cores); + if (static_branch_likely(&sched_smt_present)) { + sds = rcu_dereference(per_cpu(sd_llc_shared, cpu)); + if (sds) + return READ_ONCE(sds->has_idle_cores); + } return def; } _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel