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
89056f24
Commit
89056f24
authored
Dec 23, 2023
by
Kent Overstreet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcachefs: track transaction durations
Signed-off-by:
Kent Overstreet
<
kent.overstreet@linux.dev
>
parent
83322e8c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
12 deletions
+27
-12
fs/bcachefs/bcachefs.h
fs/bcachefs/bcachefs.h
+1
-0
fs/bcachefs/btree_iter.c
fs/bcachefs/btree_iter.c
+8
-1
fs/bcachefs/debug.c
fs/bcachefs/debug.c
+18
-11
No files found.
fs/bcachefs/bcachefs.h
View file @
89056f24
...
...
@@ -647,6 +647,7 @@ struct btree_debug {
#define BCH_TRANSACTIONS_NR 128
struct
btree_transaction_stats
{
struct
bch2_time_stats
duration
;
struct
bch2_time_stats
lock_hold_times
;
struct
mutex
lock
;
unsigned
nr_max_paths
;
...
...
fs/bcachefs/btree_iter.c
View file @
89056f24
...
...
@@ -2894,9 +2894,15 @@ u32 bch2_trans_begin(struct btree_trans *trans)
}
now
=
local_clock
();
if
(
!
IS_ENABLED
(
CONFIG_BCACHEFS_NO_LATENCY_ACCT
)
&&
time_after64
(
now
,
trans
->
last_begin_time
+
10
))
__bch2_time_stats_update
(
&
btree_trans_stats
(
trans
)
->
duration
,
trans
->
last_begin_time
,
now
);
if
(
!
trans
->
restarted
&&
(
need_resched
()
||
now
-
trans
->
last_begin_time
>
BTREE_TRANS_MAX_LOCK_HOLD_TIME_NS
))
{
time_after64
(
now
,
trans
->
last_begin_time
+
BTREE_TRANS_MAX_LOCK_HOLD_TIME_NS
)
))
{
drop_locks_do
(
trans
,
(
cond_resched
(),
0
));
now
=
local_clock
();
}
...
...
@@ -3232,6 +3238,7 @@ void bch2_fs_btree_iter_init_early(struct bch_fs *c)
for
(
s
=
c
->
btree_transaction_stats
;
s
<
c
->
btree_transaction_stats
+
ARRAY_SIZE
(
c
->
btree_transaction_stats
);
s
++
)
{
bch2_time_stats_init
(
&
s
->
duration
);
bch2_time_stats_init
(
&
s
->
lock_hold_times
);
mutex_init
(
&
s
->
lock
);
}
...
...
fs/bcachefs/debug.c
View file @
89056f24
...
...
@@ -693,7 +693,7 @@ static const struct file_operations journal_pins_ops = {
.
read
=
bch2_journal_pins_read
,
};
static
int
lock_held
_stats_open
(
struct
inode
*
inode
,
struct
file
*
file
)
static
int
btree_transaction
_stats_open
(
struct
inode
*
inode
,
struct
file
*
file
)
{
struct
bch_fs
*
c
=
inode
->
i_private
;
struct
dump_iter
*
i
;
...
...
@@ -703,7 +703,7 @@ static int lock_held_stats_open(struct inode *inode, struct file *file)
if
(
!
i
)
return
-
ENOMEM
;
i
->
iter
=
0
;
i
->
iter
=
1
;
i
->
c
=
c
;
i
->
buf
=
PRINTBUF
;
file
->
private_data
=
i
;
...
...
@@ -711,7 +711,7 @@ static int lock_held_stats_open(struct inode *inode, struct file *file)
return
0
;
}
static
int
lock_held
_stats_release
(
struct
inode
*
inode
,
struct
file
*
file
)
static
int
btree_transaction
_stats_release
(
struct
inode
*
inode
,
struct
file
*
file
)
{
struct
dump_iter
*
i
=
file
->
private_data
;
...
...
@@ -721,8 +721,8 @@ static int lock_held_stats_release(struct inode *inode, struct file *file)
return
0
;
}
static
ssize_t
lock_held
_stats_read
(
struct
file
*
file
,
char
__user
*
buf
,
size_t
size
,
loff_t
*
ppos
)
static
ssize_t
btree_transaction
_stats_read
(
struct
file
*
file
,
char
__user
*
buf
,
size_t
size
,
loff_t
*
ppos
)
{
struct
dump_iter
*
i
=
file
->
private_data
;
struct
bch_fs
*
c
=
i
->
c
;
...
...
@@ -755,6 +755,13 @@ static ssize_t lock_held_stats_read(struct file *file, char __user *buf,
prt_printf
(
&
i
->
buf
,
"Max mem used: %u"
,
s
->
max_mem
);
prt_newline
(
&
i
->
buf
);
prt_printf
(
&
i
->
buf
,
"Transaction duration:"
);
prt_newline
(
&
i
->
buf
);
printbuf_indent_add
(
&
i
->
buf
,
2
);
bch2_time_stats_to_text
(
&
i
->
buf
,
&
s
->
duration
);
printbuf_indent_sub
(
&
i
->
buf
,
2
);
if
(
IS_ENABLED
(
CONFIG_BCACHEFS_LOCK_TIME_STATS
))
{
prt_printf
(
&
i
->
buf
,
"Lock hold times:"
);
prt_newline
(
&
i
->
buf
);
...
...
@@ -786,11 +793,11 @@ static ssize_t lock_held_stats_read(struct file *file, char __user *buf,
return
i
->
ret
;
}
static
const
struct
file_operations
lock_held
_stats_op
=
{
.
owner
=
THIS_MODULE
,
.
open
=
lock_held
_stats_open
,
.
release
=
lock_held
_stats_release
,
.
read
=
lock_held
_stats_read
,
static
const
struct
file_operations
btree_transaction
_stats_op
=
{
.
owner
=
THIS_MODULE
,
.
open
=
btree_transaction
_stats_open
,
.
release
=
btree_transaction
_stats_release
,
.
read
=
btree_transaction
_stats_read
,
};
static
ssize_t
bch2_btree_deadlock_read
(
struct
file
*
file
,
char
__user
*
buf
,
...
...
@@ -882,7 +889,7 @@ void bch2_fs_debug_init(struct bch_fs *c)
c
->
btree_debug
,
&
journal_pins_ops
);
debugfs_create_file
(
"btree_transaction_stats"
,
0400
,
c
->
fs_debug_dir
,
c
,
&
lock_held
_stats_op
);
c
,
&
btree_transaction
_stats_op
);
debugfs_create_file
(
"btree_deadlock"
,
0400
,
c
->
fs_debug_dir
,
c
->
btree_debug
,
&
btree_deadlock_ops
);
...
...
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