Skip to content
This repository has been archived by the owner on Dec 28, 2020. It is now read-only.

Commit

Permalink
ion: Speed up scatterlist duplication when chaining isn't used
Browse files Browse the repository at this point in the history
When scatterlist chaining isn't used, the entire allocation is just one
contiguous array that can be quickly copied with memcpy. Do so to speed
up the scatterlist duplication process.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: Adam W. Willis <return.of.octobot@gmail.com>
  • Loading branch information
kerneltoast authored and 0ctobot committed Jul 13, 2019
1 parent 2ddfac5 commit e87950b
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions drivers/staging/android/ion/ion.c
Original file line number Diff line number Diff line change
Expand Up @@ -1064,10 +1064,15 @@ static struct sg_table *ion_dupe_sg_table(struct sg_table *orig_table)
return NULL;
}

sg_orig = orig_table->sgl;
for_each_sg(table->sgl, sg, table->nents, i) {
*sg = *sg_orig;
sg_orig = sg_next(sg_orig);
if (table->nents <= SG_MAX_SINGLE_ALLOC) {
memcpy(table->sgl, orig_table->sgl,
table->nents * sizeof(*table->sgl));
} else {
sg_orig = orig_table->sgl;
for_each_sg(table->sgl, sg, table->nents, i) {
*sg = *sg_orig;
sg_orig = sg_next(sg_orig);
}
}
return table;
}
Expand Down

0 comments on commit e87950b

Please sign in to comment.