linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Tejun Heo <tj@kernel.org>
Cc: Nigel Cunningham <nigel@nigelcunningham.com.au>,
	"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
	Jens Axboe <axboe@kernel.dk>,
	tomaz.solc@tablix.org, aaron.lu@intel.com,
	linux-kernel@vger.kernel.org, Oleg Nesterov <oleg@redhat.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Fengguang Wu <fengguang.wu@intel.com>,
	Lai Jiangshan <laijs@cn.fujitsu.com>,
	David Howells <dhowells@redhat.com>
Subject: Re: [PATCH wq/for-3.14 1/2] workqueue: update max_active clamping rules
Date: Fri, 20 Dec 2013 02:26:36 +0100	[thread overview]
Message-ID: <26696517.liOUMm9mZy@vostro.rjw.lan> (raw)
In-Reply-To: <20131219233526.GD22725@htj.dyndns.org>

On Thursday, December 19, 2013 06:35:26 PM Tejun Heo wrote:
> From bdd220b2a1b86fee14a12b69fb0cadafe60a1dac Mon Sep 17 00:00:00 2001
> From: Tejun Heo <tj@kernel.org>
> Date: Thu, 19 Dec 2013 18:33:09 -0500
> 
> @max_active handling is currently inconsistent.
> 
> * In alloc_workqueue(), 0 gets converted to the default and the value
>   gets clamped to [1, lim].
> 
> * In workqueue_set_max_active(), 0 is not converted to the default and
>   the value is clamped to [1, lim].
> 
> * When a workqueue is exposed through sysfs, input < 1 fails with
>   -EINVAL; otherwise, the value is clamped to [1, lim].
> 
> * fscache exposes max_active through a sysctl and clamps the value in
>   [1, lim].
> 
> We want to be able to express zero @max_active but as it's a special
> case and 0 is already used for default, don't want to use 0 for it.
> Update @max_active clamping so that the following rules are followed.
> 
> * In both alloc_workqueue() and workqueue_set_max_active(), 0 is
>   converted to the default, and a new special value WQ_FROZEN_ACTIVE
>   becomes 0; otherwise, the value is clamped to [1, lim].
> 
> * In both sysfs and fscache sysctl, input < 1 fails with -EINVAL;
>   otherwise, the value is clamped to [1, lim].
> 
> Signed-off-by: Tejun Heo <tj@kernel.org>
> Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
> Cc: David Howells <dhowells@redhat.com>

Well, this one looks good to me:

Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

