From patchwork Fri Sep 13 20:30:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 2892331 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8FCF39F23C for ; Fri, 13 Sep 2013 20:36:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B6A7020258 for ; Fri, 13 Sep 2013 20:36:26 +0000 (UTC) Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by mail.kernel.org (Postfix) with ESMTP id B3008201CE for ; Fri, 13 Sep 2013 20:36:25 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r8DKUKPv028038; Fri, 13 Sep 2013 16:30:22 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r8DKUJmE029019 for ; Fri, 13 Sep 2013 16:30:19 -0400 Received: from localhost ([10.18.25.216]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r8DKU6tO003460 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Fri, 13 Sep 2013 16:30:17 -0400 Date: Fri, 13 Sep 2013 16:30:06 -0400 From: Mike Snitzer To: Mikulas Patocka Message-ID: <20130913203005.GA8635@redhat.com> References: <1379024698-10487-1-git-send-email-snitzer@redhat.com> <1379098780-15141-1-git-send-email-snitzer@redhat.com> <20130913192220.GA8120@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20130913192220.GA8120@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-loop: dm-devel@redhat.com Cc: "Jun'ichi Nomura" , dm-devel@redhat.com, Frank Mayhar Subject: Re: [dm-devel] [PATCH v2 0/3] dm: allow mempool and bioset reserves to be tuned X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Fri, Sep 13 2013 at 3:22pm -0400, Mike Snitzer wrote: > On Fri, Sep 13 2013 at 2:59pm -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 > > > > 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: Signed-off-by: Frank Mayhar --- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel 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);