Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
3ea4219d
Commit
3ea4219d
authored
Feb 12, 2023
by
Kent Overstreet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcachefs: New backtrace utility code
Signed-off-by:
Kent Overstreet
<
kent.overstreet@linux.dev
>
parent
429dd427
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
12 deletions
+44
-12
fs/bcachefs/btree_locking.c
fs/bcachefs/btree_locking.c
+1
-1
fs/bcachefs/debug.c
fs/bcachefs/debug.c
+1
-1
fs/bcachefs/util.c
fs/bcachefs/util.c
+35
-9
fs/bcachefs/util.h
fs/bcachefs/util.h
+7
-1
No files found.
fs/bcachefs/btree_locking.c
View file @
3ea4219d
...
...
@@ -191,7 +191,7 @@ static noinline int break_cycle(struct lock_graph *g, struct printbuf *cycle)
prt_printf
(
&
buf
,
"backtrace:"
);
prt_newline
(
&
buf
);
printbuf_indent_add
(
&
buf
,
2
);
bch2_prt_backtrace
(
&
buf
,
trans
->
locking_wait
.
task
);
bch2_prt_
task_
backtrace
(
&
buf
,
trans
->
locking_wait
.
task
);
printbuf_indent_sub
(
&
buf
,
2
);
prt_newline
(
&
buf
);
}
...
...
fs/bcachefs/debug.c
View file @
3ea4219d
...
...
@@ -527,7 +527,7 @@ static ssize_t bch2_btree_transactions_read(struct file *file, char __user *buf,
prt_printf
(
&
i
->
buf
,
"backtrace:"
);
prt_newline
(
&
i
->
buf
);
printbuf_indent_add
(
&
i
->
buf
,
2
);
bch2_prt_backtrace
(
&
i
->
buf
,
trans
->
locking_wait
.
task
);
bch2_prt_
task_
backtrace
(
&
i
->
buf
,
trans
->
locking_wait
.
task
);
printbuf_indent_sub
(
&
i
->
buf
,
2
);
prt_newline
(
&
i
->
buf
);
...
...
fs/bcachefs/util.c
View file @
3ea4219d
...
...
@@ -266,22 +266,48 @@ void bch2_print_string_as_lines(const char *prefix, const char *lines)
console_unlock
();
}
int
bch2_
prt_backtrace
(
struct
printbuf
*
out
,
struct
task_struct
*
task
)
int
bch2_
save_backtrace
(
bch_stacktrace
*
stack
,
struct
task_struct
*
task
)
{
unsigned
long
entries
[
32
];
unsigned
i
,
nr_entries
;
unsigned
nr_entries
=
0
;
int
ret
=
0
;
stack
->
nr
=
0
;
ret
=
darray_make_room
(
stack
,
32
);
if
(
ret
)
return
ret
;
if
(
!
down_read_trylock
(
&
task
->
signal
->
exec_update_lock
))
return
0
;
return
-
1
;
do
{
nr_entries
=
stack_trace_save_tsk
(
task
,
stack
->
data
,
stack
->
size
,
0
);
}
while
(
nr_entries
==
stack
->
size
&&
!
(
ret
=
darray_make_room
(
stack
,
stack
->
size
*
2
)));
stack
->
nr
=
nr_entries
;
up_read
(
&
task
->
signal
->
exec_update_lock
);
nr_entries
=
stack_trace_save_tsk
(
task
,
entries
,
ARRAY_SIZE
(
entries
),
0
);
for
(
i
=
0
;
i
<
nr_entries
;
i
++
)
{
prt_printf
(
out
,
"[<0>] %pB"
,
(
void
*
)
entries
[
i
]);
return
ret
;
}
void
bch2_prt_backtrace
(
struct
printbuf
*
out
,
bch_stacktrace
*
stack
)
{
unsigned
long
*
i
;
darray_for_each
(
*
stack
,
i
)
{
prt_printf
(
out
,
"[<0>] %pB"
,
(
void
*
)
*
i
);
prt_newline
(
out
);
}
}
up_read
(
&
task
->
signal
->
exec_update_lock
);
return
0
;
int
bch2_prt_task_backtrace
(
struct
printbuf
*
out
,
struct
task_struct
*
task
)
{
bch_stacktrace
stack
=
{
0
};
int
ret
=
bch2_save_backtrace
(
&
stack
,
task
);
bch2_prt_backtrace
(
out
,
&
stack
);
darray_exit
(
&
stack
);
return
ret
;
}
/* time stats: */
...
...
fs/bcachefs/util.h
View file @
3ea4219d
...
...
@@ -20,6 +20,8 @@
#include "mean_and_variance.h"
#include "darray.h"
struct
closure
;
#ifdef CONFIG_BCACHEFS_DEBUG
...
...
@@ -361,7 +363,11 @@ u64 bch2_read_flag_list(char *, const char * const[]);
void
bch2_prt_u64_binary
(
struct
printbuf
*
,
u64
,
unsigned
);
void
bch2_print_string_as_lines
(
const
char
*
prefix
,
const
char
*
lines
);
int
bch2_prt_backtrace
(
struct
printbuf
*
,
struct
task_struct
*
);
typedef
DARRAY
(
unsigned
long
)
bch_stacktrace
;
int
bch2_save_backtrace
(
bch_stacktrace
*
stack
,
struct
task_struct
*
);
void
bch2_prt_backtrace
(
struct
printbuf
*
,
bch_stacktrace
*
);
int
bch2_prt_task_backtrace
(
struct
printbuf
*
,
struct
task_struct
*
);
#define NR_QUANTILES 15
#define QUANTILE_IDX(i) inorder_to_eytzinger0(i, NR_QUANTILES)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment