lkml.org 
[lkml]   [2013]   [Mar]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 04/21] workqueue: swap the two branches in pwq_adjust_max_active() to get better readability
On Wed, Mar 20, 2013 at 03:28:04AM +0800, Lai Jiangshan wrote:
> "if (!freezable || !(pwq->pool->flags & POOL_FREEZING))" is hard to read.
>
> Swap the two branches. it becomes
> "if (freezable && (pwq->pool->flags & POOL_FREEZING))", it is better.
>
> Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
> ---
> kernel/workqueue.c | 6 +++---
> 1 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/kernel/workqueue.c b/kernel/workqueue.c
> index e1b31fc..8c882ae 100644
> --- a/kernel/workqueue.c
> +++ b/kernel/workqueue.c
> @@ -3592,14 +3592,14 @@ static void pwq_adjust_max_active(struct pool_workqueue *pwq)
>
> spin_lock(&pwq->pool->lock);
>
> - if (!freezable || !(pwq->pool->flags & POOL_FREEZING)) {
> + if (freezable && (pwq->pool->flags & POOL_FREEZING)) {
> + pwq->max_active = 0;
> + } else {
> pwq->max_active = wq->saved_max_active;
>
> while (!list_empty(&pwq->delayed_works) &&
> pwq->nr_active < pwq->max_active)
> pwq_activate_first_delayed(pwq);
> - } else {
> - pwq->max_active = 0;

Well, I have tendency to put what I think is the "main" branch above
(which also is what compiler assumes to be the hotter path too without
other input, not that it matters here), but yeah, maybe swapping them
is prettier. Does this even matter?

Trying the patch.... hmm.... I don't know. It looks weirder that way.
Maybe we can do the following if !A || !B bothers you?

if (!(freezable && (pwq->pool->flags & POOL_FREEZING)))

Thanks.

--
tejun


\
 
 \ /
  Last update: 2013-03-20 19:21    [W:0.181 / U:0.132 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site