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
4c97e04a
Commit
4c97e04a
authored
Feb 06, 2019
by
Kent Overstreet
Committed by
Kent Overstreet
Oct 22, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcachefs: percpu utility code
Signed-off-by:
Kent Overstreet
<
kent.overstreet@linux.dev
>
parent
fe112812
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
17 deletions
+30
-17
fs/bcachefs/buckets.c
fs/bcachefs/buckets.c
+1
-4
fs/bcachefs/replicas.c
fs/bcachefs/replicas.c
+2
-4
fs/bcachefs/sysfs.c
fs/bcachefs/sysfs.c
+4
-9
fs/bcachefs/util.h
fs/bcachefs/util.h
+23
-0
No files found.
fs/bcachefs/buckets.c
View file @
4c97e04a
...
...
@@ -1005,10 +1005,7 @@ void bch2_mark_update(struct btree_insert *trans,
static
u64
bch2_recalc_sectors_available
(
struct
bch_fs
*
c
)
{
int
cpu
;
for_each_possible_cpu
(
cpu
)
per_cpu_ptr
(
c
->
pcpu
,
cpu
)
->
sectors_available
=
0
;
percpu_u64_set
(
&
c
->
pcpu
->
sectors_available
,
0
);
return
avail_factor
(
bch2_fs_sectors_free
(
c
));
}
...
...
fs/bcachefs/replicas.c
View file @
4c97e04a
...
...
@@ -426,14 +426,12 @@ int bch2_replicas_gc_end(struct bch_fs *c, int ret)
struct
bch_replicas_entry
*
e
=
cpu_replicas_entry
(
&
c
->
replicas
,
i
);
struct
bch_replicas_cpu
n
;
u64
v
=
0
;
int
cpu
;
u64
v
;
if
(
__replicas_has_entry
(
&
c
->
replicas_gc
,
e
))
continue
;
for_each_possible_cpu
(
cpu
)
v
+=
*
per_cpu_ptr
(
&
c
->
usage
[
0
]
->
data
[
i
],
cpu
);
v
=
percpu_u64_get
(
&
c
->
usage
[
0
]
->
data
[
i
]);
if
(
!
v
)
continue
;
...
...
fs/bcachefs/sysfs.c
View file @
4c97e04a
...
...
@@ -893,20 +893,15 @@ static const char * const bch2_rw[] = {
static
ssize_t
show_dev_iodone
(
struct
bch_dev
*
ca
,
char
*
buf
)
{
struct
printbuf
out
=
_PBUF
(
buf
,
PAGE_SIZE
);
int
rw
,
i
,
cpu
;
int
rw
,
i
;
for
(
rw
=
0
;
rw
<
2
;
rw
++
)
{
pr_buf
(
&
out
,
"%s:
\n
"
,
bch2_rw
[
rw
]);
for
(
i
=
1
;
i
<
BCH_DATA_NR
;
i
++
)
{
u64
n
=
0
;
for_each_possible_cpu
(
cpu
)
n
+=
per_cpu_ptr
(
ca
->
io_done
,
cpu
)
->
sectors
[
rw
][
i
];
for
(
i
=
1
;
i
<
BCH_DATA_NR
;
i
++
)
pr_buf
(
&
out
,
"%-12s:%12llu
\n
"
,
bch2_data_types
[
i
],
n
<<
9
);
}
bch2_data_types
[
i
],
percpu_u64_get
(
&
ca
->
io_done
->
sectors
[
rw
][
i
])
<<
9
);
}
return
out
.
pos
-
buf
;
...
...
fs/bcachefs/util.h
View file @
4c97e04a
...
...
@@ -12,6 +12,7 @@
#include <linux/llist.h>
#include <linux/log2.h>
#include <linux/percpu.h>
#include <linux/preempt.h>
#include <linux/ratelimit.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
...
...
@@ -701,6 +702,28 @@ do { \
} \
} while (0)
static
inline
u64
percpu_u64_get
(
u64
__percpu
*
src
)
{
u64
ret
=
0
;
int
cpu
;
for_each_possible_cpu
(
cpu
)
ret
+=
*
per_cpu_ptr
(
src
,
cpu
);
return
ret
;
}
static
inline
void
percpu_u64_set
(
u64
__percpu
*
dst
,
u64
src
)
{
int
cpu
;
for_each_possible_cpu
(
cpu
)
*
per_cpu_ptr
(
dst
,
cpu
)
=
0
;
preempt_disable
();
*
this_cpu_ptr
(
dst
)
=
src
;
preempt_enable
();
}
static
inline
void
acc_u64s
(
u64
*
acc
,
const
u64
*
src
,
unsigned
nr
)
{
unsigned
i
;
...
...
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