All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] rt-tests: rt-utils: Close trace fds
@ 2020-11-07  9:58 Kurt Kanzenbach
  2020-11-07  9:58 ` [PATCH 1/4] rt-tests: rt-utils: Mark internal functions static Kurt Kanzenbach
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Kurt Kanzenbach @ 2020-11-07  9:58 UTC (permalink / raw)
  To: John Kacur, Clark Williams; +Cc: rt-users, Kurt Kanzenbach

Hi John,

while using cyclictest with tracing (-b, --tracemark), I've noticed some minor
issues...

Thanks,
Kurt

Kurt Kanzenbach (4):
  rt-tests: rt-utils: Mark internal functions static
  rt-tests: rt-utils: Add function to close trace fds
  rt-tests: cyclictest: Close correct trace fds
  rt-tests: oslat: Close trace fds

 src/cyclictest/cyclictest.c |  8 +-------
 src/include/rt-utils.h      |  1 +
 src/lib/rt-utils.c          | 20 +++++++++++++++++---
 src/oslat/oslat.c           |  2 ++
 4 files changed, 21 insertions(+), 10 deletions(-)

-- 
2.26.2


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/4] rt-tests: rt-utils: Mark internal functions static
  2020-11-07  9:58 [PATCH 0/4] rt-tests: rt-utils: Close trace fds Kurt Kanzenbach
@ 2020-11-07  9:58 ` Kurt Kanzenbach
  2020-11-11  2:29   ` John Kacur
  2020-11-07  9:58 ` [PATCH 2/4] rt-tests: rt-utils: Add function to close trace fds Kurt Kanzenbach
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Kurt Kanzenbach @ 2020-11-07  9:58 UTC (permalink / raw)
  To: John Kacur, Clark Williams; +Cc: rt-users, Kurt Kanzenbach

There are some helper functions which shouldn't be exported. Mark them static.

Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
---
 src/lib/rt-utils.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/lib/rt-utils.c b/src/lib/rt-utils.c
index 54a201661786..85d41b9542a2 100644
--- a/src/lib/rt-utils.c
+++ b/src/lib/rt-utils.c
@@ -362,7 +362,7 @@ int parse_time_string(char *val)
 	return t;
 }
 
-void open_tracemark_fd(void)
+static void open_tracemark_fd(void)
 {
 	char path[MAX_PATH];
 
@@ -390,7 +390,7 @@ void open_tracemark_fd(void)
 	}
 }
 
-int trace_file_exists(char *name)
+static int trace_file_exists(char *name)
 {
 	struct stat sbuf;
 	char *tracing_prefix = get_debugfileprefix();
@@ -399,7 +399,7 @@ int trace_file_exists(char *name)
 	return stat(path, &sbuf) ? 0 : 1;
 }
 
