All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: John Stultz <jstultz@google.com>
Cc: kernel-team@android.com,
	Darren Hart <darren@os.amperecomputing.com>,
	ltp@lists.linux.it
Subject: Re: [LTP] [PATCH 6/6] sched_football: Add trace_marker messages if we're tracing
Date: Mon, 29 Apr 2024 11:17:23 +0200	[thread overview]
Message-ID: <Zi9lo1ubVkGJHzrF@yuki> (raw)
In-Reply-To: <20240423225821.4003538-7-jstultz@google.com>

Hi!
> Cc: kernel-team@android.com
> Cc: Darren Hart <darren@os.amperecomputing.com>
> Signed-off-by: John Stultz <jstultz@google.com>
> ---
>  .../realtime/func/sched_football/sched_football.c    | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/testcases/realtime/func/sched_football/sched_football.c b/testcases/realtime/func/sched_football/sched_football.c
> index 45fbf6766..ca44584b0 100644
> --- a/testcases/realtime/func/sched_football/sched_football.c
> +++ b/testcases/realtime/func/sched_football/sched_football.c
> @@ -67,6 +67,7 @@
>  #include <pthread.h>
>  #include <sched.h>
>  #include <errno.h>
> +#include <fcntl.h>
>  #include <sys/syscall.h>
>  #include <unistd.h>
>  #include <sys/prctl.h>
> @@ -167,10 +168,14 @@ void *thread_offense(void *arg)
>  	return NULL;
>  }
>  
> +#define BUF_LEN 256
>  int referee(int game_length)
>  {
>  	struct timeval start, now;
> +	char buf[BUF_LEN];
>  	int final_ball;
> +	int fd = open("/sys/kernel/tracing/trace_marker", O_RDWR, 0);
> +	int ret;
>  
>  	prctl(PR_SET_NAME, "referee", 0, 0, 0);
>  	printf("Game On (%d seconds)!\n", game_length);
> @@ -178,14 +183,19 @@ int referee(int game_length)
>  	gettimeofday(&start, NULL);
>  	now = start;
>  
> +	sprintf(buf, "I|%i|Game_Started!\n", getpid());
>  	/* Start the game! */
>  	atomic_set(0, &the_ball);
> -
> +	if (fd > 0)
> +		ret = write(fd, buf, strnlen(buf, BUF_LEN));
>  	/* Watch the game */
>  	while ((now.tv_sec - start.tv_sec) < game_length) {
>  		sleep(1);
>  		gettimeofday(&now, NULL);
>  	}
> +	sprintf(buf, "I|%i|Game_Over!\n", getpid());
> +	if (fd > 0)
> +		ret = write(fd, buf, strnlen(buf, BUF_LEN));

I know that we havre only two usages now, but it would be a bit cleaner
and readable to have a function to print the messages, e.g.

static void tracer_write(const char *msg);

And we would do:

	tracer_write("Game_Started!");

It would be a good idea to add the test name to the message as well,
maybe as:

	sprintf(buf, "sched_football|%i|%s\n", getpid(), msg);

>  	final_ball = atomic_get(&the_ball);
>  	/* Blow the whistle */
>  	printf("Game Over!\n");
> -- 
> 2.44.0.769.g3c40516874-goog
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2024-04-29  9:18 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-23 22:57 [LTP] [PATCH 0/6] sched_football: Re-add crazy fans and other cleanups John Stultz via ltp
2024-04-23 22:57 ` [LTP] [PATCH 1/6] sched_football: Drop use of sched_yeild() John Stultz via ltp
2024-04-23 22:57 ` [LTP] [PATCH 2/6] sched_football: Use atomic for ball John Stultz via ltp
2024-04-29  9:06   ` Cyril Hrubis
2024-04-29 22:56     ` John Stultz via ltp
2024-05-07  9:35       ` Cyril Hrubis
2024-04-23 22:58 ` [LTP] [PATCH 3/6] sched_football: Re-add the crazy fans to interrupt everyone John Stultz via ltp
2024-04-29  9:10   ` Cyril Hrubis
2024-04-29 23:06     ` John Stultz via ltp
2024-04-23 22:58 ` [LTP] [PATCH 4/6] sched_football: Add a sleep before the game begins to get into steady state John Stultz via ltp
2024-04-23 22:58 ` [LTP] [PATCH 5/6] sched_football: Add prctrl calls to set thread comms John Stultz via ltp
2024-04-23 22:58 ` [LTP] [PATCH 6/6] sched_football: Add trace_marker messages if we're tracing John Stultz via ltp
2024-04-29  9:17   ` Cyril Hrubis [this message]
2024-04-29 23:14     ` John Stultz via ltp

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Zi9lo1ubVkGJHzrF@yuki \
    --to=chrubis@suse.cz \
    --cc=darren@os.amperecomputing.com \
    --cc=jstultz@google.com \
    --cc=kernel-team@android.com \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.