mirror of
https://github.com/team-infusion-developers/android_kernel_samsung_msm8976.git
synced 2024-10-31 18:09:19 +00:00
UPSTREAM: zsmalloc: micro-optimize zs_object_copy()
(cherry-pick from commit 495819ead5ad02174208994ca610852a7791a2f2) A micro-optimization. Avoid additional branching and reduce (a bit) registry pressure (f.e. s_off += size; d_off += size; may be calculated twise: first for >= PAGE_SIZE check and later for offset update in "else" clause). scripts/bloat-o-meter shows some improvement add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-10 (-10) function old new delta zs_object_copy 550 540 -10 Bug: 25951511 Change-Id: Ie3255d79246493fc755e6256f12082e692c0fc3c Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Acked-by: Minchan Kim <minchan@kernel.org> Cc: Nitin Gupta <ngupta@vflare.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
4c117f8df8
commit
f3dbbaaa41
1 changed files with 7 additions and 8 deletions
|
@ -1538,7 +1538,12 @@ static void zs_object_copy(unsigned long src, unsigned long dst,
|
|||
if (written == class->size)
|
||||
break;
|
||||
|
||||
if (s_off + size >= PAGE_SIZE) {
|
||||
s_off += size;
|
||||
s_size -= size;
|
||||
d_off += size;
|
||||
d_size -= size;
|
||||
|
||||
if (s_off >= PAGE_SIZE) {
|
||||
kunmap_atomic(d_addr);
|
||||
kunmap_atomic(s_addr);
|
||||
s_page = get_next_page(s_page);
|
||||
|
@ -1547,21 +1552,15 @@ static void zs_object_copy(unsigned long src, unsigned long dst,
|
|||
d_addr = kmap_atomic(d_page);
|
||||
s_size = class->size - written;
|
||||
s_off = 0;
|
||||
} else {
|
||||
s_off += size;
|
||||
s_size -= size;
|
||||
}
|
||||
|
||||
if (d_off + size >= PAGE_SIZE) {
|
||||
if (d_off >= PAGE_SIZE) {
|
||||
kunmap_atomic(d_addr);
|
||||
d_page = get_next_page(d_page);
|
||||
BUG_ON(!d_page);
|
||||
d_addr = kmap_atomic(d_page);
|
||||
d_size = class->size - written;
|
||||
d_off = 0;
|
||||
} else {
|
||||
d_off += size;
|
||||
d_size -= size;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue