diff mbox

[v2,0/3] dm: allow mempool and bioset reserves to be tuned

Message ID 20130913203005.GA8635@redhat.com (mailing list archive)
State Superseded, archived
Delegated to: Mike Snitzer
Headers show

Commit Message

Mike Snitzer Sept. 13, 2013, 8:30 p.m. UTC
On Fri, Sep 13 2013 at  3:22pm -0400,
Mike Snitzer <snitzer@redhat.com> wrote:

> On Fri, Sep 13 2013 at  2:59pm -0400,
> Mike Snitzer <snitzer@redhat.com> wrote:
> 
> > You can pull these changes from the 'devel' branch of:
> > git://git.kernel.org/pub/scm/linux/kernel/git/snitzer/linux.git
> > 
> > To browse, see:
> > https://git.kernel.org/cgit/linux/kernel/git/snitzer/linux.git/log/?h=devel
> > 
> > v2 changes:
> > Simplified the implementation.  Dropped the peak_reserved_rq_based_ios
> > tracking, we'll use the tracepoint patch Jun'ichi Nomura suggested:
> > http://www.redhat.com/archives/dm-devel/2013-September/msg00048.html
> 
> This needs a v3 because the simplified code doesn't handle bounds
> properly (previous version handled remapping 0 to defaults).  But we
> also need a maximum value that we're willing to support.  So if the user
> exceeds that value it is reset to the max supported.

Here is an incremental diff:


--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel

Comments

Mike Snitzer Sept. 13, 2013, 9:08 p.m. UTC | #1
You can pull these changes from the 'devel' branch of:
git://git.kernel.org/pub/scm/linux/kernel/git/snitzer/linux.git

To browse, see:
https://git.kernel.org/cgit/linux/kernel/git/snitzer/linux.git/log/?h=devel

v3 changes:
Added bounds checking (if 0 reset to default, if > 1024 reset to 1024)

v2 changes:
Simplified the implementation.  Dropped the peak_reserved_rq_based_ios
tracking, we'll use the tracepoint patch Jun'ichi Nomura suggested:
http://www.redhat.com/archives/dm-devel/2013-September/msg00048.html

Mike Snitzer (3):
  dm: lower bio-based mempool reservation
  dm: add reserved_rq_based_ios module parameter
  dm: add reserved_bio_based_ios module parameter

 drivers/md/dm-io.c    |    7 ++---
 drivers/md/dm-mpath.c |    6 ++--
 drivers/md/dm.c       |   60 +++++++++++++++++++++++++++++++++++++++++++++---
 drivers/md/dm.h       |    3 ++
 4 files changed, 65 insertions(+), 11 deletions(-)

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
Frank Mayhar Sept. 18, 2013, 3:10 p.m. UTC | #2
On Fri, 2013-09-13 at 17:08 -0400, Mike Snitzer wrote:
> You can pull these changes from the 'devel' branch of:
> git://git.kernel.org/pub/scm/linux/kernel/git/snitzer/linux.git
> 
> To browse, see:
> https://git.kernel.org/cgit/linux/kernel/git/snitzer/linux.git/log/?h=devel
> 
> v3 changes:
> Added bounds checking (if 0 reset to default, if > 1024 reset to 1024)
> 
> v2 changes:
> Simplified the implementation.  Dropped the peak_reserved_rq_based_ios
> tracking, we'll use the tracepoint patch Jun'ichi Nomura suggested:
> http://www.redhat.com/archives/dm-devel/2013-September/msg00048.html

Very nice, thanks for doing this.  It also makes these parameters a lot
more clear about what they're for, which is a feature.  "MIN_IOS" was
kind of opaque without actually digging into the code.

Feel free to add

Signed-off-by: Frank Mayhar <fmayhar@google.com>

if you care to.
diff mbox

Patch

diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index a617fe3..033dc26 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -213,6 +213,7 @@  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;
 
@@ -226,15 +227,36 @@  static unsigned reserved_bio_based_ios = RESERVED_BIO_BASED_IOS;
  */
 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_bio_based_ios(void)
 {
-	return ACCESS_ONCE(reserved_bio_based_ios);
+	return __dm_get_reserved_ios(&reserved_bio_based_ios,
+				     RESERVED_BIO_BASED_IOS, RESERVED_MAX_IOS);
 }
 EXPORT_SYMBOL_GPL(dm_get_reserved_bio_based_ios);
 
 unsigned dm_get_reserved_rq_based_ios(void)
 {
-	return ACCESS_ONCE(reserved_rq_based_ios);
+	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);