lkml.org 
[lkml]   [2020]   [Sep]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] mm/mmu_notifier.c: micro-optimization substitute kzalloc with kmalloc
Date
From: Mateusz Nosek <mateusznosek0@gmail.com>

Most fields in struct pointed by 'subscriptions' are initialized explicitly
after the allocation. By changing kzalloc to kmalloc the call to memset
is avoided. As the only new code consists of 2 simple memory accesses,
the performance is increased.

Signed-off-by: Mateusz Nosek <mateusznosek0@gmail.com>
---
mm/mmu_notifier.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/mm/mmu_notifier.c b/mm/mmu_notifier.c
index 4fc918163dd3..190e198dc5be 100644
--- a/mm/mmu_notifier.c
+++ b/mm/mmu_notifier.c
@@ -625,7 +625,7 @@ int __mmu_notifier_register(struct mmu_notifier *subscription,
* know that mm->notifier_subscriptions can't change while we
* hold the write side of the mmap_lock.
*/
- subscriptions = kzalloc(
+ subscriptions = kmalloc(
sizeof(struct mmu_notifier_subscriptions), GFP_KERNEL);
if (!subscriptions)
return -ENOMEM;
@@ -636,6 +636,8 @@ int __mmu_notifier_register(struct mmu_notifier *subscription,
subscriptions->itree = RB_ROOT_CACHED;
init_waitqueue_head(&subscriptions->wq);
INIT_HLIST_HEAD(&subscriptions->deferred_list);
+ subscriptions->active_invalidate_ranges = 0;
+ subscriptions->has_itree = false;
}

ret = mm_take_all_locks(mm);
--
2.20.1
\
 
 \ /
  Last update: 2020-09-06 13:45    [W:0.095 / U:0.116 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site