Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp211262imw; Mon, 4 Jul 2022 07:54:20 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tWRDRUYxJ8jrnSbcv//KPF1LgMQwqdSeCLlWxLMznWjBf+PtbDyJ0m8DApO2rgu0voCh9U X-Received: by 2002:a17:906:5053:b0:70d:a0cc:b3fd with SMTP id e19-20020a170906505300b0070da0ccb3fdmr29288025ejk.162.1656946460467; Mon, 04 Jul 2022 07:54:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656946460; cv=none; d=google.com; s=arc-20160816; b=MOaz3/l5OmAa/sE6uodV/SvRh0gsOrbTJpaBppLB+IZeHmVWBxuo0SWeRGZUwZBsng eBSOB33O6iE5MnBAqOM/NfTOvvbyv79tk2+mhOzRsT1rAHLge38sfbHYdrmJHBWDT8W1 I9Y1IxwcFEvjwARCL28yfwHUw5Be/PYEeo7AXI99BiqkTqh52rcvV4LeFnqIsEQFL+1u Sx1A2Nwa0Q6dPC0fS5UTJo2m7hXxR8uXzFiVWsPrBXNtw+Y/PuTVcfW44kwuwKa4w3Bj ASOuYaJpUf2x+y5LQ9UmDfqx8Pon6LtGUvj2M5ZodklPJVr8197644fXZGU/Of1RZyZu 8iWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:references:in-reply-to:subject:cc:to:from :dkim-signature; bh=wCMz5VEjgh0a16F+GvqlNuK+LlxD4fJRGJ+ZP9uVyJY=; b=PZTI0LTrxDcKtS4sOAY6Q7wjnZF2zj4j4DvulJApNZq4cJz3TrXZw34et86Ix398Tl t4E77A6zmFy+wLS8NUjzzCH8xTXe2rPFUHe/dvRpyUJUj9iKShBDgwlKno3nxs3OoLZ/ 5oxL+QnHCw/R10YW1DjATRZU4gSIkgB4zXwfs5Y2NTX290f5AezZjRR01UsKAtHIAYMR 39wuTWOa8hDxl0JV3Zd+FNEzfwP3WTovlfFQioxS131fqstj9GK35O6o6zf4m/X0oV1j mIMtfbi2IOff8N+FJBO1OXMMhiin9CW1s8EDu+XHtEBzjhDyx/S7kFUjWBCPJbhQtwls LIWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AE8xjIx4; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id go20-20020a1709070d9400b007269e670e4asi8986696ejc.912.2022.07.04.07.53.55; Mon, 04 Jul 2022 07:54:20 -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=@redhat.com header.s=mimecast20190719 header.b=AE8xjIx4; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234906AbiGDOk1 (ORCPT + 99 others); Mon, 4 Jul 2022 10:40:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231392AbiGDOj7 (ORCPT ); Mon, 4 Jul 2022 10:39:59 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A6DCE10579 for ; Mon, 4 Jul 2022 07:39:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656945571; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wCMz5VEjgh0a16F+GvqlNuK+LlxD4fJRGJ+ZP9uVyJY=; b=AE8xjIx4WgxFWo7ya3SjIsBjK0Nc02uTPwi94RPHHoNHno0t2SYA6jV05xW8hUCYRx7daM izmI9vnGBqd8ksOvK2r4eA5iR7gK19xZ/vIsTVE5ad+ac1MJvKY/CXh4q9j+vnUBv5zUy9 ohXNMIAK8itVA0BfnnDI1KGy/bHoKig= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-636-xJ7bIjSpOAGMqNNqcFaCxg-1; Mon, 04 Jul 2022 10:39:30 -0400 X-MC-Unique: xJ7bIjSpOAGMqNNqcFaCxg-1 Received: by mail-wm1-f69.google.com with SMTP id r206-20020a1c44d7000000b003a02fa133ceso341252wma.2 for ; Mon, 04 Jul 2022 07:39:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version:content-transfer-encoding; bh=wCMz5VEjgh0a16F+GvqlNuK+LlxD4fJRGJ+ZP9uVyJY=; b=izbxu5wPGhamKNzsRkAHzs4A/tU97w8rV2/l6d7XhFpq7wa+b1m7fzb9yRJbtz8izY PqkREb+LMbSjGqtKomDt8NGWJl+lT42JRGmF6Kx4IpLh6DRyEMFL2LD30N1tDPEcihKv EFAgvSEzmSBN8pT3VthMZLJ3KNFq4rTwZKF74irUbGqvTOromJrD50AWmYyjK6GjysK+ V2FqJxc80mnNQe4FR9U9Y+kzifOwWf4oH4Kl5BsK2gmGB9HRICXoJO7dbKtfdITzA21r 3NZdtSMNHcC4yug3HJ4/Lo/oAN26zpLUnfToeBYpFO+ElLIie6Ql+5EkpBABWBGfzTFg TVDQ== X-Gm-Message-State: AJIora8S//gzrgITOmTsIpge/5woWPal9pcYZcX+1rCM30oOaZTSuYey lc4AIxEhQs/MuqXk2FIvql9l8G8ou0YEDtePRQYlHmpbwsCXt5KH9oWFHYmO8pp7UL7MpHReLQT fYIHDjQ2UJ0vN4btxvHxR1oy2 X-Received: by 2002:adf:e192:0:b0:21d:62ee:ef10 with SMTP id az18-20020adfe192000000b0021d62eeef10mr10874528wrb.693.1656945568644; Mon, 04 Jul 2022 07:39:28 -0700 (PDT) X-Received: by 2002:adf:e192:0:b0:21d:62ee:ef10 with SMTP id az18-20020adfe192000000b0021d62eeef10mr10874505wrb.693.1656945568348; Mon, 04 Jul 2022 07:39:28 -0700 (PDT) Received: from vschneid.remote.csb ([185.11.37.247]) by smtp.gmail.com with ESMTPSA id g14-20020a05600c4ece00b0039c99f61e5bsm17932446wmq.5.2022.07.04.07.39.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Jul 2022 07:39:27 -0700 (PDT) From: Valentin Schneider To: Hao Jia , mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com Cc: linux-kernel@vger.kernel.org, Hao Jia Subject: Re: [PATCH] sched/topology: Optimized copy default topology in sched_init_numa() In-Reply-To: <20220627105349.80715-1-jiahao.os@bytedance.com> References: <20220627105349.80715-1-jiahao.os@bytedance.com> Date: Mon, 04 Jul 2022 15:39:27 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 27/06/22 18:53, Hao Jia wrote: > The size of struct sched_domain_topology_level is 64 bytes. > For NUMA platforms, almost all are multi-core (enable CONFIG_SCHED_MC), > That is to say, the default_topology array has at least 128 bytes that > need to be copied in sched_init_numa(). For most x86 platforms, > CONFIG_SCHED_SMT will be enabled, so more copies will be required. > > And memcpy() will be optimized under different architectures. > Fortunately, for platforms with CONFIG_NUMA enabled, > these optimizations are likely to be used. > So, let's use memcpy to copy default topology in sched_init_numa(). > > Tests are done in an Intel Xeon(R) Platinum 8260 CPU@2.40GHz machine > with 2 NUMA nodes each of which has 24 cores with SMT2 enabled, so 96 > CPUs in total. > > Use RDTSC to count time-consuming, and based on 5.19-rc4. > > Enable CONFIG_SCHED_SMT && CONFIG_SCHED_CLUSTER && CONFIG_SCHED_MC, > So the default_topology array has 256 bytes that need to be copied > in sched_init_numa(). > 5.19-rc4 5.19-rc4 with patch > average tsc ticks 516.57 85.33 =EF=BC=88-83.48%*=EF=BC=89 > > Enable CONFIG_SCHED_MC, So the default_topology array has > 128 bytes that need to be copied in sched_init_numa(). > 5.19-rc4 5.19-rc4 with patch > average tsc ticks 65.71 55.00 =EF=BC=88-16.30%*=EF=BC=89 > > Signed-off-by: Hao Jia It's not a very hot path but I guess this lets you shave off a bit of boot time... While you're at it, you could add an early if (nr_node_ids =3D=3D 1) return; since !NUMA systems still go through sched_init_numa() if they have a kernel with CONFIG_NUMA (which should be most of them nowdays) and IIRC they end up with an unused NODE topology level. Regardless: Reviewed-by: Valentin Schneider