linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lai Jiangshan <laijs@linux.alibaba.com>
To: linux-kernel@vger.kernel.org
Cc: Lai Jiangshan <laijs@linux.alibaba.com>,
	Tejun Heo <tj@kernel.org>, Lai Jiangshan <jiangshanlai@gmail.com>
Subject: [PATCH 3/4] workqueue: free wq->unbound_attrs earlier
Date: Fri, 29 May 2020 06:59:01 +0000	[thread overview]
Message-ID: <20200529065903.1758-4-laijs@linux.alibaba.com> (raw)
In-Reply-To: <20200529065903.1758-1-laijs@linux.alibaba.com>

wq->unbound_attrs is never accessed in rcu read site, so that
it can be freed earlier and relieves memory pressure earlier,
although slightly.

Signed-off-by: Lai Jiangshan <laijs@linux.alibaba.com>
---
 kernel/workqueue.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 8d017727bfbc..c0cbe0de95d0 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -3489,8 +3489,6 @@ static void rcu_free_wq(struct rcu_head *rcu)
 
 	if (!(wq->flags & WQ_UNBOUND))
 		free_percpu(wq->cpu_pwqs);
-	else
-		free_workqueue_attrs(wq->unbound_attrs);
 
 	kfree(wq);
 }
@@ -3678,6 +3676,7 @@ static void pwq_unbound_release_workfn(struct work_struct *work)
 	 */
 	if (is_last) {
 		wq_unregister_lockdep(wq);
+		free_workqueue_attrs(wq->unbound_attrs);
 		call_rcu(&wq->rcu, rcu_free_wq);
 	}
 }
-- 
2.20.1


  parent reply	other threads:[~2020-05-29  6:59 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-29  6:58 [PATCH 0/4] workqueue: simple cleanups Lai Jiangshan
2020-05-29  6:58 ` [PATCH 1/4] workqueue: void unneeded requeuing the pwq in rescuer thread Lai Jiangshan
2020-05-29 14:22   ` Tejun Heo
2020-05-29  6:59 ` [PATCH 2/4] workqueue: don't check wq->rescuer in rescuer Lai Jiangshan
2020-05-29 14:14   ` Tejun Heo
2020-05-29 14:58     ` Lai Jiangshan
2020-05-29 15:04       ` Tejun Heo
2020-05-29  6:59 ` Lai Jiangshan [this message]
2020-05-29 14:23   ` [PATCH 3/4] workqueue: free wq->unbound_attrs earlier Tejun Heo
2020-05-29  6:59 ` [PATCH 4/4] workqueue: remove useless unlock() and lock() in series Lai Jiangshan
2020-05-29 14:26   ` Tejun Heo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200529065903.1758-4-laijs@linux.alibaba.com \
    --to=laijs@linux.alibaba.com \
    --cc=jiangshanlai@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).