-void debugfs_prepare(void)
+static void debugfs_prepare(void)
 {
 	if (mount_debugfs(NULL))
 		fatal("could not mount debugfs");
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/4] rt-tests: rt-utils: Add function to close trace fds
  2020-11-07  9:58 [PATCH 0/4] rt-tests: rt-utils: Close trace fds Kurt Kanzenbach
  2020-11-07  9:58 ` [PATCH 1/4] rt-tests: rt-utils: Mark internal functions static Kurt Kanzenbach
@ 2020-11-07  9:58 ` Kurt Kanzenbach
  2020-11-11  2:30   ` John Kacur
  2020-11-07  9:58 ` [PATCH 3/4] rt-tests: cyclictest: Close correct " Kurt Kanzenbach
  2020-11-07  9:58 ` [PATCH 4/4] rt-tests: oslat: Close " Kurt Kanzenbach
  3 siblings, 1 reply; 9+ messages in thread
From: Kurt Kanzenbach @ 2020-11-07  9:58 UTC (permalink / raw)
  To: John Kacur, Clark Williams; +Cc: rt-users, Kurt Kanzenbach

Currently the trace fds are not closed. Add a function for it.

Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
---
 src/include/rt-utils.h |  1 +
 src/lib/rt-utils.c     | 14 ++++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/src/include/rt-utils.h b/src/include/rt-utils.h
index 4ed1cbc53ece..c6fb220cdb0a 100644
--- a/src/include/rt-utils.h
+++ b/src/include/rt-utils.h
@@ -31,6 +31,7 @@ int parse_time_string(char *val);
 
 void enable_trace_mark(void);
 void tracemark(char *fmt, ...) __attribute__((format(printf, 1, 2)));
+void disable_trace_mark(void);
 
 #define MSEC_PER_SEC		1000
 #define USEC_PER_SEC		1000000
diff --git a/src/lib/rt-utils.c b/src/lib/rt-utils.c
index 85d41b9542a2..a30e1e4ce436 100644
--- a/src/lib/rt-utils.c
+++ b/src/lib/rt-utils.c
@@ -390,6 +390,15 @@ static void open_tracemark_fd(void)
 	}
 }
 
+static void close_tracemark_fd(void)
+{
+	if (tracemark_fd > 0)
+		close(tracemark_fd);
+
+	if (trace_fd > 0)
+		close(trace_fd);
+}
+
 static int trace_file_exists(char *name)
 {
 	struct stat sbuf;
@@ -437,3 +446,8 @@ void enable_trace_mark(void)
 	debugfs_prepare();
 	open_tracemark_fd();
 }
+
+void disable_trace_mark(void)
+{
+	close_tracemark_fd();
+}
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/4] rt-tests: cyclictest: Close correct trace fds
  2020-11-07  9:58 [PATCH 0/4] rt-tests: rt-utils: Close trace fds Kurt Kanzenbach
  2020-11-07  9:58 ` [PATCH 1/4] rt-tests: rt-utils: Mark internal functions static Kurt Kanzenbach
  2020-11-07  9:58 ` [PATCH 2/4] rt-tests: rt-utils: Add function to close trace fds Kurt Kanzenbach
@ 2020-11-07  9:58 ` Kurt Kanzenbach
  2020-11-11  2:32   ` John Kacur
  2020-11-07  9:58 ` [PATCH 4/4] rt-tests: oslat: Close " Kurt Kanzenbach
  3 siblings, 1 reply; 9+ messages in thread
From: Kurt Kanzenbach @ 2020-11-07  9:58 UTC (permalink / raw)
  To: John Kacur, Clark Williams; +Cc: rt-users, Kurt Kanzenbach

Remove the last lefotovers from migrating cyclictest to rt-utils.

The rt-utils module is reponsible for handling the tracing code.

Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
---
 src/cyclictest/cyclictest.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index 34aa9be583f8..0ec0b235dba3 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -283,9 +283,6 @@ enum {
 	ERROR_NOTFOUND	= -2,
 };
 
-static int trace_fd     = -1;
-static int tracemark_fd = -1;
-
 /*
  * Raise the soft priority limit up to prio, if that is less than or equal
  * to the hard limit
@@ -2272,10 +2269,7 @@ int main(int argc, char **argv)
 	}
  out:
 	/* close any tracer file descriptors */
-	if (tracemark_fd >= 0)
-		close(tracemark_fd);
-	if (trace_fd >= 0)
-		close(trace_fd);
+	disable_trace_mark();
 
 	/* unlock everything */
 	if (lockall)
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 4/4] rt-tests: oslat: Close trace fds
  2020-11-07  9:58 [PATCH 0/4] rt-tests: rt-utils: Close trace fds Kurt Kanzenbach
                   ` (2 preceding siblings ...)
  2020-11-07  9:58 ` [PATCH 3/4] rt-tests: cyclictest: Close correct " Kurt Kanzenbach
@ 2020-11-07  9:58 ` Kurt Kanzenbach
  2020-11-11  2:34   ` John Kacur
  3 siblings, 1 reply; 9+ messages in thread
From: Kurt Kanzenbach @ 2020-11-07  9:58 UTC (permalink / raw)
  To: John Kacur, Clark Williams; +Cc: rt-users, Kurt Kanzenbach

oslat is also using enable_trace_mark() and never closes the fds. Add it.

Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
---
 src/oslat/oslat.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/oslat/oslat.c b/src/oslat/oslat.c
index 918e6733c066..0018c472e0c1 100644
--- a/src/oslat/oslat.c
+++ b/src/oslat/oslat.c
@@ -871,5 +871,7 @@ int main(int argc, char *argv[])
 		g.cpu_list = NULL;
 	}
 
+	disable_trace_mark();
+
 	return 0;
 }
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/4] rt-tests: rt-utils: Mark internal functions static
  2020-11-07  9:58 ` [PATCH 1/4] rt-tests: rt-utils: Mark internal functions static Kurt Kanzenbach
@ 2020-11-11  2:29   ` John Kacur
  0 siblings, 0 replies; 9+ messages in thread
From: John Kacur @ 2020-11-11  2:29 UTC (permalink / raw)
  To: Kurt Kanzenbach; +Cc: Clark Williams, rt-users



On Sat, 7 Nov 2020, Kurt Kanzenbach wrote:

> There are some helper functions which shouldn't be exported. Mark them static.
> 
> Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
> ---
>  src/lib/rt-utils.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/src/lib/rt-utils.c b/src/lib/rt-utils.c
> index 54a201661786..85d41b9542a2 100644
> --- a/src/lib/rt-utils.c
> +++ b/src/lib/rt-utils.c
> @@ -362,7 +362,7 @@ int parse_time_string(char *val)
>  	return t;
>  }
>  
> -void open_tracemark_fd(void)
> +static void open_tracemark_fd(void)
>  {
>  	char path[MAX_PATH];
>  
> @@ -390,7 +390,7 @@ void open_tracemark_fd(void)
>  	}
>  }
>  
> -int trace_file_exists(char *name)
> +static int trace_file_exists(char *name)
>  {
>  	struct stat sbuf;
>  	char *tracing_prefix = get_debugfileprefix();
> @@ -399,7 +399,7 @@ int trace_file_exists(char *name)
>  	return stat(path, &sbuf) ? 0 : 1;
>  }
>  
> -void debugfs_prepare(void)
> +static void debugfs_prepare(void)
>  {
>  	if (mount_debugfs(NULL))
>  		fatal("could not mount debugfs");
> -- 
> 2.26.2
> 
> 
Signed-off-by: John Kacur <jkacur@redhat.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/4] rt-tests: rt-utils: Add function to close trace fds
  2020-11-07  9:58 ` [PATCH 2/4] rt-tests: rt-utils: Add function to close trace fds Kurt Kanzenbach
@ 2020-11-11  2:30   ` John Kacur
  0 siblings, 0 replies; 9+ messages in thread
From: John Kacur @ 2020-11-11  2:30 UTC (permalink / raw)
  To: Kurt Kanzenbach; +Cc: Clark Williams, rt-users



On Sat, 7 Nov 2020, Kurt Kanzenbach wrote:

> Currently the trace fds are not closed. Add a function for it.
> 
> Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
> ---
>  src/include/rt-utils.h |  1 +
>  src/lib/rt-utils.c     | 14 ++++++++++++++
>  2 files changed, 15 insertions(+)
> 
> diff --git a/src/include/rt-utils.h b/src/include/rt-utils.h
> index 4ed1cbc53ece..c6fb220cdb0a 100644
> --- a/src/include/rt-utils.h
> +++ b/src/include/rt-utils.h
> @@ -31,6 +31,7 @@ int parse_time_string(char *val);
>  
>  void enable_trace_mark(void);
>  void tracemark(char *fmt, ...) __attribute__((format(printf, 1, 2)));
> +void disable_trace_mark(void);
>  
>  #define MSEC_PER_SEC		1000
>  #define USEC_PER_SEC		1000000
> diff --git a/src/lib/rt-utils.c b/src/lib/rt-utils.c
> index 85d41b9542a2..a30e1e4ce436 100644
> --- a/src/lib/rt-utils.c
> +++ b/src/lib/rt-utils.c
> @@ -390,6 +390,15 @@ static void open_tracemark_fd(void)
>  	}
>  }
>  
> +static void close_tracemark_fd(void)
> +{
> +	if (tracemark_fd > 0)
> +		close(tracemark_fd);
> +
> +	if (trace_fd > 0)
> +		close(trace_fd);
> +}
> +
>  static int trace_file_exists(char *name)
>  {
>  	struct stat sbuf;
> @@ -437,3 +446,8 @@ void enable_trace_mark(void)
>  	debugfs_prepare();
>  	open_tracemark_fd();
>  }
> +
> +void disable_trace_mark(void)
> +{
> +	close_tracemark_fd();
> +}
> -- 
> 2.26.2
> 
> 
Signed-off-by: John Kacur <jkacur@redhat.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 3/4] rt-tests: cyclictest: Close correct trace fds
  2020-11-07  9:58 ` [PATCH 3/4] rt-tests: cyclictest: Close correct " Kurt Kanzenbach
@ 2020-11-11  2:32   ` John Kacur
  0 siblings, 0 replies; 9+ messages in thread
