Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
linux-elphel
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
linux-elphel
Commits
8209132f
Commit
8209132f
authored
Jun 13, 2023
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
trying mmap-ed first for large ranges
parent
5ffd6dc5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
2 deletions
+17
-2
bio.c
src/block/bio.c
+17
-2
No files found.
src/block/bio.c
View file @
8209132f
...
@@ -842,6 +842,8 @@ EXPORT_SYMBOL(bio_add_page);
...
@@ -842,6 +842,8 @@ EXPORT_SYMBOL(bio_add_page);
* For multi-segment *iter, this function only adds pages from the
* For multi-segment *iter, this function only adds pages from the
* the next non-empty segment of the iov iterator.
* the next non-empty segment of the iov iterator.
*/
*/
// undefine to skip
#define SUSPECT_MMAPED (4 * PAGE_SIZE)
static
int
__bio_iov_iter_get_pages
(
struct
bio
*
bio
,
struct
iov_iter
*
iter
)
static
int
__bio_iov_iter_get_pages
(
struct
bio
*
bio
,
struct
iov_iter
*
iter
)
{
{
unsigned
short
nr_pages
=
bio
->
bi_max_vecs
-
bio
->
bi_vcnt
,
idx
;
unsigned
short
nr_pages
=
bio
->
bi_max_vecs
-
bio
->
bi_vcnt
,
idx
;
...
@@ -854,12 +856,25 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter)
...
@@ -854,12 +856,25 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter)
pr_debug
(
" *B* niter->type=%d, iter->iov_offset=0x%08x, iter->count=0x%08x, iter->nr_segs=0x%08lx"
,
\
pr_debug
(
" *B* niter->type=%d, iter->iov_offset=0x%08x, iter->count=0x%08x, iter->nr_segs=0x%08lx"
,
\
iter
->
type
,
iter
->
iov_offset
,
iter
->
count
,
iter
->
nr_segs
);
// *B* niter->type=1, iter->iov_offset=0x00000000, iter->count=0x0009f000, iter->nr_segs=0x00000001
iter
->
type
,
iter
->
iov_offset
,
iter
->
count
,
iter
->
nr_segs
);
// *B* niter->type=1, iter->iov_offset=0x00000000, iter->count=0x0009f000, iter->nr_segs=0x00000001
}
}
// If suspected "Elphel" - try it first?
#ifdef SUSPECT_MMAPED
if
((
bio
->
bi_vcnt
==
0
)
&&
(
iter
->
iov_offset
==
0
)
&&
(
iter
->
nr_segs
==
1
)
&&
(
iter
->
count
>=
SUSPECT_MMAPED
))
{
pr_debug
(
" *B1* Suspecting mmaped memory, iter->count=0x%08x > 0x%08x"
,
iter
->
count
,
(
int
)
SUSPECT_MMAPED
);
size
=
iov_iter_get_pages_elphel
(
iter
,
pages
,
LONG_MAX
,
nr_pages
,
&
offset
);
// try mmap-ed
if
(
size
<
0
){
pr_debug
(
"mmaped failed (err=%d) trying pinning userspace memory"
,
size
);
size
=
iov_iter_get_pages
(
iter
,
pages
,
LONG_MAX
,
nr_pages
,
&
offset
);
// regular way with userspace
}
}
else
{
size
=
iov_iter_get_pages
(
iter
,
pages
,
LONG_MAX
,
nr_pages
,
&
offset
);
// regular way with userspace
}
#else
size
=
iov_iter_get_pages
(
iter
,
pages
,
LONG_MAX
,
nr_pages
,
&
offset
);
size
=
iov_iter_get_pages
(
iter
,
pages
,
LONG_MAX
,
nr_pages
,
&
offset
);
#endif
if
(
unlikely
(
size
<=
0
))
{
if
(
unlikely
(
size
<=
0
))
{
pr_debug
(
"Error=%d, trying continuous mmap-ed pages, bio->bi_vcnt=0x%04x, bio->bi_max_vecs=0x%04x, offset=0x%08x"
,
pr_debug
(
"Error=%d, trying continuous mmap-ed pages, bio->bi_vcnt=0x%04x, bio->bi_max_vecs=0x%04x, offset=0x%08x"
,
size
,
bio
->
bi_vcnt
,
bio
->
bi_max_vecs
,
offset
);
size
,
bio
->
bi_vcnt
,
bio
->
bi_max_vecs
,
offset
);
if
((
size
==
-
EFAULT
)
&&
(
bio
->
bi_vcnt
==
0
)
&&
(
offset
==
0
)
&&
(
iter
->
nr_segs
==
1
)){
// Only for all pages, single segment
if
((
size
==
-
EFAULT
)
&&
(
bio
->
bi_vcnt
==
0
)
&&
(
iter
->
iov_
offset
==
0
)
&&
(
iter
->
nr_segs
==
1
)){
// Only for all pages, single segment
size
=
iov_iter_get_pages_elphel
(
iter
,
pages
,
LONG_MAX
,
nr_pages
,
&
offset
);
size
=
iov_iter_get_pages_elphel
(
iter
,
pages
,
LONG_MAX
,
nr_pages
,
&
offset
);
}
}
if
(
unlikely
(
size
<=
0
))
{
if
(
unlikely
(
size
<=
0
))
{
...
...
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