2019-04-10 12:36:29

by Thomas Gleixner

[permalink] [raw]
Subject: [RFC patch 29/41] btrfs: ref-verify: Simplify stack trace retrieval

Replace the indirection through struct stack_trace with an invocation of
the storage array based interface.

Signed-off-by: Thomas Gleixner <[email protected]>
Cc: David Sterba <[email protected]>
Cc: Chris Mason <[email protected]>
Cc: Josef Bacik <[email protected]>
Cc: [email protected]
---
fs/btrfs/ref-verify.c | 15 ++-------------
1 file changed, 2 insertions(+), 13 deletions(-)

--- a/fs/btrfs/ref-verify.c
+++ b/fs/btrfs/ref-verify.c
@@ -205,28 +205,17 @@ static struct root_entry *lookup_root_en
#ifdef CONFIG_STACKTRACE
static void __save_stack_trace(struct ref_action *ra)
{
- struct stack_trace stack_trace;
-
- stack_trace.max_entries = MAX_TRACE;
- stack_trace.nr_entries = 0;
- stack_trace.entries = ra->trace;
- stack_trace.skip = 2;
- save_stack_trace(&stack_trace);
- ra->trace_len = stack_trace.nr_entries;
+ ra->trace_len = stack_trace_save(ra->trace, MAX_TRACE, 2);
}

static void __print_stack_trace(struct btrfs_fs_info *fs_info,
struct ref_action *ra)
{
- struct stack_trace trace;
-
if (ra->trace_len == 0) {
btrfs_err(fs_info, " ref-verify: no stacktrace");
return;
}
- trace.nr_entries = ra->trace_len;
- trace.entries = ra->trace;
- print_stack_trace(&trace, 2);
+ stack_trace_print(ra->trace, ra->trace_len, 2);
}
#else
static void inline __save_stack_trace(struct ref_action *ra)



2019-04-10 11:33:25

by Johannes Thumshirn

[permalink] [raw]
Subject: Re: [RFC patch 29/41] btrfs: ref-verify: Simplify stack trace retrieval

