From: Mike Snitzer <snitzer@redhat.com>
To: Frank Mayhar <fmayhar@google.com>, Mikulas Patocka <mpatocka@redhat.com>
Cc: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>, dm-devel@redhat.com
Subject: [PATCH v3 2/3] dm: add reserved_rq_based_ios module parameter
Date: Fri, 13 Sep 2013 17:08:13 -0400 [thread overview]
Message-ID: <1379106494-16366-3-git-send-email-snitzer@redhat.com> (raw)
In-Reply-To: <1379106494-16366-1-git-send-email-snitzer@redhat.com>
Allow user to change the number of IOs that are reserved by
request-based DM's mempools by writing to this file:
/sys/module/dm_mod/parameters/reserved_rq_based_ios
The default value is RESERVED_REQUEST_BASED_IOS (256). The maximum
allowed value is RESERVED_MAX_IOS (1024).
Export dm_get_reserved_rq_based_ios() for use by DM targets and core
code. Switch to sizing dm-mpath's mempool using DM core's configurable
'reserved_rq_based_ios'.
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Acked-by: Mikulas Patocka <mpatocka@redhat.com>
---
drivers/md/dm-mpath.c | 6 +++---
drivers/md/dm.c | 38 +++++++++++++++++++++++++++++++++++++-
drivers/md/dm.h | 2 ++
3 files changed, 42 insertions(+), 4 deletions(-)
diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
index b759a12..e0bed10 100644
--- a/drivers/md/dm-mpath.c
+++ b/drivers/md/dm-mpath.c
@@ -7,6 +7,7 @@
#include <linux/device-mapper.h>
+#include "dm.h"
#include "dm-path-selector.h"
#include "dm-uevent.h"
@@ -116,8 +117,6 @@ struct dm_mpath_io {
typedef int (*action_fn) (struct pgpath *pgpath);
-#define MIN_IOS 256 /* Mempool size */
-
static struct kmem_cache *_mpio_cache;
static struct workqueue_struct *kmultipathd, *kmpath_handlerd;
@@ -190,6 +189,7 @@ static void free_priority_group(struct priority_group *pg,
static struct multipath *alloc_multipath(struct dm_target *ti)
{
struct multipath *m;
+ unsigned min_ios = dm_get_reserved_rq_based_ios();
m = kzalloc(sizeof(*m), GFP_KERNEL);
if (m) {
@@ -202,7 +202,7 @@ static struct multipath *alloc_multipath(struct dm_target *ti)
INIT_WORK(&m->trigger_event, trigger_event);
init_waitqueue_head(&m->pg_init_wait);
mutex_init(&m->work_mutex);
- m->mpio_pool = mempool_create_slab_pool(MIN_IOS, _mpio_cache);
+ m->mpio_pool = mempool_create_slab_pool(min_ios, _mpio_cache);
if (!m->mpio_pool) {
kfree(m);
return NULL;
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 47bac14..93ba644 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -213,9 +213,41 @@ struct dm_md_mempools {
#define RESERVED_BIO_BASED_IOS 16
#define RESERVED_REQUEST_BASED_IOS 256
+#define RESERVED_MAX_IOS 1024
static struct kmem_cache *_io_cache;
static struct kmem_cache *_rq_tio_cache;
+/*
+ * Request-based DM's mempools' reserved IOs set by the user.
+ */
+static unsigned reserved_rq_based_ios = RESERVED_REQUEST_BASED_IOS;
+
+static unsigned __dm_get_reserved_ios(unsigned *reserved_ios,
+ unsigned def, unsigned max)
+{
+ unsigned ios = ACCESS_ONCE(*reserved_ios);
+ unsigned modified_ios = 0;
+
+ if (!ios)
+ modified_ios = def;
+ else if (ios > max)
+ modified_ios = max;
+
+ if (modified_ios) {
+ (void)cmpxchg(reserved_ios, ios, modified_ios);
+ ios = modified_ios;
+ }
+
+ return ios;
+}
+
+unsigned dm_get_reserved_rq_based_ios(void)
+{
+ return __dm_get_reserved_ios(&reserved_rq_based_ios,
+ RESERVED_REQUEST_BASED_IOS, RESERVED_MAX_IOS);
+}
+EXPORT_SYMBOL_GPL(dm_get_reserved_rq_based_ios);
+
static int __init local_init(void)
{
int r = -ENOMEM;
@@ -2867,7 +2899,7 @@ struct dm_md_mempools *dm_alloc_md_mempools(unsigned type, unsigned integrity, u
front_pad = roundup(per_bio_data_size, __alignof__(struct dm_target_io)) + offsetof(struct dm_target_io, clone);
} else if (type == DM_TYPE_REQUEST_BASED) {
cachep = _rq_tio_cache;
- pool_size = RESERVED_REQUEST_BASED_IOS;
+ pool_size = dm_get_reserved_rq_based_ios();
front_pad = offsetof(struct dm_rq_clone_bio_info, clone);
/* per_bio_data_size is not used. See __bind_mempools(). */
WARN_ON(per_bio_data_size != 0);
@@ -2925,6 +2957,10 @@ module_exit(dm_exit);
module_param(major, uint, 0);
MODULE_PARM_DESC(major, "The major number of the device mapper");
+
+module_param(reserved_rq_based_ios, uint, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(reserved_rq_based_ios, "Reserved IOs in request-based mempools");
+
MODULE_DESCRIPTION(DM_NAME " driver");
MODULE_AUTHOR("Joe Thornber <dm-devel@redhat.com>");
MODULE_LICENSE("GPL");
diff --git a/drivers/md/dm.h b/drivers/md/dm.h
index 5e604cc..1539650 100644
--- a/drivers/md/dm.h
+++ b/drivers/md/dm.h
@@ -184,6 +184,8 @@ void dm_free_md_mempools(struct dm_md_mempools *pools);
/*
* Helpers that are used by DM core
*/
+unsigned dm_get_reserved_rq_based_ios(void);
+
static inline bool dm_message_test_buffer_overflow(char *result, unsigned maxlen)
{
return !maxlen || strlen(result) + 1 >= maxlen;
--
1.7.1
next prev parent reply other threads:[~2013-09-13 21:08 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1376070533.26057.244.camel@bobble.lax.corp.google.com>
2013-08-17 12:30 ` [dm-devel] [PATCH] dm: Make MIN_IOS, et al, tunable via sysctl Alasdair G Kergon
2013-08-19 13:40 ` Mike Snitzer
2013-08-19 15:04 ` Frank Mayhar
2013-08-19 14:00 ` Mike Snitzer
2013-08-19 17:54 ` [dm-devel] " Frank Mayhar
2013-08-19 18:15 ` Mike Snitzer
2013-08-20 21:44 ` [dm-devel] " Mikulas Patocka
2013-08-20 21:52 ` Frank Mayhar
2013-08-20 21:41 ` Mikulas Patocka
2013-08-20 21:22 ` [dm-devel] [PATCH] " Mikulas Patocka
2013-08-20 21:28 ` Frank Mayhar
2013-08-20 21:47 ` Mikulas Patocka
2013-08-20 21:57 ` Frank Mayhar
2013-08-20 22:24 ` Mike Snitzer
2013-08-20 22:52 ` Mikulas Patocka
2013-08-20 23:14 ` Frank Mayhar
2013-08-22 17:26 ` Frank Mayhar
2013-08-26 14:28 ` Mikulas Patocka
2013-09-12 22:24 ` [PATCH 0/7] dm: allow mempool and bioset reserves to be tuned Mike Snitzer
2013-09-12 22:24 ` [PATCH 1/7] dm: lower bio-based mempool reservation Mike Snitzer
2013-09-12 22:40 ` Mikulas Patocka
2013-09-12 22:24 ` [PATCH 2/7] dm: add reserved_rq_based_ios module parameter Mike Snitzer
2013-09-12 22:45 ` Mikulas Patocka
2013-09-12 23:15 ` Mike Snitzer
2013-09-12 23:27 ` Mikulas Patocka
2013-09-12 23:32 ` Mike Snitzer
2013-09-12 22:24 ` [PATCH 3/7] dm: add reserved_bio_based_ios " Mike Snitzer
2013-09-12 22:47 ` Mikulas Patocka
2013-09-12 23:11 ` Mike Snitzer
2013-09-12 23:17 ` Mikulas Patocka
2013-09-18 15:17 ` Frank Mayhar
2013-09-12 22:24 ` [PATCH 4/7] dm io: use dm_get_reserved_bio_based_ios to size reserves Mike Snitzer
2013-09-12 22:48 ` Mikulas Patocka
2013-09-12 22:24 ` [PATCH 5/7] dm mpath: use dm_get_reserved_rq_based_ios to size mempool Mike Snitzer
2013-09-12 22:48 ` Mikulas Patocka
2013-09-12 22:24 ` [PATCH 6/7] dm: track the maximum number of bios in a cloned request Mike Snitzer
2013-09-12 22:55 ` Mikulas Patocka
2013-09-12 23:09 ` Mike Snitzer
2013-09-12 22:24 ` [PATCH 7/7] dm: optimize clone_rq() when track_peak_rq_based_ios is disabled Mike Snitzer
2013-09-12 23:00 ` Mikulas Patocka
2013-09-12 23:06 ` Mike Snitzer
2013-09-12 23:30 ` Mikulas Patocka
2013-09-12 23:53 ` Mike Snitzer
2013-09-13 4:46 ` Jun'ichi Nomura
2013-09-13 13:04 ` Mike Snitzer
2013-09-13 14:34 ` Mikulas Patocka
2013-09-13 18:59 ` [PATCH v2 0/3] dm: allow mempool and bioset reserves to be tuned Mike Snitzer
2013-09-13 18:59 ` [PATCH v2 1/3] dm: lower bio-based mempool reservation Mike Snitzer
2013-09-13 18:59 ` [PATCH v2 2/3] dm: add reserved_rq_based_ios module parameter Mike Snitzer
2013-09-13 18:59 ` [PATCH v2 3/3] dm: add reserved_bio_based_ios " Mike Snitzer
2013-09-13 19:22 ` [PATCH v2 0/3] dm: allow mempool and bioset reserves to be tuned Mike Snitzer
2013-09-13 20:30 ` Mike Snitzer
2013-09-13 21:08 ` [PATCH v3 " Mike Snitzer
2013-09-13 21:08 ` [PATCH v3 1/3] dm: lower bio-based mempool reservation Mike Snitzer
2013-09-13 21:08 ` Mike Snitzer [this message]
2013-09-13 21:08 ` [PATCH v3 3/3] dm: add reserved_bio_based_ios module parameter Mike Snitzer
2013-09-18 15:10 ` [PATCH v3 0/3] dm: allow mempool and bioset reserves to be tuned Frank Mayhar
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=1379106494-16366-3-git-send-email-snitzer@redhat.com \
--to=snitzer@redhat.com \
--cc=dm-devel@redhat.com \
--cc=fmayhar@google.com \
--cc=j-nomura@ce.jp.nec.com \
--cc=mpatocka@redhat.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).