From patchwork Mon Jan 22 22:13:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Crystal Wood X-Patchwork-Id: 765522 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0E2933EA88 for ; Mon, 22 Jan 2024 22:13:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705961607; cv=none; b=h4gnRRjxQyXng5jCbq2iBLHX2veYqhvIT4Bb2617zg4acGk0CX6Em4DJBjssj+VreBMGShOeQVcgnhk4wrDcgTTo1vRTnF140Y2G1pyN4F3Plz4qe0NFQtbyoG8XWo0hpjNSTYL+R1QgLBa7n+pyA9oaDrol1UXb1UBhzQ0+jf4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705961607; c=relaxed/simple; bh=o7wjQr4+IDIK2uOe9kb/g/RhGNGzJHYcNk2F+eLOMgE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=iK8CYUEycW2yLpHJRekRMoXr423MJQajMl/ua8vU4OeZQXW98GSDtPrJAV8lHab4LCdbLvL3ES9MdVr2jCec5Dwq5bPRG+cqYjjcx5XI7yUFQqvFzflNdMK8U7uIbytq5tfoewryq1MN12HYX82tANXn+E/kTsXy3hPbn1P6rj4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=DN/8LZBD; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="DN/8LZBD" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705961604; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=30mCPBuhE3uBUdndRzdf3gHuWyJAslCgR5rzQ119oks=; b=DN/8LZBDYpMAkEdAJyPfNqGSZD6Tf4OW+kMc77MDmRd2QpxViejL0Mr9A9yfKciZSXZAGw X/YOsHYhSLMu/JyEx9Po+KzNpZI9G9TKx4aT5pSXEAAv3jWgLiLJkN4ewWHVCc2c0n274R VYleojQ2VECuA682UTPLDOmVn0qLB2A= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-434-KmOECz7VNGKWzpq8gsyC7g-1; Mon, 22 Jan 2024 17:13:22 -0500 X-MC-Unique: KmOECz7VNGKWzpq8gsyC7g-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AEBBD10651E6 for ; Mon, 22 Jan 2024 22:13:21 +0000 (UTC) Received: from p1g2.redhat.com (unknown [10.2.16.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 659D9492BC6; Mon, 22 Jan 2024 22:13:21 +0000 (UTC) From: Crystal Wood To: John Kacur , Clark Williams Cc: linux-rt-users@vger.kernel.org, Crystal Wood Subject: [PATCH 1/3] rt-tests: cyclics: Fix json segfault when not using histogram Date: Mon, 22 Jan 2024 16:13:19 -0600 Message-ID: <20240122221321.9545-1-crwood@redhat.com> Precedence: bulk X-Mailing-List: linux-rt-users@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 If we're not generating a histogram, don't call the histogram code with a NULL pointer. Also don't print the rest of the histogram json node. Signed-off-by: Crystal Wood --- src/cyclictest/cyclictest.c | 11 ++++++----- src/sched_deadline/cyclicdeadline.c | 9 +++++---- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c index 6169170fc66d..33fac3b95f5d 100644 --- a/src/cyclictest/cyclictest.c +++ b/src/cyclictest/cyclictest.c @@ -1778,12 +1778,13 @@ static void write_stats(FILE *f, void *data __attribute__ ((unused))) fprintf(f, " \"resolution_in_ns\": %u,\n", use_nsecs); fprintf(f, " \"thread\": {\n"); for (i = 0; i < num_threads; i++) { - fprintf(f, " \"%u\": {\n", i); - - fprintf(f, " \"histogram\": {"); s = par[i]->stats; - hist_print_json(par[i]->stats->hist, f); - fprintf(f, " },\n"); + fprintf(f, " \"%u\": {\n", i); + if (s->hist) { + fprintf(f, " \"histogram\": {"); + hist_print_json(s->hist, f); + fprintf(f, " },\n"); + } fprintf(f, " \"cycles\": %ld,\n", s->cycles); fprintf(f, " \"min\": %ld,\n", s->min); fprintf(f, " \"max\": %ld,\n", s->max); diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c index e449be57870e..b3155547b9bb 100644 --- a/src/sched_deadline/cyclicdeadline.c +++ b/src/sched_deadline/cyclicdeadline.c @@ -1141,10 +1141,11 @@ static void write_stats(FILE *f, void *data) for (i = 0; i < nr_threads; i++) { s = &sd[i].stat; fprintf(f, " \"%u\": {\n", i); - - fprintf(f, " \"histogram\": {"); - hist_print_json(s->hist, f); - fprintf(f, " },\n"); + if (s->hist) { + fprintf(f, " \"histogram\": {"); + hist_print_json(s->hist, f); + fprintf(f, " },\n"); + } fprintf(f, " \"cycles\": %ld,\n", s->cycles); fprintf(f, " \"min\": %ld,\n", s->min); fprintf(f, " \"max\": %ld,\n", s->max); From patchwork Mon Jan 22 22:13:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Crystal Wood X-Patchwork-Id: 765024 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C745482E2 for ; Mon, 22 Jan 2024 22:13:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705961606; cv=none; b=UPF5CKcrEgmt2xFZYJh5OrjQRiTE4FKC0gidy5p7hnRwccmcQZ9UMP8obnkP4rtmZrD7IIkmpKv8ViRYQwb7uiQGK0D1Vm1mF2eRm6nXE24ieXajDCl0teTe/RgdPYVVSljMz/Ne53Qo0/EC5vcTvxQZHLVU3mV691yPb8USanw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705961606; c=relaxed/simple; bh=n4pjtSkoWSVLYcomp1m3GeLU4iXPOF9YKXY1ouyN874=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tHATNvnE195EchKA1O1nBDbsMG4SV+b45uOYtU22anneTKR7bmf8UXQ/TJr9/mAwfUkYmUxj9DUfjDByzvxxHUZJUx3qJyw3uM1hgmVVjPzrMwiDt6u0HUJTCee7QI0tEFW9mCawyHfqewCAYT5ISjkcOUqTXSR1AjldrLL5OD0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Z3zYEkTS; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Z3zYEkTS" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705961604; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BYwZJx1JOJPadtHq/jmXfmxYWdvpYTL+5Uh4sVZ3lYs=; b=Z3zYEkTSYDFNS4qB3aRnRA5uPISsUZAPTCprpK9O/ZM/lsCfFlz/1tt2P2zYyzCdbUiNDW 1CnnFAG8imbjAUoaq50YDpQ5RoLEqgB17llwc48/aR/QVmDWOm/QpqzpCdmeNI1ka4+hpB 9EFdOWPMIwuJD7SsI7+87jn55+GyzKo= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-622-_jVzkroIPxi7lfDDA9lDUA-1; Mon, 22 Jan 2024 17:13:22 -0500 X-MC-Unique: _jVzkroIPxi7lfDDA9lDUA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 165AA1C05AEE for ; Mon, 22 Jan 2024 22:13:22 +0000 (UTC) Received: from p1g2.redhat.com (unknown [10.2.16.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id C2D73492BC6; Mon, 22 Jan 2024 22:13:21 +0000 (UTC) From: Crystal Wood To: John Kacur , Clark Williams Cc: linux-rt-users@vger.kernel.org, Crystal Wood Subject: [PATCH 2/3] rt-tests: cyclicdeadline: Print the histogram regardless of quiet Date: Mon, 22 Jan 2024 16:13:20 -0600 Message-ID: <20240122221321.9545-2-crwood@redhat.com> In-Reply-To: <20240122221321.9545-1-crwood@redhat.com> References: <20240122221321.9545-1-crwood@redhat.com> Precedence: bulk X-Mailing-List: linux-rt-users@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 The histogram printing code should not have been gated by !quiet, even though other summary printing code is. The non-histogram output also should not have been gated based on the presence of the histogram. Signed-off-by: Crystal Wood Signed-off-by: John Kacur --- src/sched_deadline/cyclicdeadline.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c index b3155547b9bb..3cb8f714b788 100644 --- a/src/sched_deadline/cyclicdeadline.c +++ b/src/sched_deadline/cyclicdeadline.c @@ -1117,15 +1117,15 @@ static void loop(struct sched_data *sched_data, int nr_threads) usleep(10000); if (!quiet) { printf("\033[%dB", nr_threads + 2); - } else { - if (histogram) { - FILE *out = histfile ? histfile : stdout; + } else if (!histogram) { + for (i = 0; i < nr_threads; ++i) + print_stat(stdout, &sched_data[i], i, 0, 0); + } - print_hist(out, sched_data, nr_threads); - } else { - for (i = 0; i < nr_threads; ++i) - print_stat(stdout, &sched_data[i], i, 0, 0); - } + if (histogram) { + FILE *out = histfile ? histfile : stdout; + + print_hist(out, sched_data, nr_threads); } } From patchwork Mon Jan 22 22:13:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Crystal Wood X-Patchwork-Id: 765023 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6C6F348791 for ; Mon, 22 Jan 2024 22:13:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705961608; cv=none; b=MWNUqlJHWtyh1r0G8m+rVzS3+P3L/8FCzb1LCyAObG/uL7m2ePszv66kDCh2UWwCjzqOOYqdSOPL4ZuUqUUXbuI8hYPiitCFEawYQGxhlF8G5zx0yxsb2pSOqo3AVYbEDmz9uwNZCezRAj2kqebIFpnl+LiLVT8j4r+d9njkBZU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705961608; c=relaxed/simple; bh=xW+RTWQDX85fj6TvqqXUjnPMd6PdJROBXIez4R9B7rs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kjuHfXXQ8PQ+tM6CRHzJvLHRC9igyZUCMcw10o4atwaIm+a0E9NxCy++BiWsKxfoI8zGP1KLV+2YGo97LA+woQ2dzqnfumXzZaBlpH8sssT2EA6rvQfPXHMbH/bz3ks4uiRkkhEAom7iz+efQ33wil5eN6SeB4eOfhUMiqPJvT4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=PXpMgRus; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="PXpMgRus" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705961606; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YLhpYfKsYLYfBvYCexc28NpN6drEb0PWpOeUCl0CudQ=; b=PXpMgRusPmp5Atm8SMCMCZWs18ovYktrAtE8h/mQv+IVO+RRhuog261kTAEzDhLonUXifS yOMNdByX4akdmDOX8R7fWInH/mP2lcwLdHNLH/5byWBQLgn2tKoKQugxJFr6fOcJNpeW39 n9iS57MR9+KeqYQr0ZJerkHdhm5cB1M= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-124-MhnlhgSqPjitAm9QuUbrmg-1; Mon, 22 Jan 2024 17:13:24 -0500 X-MC-Unique: MhnlhgSqPjitAm9QuUbrmg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7489883538A for ; Mon, 22 Jan 2024 22:13:22 +0000 (UTC) Received: from p1g2.redhat.com (unknown [10.2.16.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2BCF2492BC6; Mon, 22 Jan 2024 22:13:22 +0000 (UTC) From: Crystal Wood To: John Kacur , Clark Williams Cc: linux-rt-users@vger.kernel.org, Crystal Wood Subject: [PATCH 3/3] rt-tests: cyclicdeadline: Remove dead "verbose" code in print_stat() Date: Mon, 22 Jan 2024 16:13:21 -0600 Message-ID: <20240122221321.9545-3-crwood@redhat.com> In-Reply-To: <20240122221321.9545-1-crwood@redhat.com> References: <20240122221321.9545-1-crwood@redhat.com> Precedence: bulk X-Mailing-List: linux-rt-users@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 print_stat() isn't and has never been called with verbose set, and that codepath doesn't even print anything. Remove it. Signed-off-by: Crystal Wood Signed-off-by: John Kacur --- src/sched_deadline/cyclicdeadline.c | 46 ++++++++++------------------- 1 file changed, 15 insertions(+), 31 deletions(-) diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c index 3cb8f714b788..7525ad136d2c 100644 --- a/src/sched_deadline/cyclicdeadline.c +++ b/src/sched_deadline/cyclicdeadline.c @@ -53,7 +53,6 @@ typedef int s32; /* Struct for statistics */ struct thread_stat { unsigned long cycles; - unsigned long cyclesread; long min; long max; long act; @@ -64,8 +63,6 @@ struct thread_stat { int threadstarted; int tid; long reduce; - long redmax; - long cycleofmax; }; struct sched_data { @@ -775,36 +772,23 @@ static void print_hist(FILE *fp, struct sched_data *sd, int nthreads) fprintf(fp, "\n"); } -static void print_stat(FILE *fp, struct sched_data *sd, int index, int verbose, int quiet) +static void print_stat(FILE *fp, struct sched_data *sd, int index, int quiet) { struct thread_stat *stat = &sd->stat; + char *fmt; - if (!verbose) { - if (quiet != 1) { - char *fmt; - if (use_nsecs) - fmt = "T:%2d (%5d) I:%ld C:%7lu " - "Min:%7ld Act:%8ld Avg:%8ld Max:%8ld\n"; - else - fmt = "T:%2d (%5d) I:%ld C:%7lu " - "Min:%7ld Act:%5ld Avg:%5ld Max:%8ld\n"; - fprintf(fp, fmt, index, stat->tid, - sd->deadline_us, stat->cycles, stat->min, stat->act, - stat->cycles ? - (long)(stat->avg/stat->cycles) : 0, stat->max); - } - } else { - while (stat->cycles != stat->cyclesread) { - long diff = stat->values - [stat->cyclesread & sd->bufmsk]; + if (quiet) + return; - if (diff > stat->redmax) { - stat->redmax = diff; - stat->cycleofmax = stat->cyclesread; - } - stat->cyclesread++; - } - } + if (use_nsecs) + fmt = "T:%2d (%5d) I:%ld C:%7lu Min:%7ld Act:%8ld Avg:%8ld Max:%8ld\n"; + else + fmt = "T:%2d (%5d) I:%ld C:%7lu Min:%7ld Act:%5ld Avg:%5ld Max:%8ld\n"; + + fprintf(fp, fmt, index, stat->tid, + sd->deadline_us, stat->cycles, stat->min, stat->act, + stat->cycles ? + (long)(stat->avg/stat->cycles) : 0, stat->max); } static u64 do_runtime(struct sched_data *sd, u64 period) @@ -1109,7 +1093,7 @@ static void loop(struct sched_data *sched_data, int nr_threads) while (!shutdown) { for (i = 0; i < nr_threads; i++) - print_stat(stdout, &sched_data[i], i, 0, quiet); + print_stat(stdout, &sched_data[i], i, quiet); usleep(10000); if (!quiet) printf("\033[%dA", nr_threads); @@ -1119,7 +1103,7 @@ static void loop(struct sched_data *sched_data, int nr_threads) printf("\033[%dB", nr_threads + 2); } else if (!histogram) { for (i = 0; i < nr_threads; ++i) - print_stat(stdout, &sched_data[i], i, 0, 0); + print_stat(stdout, &sched_data[i], i, 0); } if (histogram) {