> ---
>  fs/fscache/main.c         | 10 +++++++---
>  include/linux/workqueue.h |  1 +
>  kernel/workqueue.c        |  6 +++++-
>  3 files changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/fscache/main.c b/fs/fscache/main.c
> index 7c27907..9d5a716 100644
> --- a/fs/fscache/main.c
> +++ b/fs/fscache/main.c
> @@ -62,9 +62,13 @@ static int fscache_max_active_sysctl(struct ctl_table *table, int write,
>  	int ret;
>  
>  	ret = proc_dointvec(table, write, buffer, lenp, ppos);
> -	if (ret == 0)
> -		workqueue_set_max_active(*wqp, *datap);
> -	return ret;
> +	if (ret < 0)
> +		return ret;
> +	if (*datap < 1)
> +		return -EINVAL;
> +
> +	workqueue_set_max_active(*wqp, *datap);
> +	return 0;
>  }
>  
>  ctl_table fscache_sysctls[] = {
> diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h
> index 594521b..334daa3 100644
> --- a/include/linux/workqueue.h
> +++ b/include/linux/workqueue.h
> @@ -338,6 +338,7 @@ enum {
>  	__WQ_DRAINING		= 1 << 16, /* internal: workqueue is draining */
>  	__WQ_ORDERED		= 1 << 17, /* internal: workqueue is ordered */
>  
> +	WQ_FROZEN_ACTIVE	= -1,	  /* special value for frozen wq */
>  	WQ_MAX_ACTIVE		= 512,	  /* I like 512, better ideas? */
>  	WQ_MAX_UNBOUND_PER_CPU	= 4,	  /* 4 * #cpus for unbound wq */
>  	WQ_DFL_ACTIVE		= WQ_MAX_ACTIVE / 2,
> diff --git a/kernel/workqueue.c b/kernel/workqueue.c
> index 987293d..6748fbf 100644
> --- a/kernel/workqueue.c
> +++ b/kernel/workqueue.c
> @@ -4136,6 +4136,11 @@ static int wq_clamp_max_active(int max_active, unsigned int flags,
>  {
>  	int lim = flags & WQ_UNBOUND ? WQ_UNBOUND_MAX_ACTIVE : WQ_MAX_ACTIVE;
>  
> +	if (max_active == 0)
> +		return WQ_DFL_ACTIVE;
> +	if (max_active == WQ_FROZEN_ACTIVE)
> +		return 0;
> +
>  	if (max_active < 1 || max_active > lim)
>  		pr_warn("workqueue: max_active %d requested for %s is out of range, clamping between %d and %d\n",
>  			max_active, name, 1, lim);
> @@ -4176,7 +4181,6 @@ struct workqueue_struct *__alloc_workqueue_key(const char *fmt,
>  	vsnprintf(wq->name, sizeof(wq->name), fmt, args);
>  	va_end(args);
>  
> -	max_active = max_active ?: WQ_DFL_ACTIVE;
>  	max_active = wq_clamp_max_active(max_active, flags, wq->name);
>  
>  	/* init wq */
> 
-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

  reply	other threads:[~2013-12-20  1:13 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-13 17:49 Writeback threads and freezable Tejun Heo
2013-12-13 18:52 ` Tejun Heo
2013-12-13 20:40   ` [PATCH] libata, freezer: avoid block device removal while system is frozen Tejun Heo
2013-12-13 22:45     ` Nigel Cunningham
2013-12-13 23:07       ` Tejun Heo
2013-12-13 23:15         ` Nigel Cunningham
2013-12-14  1:55           ` Dave Chinner
2013-12-14 20:31           ` Tejun Heo
2013-12-14 20:36             ` Tejun Heo
2013-12-14 21:21               ` Nigel Cunningham
2013-12-17  2:35                 ` Rafael J. Wysocki
2013-12-17  2:34             ` Rafael J. Wysocki
2013-12-17 12:34               ` Tejun Heo
2013-12-18  0:35                 ` Rafael J. Wysocki
2013-12-18 11:17                   ` Tejun Heo
2013-12-18 21:48                     ` Rafael J. Wysocki
2013-12-18 21:39                       ` Tejun Heo
2013-12-18 21:41                         ` Tejun Heo
2013-12-18 22:04                           ` Rafael J. Wysocki
2013-12-19 23:35                             ` [PATCH wq/for-3.14 1/2] workqueue: update max_active clamping rules Tejun Heo
2013-12-20  1:26                               ` Rafael J. Wysocki [this message]
2013-12-19 23:37                             ` [PATCH wq/for-3.14 2/2] workqueue: implement @drain for workqueue_set_max_active() Tejun Heo
2013-12-20  1:31                               ` Rafael J. Wysocki
2013-12-20 13:32                                 ` Tejun Heo
2013-12-20 13:56                                   ` Rafael J. Wysocki
2013-12-20 14:23                                     ` Tejun Heo
2013-12-16 12:12         ` [PATCH] libata, freezer: avoid block device removal while system is frozen Ming Lei
2013-12-16 12:45           ` Tejun Heo
2013-12-16 13:24             ` Ming Lei
2013-12-16 16:05               ` Tejun Heo
2013-12-17  2:38     ` Rafael J. Wysocki
2013-12-17 12:36       ` Tejun Heo
2013-12-18  0:23         ` Rafael J. Wysocki
2013-12-17 12:50     ` [PATCH v2] " Tejun Heo
2013-12-18  1:04       ` Rafael J. Wysocki
2013-12-18 11:08         ` Tejun Heo
2013-12-18 12:07       ` [PATCH v3] " Tejun Heo
2013-12-18 22:08         ` Rafael J. Wysocki
2013-12-19 17:24           ` Tejun Heo
2013-12-19 18:54         ` [PATCH v4] " Tejun Heo
2013-12-14  1:53 ` Writeback threads and freezable Dave Chinner
2013-12-14 17:30   ` Greg Kroah-Hartman
2013-12-14 20:23   ` Tejun Heo
2013-12-16  3:56     ` Dave Chinner
2013-12-16 12:51       ` Tejun Heo
2013-12-16 12:56         ` Tejun Heo
2013-12-18  0:35           ` Dave Chinner
2013-12-18 11:43             ` Tejun Heo
2013-12-18 22:14               ` Rafael J. Wysocki
2013-12-19  4:08               ` Dave Chinner
2013-12-19 16:24                 ` Tejun Heo
2013-12-20  0:51                   ` Dave Chinner
2013-12-20 14:51                     ` Tejun Heo
2013-12-20 14:00                   ` Rafael J. Wysocki

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=26696517.liOUMm9mZy@vostro.rjw.lan \
    --to=rjw@rjwysocki.net \
    --cc=aaron.lu@intel.com \
    --cc=axboe@kernel.dk \
    --cc=dhowells@redhat.com \
    --cc=fengguang.wu@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=laijs@cn.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nigel@nigelcunningham.com.au \
    --cc=oleg@redhat.com \
    --cc=rafael.j.wysocki@intel.com \
    --cc=tj@kernel.org \
    --cc=tomaz.solc@tablix.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).