Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 22 Sep 2017 02:36:36 +0000 (UTC)
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r323894 - head/sys/cam
Message-ID:  <201709220236.v8M2aaFG081756@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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;
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201709220236.v8M2aaFG081756>