linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: wanghaibin <wanghaibin.wang@huawei.com>
Cc: linux-kernel@vger.kernel.org, jiangshanlai@gmail.com,
	peter.huangpeng@huawei.com
Subject: [RFC PATCH 4/4] workqueue: simplify the apply_workqueue_attrs_locked function.
Date: Thu, 7 Jan 2016 11:07:32 -0500	[thread overview]
Message-ID: <20160107160732.GD1898@mtj.duckdns.org> (raw)
In-Reply-To: <1452170339-26748-5-git-send-email-wanghaibin.wang@huawei.com>

Hello,

Applied to wq/for-4.5 with some adjustments to patch title
description.

Thanks.
------ 8< ------
>From 6201171e3b2c02992e62448636631a0dfe4e9d20 Mon Sep 17 00:00:00 2001
From: wanghaibin <wanghaibin.wang@huawei.com>
Date: Thu, 7 Jan 2016 20:38:59 +0800
Subject: [PATCH] workqueue: simplify the apply_workqueue_attrs_locked()

If the apply_wqattrs_prepare() returns NULL, it has already cleaned up
the related resources, so it can return directly and avoid calling the
clean up function again.

This doesn't introduce any functional changes.

Signed-off-by: wanghaibin <wanghaibin.wang@huawei.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
---
 kernel/workqueue.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 1ecb588..61a0264 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -3651,7 +3651,6 @@ static int apply_workqueue_attrs_locked(struct workqueue_struct *wq,
 					const struct workqueue_attrs *attrs)
 {
 	struct apply_wqattrs_ctx *ctx;
-	int ret = -ENOMEM;
 
 	/* only unbound workqueues can change attributes */
 	if (WARN_ON(!(wq->flags & WQ_UNBOUND)))
@@ -3662,16 +3661,14 @@ static int apply_workqueue_attrs_locked(struct workqueue_struct *wq,
 		return -EINVAL;
 
 	ctx = apply_wqattrs_prepare(wq, attrs);
+	if (!ctx)
+		return -ENOMEM;
 
 	/* the ctx has been prepared successfully, let's commit it */
-	if (ctx) {
-		apply_wqattrs_commit(ctx);
-		ret = 0;
-	}
-
+	apply_wqattrs_commit(ctx);
 	apply_wqattrs_cleanup(ctx);
 
-	return ret;
+	return 0;
 }
 
 /**
-- 
2.5.0


      reply	other threads:[~2016-01-07 16:07 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-07 12:38 [RFC PATCH 0/4] fixs/suggestions for workqueue subsystem wanghaibin
2016-01-07 12:38 ` [RFC PATCH 1/4] workqueue: move the wq_update_unbound_numa_attrs_buf allocation location wanghaibin
2016-01-07 15:48   ` Tejun Heo
2016-01-11  5:21     ` wanghaibin
2016-01-07 12:38 ` [RFC PATCH 2/4] workqueue: free the allocated memory resource when wq_numa_init failed wanghaibin
2016-01-07 15:50   ` Tejun Heo
2016-01-11  4:26     ` wanghaibin
2016-01-07 12:38 ` [RFC PATCH 3/4] workqueue: remove the unbind workqueue attr sys_file before unregister the workqueue device wanghaibin
2016-01-07 16:00   ` Tejun Heo
2016-01-11 12:23     ` wanghaibin
2016-01-07 12:38 ` [RFC PATCH 4/4] workqueue: simplify the apply_workqueue_attrs_locked function wanghaibin
2016-01-07 16:07   ` Tejun Heo [this message]

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=20160107160732.GD1898@mtj.duckdns.org \
    --to=tj@kernel.org \
    --cc=jiangshanlai@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peter.huangpeng@huawei.com \
    --cc=wanghaibin.wang@huawei.com \
    /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).