On Wed, Apr 10, 2019 at 12:28:23PM +0200, Thomas Gleixner wrote:
> Replace the indirection through struct stack_trace with an invocation of
> the storage array based interface.
>
> Signed-off-by: Thomas Gleixner <[email protected]>
> Cc: David Sterba <[email protected]>
> Cc: Chris Mason <[email protected]>
> Cc: Josef Bacik <[email protected]>
> Cc: [email protected]
> ---
> fs/btrfs/ref-verify.c | 15 ++-------------
> 1 file changed, 2 insertions(+), 13 deletions(-)
>
> --- a/fs/btrfs/ref-verify.c
> +++ b/fs/btrfs/ref-verify.c
> @@ -205,28 +205,17 @@ static struct root_entry *lookup_root_en
> #ifdef CONFIG_STACKTRACE
> static void __save_stack_trace(struct ref_action *ra)
> {
> - struct stack_trace stack_trace;
> -
> - stack_trace.max_entries = MAX_TRACE;
> - stack_trace.nr_entries = 0;
> - stack_trace.entries = ra->trace;
> - stack_trace.skip = 2;
> - save_stack_trace(&stack_trace);
> - ra->trace_len = stack_trace.nr_entries;
> + ra->trace_len = stack_trace_save(ra->trace, MAX_TRACE, 2);


Stupid question: why are you passing a '2' for 'skipnr' and in
stack_trace_save() from your series you set stack_trace::skip as skipnr + 1.

Wouldn't this result in a stack_trace::skip = 3? Or is it the number of
functions to be skipped and you don't want to have stack_trace_save() saved as
well?

Thanks,
Johannes
--
Johannes Thumshirn SUSE Labs Filesystems
[email protected] +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg
GF: Felix Imend?rffer, Mary Higgins, Sri Rasiah
HRB 21284 (AG N?rnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

2019-04-10 13:36:15

by Johannes Thumshirn

[permalink] [raw]
Subject: Re: [RFC patch 29/41] btrfs: ref-verify: Simplify stack trace retrieval

On Wed, Apr 10, 2019 at 02:05:17PM +0200, Thomas Gleixner wrote:
> Correct. The extra call will shift the skipped one up, so I compensate for that.

OK, then
Reviewed-by: Johannes Thumshirn <[email protected]>
in case the series goes in.
--
Johannes Thumshirn SUSE Labs Filesystems
[email protected] +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg
GF: Felix Imend?rffer, Mary Higgins, Sri Rasiah
HRB 21284 (AG N?rnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

2019-04-10 13:48:39

by Alexander Potapenko

[permalink] [raw]
Subject: Re: [RFC patch 29/41] btrfs: ref-verify: Simplify stack trace retrieval

On Wed, Apr 10, 2019 at 1:06 PM Thomas Gleixner <[email protected]> wrote:
>
> Replace the indirection through struct stack_trace with an invocation of
> the storage array based interface.
>
> Signed-off-by: Thomas Gleixner <[email protected]>
> Cc: David Sterba <[email protected]>
> Cc: Chris Mason <[email protected]>
> Cc: Josef Bacik <[email protected]>
> Cc: [email protected]
> ---
> fs/btrfs/ref-verify.c | 15 ++-------------
> 1 file changed, 2 insertions(+), 13 deletions(-)
>
> --- a/fs/btrfs/ref-verify.c
> +++ b/fs/btrfs/ref-verify.c
> @@ -205,28 +205,17 @@ static struct root_entry *lookup_root_en
> #ifdef CONFIG_STACKTRACE
> static void __save_stack_trace(struct ref_action *ra)
> {
> - struct stack_trace stack_trace;
> -
> - stack_trace.max_entries = MAX_TRACE;
> - stack_trace.nr_entries = 0;
> - stack_trace.entries = ra->trace;
> - stack_trace.skip = 2;
> - save_stack_trace(&stack_trace);
> - ra->trace_len = stack_trace.nr_entries;
> + ra->trace_len = stack_trace_save(ra->trace, MAX_TRACE, 2);
Now that stack_trace.skip is gone, it's unclear what this "2" stands for.
Maybe add an inline comment saying it's skipnr?
(This is probably valid for all other stack_trace_save() callsites)
> }
>
> static void __print_stack_trace(struct btrfs_fs_info *fs_info,
> struct ref_action *ra)
> {
> - struct stack_trace trace;
> -
> if (ra->trace_len == 0) {
> btrfs_err(fs_info, " ref-verify: no stacktrace");
> return;
> }
> - trace.nr_entries = ra->trace_len;
> - trace.entries = ra->trace;
> - print_stack_trace(&trace, 2);
> + stack_trace_print(ra->trace, ra->trace_len, 2);
> }
> #else
> static void inline __save_stack_trace(struct ref_action *ra)
>
>


--
Alexander Potapenko
Software Engineer

Google Germany GmbH
Erika-Mann-Straße, 33
80636 München

Geschäftsführer: Paul Manicle, Halimah DeLaine Prado
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg

2019-04-10 15:39:33

by Thomas Gleixner

[permalink] [raw]
Subject: Re: [RFC patch 29/41] btrfs: ref-verify: Simplify stack trace retrieval

On Wed, 10 Apr 2019, Johannes Thumshirn wrote:

> On Wed, Apr 10, 2019 at 12:28:23PM +0200, Thomas Gleixner wrote:
> > Replace the indirection through struct stack_trace with an invocation of
> > the storage array based interface.
> >
> > Signed-off-by: Thomas Gleixner <[email protected]>
> > Cc: David Sterba <[email protected]>
> > Cc: Chris Mason <[email protected]>
> > Cc: Josef Bacik <[email protected]>
> > Cc: [email protected]
> > ---
> > fs/btrfs/ref-verify.c | 15 ++-------------
> > 1 file changed, 2 insertions(+), 13 deletions(-)
> >
> > --- a/fs/btrfs/ref-verify.c
> > +++ b/fs/btrfs/ref-verify.c
> > @@ -205,28 +205,17 @@ static struct root_entry *lookup_root_en
> > #ifdef CONFIG_STACKTRACE
> > static void __save_stack_trace(struct ref_action *ra)
> > {
> > - struct stack_trace stack_trace;
> > -
> > - stack_trace.max_entries = MAX_TRACE;
> > - stack_trace.nr_entries = 0;
> > - stack_trace.entries = ra->trace;
> > - stack_trace.skip = 2;
> > - save_stack_trace(&stack_trace);
> > - ra->trace_len = stack_trace.nr_entries;
> > + ra->trace_len = stack_trace_save(ra->trace, MAX_TRACE, 2);
>
>
> Stupid question: why are you passing a '2' for 'skipnr' and in
> stack_trace_save() from your series you set stack_trace::skip as skipnr + 1.
>
> Wouldn't this result in a stack_trace::skip = 3? Or is it the number of
> functions to be skipped and you don't want to have stack_trace_save() saved as
> well?

Correct. The extra call will shift the skipped one up, so I compensate for that.

Thanks,

tglx

2019-04-10 16:16:59

by David Sterba

[permalink] [raw]
Subject: Re: [RFC patch 29/41] btrfs: ref-verify: Simplify stack trace retrieval

On Wed, Apr 10, 2019 at 12:28:23PM +0200, Thomas Gleixner wrote:
> Replace the indirection through struct stack_trace with an invocation of
> the storage array based interface.
>
> Signed-off-by: Thomas Gleixner <[email protected]>
> Cc: David Sterba <[email protected]>
> Cc: Chris Mason <[email protected]>
> Cc: Josef Bacik <[email protected]>
> Cc: [email protected]

Acked-by: David Sterba <[email protected]>