Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2433771rdb; Wed, 4 Oct 2023 00:26:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHfcCcS3v2e61aLe254XzZgtg28bS0qa02+HVstAjnT/pbYughOUIx1p7E/rbSDqW1nsYVM X-Received: by 2002:a05:6a20:5648:b0:15e:9d1b:84bf with SMTP id is8-20020a056a20564800b0015e9d1b84bfmr1681113pzc.23.1696404417034; Wed, 04 Oct 2023 00:26:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696404417; cv=none; d=google.com; s=arc-20160816; b=RDu3gTg+33g1v3GqAEaydJdMkfbOU27/DsX6auO8DzOYBld2ePfl4Z60P0RuVPbYZF TsI/j0VcqHgAN40pR6DY3n4wAeCFmJYoU009Xv1VtjZvA4shHy82iHzYRbkBEm59/Qzn YMkDnqey84h8TxC6MLs/RmTVF0PNtSHLXZk0U5fRoAa829nFnznXUbjHCPubgfvz62Oo nbxe7s/56+4HH5R2xEX4RSWnsmOi2/DCvV/HlMvKLtjBvLL40hErpAdFFtltoaY0dxXE 14TOrqsgVoJbT9JV9rhGjbEmJHLSQdDC06rV9XaZ5uYjaPg2DaUjhbbN6DsAZH7mdsXd HfZw== 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:sender:dkim-signature; bh=ampmjb5nn6WsDhiRi4sd5xEjXsA9NxoOOxrN/nCo4sk=; fh=JbgaRbMGb6/Z+AzjqKOJqMx85zyosMH76CO0wwMhiys=; b=OxDC2g7XXP/obMRRCU9wlWcpFwoW8jAxYNVae4TMY6oogjyZQyUlmVQoUfkAKGkq5m H1Jo3hA7TcUfy337v55jz3kdsW8/wkx3yT9di3Uv7TAVU2zmsIr51bScP5jhW37J+JMk d8PfMsOnt8uUO96Z+X64oQm7FJM6SG/oHXgBZwW9vh0KcOJ2bV4Vt1vo0y8Al6CHFv+W 8QkV2xhNaV7aEuti36DJCEs3DFoVGDxZoXKa+dgW1pmnsMS0M3NnCX4pBykJEmHVlkLz ITsFEQBSbJGHt7Kli54S6u4iAJXsdwNtbKTD1nZHu+S8J9QAwx2Lf+X0O2cRQ5sJ/1Un +acA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=WpceyEMN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id bv9-20020a632e09000000b00578ac88e239si3173767pgb.595.2023.10.04.00.26.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 00:26:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=WpceyEMN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id CF970832D721; Wed, 4 Oct 2023 00:26:55 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232802AbjJDH04 (ORCPT + 99 others); Wed, 4 Oct 2023 03:26:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232754AbjJDH0z (ORCPT ); Wed, 4 Oct 2023 03:26:55 -0400 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35C2598; Wed, 4 Oct 2023 00:26:52 -0700 (PDT) Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-99de884ad25so318325866b.3; Wed, 04 Oct 2023 00:26:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696404410; x=1697009210; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:from:to:cc:subject:date:message-id :reply-to; bh=ampmjb5nn6WsDhiRi4sd5xEjXsA9NxoOOxrN/nCo4sk=; b=WpceyEMNR+xjdVzqOpNYMoQkfJudTbdhgF1ygspyMhP/doH0CnLUfc3PN79CxsbVwH WUK756ZlNpNKwtxeINrVyxsjkY3ABfSdS1oQGJpSju4Wuj9QCB1PIkdsuVQgY4QfHg3E Vpc7r57M2LcO3ycqeEWv7/b8ddcOOS7yVV3UcYfnaDPeIssfXPcubHdDJZkQTRFNdIZ0 UFjY2dtH/JdphGDV3R7BQkvIYyIZmSy89//L00wJsu1FQiyuaa/s1+0gflESbBhcSlZc JGRQl2H7+8crv90PB5fMVbQMI2NLunnecq6PcuXEh8Tgcy8G3/c2kvm/hhZsXp1SgNFe ISBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696404410; x=1697009210; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ampmjb5nn6WsDhiRi4sd5xEjXsA9NxoOOxrN/nCo4sk=; b=qyjuokW8eNatZYFYWXy/bPPWkq9UK7zQy64WJB9SenapCDevhP7w4BceEdNV6Tdy92 xnj8jKg6dSVHx1wGCycPgkbmp1uD3NCX8Vv1dLzHS3rwdZ3wwBWkpGUxirpGEnxN6s/L tshz4nOnWGW4ZgMmXwYzdCEEtL5PaDKaz1Kx2aXRQ6Gg/1fk9gWon/23vA++1e3clMNO Uk9XUgw26iYsHFSkhP5WHZcTY6qiM+pzzcK0Rihfsq7/g7qrTzPYcgHgkgrOnnq3hBo0 z/4O9EXkp7V/Ar9XTJX2c9mBy7VM5576fp7pmy+6plXtMehpGYMU03aMCRXhkBKCM52k srDw== X-Gm-Message-State: AOJu0Yx0+AiGhsijjRqE7DqK1H57/XTWOkdonNLcjz9jfMe/jE98dcmL iSY+/4WMCM6Kmhqqf1V7ZwIz+Z9defQ= X-Received: by 2002:a17:906:30db:b0:9ae:41db:c27f with SMTP id b27-20020a17090630db00b009ae41dbc27fmr1568311ejb.10.1696404410443; Wed, 04 Oct 2023 00:26:50 -0700 (PDT) Received: from gmail.com (1F2EF530.nat.pool.telekom.hu. [31.46.245.48]) by smtp.gmail.com with ESMTPSA id l7-20020a1709061c4700b00997d7aa59fasm2320059ejg.14.2023.10.04.00.26.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 00:26:48 -0700 (PDT) Sender: Ingo Molnar Date: Wed, 4 Oct 2023 09:26:46 +0200 From: Ingo Molnar To: Namhyung Kim Cc: Peter Zijlstra , Mark Rutland , Alexander Shishkin , Arnaldo Carvalho de Melo , LKML , Stephane Eranian , Kan Liang , Ravi Bangoria , stable@vger.kernel.org Subject: Re: [PATCH] perf/core: Introduce cpuctx->cgrp_ctx_list Message-ID: References: <20231004040844.797044-1-namhyung@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231004040844.797044-1-namhyung@kernel.org> X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE, SPF_PASS autolearn=no 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 04 Oct 2023 00:26:56 -0700 (PDT) * Namhyung Kim wrote: > AFAIK we don't have a tool to measure the context switch overhead > directly. (I think I should add one to perf ftrace latency). But I can > see it with a simple perf bench command like this. > > $ perf bench sched pipe -l 100000 > # Running 'sched/pipe' benchmark: > # Executed 100000 pipe operations between two processes > > Total time: 0.650 [sec] > > 6.505740 usecs/op > 153710 ops/sec > > It runs two tasks communicate each other using a pipe so it should > stress the context switch code. This is the normal numbers on my > system. But after I run these two perf stat commands in background, > the numbers vary a lot. > > $ sudo perf stat -a -e cycles -G user.slice -- sleep 100000 & > $ sudo perf stat -a -e uncore_imc/cas_count_read/ -- sleep 10000 & > > I will show the last two lines of perf bench sched pipe output for > three runs. > > 58.597060 usecs/op # run 1 > 17065 ops/sec > > 11.329240 usecs/op # run 2 > 88267 ops/sec > > 88.481920 usecs/op # run 3 > 11301 ops/sec > > I think the deviation comes from the fact that uncore events are managed > a certain number of cpus only. If the target process runs on a cpu that > manages uncore pmu, it'd take longer. Otherwise it won't affect the > performance much. The numbers of pipe-message context switching will vary a lot depending on CPU migration patterns as well. The best way to measure context-switch overhead is to pin that task to a single CPU with something like: $ taskset 1 perf stat --null --repeat 10 perf bench sched pipe -l 10000 >/dev/null Performance counter stats for 'perf bench sched pipe -l 10000' (10 runs): 0.049798 +- 0.000102 seconds time elapsed ( +- 0.21% ) as you can see the 0.21% stddev is pretty low. If we allow 2 CPUs, both runtime and stddev is much higher: $ taskset 3 perf stat --null --repeat 10 perf bench sched pipe -l 10000 >/dev/null Performance counter stats for 'perf bench sched pipe -l 10000' (10 runs): 1.4835 +- 0.0383 seconds time elapsed ( +- 2.58% ) Thanks, Ingo