aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorSergey Senozhatsky <sergey.senozhatsky@gmail.com>2015-04-15 19:16:15 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-04-15 19:35:22 -0400
commit495819ead5ad02174208994ca610852a7791a2f2 (patch)
tree3e1c75d7ceefac98519dfae8c181e9b1712bc0f6 /mm
parent1ec7cfb13acb8047ae5baafb43d2cd6b64ac85b9 (diff)
zsmalloc: micro-optimize zs_object_copy()
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 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>
Diffstat (limited to 'mm')
-rw-r--r--mm/zsmalloc.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 8705a010e2d3..a9a9ff233a13 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -1537,7 +1537,12 @@ static void zs_object_copy(unsigned long src, unsigned long dst,
1537 if (written == class->size) 1537 if (written == class->size)
1538 break; 1538 break;
1539 1539
1540 if (s_off + size >= PAGE_SIZE) { 1540 s_off += size;
1541 s_size -= size;
1542 d_off += size;
1543 d_size -= size;
1544
1545 if (s_off >= PAGE_SIZE) {
1541 kunmap_atomic(d_addr); 1546 kunmap_atomic(d_addr);
1542 kunmap_atomic(s_addr); 1547 kunmap_atomic(s_addr);
1543 s_page = get_next_page(s_page); 1548 s_page = get_next_page(s_page);
@@ -1546,21 +1551,15 @@ static void zs_object_copy(unsigned long src, unsigned long dst,
1546 d_addr = kmap_atomic(d_page); 1551 d_addr = kmap_atomic(d_page);
1547 s_size = class->size - written; 1552 s_size = class->size - written;
1548 s_off = 0; 1553 s_off = 0;
1549 } else {
1550 s_off += size;
1551 s_size -= size;
1552 } 1554 }
1553 1555
1554 if (d_off + size >= PAGE_SIZE) { 1556 if (d_off >= PAGE_SIZE) {
1555 kunmap_atomic(d_addr); 1557 kunmap_atomic(d_addr);
1556 d_page = get_next_page(d_page); 1558 d_page = get_next_page(d_page);
1557 BUG_ON(!d_page); 1559 BUG_ON(!d_page);
1558 d_addr = kmap_atomic(d_page); 1560 d_addr = kmap_atomic(d_page);
1559 d_size = class->size - written; 1561 d_size = class->size - written;
1560 d_off = 0; 1562 d_off = 0;
1561 } else {
1562 d_off += size;
1563 d_size -= size;
1564 } 1563 }
1565 } 1564 }
1566 1565