Patchwork [v3,1/1] latencytop: fix mount error

login
register
mail settings
Submitter Roxana
Date July 14, 2014, 10:58 a.m.
Message ID <bdbcbfeed06623ac20632e04036ff5eb15e53258.1405335436.git.roxana.ciobanu@intel.com>
Download mbox | patch
Permalink /patch/75457/
State New
Headers show

Comments

Roxana - July 14, 2014, 10:58 a.m.
Added a check to ensure debugfs is not mounted before trying
to mount it, because sysfs.sh already mounts it.

[ YOCTO #6498 ]

Signed-off-by: Roxana Ciobanu <roxana.ciobanu@intel.com>
---
 .../latencytop-0.5/latencytop-fsync-mount.patch    | 37 ++++++++++++++++++++++
 meta/recipes-kernel/latencytop/latencytop_0.5.bb   |  3 +-
 2 files changed, 39 insertions(+), 1 deletion(-)
 create mode 100644 meta/recipes-kernel/latencytop/latencytop-0.5/latencytop-fsync-mount.patch
Saul Wold - July 14, 2014, 5:49 p.m.
On 07/14/2014 03:58 AM, Roxana Ciobanu wrote:
> Added a check to ensure debugfs is not mounted before trying
> to mount it, because sysfs.sh already mounts it.
>
> [ YOCTO #6498 ]
>
> Signed-off-by: Roxana Ciobanu <roxana.ciobanu@intel.com>
> ---
>   .../latencytop-0.5/latencytop-fsync-mount.patch    | 37 ++++++++++++++++++++++
>   meta/recipes-kernel/latencytop/latencytop_0.5.bb   |  3 +-
>   2 files changed, 39 insertions(+), 1 deletion(-)
>   create mode 100644 meta/recipes-kernel/latencytop/latencytop-0.5/latencytop-fsync-mount.patch
>
> diff --git a/meta/recipes-kernel/latencytop/latencytop-0.5/latencytop-fsync-mount.patch b/meta/recipes-kernel/latencytop/latencytop-0.5/latencytop-fsync-mount.patch
> new file mode 100644
> index 0000000..9f2e120
> --- /dev/null
> +++ b/meta/recipes-kernel/latencytop/latencytop-0.5/latencytop-fsync-mount.patch

This patch file needs Signed-off-by and Upstream-Status tags.  Also have 
you submitted this change to the upstream community?

Sau!

> @@ -0,0 +1,37 @@
> +Index: latencytop-0.5/fsync.c
> +===================================================================
> +--- latencytop-0.5.orig/fsync.c	2014-07-14 13:25:27.657187985 +0300
> ++++ latencytop-0.5/fsync.c	2014-07-14 13:26:12.033187979 +0300
> +@@ -32,6 +32,7 @@
> + #include <time.h>
> + #include <wchar.h>
> + #include <ctype.h>
> ++#include <sys/stat.h>
> +
> + #include <glib.h>
> +
> +@@ -142,16 +143,23 @@
> + int enable_fsync_tracer(void)
> + {
> + 	int ret;
> ++    struct stat s_debug, s_mount_point;
> ++
> + /*
> +  * Steps to do:
> +  *
> ++ * check if /sys/kernel/debug is mounted
> +  * mount -t debugfs none /sys/kernel/debug/
> +  * cd /sys/kernel/debug/tracing
> +  * echo fsync > current_tracer
> +  * echo ftrace_printk > iter_ctrl
> +  * echo 1 > tracing_on
> +  */
> +-	ret = system("/bin/mount -t debugfs none /sys/kernel/debug/");
> ++
> ++    stat("/sys/kernel/debug/..", &s_debug);
> ++    if (stat("/sys/kernel/debug", &s_mount_point) != 0 ||
Why do two stats here?  Can't you stat an entry inside of the 
/sys/kernel/debug directory?

Sau!
> ++        (s_debug.st_dev == s_mount_point.st_dev))
> ++        ret = system("/bin/mount -t debugfs none /sys/kernel/debug/");
> + 	if (!ret)
> + 		return -1;
> + 	write_to_file("/sys/kernel/debug/tracing/current_tracer", "fsync");	
> diff --git a/meta/recipes-kernel/latencytop/latencytop_0.5.bb b/meta/recipes-kernel/latencytop/latencytop_0.5.bb
> index 516e2c5..243f3d9 100644
> --- a/meta/recipes-kernel/latencytop/latencytop_0.5.bb
> +++ b/meta/recipes-kernel/latencytop/latencytop_0.5.bb
> @@ -10,7 +10,8 @@ PR = "r3"
>
>   SRC_URI = "http://www.latencytop.org/download/latencytop-${PV}.tar.gz \
>               file://latencytop-makefile.patch \
> -            file://latencytop-fsync.patch"
> +            file://latencytop-fsync.patch \
> +            file://latencytop-fsync-mount.patch"
>
>   SRC_URI[md5sum] = "73bb3371c6ee0b0e68e25289027e865c"
>   SRC_URI[sha256sum] = "9e7f72fbea7bd918e71212a1eabaad8488d2c602205d2e3c95d62cd57e9203ef"
>
Ross Burton - July 14, 2014, 6:56 p.m.
On 14 July 2014 18:49, Saul Wold <sgw@linux.intel.com> wrote:
> Why do two stats here?  Can't you stat an entry inside of the
> /sys/kernel/debug directory?

It's the idiomatic "is this a mount point" test: look at the device
number inside and outside the hopeful mount point, and if they're
different then there's a mount.  You need to stat twice to determine
this.

Ross

Patch

diff --git a/meta/recipes-kernel/latencytop/latencytop-0.5/latencytop-fsync-mount.patch b/meta/recipes-kernel/latencytop/latencytop-0.5/latencytop-fsync-mount.patch
new file mode 100644
index 0000000..9f2e120
--- /dev/null
+++ b/meta/recipes-kernel/latencytop/latencytop-0.5/latencytop-fsync-mount.patch
@@ -0,0 +1,37 @@ 
+Index: latencytop-0.5/fsync.c
+===================================================================
+--- latencytop-0.5.orig/fsync.c	2014-07-14 13:25:27.657187985 +0300
++++ latencytop-0.5/fsync.c	2014-07-14 13:26:12.033187979 +0300
+@@ -32,6 +32,7 @@
+ #include <time.h>
+ #include <wchar.h>
+ #include <ctype.h>
++#include <sys/stat.h>
+ 
+ #include <glib.h>
+ 
+@@ -142,16 +143,23 @@
+ int enable_fsync_tracer(void)
+ {
+ 	int ret;
++    struct stat s_debug, s_mount_point;
++
+ /*
+  * Steps to do:
+  *
++ * check if /sys/kernel/debug is mounted
+  * mount -t debugfs none /sys/kernel/debug/
+  * cd /sys/kernel/debug/tracing
+  * echo fsync > current_tracer
+  * echo ftrace_printk > iter_ctrl 
+  * echo 1 > tracing_on
+  */
+-	ret = system("/bin/mount -t debugfs none /sys/kernel/debug/");
++
++    stat("/sys/kernel/debug/..", &s_debug);
++    if (stat("/sys/kernel/debug", &s_mount_point) != 0 ||
++        (s_debug.st_dev == s_mount_point.st_dev))
++        ret = system("/bin/mount -t debugfs none /sys/kernel/debug/");
+ 	if (!ret) 
+ 		return -1;
+ 	write_to_file("/sys/kernel/debug/tracing/current_tracer", "fsync");	
diff --git a/meta/recipes-kernel/latencytop/latencytop_0.5.bb b/meta/recipes-kernel/latencytop/latencytop_0.5.bb
index 516e2c5..243f3d9 100644
--- a/meta/recipes-kernel/latencytop/latencytop_0.5.bb
+++ b/meta/recipes-kernel/latencytop/latencytop_0.5.bb
@@ -10,7 +10,8 @@  PR = "r3"
 
 SRC_URI = "http://www.latencytop.org/download/latencytop-${PV}.tar.gz \
             file://latencytop-makefile.patch \
-            file://latencytop-fsync.patch"
+            file://latencytop-fsync.patch \
+            file://latencytop-fsync-mount.patch"
 
 SRC_URI[md5sum] = "73bb3371c6ee0b0e68e25289027e865c"
 SRC_URI[sha256sum] = "9e7f72fbea7bd918e71212a1eabaad8488d2c602205d2e3c95d62cd57e9203ef"