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 B937BC433EC for ; Mon, 22 Mar 2021 13:18:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A1A266191D for ; Mon, 22 Mar 2021 13:18:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233414AbhCVNRZ (ORCPT ); Mon, 22 Mar 2021 09:17:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230169AbhCVNLw (ORCPT ); Mon, 22 Mar 2021 09:11:52 -0400 Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44E4EC061756 for ; Mon, 22 Mar 2021 06:11:52 -0700 (PDT) Received: by mail-lj1-x22f.google.com with SMTP id y1so20928237ljm.10 for ; Mon, 22 Mar 2021 06:11:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=THXO5+mjXh1wGkFTexS2PYltIzJKCCGh8lFumPrqIUY=; b=V3NLN9AF7s5KHxwHc8zstJJRA3ykdhSnxEDgxe3WMgNzeRnF423817353hONJNttBt IipdJOsfIG8B74RBK7vEBWA8NjXegBGPcFFshSF6RtBDZYXY8g/+BEuUHCmdhBg8PBcu GWLDSgNX+lM5Iw6oQ2LtCLigAaCIf0gJc6yqPXCz7jJQxaL5XPQKAsuD2KS1sVkBIyfJ 0Fw3ynmBI/1BHRLOINoThu+fkeg08RVu5S2IEMDWXlcMPHjahTG21ixlx9q8gJueuA13 baqsv5uWiL9u0gV3hxc/W4SBGDOmQzYh2Yy4EyJP8vsqpgCyxQSwmn7UeNyODsGK3qw8 t2OQ== 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=THXO5+mjXh1wGkFTexS2PYltIzJKCCGh8lFumPrqIUY=; b=h+OOxDSxmT3n36L006aqYW0lG44GM3UhC4xrgOKhGwVFiVYm1cOlhK3V5/TPQIeUQn 1NdnpdhRaBXTuJaq2bv+XkFRTWRCOS6LwJJQHD/M7MZbgaVYqqEYc2tasuRFIkLWKkJj NWL19OQQPyYJ97fjPeLDfx55ORHB2wPTYmfi/mSThRN8J9g20MW3/ZS60AAnwI7KQ0R+ PjRJSTDwyM6ZhN9qkViSbHxY0RhAoEx5eZoaO9/UbPqjI/JIMre/hw4hBJSytgvjsdT5 DZyRFhbbmhn44rRdyhvEuWmyhgezoIrhZ0Pkd0UUDA48vsz0gj/zuEyTC3ccGG3V8U4W BEgw== X-Gm-Message-State: AOAM5312y10StHly1EEeAZ1xNtWKAnZzV0dks6YSRxSYH+2oEXMnC3vt HiH2VDYaWoZqA2NbCuqE5LNho8LAaxcPsuMoWge+ztP16jo= X-Google-Smtp-Source: ABdhPJz16JNIGQBV7CTW00f/Xrkuu51V8tB5htHWVkMZgSlN0DgeAVtgBo8MdX20BkyJVz4NDLMTzFFdflAQpS3lAsE= X-Received: by 2002:a2e:96c3:: with SMTP id d3mr9982514ljj.284.1616418710743; Mon, 22 Mar 2021 06:11:50 -0700 (PDT) MIME-Version: 1.0 References: <20210320221432.924-1-song.bao.hua@hisilicon.com> In-Reply-To: <20210320221432.924-1-song.bao.hua@hisilicon.com> From: Vincent Guittot Date: Mon, 22 Mar 2021 14:11:38 +0100 Message-ID: Subject: Re: [PATCH] sched/fair: remove redundant test_idle_cores for non-smt To: Barry Song Cc: Ingo Molnar , Peter Zijlstra , Juri Lelli , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , Aubrey Li , LAK , linux-kernel , "xuwei (O)" , "Zengtao (B)" , Guodong Xu , yangyicong@huawei.com, "Liguozhu (Kenneth)" , linuxarm@openeuler.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 20 Mar 2021 at 23:21, 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% > > Signed-off-by: Barry Song Reviewed-by: Vincent Guittot > --- > kernel/sched/fair.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index 2e2ab1e..de42a32 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -6038,9 +6038,11 @@ static inline bool test_idle_cores(int cpu, bool def) > { > 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; > } > -- > 1.8.3.1 > 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 4FF9AC433C1 for ; Mon, 22 Mar 2021 13:16:31 +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 E4F8761606 for ; Mon, 22 Mar 2021 13:16:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E4F8761606 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.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:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=kMmxjrWlxe6E37quCj0ACLLRC5Me5pdn0CN09SjBxjw=; b=hR/tA2ixrvt14/gRFYM/mxfbh JTseOOg9P2B2vjxdKfMDKUkC4qB9CL7hTYKzdUDspkUYPmVgCfTMy7s/WW/laWgwOyLxYD/Ljy1zi kqQCJymH2GGnpB+zhglB2akFqVJfOHT2Nlw3EmxvRU/t3xV8YYMqw0v6YFJyjBsT2W1zr1BCXriUt cadS4AWDegCviZDe4FgqnktIhlBq56mqySUQrULdKY0e17bbgG8mUHWLzqHGGQ6volOcp47yURr50 y51CMVKyg8OjT1GVBS9TkrDhm3TLqL8aaMjitNVhsXxeE3XwRveutuXkod4HlU9rMFifdbbB7+blr znDY39jCQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lOKNk-00BfAD-4T; Mon, 22 Mar 2021 13:14:08 +0000 Received: from mail-lj1-x231.google.com ([2a00:1450:4864:20::231]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lOKLa-00Ben4-Jg for linux-arm-kernel@lists.infradead.org; Mon, 22 Mar 2021 13:13:58 +0000 Received: by mail-lj1-x231.google.com with SMTP id 184so20941005ljf.9 for ; Mon, 22 Mar 2021 06:11:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=THXO5+mjXh1wGkFTexS2PYltIzJKCCGh8lFumPrqIUY=; b=V3NLN9AF7s5KHxwHc8zstJJRA3ykdhSnxEDgxe3WMgNzeRnF423817353hONJNttBt IipdJOsfIG8B74RBK7vEBWA8NjXegBGPcFFshSF6RtBDZYXY8g/+BEuUHCmdhBg8PBcu GWLDSgNX+lM5Iw6oQ2LtCLigAaCIf0gJc6yqPXCz7jJQxaL5XPQKAsuD2KS1sVkBIyfJ 0Fw3ynmBI/1BHRLOINoThu+fkeg08RVu5S2IEMDWXlcMPHjahTG21ixlx9q8gJueuA13 baqsv5uWiL9u0gV3hxc/W4SBGDOmQzYh2Yy4EyJP8vsqpgCyxQSwmn7UeNyODsGK3qw8 t2OQ== 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=THXO5+mjXh1wGkFTexS2PYltIzJKCCGh8lFumPrqIUY=; b=n0FW9/KEwY6K7DrpjOdvLwYYzNQfaCmYySJqQRd3DK37eJH/qMdFuC+C2PPKHPM+2b 2qI9yS6UvsC7ICvp463N8RhjCwRZnqPthSSIRBNZjRrE2mQvr/RiUoooglWU8+d4yl9p XeBtRjdd8zHbycO4ccXohi8vTkyM64rodHqHujFNsYGYGV5O8Njo2XOMtDyqvBN0Jpto bKgpvntqwoQ9rVPriXUEA07fR/zunlfgKQq90q8Wk3Uj3tFLKg/cLztunlqZNW/3Mn+r d1pyWK4O92sDrVNk68bM2RxPjOGg/WR1gFgAUuJYRt73b+c/JsSSbUyLj/6t9p08gnVO ucuQ== X-Gm-Message-State: AOAM530vt9ARtsVK0oZc9BBFLz3d1kS7908eEWREMOVM8G/hUGwEAGwo GW4elf1z+vS0zFJ+7STmflhtdW77zRJmfetPFAlT/A== X-Google-Smtp-Source: ABdhPJz16JNIGQBV7CTW00f/Xrkuu51V8tB5htHWVkMZgSlN0DgeAVtgBo8MdX20BkyJVz4NDLMTzFFdflAQpS3lAsE= X-Received: by 2002:a2e:96c3:: with SMTP id d3mr9982514ljj.284.1616418710743; Mon, 22 Mar 2021 06:11:50 -0700 (PDT) MIME-Version: 1.0 References: <20210320221432.924-1-song.bao.hua@hisilicon.com> In-Reply-To: <20210320221432.924-1-song.bao.hua@hisilicon.com> From: Vincent Guittot Date: Mon, 22 Mar 2021 14:11:38 +0100 Message-ID: Subject: Re: [PATCH] sched/fair: remove redundant test_idle_cores for non-smt To: Barry Song Cc: Ingo Molnar , Peter Zijlstra , Juri Lelli , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , Aubrey Li , LAK , linux-kernel , "xuwei (O)" , "Zengtao (B)" , Guodong Xu , yangyicong@huawei.com, "Liguozhu (Kenneth)" , linuxarm@openeuler.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210322_131356_363202_F3552061 X-CRM114-Status: GOOD ( 23.74 ) 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 Sat, 20 Mar 2021 at 23:21, 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% > > Signed-off-by: Barry Song Reviewed-by: Vincent Guittot > --- > kernel/sched/fair.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index 2e2ab1e..de42a32 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -6038,9 +6038,11 @@ static inline bool test_idle_cores(int cpu, bool def) > { > 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; > } > -- > 1.8.3.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel