lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 19 Nov 2019 11:26:57 +0800
From:   Yunfeng Ye <yeyunfeng@...wei.com>
To:     Thomas Gleixner <tglx@...utronix.de>
CC:     <gregkh@...uxfoundation.org>, <bvanassche@....org>,
        <alexander.h.duyck@...ux.intel.com>, <bhelgaas@...gle.com>,
        <sakari.ailus@...ux.intel.com>, <linux-kernel@...r.kernel.org>,
        "hushiyuan@...wei.com" <hushiyuan@...wei.com>,
        "linfeilong@...wei.com" <linfeilong@...wei.com>
Subject: [PATCH v3] async: Let kfree() out of the critical area of the lock

The async_lock is big global lock, and kfree() is not always cheap, it
will increase lock contention. it's better let kfree() outside the lock
to keep the critical area as short as possible.

Signed-off-by: Yunfeng Ye <yeyunfeng@...wei.com>
Reviewed-by: Alexander Duyck <alexander.h.duyck@...ux.intel.com>
Reviewed-by: Bart Van Assche <bvanassche@....org>
---
v2 -> v3:
 - move kfree() after wake_up(&async_done)

v1 -> v2:
 - update the description
 - add "Reviewed-by"

 kernel/async.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/async.c b/kernel/async.c
index 4f9c1d614016..d2ab75e8b1ab 100644
--- a/kernel/async.c
+++ b/kernel/async.c
@@ -135,14 +135,14 @@ static void async_run_entry_fn(struct work_struct *work)
 	list_del_init(&entry->domain_list);
 	list_del_init(&entry->global_list);

-	/* 3) free the entry */
-	kfree(entry);
 	atomic_dec(&entry_count);
-
 	spin_unlock_irqrestore(&async_lock, flags);

-	/* 4) wake up any waiters */
+	/* 3) wake up any waiters */
 	wake_up(&async_done);
+
+	/* 4) free the entry */
+	kfree(entry);
 }

 /**
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