From nobody Sun Oct 5 18:16:45 2025 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E7B6F2D0C73 for ; Thu, 31 Jul 2025 13:27:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753968422; cv=none; b=Pm8s+s3R9H7flK6/h+ucyAQOth+Krbvf5x5otvjOAuumwP9PxKJ8KTRqDMqUIRmJtP6wKoMhwi9J9Bt7XDHO/utBiBRfqwXYrDOCaIlKtN3uZIO+f62DcqJiugSvnTbgDNG8shwy6Oy8wUAYMJFPEMOuzcrHPcz2g1gpLE4ifnE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753968422; c=relaxed/simple; bh=U2Q/nA8/fs3IaxhsmxtBPWhflIIPydiW0Xcing3X6TQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Content-Type; b=jLTqKOt/hrbNpE7Q4WMsH0GtGeV/6yC68t5WlIcfzIROVhDHoDAgejR6aDWXuYi5+tu6RKF237Gn4BAPk1uz1F/BUFsqlrPeDtugIBQS7ndaoHjV3ISq3bAnfQN/nADPW6Eci14MV38N7870WJIc+S/qXSyp6EYRvKS9CW63EkA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--yuzhuo.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Jg4T17Fu; arc=none smtp.client-ip=209.85.214.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--yuzhuo.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Jg4T17Fu" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-2400cbd4241so12638835ad.3 for ; Thu, 31 Jul 2025 06:27:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1753968420; x=1754573220; darn=vger.kernel.org; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=cS0kX7TvRYgQTsqu0GMqG/8vvD7pFz5fsy9ObfHAWm4=; b=Jg4T17FugmVHZwRiwS3QLHVhMZkjjr/LQTLtSfLnY8fYp6RWCCP1q1G9cAWNeV9PoO 19/Ez/k0IFszuunhz30CmIKDUmIWeVX4IZAkxtxUHe4Ic685tzJCD0Zfb22HggSuhvCL 3XsKBZ1CxoldgPPe3YrDWDairLV94zT5dPcLMSqxo2xiRUtPoYshTI0hdovKfw/s58gf YbYx3ivr9YD0gu+Rp9eDB+q4JDv1UmgsnxC7BgtZRhX0vMcBjCUiwYIJORK+108xXmpl anpDjuGEfxWc49HoVZv/4KoM+pTk79di7/msXig6WlK/5lDpDUW4UradQd4mHjPho+md 7Iog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753968420; x=1754573220; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=cS0kX7TvRYgQTsqu0GMqG/8vvD7pFz5fsy9ObfHAWm4=; b=Tn1vRK+IBa3mI+HwxHRo9GzdnL2u/sLVvqsSytDybmaIx7P/8TsPmfMFqhXHfP9qnk XIuUftW4UEPWmHYop1QZNMQGOvIgEubPSZyBR08pb/kC7NfpHALKLqE9pxf5mgtYorer EFmNaANRvBnPsWpy0PnixYvbPn+LATu5iTRi+3RQt5ieWI9It+w4RbkRC+9q4sGsrV0g wcplp1QSU4vLx/an4iVsqv3+RN0oqNyA5ytbMwI10Db4ky09LJQoWHXXTqZbOac7VEmD H7sImkHlsobocNxziRgpLwq9774MxASzXb91nfM4+jxKyudCrcfhbfzLjCbM/WOzb3X0 H61w== X-Forwarded-Encrypted: i=1; AJvYcCVij2MQNwNI8PYq1psihSgewrMVr1PQDDL75HgELE4V3DtHrdH0+48x5W4wHZpzqRVfqsa3PGI48RgQMNE=@vger.kernel.org X-Gm-Message-State: AOJu0YzZXkRFfobj8Pw74we9beTHObRsvZ2YcDBWwnUKoIMuDhHDZ2fr xZa1/gEexP4qjnBULpz2sF1NlaNT9LyV6PF4Ej7lcI0lUM9tBNcAGZN7BJlrs3cMJPidCtvtpSo DqhQ+XA== X-Google-Smtp-Source: AGHT+IEwFWYPRxHNlmybj0gexk68rMr7gVOb927INT9mYj/fa8gmdq1czl+fytYCMaogstSXj8WleWU/75s= X-Received: from plrj13.prod.google.com ([2002:a17:903:28d:b0:23f:cd94:8c5e]) (user=yuzhuo job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:4b43:b0:240:8ec:fe2 with SMTP id d9443c01a7336-24096a4fa57mr127525435ad.4.1753968420421; Thu, 31 Jul 2025 06:27:00 -0700 (PDT) Date: Thu, 31 Jul 2025 06:26:14 -0700 In-Reply-To: <20250731132615.938435-1-yuzhuo@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250731132615.938435-1-yuzhuo@google.com> X-Mailer: git-send-email 2.50.1.565.gc32cd1483b-goog Message-ID: <20250731132615.938435-5-yuzhuo@google.com> Subject: [PATCH v1 4/5] perf bench: Add 'ratio' mode to 'sync rcu' From: Yuzhuo Jing To: Davidlohr Bueso , "Paul E . McKenney" , Josh Triplett , Frederic Weisbecker , Neeraj Upadhyay , Joel Fernandes , Boqun Feng , Uladzislau Rezki , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Liang Kan , Yuzhuo Jing , Yuzhuo Jing , Sebastian Andrzej Siewior , linux-kernel@vger.kernel.org, rcu@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a 'ratio' mode to RCU benchmark. This mode helps investigate performance effects on the ratio between selected two parameters. The command is defined as: ratio is the sum of and . specifies the range of param1's values, and thus param2's values can be calculated as 'total-param1'. Example usage: $ ./perf bench sync rcu ratio sync 10 0:10:3 nreaders nwriters \# Running 'sync/rcu' benchmark: Running experiment with options: nreaders=3D0 nwriters=3D10 Experiment finished. Average grace-period duration: 16494.413 microseconds Minimum grace-period duration: 7994.842 50th percentile grace-period duration: 17999.439 90th percentile grace-period duration: 18001.923 99th percentile grace-period duration: 23999.068 Maximum grace-period duration: 24000.441 Cooling down (3s).. Running experiment with options: nreaders=3D3 nwriters=3D7 Experiment finished. Average grace-period duration: 140018.793 microseconds Minimum grace-period duration: 11987.02 50th percentile grace-period duration: 120999.879 90th percentile grace-period duration: 218000.011 99th percentile grace-period duration: 218006.372 Maximum grace-period duration: 219002.024 Cooling down (3s).. Running experiment with options: nreaders=3D6 nwriters=3D4 Experiment finished. Average grace-period duration: 210481.539 microseconds Minimum grace-period duration: 5999.579 50th percentile grace-period duration: 217999.902 90th percentile grace-period duration: 218000.529 99th percentile grace-period duration: 218998.809 Maximum grace-period duration: 219000.652 Cooling down (3s).. Running experiment with options: nreaders=3D9 nwriters=3D1 Experiment finished. Average grace-period duration: 210782.119 microseconds Minimum grace-period duration: 89997.154 50th percentile grace-period duration: 217999.829 90th percentile grace-period duration: 218001.299 99th percentile grace-period duration: 219003.072 Maximum grace-period duration: 324116.763 Signed-off-by: Yuzhuo Jing --- tools/perf/bench/sync-rcu.c | 74 +++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/tools/perf/bench/sync-rcu.c b/tools/perf/bench/sync-rcu.c index 921520a645ae..73142fd5be21 100644 --- a/tools/perf/bench/sync-rcu.c +++ b/tools/perf/bench/sync-rcu.c @@ -55,6 +55,7 @@ static const char *const bench_rcu_usage[] =3D { "perf bench sync rcu [options..] [-- ..]", "perf bench sync rcu [options..] once [..] [-- = ..]", "perf bench sync rcu [options..] range [..] [-- = ..]", + "perf bench sync rcu [options..] ratio <= param1_name> [..] [-- ..]", "", " : The type of grace period to use: sync, async, exp (expedite= d)", " This sets the gp_exp or gp_async kernel module parameters.", @@ -83,12 +84,17 @@ static const char *const bench_rcu_usage[] =3D { " If a parameter does not specify end, or start=3Dend, it behaves= ", " the same as 'once' mode. The range parameter types are validat= ed", " agains `modinfo rcuscale` to ensure they are integer.", + " ratio: Run benchmark that changes the ratio between two parameters.", + " specifies the sum of param1 and param2, and ", + " is the range of param1 values. param2 is calculated by total-p= aram1.", + " Additional non-range parameters may also be specified.", "", "Examples:", " perf bench sync rcu --hist once exp nreaders=3D1 nwriters=3D1 writer_c= pu_offset=3D1", " perf bench sync rcu once", " perf bench sync rcu once sync nreaders=3D1 nwriters=3D1 writer_cpu_of= fset=3D1", " perf bench sync rcu range exp nreaders=3D1:2 nwriters=3D1 writer_cpu_= offset=3D0:2", + " perf bench sync rcu ratio sync 10 0:10:3 nreaders nwriters", "", " perf bench sync rcu once sync nreaders=3D1 nwriters=3D1 writer_cpu_of= fset=3D1 -- \\", " perf stat -e ipi:ipi_send_cpu,rcu:rcu_grace_period \\", @@ -1194,6 +1200,72 @@ static void test_range(int argc, const char *argv[]) test_range_recursive(0, &modprobe_cmd); } =20 +/* + * Test ratio. Use loop on two range options. + * + * Does not allow ranges for other options. + * + * Example: + * perf bench rcu ratio sync 10 1:10:2 nreaders nwriters + * will run the following experiments: + * nreaders=3D1, nwriters=3D9 + * nreaders=3D2, nwriters=3D8 + * nreaders=3D3, nwriters=3D7 + * ... + * nreaders=3D9, nwriters=3D1 + */ +static void test_ratio(int argc, const char *argv[]) +{ + MODPROBE_CMD_INIT; + + int total; + struct range option1_range; + const char *option1_name; + const char *option2_name; + + if (argc < 4) + usage_with_options(bench_rcu_usage, bench_rcu_options); + + total =3D parse_int(argv[0]); + parse_range(&option1_range, argv[1]); + option1_name =3D argv[2]; + option2_name =3D argv[3]; + + check_param_name(option1_name); + check_param_name(option2_name); + + if (total < option1_range.start || total < option1_range.end) + fail("Total must be greater than or equal to the range bounary"); + + parse_module_params(argc - 4, argv + 4, false); + + modprobe_collect_simple_options(&modprobe_cmd); + + for (int i =3D option1_range.start; i <=3D option1_range.end; i +=3D opti= on1_range.step) { + int j =3D total - i; + + struct modprobe_param param1, param2; + + param_print_key_value(¶m1, "%s=3D%d", option1_name, i); + param_print_key_value(¶m2, "%s=3D%d", option2_name, j); + + modprobe_cmd_add(&modprobe_cmd, param1.value); + modprobe_cmd_add(&modprobe_cmd, param2.value); + + runonce(&modprobe_cmd); + + modprobe_cmd_pop(&modprobe_cmd); + modprobe_cmd_pop(&modprobe_cmd); + + if (i + option1_range.step <=3D option1_range.end) { + printf("Cooling down (%ds)..\n", cooldown); + if (!dryrun) + sleep(cooldown); + puts(""); + } + } +} + /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D Entry Point =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ =20 int bench_sync_rcu(int argc, const char **argv) @@ -1228,6 +1300,8 @@ int bench_sync_rcu(int argc, const char **argv) cmd =3D test_once; else if (strcmp(runmode, "range") =3D=3D 0) cmd =3D test_range; + else if (strcmp(runmode, "ratio") =3D=3D 0) + cmd =3D test_ratio; else usage_with_options(bench_rcu_usage, bench_rcu_options); =20 --=20 2.50.1.565.gc32cd1483b-goog