tracing: Fix document and blktrace
Subsystems (4)
Masami Hiramatsu
maintainercover tracing: Fix document and blktrace
Hi,
Here are 2 small fixes for ftrace, one is documentation fix to add stacktrace action and another is blktrace fix so that user can set the current enablement parameter without an error.
Thank you,
---
Masami Hiramatsu (2):
docs: tracing: Add stacktrace filter command tracing/blktrace: Fix to allow setting same value
Documentation/trace/ftrace.rst | 3 +++ kernel/trace/blktrace.c | 11 +++++++---- 2 files changed, 10 insertions(+), 4 deletions(-)
--
Masami Hiramatsu (Linaro) <[email protected]>
Masami Hiramatsu
maintainerPATCH 1/2 docs: tracing: Add stacktrace filter command
Add a description of stacktrace filter command.
--- Documentation/trace/ftrace.rst | 3 +++ 1 file changed, 3 insertions(+)
Documentation/trace/ftrace.rst +3 -0
@@ -2987,6 +2987,9 @@ The following commands are supported: command, it only prints out the contents of the ring buffer for the CPU that executed the function that triggered the dump. +- stacktrace: + When the function is hit, a stack trace is recorded. + trace_pipe ----------
Masami Hiramatsu
maintainerPATCH 2/2 tracing/blktrace: Fix to allow setting same value
In reply to Masami HiramatsuCurrent trace-enable attribute in sysfs returns an error if user writes the same setting value as current one, e.g.
# cat /sys/block/sda/trace/enable 0 # echo 0 > /sys/block/sda/trace/enable bash: echo: write error: Invalid argument # echo 1 > /sys/block/sda/trace/enable # echo 1 > /sys/block/sda/trace/enable bash: echo: write error: Device or resource busy
But this is not a preferred behavior, it should ignore if new setting is same as current one. This fixes the problem as below.
# cat /sys/block/sda/trace/enable 0 # echo 0 > /sys/block/sda/trace/enable # echo 1 > /sys/block/sda/trace/enable # echo 1 > /sys/block/sda/trace/enable
--- kernel/trace/blktrace.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
kernel/trace/blktrace.c +7 -4
@@ -1602,11 +1602,11 @@ static int blk_trace_remove_queue(struct request_queue *q)struct blk_trace *bt; bt =xchg (&q->blk_trace,NULL ); -if (bt ==NULL ) -return -EINVAL ; +if (bt !=NULL ) { +put_probe_ref (); +blk_trace_free (bt); + } -put_probe_ref (); -blk_trace_free (bt);return 0 ; }
@@ -1619,6 +1619,9 @@ static int blk_trace_setup_queue(struct request_queue *q,struct blk_trace *bt =NULL ;int ret = -ENOMEM ; +if (q->blk_trace) +return 0 ; + bt =kzalloc (sizeof (*bt),GFP_KERNEL );if (!bt)return -ENOMEM ;
Re: [PATCH 1/2] docs: tracing: Add stacktrace filter command
In reply to Masami HiramatsuQuoted 5 lines · On Thu, 16 Aug 2018 18:50:47 +0900 Masami Hiramatsu <[email protected]> wrote:
Add a description of stacktrace filter command.
Signed-off-by Masami Hiramatsu <[email protected]>Cc Jonathan Corbet <[email protected]>
Jon, want to pull this patch into your tree?
-- Steve
Quoted 18 lines
--- Documentation/trace/ftrace.rst | 3 +++ 1 file changed, 3 insertions(+)Documentation/trace/ftrace.rst +3
-0@@ -2987,6 +2987,9 @@ The following commands are supported: command, it only prints out the contents of the ring buffer for the CPU that executed the function that triggered the dump. +- stacktrace: + When the function is hit, a stack trace is recorded. + trace_pipe ----------
Steven Rostedt
maintainerRe: [PATCH 2/2] tracing/blktrace: Fix to allow setting same value
In reply to Masami HiramatsuQuoted 50 lines · On Thu, 16 Aug 2018 18:51:15 +0900 Masami Hiramatsu <[email protected]> wrote:
Current trace-enable attribute in sysfs returns an error if user writes the same setting value as current one, e.g.
# cat /sys/block/sda/trace/enable 0 # echo 0 > /sys/block/sda/trace/enable bash: echo: write error: Invalid argument # echo 1 > /sys/block/sda/trace/enable # echo 1 > /sys/block/sda/trace/enable bash: echo: write error: Device or resource busyBut this is not a preferred behavior, it should ignore if new setting is same as current one. This fixes the problem as below.
# cat /sys/block/sda/trace/enable 0 # echo 0 > /sys/block/sda/trace/enable # echo 1 > /sys/block/sda/trace/enable # echo 1 > /sys/block/sda/trace/enableSigned-off-by Masami Hiramatsu <[email protected]>Cc Jens Axboe <[email protected]>--- kernel/trace/blktrace.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)kernel/trace/blktrace.c +4
-4@@ -1602,11 +1602,11 @@ static int blk_trace_remove_queue(struct request_queue *q)struct blk_trace *bt; bt =xchg (&q->blk_trace,NULL ); -if (bt ==NULL ) -return -EINVAL ; +if (bt !=NULL ) { +put_probe_ref (); +blk_trace_free (bt); + } -put_probe_ref (); -blk_trace_free (bt);return 0 ; }
kernel/trace/blktrace.c static int blk_trace_setup_queue(struct request_queue *q, · line 1627
Quoted 9 lines
kernel/trace/blktrace.c +3
-0@@ -1619,6 +1619,9 @@ static int blk_trace_setup_queue(struct request_queue *q,struct blk_trace *bt =NULL ;int ret = -ENOMEM ; +if (q->blk_trace) +return 0 ; + bt =kzalloc (sizeof (*bt),GFP_KERNEL );if (!bt)return -ENOMEM ;
Hmm, why not just do this? Does this fix it too?
kernel/trace/blktrace.c +2 -0
@@ -1841,6 +1841,8 @@ static ssize_t sysfs_blk_trace_attr_store(struct device *dev,mutex_lock (&q->blk_trace_mutex);if (attr == &dev_attr_enable) { +if (!!value == !!q->blk_trace) + goto out_unlock_bdev;if (value) ret =blk_trace_setup_queue (q, bdev);else
-- Steve
Masami Hiramatsu
maintainerRe: [PATCH 2/2] tracing/blktrace: Fix to allow setting same value
Quoted 56 lines · On Thu, 16 Aug 2018 10:38:02 -0400 Steven Rostedt <[email protected]> wrote:
Quoted 53 lines · On Thu, 16 Aug 2018 18:51:15 +0900 Masami Hiramatsu <[email protected]> wrote:
Current trace-enable attribute in sysfs returns an error if user writes the same setting value as current one, e.g.
# cat /sys/block/sda/trace/enable 0 # echo 0 > /sys/block/sda/trace/enable bash: echo: write error: Invalid argument # echo 1 > /sys/block/sda/trace/enable # echo 1 > /sys/block/sda/trace/enable bash: echo: write error: Device or resource busyBut this is not a preferred behavior, it should ignore if new setting is same as current one. This fixes the problem as below.
# cat /sys/block/sda/trace/enable 0 # echo 0 > /sys/block/sda/trace/enable # echo 1 > /sys/block/sda/trace/enable # echo 1 > /sys/block/sda/trace/enableSigned-off-by Masami Hiramatsu <[email protected]>Cc Jens Axboe <[email protected]>--- kernel/trace/blktrace.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)kernel/trace/blktrace.c +4
-4@@ -1602,11 +1602,11 @@ static int blk_trace_remove_queue(struct request_queue *q)struct blk_trace *bt; bt =xchg (&q->blk_trace,NULL ); -if (bt ==NULL ) -return -EINVAL ; +if (bt !=NULL ) { +put_probe_ref (); +blk_trace_free (bt); + } -put_probe_ref (); -blk_trace_free (bt);return 0 ; }@@ -1619,6 +1619,9 @@ static int blk_trace_setup_queue(struct request_queue *q,struct blk_trace *bt =NULL ;int ret = -ENOMEM ;
Quoted 8 lines
kernel/trace/blktrace.c static int blk_trace_setup_queue(struct request_queue *q, · line 1627
Quoted 6 lines
kernel/trace/blktrace.c +3
-0+if (q->blk_trace) +return 0 ; + bt =kzalloc (sizeof (*bt),GFP_KERNEL );if (!bt)return -ENOMEM ;Hmm, why not just do this? Does this fix it too?
Ah, yes, but we need to clear "ret" in that case.
Thanks!
Quoted 16 lines
kernel/trace/blktrace.c +2
-1@@ -1841,6 +1841,8 @@ static ssize_t sysfs_blk_trace_attr_store(struct device *dev,mutex_lock (&q->blk_trace_mutex);if (attr == &dev_attr_enable) { +if (!!value == !!q->blk_trace) + goto out_unlock_bdev;if (value) ret =blk_trace_setup_queue (q, bdev);else -- Steve
Signature · 1 line
Masami Hiramatsu <[email protected]>
Steven Rostedt
maintainerRe: [PATCH 2/2] tracing/blktrace: Fix to allow setting same value
Quoted 68 lines · On Fri, 17 Aug 2018 01:38:47 +0900 Masami Hiramatsu <[email protected]> wrote:
Quoted 56 lines · On Thu, 16 Aug 2018 10:38:02 -0400 Steven Rostedt <[email protected]> wrote:
Quoted 53 lines · On Thu, 16 Aug 2018 18:51:15 +0900 Masami Hiramatsu <[email protected]> wrote:
Current trace-enable attribute in sysfs returns an error if user writes the same setting value as current one, e.g.
# cat /sys/block/sda/trace/enable 0 # echo 0 > /sys/block/sda/trace/enable bash: echo: write error: Invalid argument # echo 1 > /sys/block/sda/trace/enable # echo 1 > /sys/block/sda/trace/enable bash: echo: write error: Device or resource busyBut this is not a preferred behavior, it should ignore if new setting is same as current one. This fixes the problem as below.
# cat /sys/block/sda/trace/enable 0 # echo 0 > /sys/block/sda/trace/enable # echo 1 > /sys/block/sda/trace/enable # echo 1 > /sys/block/sda/trace/enableSigned-off-by Masami Hiramatsu <[email protected]>Cc Jens Axboe <[email protected]>--- kernel/trace/blktrace.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)kernel/trace/blktrace.c +4
-4@@ -1602,11 +1602,11 @@ static int blk_trace_remove_queue(struct request_queue *q)struct blk_trace *bt; bt =xchg (&q->blk_trace,NULL ); -if (bt ==NULL ) -return -EINVAL ; +if (bt !=NULL ) { +put_probe_ref (); +blk_trace_free (bt); + } -put_probe_ref (); -blk_trace_free (bt);return 0 ; }@@ -1619,6 +1619,9 @@ static int blk_trace_setup_queue(struct request_queue *q,struct blk_trace *bt =NULL ;int ret = -ENOMEM ;Quoted 8 lines
kernel/trace/blktrace.c static int blk_trace_setup_queue(struct request_queue *q, · line 1627
Quoted 6 lines
kernel/trace/blktrace.c +3
-0+if (q->blk_trace) +return 0 ; + bt =kzalloc (sizeof (*bt),GFP_KERNEL );if (!bt)return -ENOMEM ;Hmm, why not just do this? Does this fix it too?
Quoted 1 line
Ah, yes, but we need to clear "ret" in that case.
Sure.
Quoted 12 lines
Thanks!
Quoted 8 lines
kernel/trace/blktrace.c +0
-0@@ -1841,6 +1841,8 @@ static ssize_t sysfs_blk_trace_attr_store(struct device *dev,mutex_lock (&q->blk_trace_mutex);
Quoted 2 lines
kernel/trace/blktrace.c static ssize_t sysfs_blk_trace_attr_store(struct device *dev, · line 1844
Quoted 2 lines
kernel/trace/blktrace.c +1
-0if (attr == &dev_attr_enable) { +if (!!value == !!q->blk_trace) {
+ ret = 0;
Quoted 1 line
kernel/trace/blktrace.c static ssize_t sysfs_blk_trace_attr_store(struct device *dev, · line 1845
Quoted 1 line
kernel/trace/blktrace.c +1
-0+ goto out_unlock_bdev;
+ }
-- Steve
Quoted 7 lines
Quoted 5 lines
kernel/trace/blktrace.c +0
-1if (value) ret =blk_trace_setup_queue (q, bdev);else -- Steve
Re: [PATCH 2/2] tracing/blktrace: Fix to allow setting same value
Quoted 19 lines · On Thu, 16 Aug 2018 12:49:17 -0400 Steven Rostedt <[email protected]> wrote:
Quoted 4 lines
Quoted 2 lines
Hmm, why not just do this? Does this fix it too?
Ah, yes, but we need to clear "ret" in that case.
Sure.
Quoted 11 lines
Thanks!
Quoted 8 lines
kernel/trace/blktrace.c +0
-0@@ -1841,6 +1841,8 @@ static ssize_t sysfs_blk_trace_attr_store(struct device *dev,mutex_lock (&q->blk_trace_mutex);
Quoted 6 lines
Quoted 2 lines
kernel/trace/blktrace.c static ssize_t sysfs_blk_trace_attr_store(struct device *dev, · line 1844
Quoted 2 lines
kernel/trace/blktrace.c +1
-0if (attr == &dev_attr_enable) { +if (!!value == !!q->blk_trace) {+ ret = 0;
Quoted 1 line
kernel/trace/blktrace.c static ssize_t sysfs_blk_trace_attr_store(struct device *dev, · line 1845
Quoted 1 line
kernel/trace/blktrace.c +1
-0+ goto out_unlock_bdev;+ }
OK, I tested and ensured that this works.
Thanks!
Signature · 1 line
Masami Hiramatsu <[email protected]>
Jonathan Corbet
maintainerRe: [PATCH 1/2] docs: tracing: Add stacktrace filter command
In reply to Steven RostedtQuoted 5 lines · On Thu, 16 Aug 2018 08:50:31 -0400 Steven Rostedt <[email protected]> wrote:
Quoted 2 lines · On Thu, 16 Aug 2018 18:50:47 +0900 Masami Hiramatsu <[email protected]> wrote:
Add a description of stacktrace filter command.
Quoted 7 lines
Quoted 3 lines
Signed-off-by Masami Hiramatsu <[email protected]>Cc Jonathan Corbet <[email protected]>Jon, want to pull this patch into your tree?
Applied (finally), thanks.
jon