From owner-svn-src-head@freebsd.org Fri Sep 22 02:36:37 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B966BE0A981; Fri, 22 Sep 2017 02:36:37 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 81E677537F; Fri, 22 Sep 2017 02:36:37 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v8M2aaXL081757; Fri, 22 Sep 2017 02:36:36 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v8M2aaFG081756; Fri, 22 Sep 2017 02:36:36 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201709220236.v8M2aaFG081756@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Fri, 22 Sep 2017 02:36:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r323894 - head/sys/cam X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: head/sys/cam X-SVN-Commit-Revision: 323894 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Sep 2017 02:36:37 -0000 Author: imp Date: Fri Sep 22 02:36:36 2017 New Revision: 323894 URL: https://svnweb.freebsd.org/changeset/base/323894 Log: cam iosched: Bettar account IOPS for smoother performance Prevent cam_iosched_iops_tick() from discarding 'unspent' ios unless it's a new accounting interval. Previously ios that weren't used between ticks were lost, as a result the iops limiter could enforce a limit below the configured maximum. Obtained from: ElectroBSD Submitted by: Fabian Keil PR: 221974 Modified: head/sys/cam/cam_iosched.c Modified: head/sys/cam/cam_iosched.c ============================================================================== --- head/sys/cam/cam_iosched.c Fri Sep 22 02:36:32 2017 (r323893) +++ head/sys/cam/cam_iosched.c Fri Sep 22 02:36:36 2017 (r323894) @@ -423,19 +423,30 @@ cam_iosched_iops_init(struct iop_stats *ios) static int cam_iosched_iops_tick(struct iop_stats *ios) { + int new_ios; - if ((ios->softc->total_ticks % ios->softc->quanta) == 0) - ios->l_value2 = 0; - - ios->l_value1 = (int)((ios->current * (uint64_t)ios->softc->this_frac) >> 16); /* * Allow at least one IO per tick until all * the IOs for this interval have been spent. */ - if (ios->l_value1 <= 0 && ios->l_value2 < ios->current) { - ios->l_value1 = 1; + new_ios = (int)((ios->current * (uint64_t)ios->softc->this_frac) >> 16); + if (new_ios < 1 && ios->l_value2 < ios->current) { + new_ios = 1; ios->l_value2++; } + + /* + * If this a new accounting interval, discard any "unspent" ios + * granted in the previous interval. Otherwise add the new ios to + * the previously granted ones that haven't been spent yet. + */ + if ((ios->softc->total_ticks % ios->softc->quanta) == 0) { + ios->l_value1 = new_ios; + ios->l_value2 = 1; + } else { + ios->l_value1 += new_ios; + } + return 0; }