FreeBSD Bugzilla – Attachment 185948 Details for
Bug 221957
cam iosched: Add a handler for the quanta sysctl to enforce valid values
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
cam iosched: Add a handler for the quanta sysctl to enforce valid values
0005-cam-iosched-Add-a-handler-for-the-quanta-sysctl-to-en.diff (text/plain), 3.41 KB, created by
Fabian Keil
on 2017-08-31 10:25:08 UTC
(
hide
)
Description:
cam iosched: Add a handler for the quanta sysctl to enforce valid values
Filename:
MIME Type:
Creator:
Fabian Keil
Created:
2017-08-31 10:25:08 UTC
Size:
3.41 KB
patch
obsolete
>From 60038eac35d496b9ff2be31a855dd294d1af8314 Mon Sep 17 00:00:00 2001 >From: Fabian Keil <fk@fabiankeil.de> >Date: Thu, 3 Aug 2017 12:53:12 +0200 >Subject: [PATCH 5/8] cam iosched: Add a handler for the quanta sysctl to > enforce valid values > >Invalid values can result in devision-by-zero panics and other >undesirable behaviour. > >Example panic: > > Fatal trap 18: integer divide fault while in kernel mode > cpuid = 0; apic id = 00 > instruction pointer = 0x20:0xffffffff802998e5 > stack pointer = 0x28:0xfffffe01ea3bf8d0 > frame pointer = 0x28:0xfffffe01ea3bf900 > code segment = base 0x0, limit 0xfffff, type 0x1b > = DPL 0, pres 1, long 1, def32 0, gran 1 > processor eflags = interrupt enabled, resume, IOPL = 0 > current process = 12 (swi4: clock (0)) > trap number = 18 > panic: integer divide fault > cpuid = 0 > KDB: stack backtrace: > db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe01ea3bf510 > vpanic() at vpanic+0x186/frame 0xfffffe01ea3bf590 > panic() at panic+0x43/frame 0xfffffe01ea3bf5f0 > trap_fatal() at trap_fatal+0x322/frame 0xfffffe01ea3bf640 > trap() at trap+0x5e/frame 0xfffffe01ea3bf800 > calltrap() at calltrap+0x8/frame 0xfffffe01ea3bf800 > --- trap 0x12, rip = 0xffffffff802998e5, rsp = 0xfffffe01ea3bf8d0, rbp = 0xfffffe01ea3bf900 --- > cam_iosched_ticker() at cam_iosched_ticker+0x25/frame 0xfffffe01ea3bf900 > softclock_call_cc() at softclock_call_cc+0x13e/frame 0xfffffe01ea3bf9b0 > softclock() at softclock+0xb9/frame 0xfffffe01ea3bf9e0 > intr_event_execute_handlers() at intr_event_execute_handlers+0xec/frame 0xfffffe01ea3bfa20 > ithread_loop() at ithread_loop+0xd6/frame 0xfffffe01ea3bfa70 > fork_exit() at fork_exit+0x85/frame 0xfffffe01ea3bfab0 > fork_trampoline() at fork_trampoline+0xe/frame 0xfffffe01ea3bfab0 > --- trap 0, rip = 0, rsp = 0, rbp = 0 --- > Uptime: 2h29m20s > Dumping 1165 out of 8055 MB:..2%..11%..21%..31%..42%..51%..61%..71%..81%..91% > >Obtained from: ElectroBSD >--- > sys/cam/cam_iosched.c | 28 +++++++++++++++++++++++++--- > 1 file changed, 25 insertions(+), 3 deletions(-) > >diff --git a/sys/cam/cam_iosched.c b/sys/cam/cam_iosched.c >index f2e69d9fd84c..7f04db03352e 100644 >--- a/sys/cam/cam_iosched.c >+++ b/sys/cam/cam_iosched.c >@@ -880,6 +880,28 @@ cam_iosched_sysctl_latencies(SYSCTL_HANDLER_ARGS) > return (error); > } > >+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) { >+ printf("cam iosched: Quanta has to be above 0 and below %d (kern.hz).\n", 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) > { >@@ -1101,9 +1123,9 @@ void cam_iosched_sysctl_init(struct cam_iosched_softc *isc, > &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, >-- >2.14.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 221957
: 185948