Commit 8209132f authored by Andrey Filippov's avatar Andrey Filippov

trying mmap-ed first for large ranges

parent 5ffd6dc5
......@@ -842,6 +842,8 @@ EXPORT_SYMBOL(bio_add_page);
* For multi-segment *iter, this function only adds pages from the
* 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)
{
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)
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
}
// 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);
#endif
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",
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);
}
if (unlikely(size <= 0)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment