Date: Fri, 25 May 2018 23:18:06 +0000 (UTC) From: Sean Bruno <sbruno@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r334229 - stable/11/sys/cam Message-ID: <201805252318.w4PNI6X5054481@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: sbruno Date: Fri May 25 23:18:06 2018 New Revision: 334229 URL: https://svnweb.freebsd.org/changeset/base/334229 Log: MFC r323829 cam iosched: Add a handler for the quanta sysctl to enforce valid values MFC r323831 cam iosched: Schedule cam_iosched_ticker() quanta times per second PR: 221956 221957 Submitted by: imp Approved by: re (marius) Modified: stable/11/sys/cam/cam_iosched.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cam/cam_iosched.c ============================================================================== --- stable/11/sys/cam/cam_iosched.c Fri May 25 21:46:53 2018 (r334228) +++ stable/11/sys/cam/cam_iosched.c Fri May 25 23:18:06 2018 (r334229) @@ -510,7 +510,7 @@ cam_iosched_ticker(void *arg) struct cam_iosched_softc *isc = arg; sbintime_t now, delta; - callout_reset(&isc->ticker, hz / isc->quanta - 1, cam_iosched_ticker, isc); + callout_reset(&isc->ticker, hz / isc->quanta1, cam_iosched_ticker, isc); now = sbinuptime(); delta = now - isc->last_time; @@ -753,7 +753,7 @@ cam_iosched_limiter_sysctl(SYSCTL_HANDLER_ARGS) } } else { if (cantick != 0) { - callout_reset(&isc->ticker, hz / isc->quanta - 1, cam_iosched_ticker, isc); + callout_reset(&isc->ticker, hz / isc->quanta, cam_iosched_ticker, isc); isc->flags |= CAM_IOSCHED_FLAG_CALLOUT_ACTIVE; } } @@ -821,6 +821,27 @@ cam_iosched_sbintime_sysctl(SYSCTL_HANDLER_ARGS) return 0; } +static int +cam_iosched_quanta_sysctl(SYSCTL_HANDLER_ARGS) +{ + int *quanta; + int error, value; + + quanta = (unsigned *)arg1; + value = *quanta; + + error = sysctl_handle_int(oidp, (int *)&value, 0, req); + if ((error != 0) || (req->newptr == NULL)) + return (error); + + if (value < 1 || value > hz) + return (EINVAL); + + *quanta = value; + + return (0); +} + static void cam_iosched_iop_stats_sysctl_init(struct cam_iosched_softc *isc, struct iop_stats *ios, char *name) { @@ -971,7 +992,7 @@ cam_iosched_init(struct cam_iosched_softc **iscp, stru callout_init_mtx(&(*iscp)->ticker, cam_periph_mtx(periph), 0); (*iscp)->periph = periph; cam_iosched_cl_init(&(*iscp)->cl, *iscp); - callout_reset(&(*iscp)->ticker, hz / (*iscp)->quanta - 1, cam_iosched_ticker, *iscp); + callout_reset(&(*iscp)->ticker, hz / (*iscp)->quanta, cam_iosched_ticker, *iscp); (*iscp)->flags |= CAM_IOSCHED_FLAG_CALLOUT_ACTIVE; } #endif @@ -1042,9 +1063,9 @@ void cam_iosched_sysctl_init(struct cam_iosched_softc &isc->read_bias, 100, "How biased towards read should we be independent of limits"); - SYSCTL_ADD_INT(ctx, n, - OID_AUTO, "quanta", CTLFLAG_RW, - &isc->quanta, 200, + SYSCTL_ADD_PROC(ctx, n, + OID_AUTO, "quanta", CTLTYPE_UINT | CTLFLAG_RW, + &isc->quanta, 0, cam_iosched_quanta_sysctl, "I", "How many quanta per second do we slice the I/O up into"); SYSCTL_ADD_INT(ctx, n,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201805252318.w4PNI6X5054481>