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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Sep 13 2013 at  3:22pm -0400,
Mike Snitzer <snitzer@xxxxxxxxxx> wrote:

> On Fri, Sep 13 2013 at  2:59pm -0400,
> Mike Snitzer <snitzer@xxxxxxxxxx> 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:

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);
 

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




[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux