Date: Wed, 11 Aug 2021 00:07:24 GMT From: Alexander Motin <mav@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 303477d32530 - main - cam(4): Mark all sysctls as CTLFLAG_MPSAFE. Message-ID: <202108110007.17B07OJb033982@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=303477d3253007bb5732deed2daea86b2cbd9aa8 commit 303477d3253007bb5732deed2daea86b2cbd9aa8 Author: Alexander Motin <mav@FreeBSD.org> AuthorDate: 2021-08-11 00:05:40 +0000 Commit: Alexander Motin <mav@FreeBSD.org> CommitDate: 2021-08-11 00:07:19 +0000 cam(4): Mark all sysctls as CTLFLAG_MPSAFE. This code does not use Giant lock for very long time. MFC after: 2 weeks --- sys/cam/ata/ata_da.c | 6 +++--- sys/cam/cam_iosched.c | 14 +++++++------- sys/cam/ctl/ctl.c | 2 +- sys/cam/ctl/ctl_ha.c | 2 +- sys/cam/scsi/scsi_all.c | 2 +- sys/cam/scsi/scsi_cd.c | 2 +- sys/cam/scsi/scsi_da.c | 12 ++++++------ sys/cam/scsi/scsi_xpt.c | 24 ++---------------------- 8 files changed, 22 insertions(+), 42 deletions(-) diff --git a/sys/cam/ata/ata_da.c b/sys/cam/ata/ata_da.c index 7063a40fcc3c..72bbbfe8ab1f 100644 --- a/sys/cam/ata/ata_da.c +++ b/sys/cam/ata/ata_da.c @@ -1494,7 +1494,7 @@ adasysctlinit(void *context, int pending) SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "delete_method", - CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE, softc, 0, adadeletemethodsysctl, "A", "BIO_DELETE execution method"); SYSCTL_ADD_UQUAD(&softc->sysctl_ctx, @@ -1517,12 +1517,12 @@ adasysctlinit(void *context, int pending) &softc->write_cache, 0, "Enable disk write cache."); SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "zone_mode", - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, softc, 0, adazonemodesysctl, "A", "Zone Mode"); SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "zone_support", - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, softc, 0, adazonesupsysctl, "A", "Zone Support"); SYSCTL_ADD_UQUAD(&softc->sysctl_ctx, diff --git a/sys/cam/cam_iosched.c b/sys/cam/cam_iosched.c index b293002fb2ca..98ae98bc1d80 100644 --- a/sys/cam/cam_iosched.c +++ b/sys/cam/cam_iosched.c @@ -1009,7 +1009,7 @@ cam_iosched_iop_stats_sysctl_init(struct cam_iosched_softc *isc, struct iop_stat SYSCTL_ADD_PROC(ctx, n, OID_AUTO, "limiter", - CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE, ios, 0, cam_iosched_limiter_sysctl, "A", "Current limiting type."); SYSCTL_ADD_INT(ctx, n, @@ -1027,7 +1027,7 @@ cam_iosched_iop_stats_sysctl_init(struct cam_iosched_softc *isc, struct iop_stat SYSCTL_ADD_PROC(ctx, n, OID_AUTO, "latencies", - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, &ios->latencies, 0, cam_iosched_sysctl_latencies, "A", "Array of power of 2 latency from 1ms to 1.024s"); @@ -1057,22 +1057,22 @@ cam_iosched_cl_sysctl_init(struct cam_iosched_softc *isc) SYSCTL_ADD_PROC(ctx, n, OID_AUTO, "type", - CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE, clp, 0, cam_iosched_control_type_sysctl, "A", "Control loop algorithm"); SYSCTL_ADD_PROC(ctx, n, OID_AUTO, "steer_interval", - CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE, &clp->steer_interval, 0, cam_iosched_sbintime_sysctl, "A", "How often to steer (in us)"); SYSCTL_ADD_PROC(ctx, n, OID_AUTO, "lolat", - CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE, &clp->lolat, 0, cam_iosched_sbintime_sysctl, "A", "Low water mark for Latency (in us)"); SYSCTL_ADD_PROC(ctx, n, OID_AUTO, "hilat", - CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE, &clp->hilat, 0, cam_iosched_sbintime_sysctl, "A", "Hi water mark for Latency (in us)"); SYSCTL_ADD_INT(ctx, n, @@ -1200,7 +1200,7 @@ void cam_iosched_sysctl_init(struct cam_iosched_softc *isc, "How biased towards read should we be independent of limits"); SYSCTL_ADD_PROC(ctx, n, - OID_AUTO, "quanta", CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + OID_AUTO, "quanta", CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_MPSAFE, &isc->quanta, 0, cam_iosched_quanta_sysctl, "I", "How many quanta per second do we slice the I/O up into"); diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c index 575c8eea5198..8ad8bcec434b 100644 --- a/sys/cam/ctl/ctl.c +++ b/sys/cam/ctl/ctl.c @@ -1978,7 +1978,7 @@ ctl_init(void) SYSCTL_ADD_PROC(&softc->sysctl_ctx,SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "ha_role", - CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_NEEDGIANT, + CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0, ctl_ha_role_sysctl, "I", "HA role for this head"); if (softc->is_single == 0) { diff --git a/sys/cam/ctl/ctl_ha.c b/sys/cam/ctl/ctl_ha.c index 80dfc543303d..e2ecb9706f56 100644 --- a/sys/cam/ctl/ctl_ha.c +++ b/sys/cam/ctl/ctl_ha.c @@ -896,7 +896,7 @@ ctl_ha_msg_init(struct ctl_softc *ctl_softc) SYSCTL_ADD_PROC(&ctl_softc->sysctl_ctx, SYSCTL_CHILDREN(ctl_softc->sysctl_tree), OID_AUTO, "ha_peer", - CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0, ctl_ha_peer_sysctl, "A", "HA peer connection method"); if (ctl_ha_msg_register(CTL_HA_CHAN_DATA, ctl_dt_event_handler) diff --git a/sys/cam/scsi/scsi_all.c b/sys/cam/scsi/scsi_all.c index 1b60003a4ac7..5a50d5bb134b 100644 --- a/sys/cam/scsi/scsi_all.c +++ b/sys/cam/scsi/scsi_all.c @@ -9236,7 +9236,7 @@ sysctl_scsi_delay(SYSCTL_HANDLER_ARGS) return (set_scsi_delay(delay)); } SYSCTL_PROC(_kern_cam, OID_AUTO, scsi_delay, - CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, 0, 0, sysctl_scsi_delay, "I", + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 0, sysctl_scsi_delay, "I", "Delay to allow devices to settle after a SCSI bus reset (ms)"); static int diff --git a/sys/cam/scsi/scsi_cd.c b/sys/cam/scsi/scsi_cd.c index e790b0c89d02..4babe4003050 100644 --- a/sys/cam/scsi/scsi_cd.c +++ b/sys/cam/scsi/scsi_cd.c @@ -538,7 +538,7 @@ cdsysctlinit(void *context, int pending) */ SYSCTL_ADD_PROC(&softc->sysctl_ctx,SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "minimum_cmd_size", - CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, &softc->minimum_command_size, 0, cdcmdsizesysctl, "I", "Minimum CDB size"); diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c index 676bf33d0bf8..40978d68cebf 100644 --- a/sys/cam/scsi/scsi_da.c +++ b/sys/cam/scsi/scsi_da.c @@ -1579,7 +1579,7 @@ SYSCTL_INT(_kern_cam_da, OID_AUTO, enable_uma_ccbs, CTLFLAG_RWTUN, &da_enable_uma_ccbs, 0, "Use UMA for CCBs"); SYSCTL_PROC(_kern_cam_da, OID_AUTO, default_softtimeout, - CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, NULL, 0, + CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_MPSAFE, NULL, 0, dasysctlsofttimeout, "I", "Soft I/O timeout (ms)"); TUNABLE_INT64("kern.cam.da.default_softtimeout", &da_default_softtimeout); @@ -2280,17 +2280,17 @@ dasysctlinit(void *context, int pending) */ SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "delete_method", - CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0, dadeletemethodsysctl, "A", "BIO_DELETE execution method"); SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "delete_max", - CTLTYPE_U64 | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + CTLTYPE_U64 | CTLFLAG_RW | CTLFLAG_MPSAFE, softc, 0, dadeletemaxsysctl, "Q", "Maximum BIO_DELETE size"); SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "minimum_cmd_size", - CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, &softc->minimum_cmd_size, 0, dacmdsizesysctl, "I", "Minimum CDB size"); SYSCTL_ADD_UQUAD(&softc->sysctl_ctx, @@ -2308,12 +2308,12 @@ dasysctlinit(void *context, int pending) SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "zone_mode", - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, softc, 0, dazonemodesysctl, "A", "Zone Mode"); SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "zone_support", - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, softc, 0, dazonesupsysctl, "A", "Zone Support"); SYSCTL_ADD_UQUAD(&softc->sysctl_ctx, diff --git a/sys/cam/scsi/scsi_xpt.c b/sys/cam/scsi/scsi_xpt.c index 6b77d50b25c3..46cc4c1699f1 100644 --- a/sys/cam/scsi/scsi_xpt.c +++ b/sys/cam/scsi/scsi_xpt.c @@ -79,11 +79,8 @@ struct scsi_quirk_entry { #define SCSI_QUIRK(dev) ((struct scsi_quirk_entry *)((dev)->quirk)) static int cam_srch_hi = 0; -static int sysctl_cam_search_luns(SYSCTL_HANDLER_ARGS); -SYSCTL_PROC(_kern_cam, OID_AUTO, cam_srch_hi, - CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_NEEDGIANT, 0, 0, - sysctl_cam_search_luns, "I", - "allow search above LUN 7 for SCSI3 and greater devices"); +SYSCTL_INT(_kern_cam, OID_AUTO, cam_srch_hi, CTLFLAG_RWTUN, + &cam_srch_hi, 0, "Search above LUN 7 for SCSI3 and greater devices"); #define CAM_SCSI2_MAXLUN 8 #define CAM_CAN_GET_SIMPLE_LUN(x, i) \ @@ -1899,23 +1896,6 @@ scsi_find_quirk(struct cam_ed *device) device->maxtags = quirk->maxtags; } -static int -sysctl_cam_search_luns(SYSCTL_HANDLER_ARGS) -{ - int error, val; - - val = cam_srch_hi; - error = sysctl_handle_int(oidp, &val, 0, req); - if (error != 0 || req->newptr == NULL) - return (error); - if (val == 0 || val == 1) { - cam_srch_hi = val; - return (0); - } else { - return (EINVAL); - } -} - typedef struct { union ccb *request_ccb; struct ccb_pathinq *cpi;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202108110007.17B07OJb033982>