From: John Kacur @ 2020-11-11  2:32 UTC (permalink / raw)
  To: Kurt Kanzenbach; +Cc: Clark Williams, rt-users



On Sat, 7 Nov 2020, Kurt Kanzenbach wrote:

> Remove the last lefotovers from migrating cyclictest to rt-utils.
> 
> The rt-utils module is reponsible for handling the tracing code.
> 
> Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
> ---
>  src/cyclictest/cyclictest.c | 8 +-------
>  1 file changed, 1 insertion(+), 7 deletions(-)
> 
> diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
> index 34aa9be583f8..0ec0b235dba3 100644
> --- a/src/cyclictest/cyclictest.c
> +++ b/src/cyclictest/cyclictest.c
> @@ -283,9 +283,6 @@ enum {
>  	ERROR_NOTFOUND	= -2,
>  };
>  
> -static int trace_fd     = -1;
> -static int tracemark_fd = -1;
> -
>  /*
>   * Raise the soft priority limit up to prio, if that is less than or equal
>   * to the hard limit
> @@ -2272,10 +2269,7 @@ int main(int argc, char **argv)
>  	}
>   out:
>  	/* close any tracer file descriptors */
> -	if (tracemark_fd >= 0)
> -		close(tracemark_fd);
> -	if (trace_fd >= 0)
> -		close(trace_fd);
> +	disable_trace_mark();
>  
>  	/* unlock everything */
>  	if (lockall)
> -- 
> 2.26.2
> 
> 
Signed-off-by: John Kacur <jkacur@redhat.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 4/4] rt-tests: oslat: Close trace fds
  2020-11-07  9:58 ` [PATCH 4/4] rt-tests: oslat: Close " Kurt Kanzenbach
@ 2020-11-11  2:34   ` John Kacur
  0 siblings, 0 replies; 9+ messages in thread
From: John Kacur @ 2020-11-11  2:34 UTC (permalink / raw)
  To: Kurt Kanzenbach; +Cc: Clark Williams, rt-users



On Sat, 7 Nov 2020, Kurt Kanzenbach wrote:

> oslat is also using enable_trace_mark() and never closes the fds. Add it.
> 
> Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
> ---
>  src/oslat/oslat.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/src/oslat/oslat.c b/src/oslat/oslat.c
> index 918e6733c066..0018c472e0c1 100644
> --- a/src/oslat/oslat.c
> +++ b/src/oslat/oslat.c
> @@ -871,5 +871,7 @@ int main(int argc, char *argv[])
>  		g.cpu_list = NULL;
>  	}
>  
> +	disable_trace_mark();
> +
>  	return 0;
>  }
> -- 
> 2.26.2
> 
> 
Signed-off-by: John Kacur <jkacur@redhat.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-11-11  2:34 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-07  9:58 [PATCH 0/4] rt-tests: rt-utils: Close trace fds Kurt Kanzenbach
2020-11-07  9:58 ` [PATCH 1/4] rt-tests: rt-utils: Mark internal functions static Kurt Kanzenbach
2020-11-11  2:29   ` John Kacur
2020-11-07  9:58 ` [PATCH 2/4] rt-tests: rt-utils: Add function to close trace fds Kurt Kanzenbach
2020-11-11  2:30   ` John Kacur
2020-11-07  9:58 ` [PATCH 3/4] rt-tests: cyclictest: Close correct " Kurt Kanzenbach
2020-11-11  2:32   ` John Kacur
2020-11-07  9:58 ` [PATCH 4/4] rt-tests: oslat: Close " Kurt Kanzenbach
2020-11-11  2:34   ` John Kacur

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.