Lines Matching +full:user +full:- +full:selected
1 /*-
2 * SPDX-License-Identifier: BSD-3-Clause
182 &numdevsize, NULL, 0) == -1) { in devstat_getnumdevs()
187 return(-1); in devstat_getnumdevs()
192 if (KREADNL(kd, X_NUMDEVS, numdevs) == -1) in devstat_getnumdevs()
193 return(-1); in devstat_getnumdevs()
219 &gensize, NULL, 0) == -1) { in devstat_getgeneration()
223 return(-1); in devstat_getgeneration()
227 if (KREADNL(kd, X_GENERATION, generation) == -1) in devstat_getgeneration()
228 return(-1); in devstat_getgeneration()
253 NULL, 0) == -1) { in devstat_getversion()
257 return(-1); in devstat_getversion()
261 if (KREADNL(kd, X_VERSION, version) == -1) in devstat_getversion()
262 return(-1); in devstat_getversion()
271 * devstat error buffer, and return -1. If they match, return 0.
282 * If getversion() returns an error (i.e. -1), then it in devstat_checkversion()
287 if (version == -1) in devstat_checkversion()
293 DEVSTAT_ERRBUF_SIZE - buflen, in devstat_checkversion()
296 "version %d\n", version == -1 ? "\n" : "", in devstat_checkversion()
305 DEVSTAT_ERRBUF_SIZE - buflen, in devstat_checkversion()
310 DEVSTAT_ERRBUF_SIZE - buflen, in devstat_checkversion()
317 retval = -1; in devstat_checkversion()
328 * -1 -- error
329 * 0 -- device list is unchanged
330 * 1 -- device list has changed
342 dinfo = stats->dinfo; in devstat_getdevs()
346 "%s: stats->dinfo was NULL", __func__); in devstat_getdevs()
347 return(-1); in devstat_getdevs()
350 oldgeneration = dinfo->generation; in devstat_getdevs()
354 stats->snap_time = ts.tv_sec + ts.tv_nsec * 1e-9; in devstat_getdevs()
357 if (dinfo->mem_ptr == NULL) { in devstat_getdevs()
363 if ((dinfo->numdevs = devstat_getnumdevs(kd)) < 0) in devstat_getdevs()
364 return(-1); in devstat_getdevs()
371 dssize = (dinfo->numdevs * sizeof(struct devstat)) + in devstat_getdevs()
373 dinfo->mem_ptr = (u_int8_t *)malloc(dssize); in devstat_getdevs()
374 if (dinfo->mem_ptr == NULL) { in devstat_getdevs()
378 return(-1); in devstat_getdevs()
381 dssize = (dinfo->numdevs * sizeof(struct devstat)) + in devstat_getdevs()
390 * the user can just wait until all devices are added. in devstat_getdevs()
394 dinfo->mem_ptr, in devstat_getdevs()
396 if (error != -1 || errno != EBUSY) in devstat_getdevs()
399 if (error == -1) { in devstat_getdevs()
410 if ((dinfo->numdevs = devstat_getnumdevs(kd)) < 0) in devstat_getdevs()
411 return(-1); in devstat_getdevs()
413 dssize = (dinfo->numdevs * in devstat_getdevs()
415 dinfo->mem_ptr = (u_int8_t *) in devstat_getdevs()
416 realloc(dinfo->mem_ptr, dssize); in devstat_getdevs()
418 dinfo->mem_ptr, &dssize, NULL, 0)) == -1) { in devstat_getdevs()
424 return(-1); in devstat_getdevs()
431 return(-1); in devstat_getdevs()
436 if (KREADNL(kd, X_TIME_UPTIME, ts.tv_sec) == -1) in devstat_getdevs()
437 return(-1); in devstat_getdevs()
439 stats->snap_time = ts.tv_sec; in devstat_getdevs()
442 * This is of course non-atomic, but since we are working in devstat_getdevs()
445 if ((dinfo->numdevs = devstat_getnumdevs(kd)) == -1) in devstat_getdevs()
446 return(-1); in devstat_getdevs()
447 if ((dinfo->mem_ptr = (u_int8_t *)get_devstat_kvm(kd)) == NULL) in devstat_getdevs()
448 return(-1); in devstat_getdevs()
454 dinfo->generation = *(long *)dinfo->mem_ptr; in devstat_getdevs()
471 if (oldgeneration != dinfo->generation) { in devstat_getdevs()
472 if (devstat_getnumdevs(kd) != dinfo->numdevs) { in devstat_getdevs()
473 if ((dinfo->numdevs = devstat_getnumdevs(kd)) < 0) in devstat_getdevs()
474 return(-1); in devstat_getdevs()
475 dssize = (dinfo->numdevs * sizeof(struct devstat)) + in devstat_getdevs()
477 dinfo->mem_ptr = (u_int8_t *)realloc(dinfo->mem_ptr, in devstat_getdevs()
483 dinfo->devices = (struct devstat *)(dinfo->mem_ptr + sizeof(long)); in devstat_getdevs()
491 * Devices are selected/deselected based upon the following criteria:
492 * - devices specified by the user on the command line
493 * - devices matching any device type expressions given on the command line
494 * - devices with the highest I/O, if 'top' mode is enabled
495 * - the first n unselected devices in the device list, if maxshowdevs
496 * devices haven't already been selected and if the user has not
500 * - device selection list (dev_select)
501 * - current number of devices selected (num_selected)
502 * - total number of devices in the selection list (num_selections)
503 * - devstat generation as of the last time selectdevs() was called
505 * - current devstat generation (current_generation)
506 * - current list of devices and statistics (devices)
507 * - number of devices in the current device list (numdevs)
508 * - compiled version of the command line device type arguments (matches)
509 * - This is optional. If the number of devices is 0, this will be ignored.
510 * - The matching code pays attention to the current selection mode. So
513 * - number of device type matching expressions (num_matches)
514 * - Set to 0 to disable the matching code.
515 * - list of devices specified on the command line by the user (dev_selections)
516 * - number of devices selected on the command line by the user
518 * - Our selection mode. There are four different selection modes:
519 * - add mode. (DS_SELECT_ADD) Any devices matching devices explicitly
520 * selected by the user or devices matching a pattern given by the
521 * user will be selected in addition to devices that are already
522 * selected. Additional devices will be selected, up to maxshowdevs
524 * - only mode. (DS_SELECT_ONLY) Only devices matching devices
525 * explicitly given by the user or devices matching a pattern
526 * given by the user will be selected. No other devices will be
527 * selected.
528 * - addonly mode. (DS_SELECT_ADDONLY) This is similar to add and
529 * only. Basically, this will not de-select any devices that are
530 * current selected, as only mode would, but it will also not
532 * - remove mode. (DS_SELECT_REMOVE) Any devices matching devices
533 * explicitly selected by the user or devices matching a pattern
534 * given by the user will be de-selected.
535 * - maximum number of devices we can select (maxshowdevs)
536 * - flag indicating whether or not we're in 'top' mode (perf_select)
539 * - the device selection list may be modified and passed back out
540 * - the number of devices selected and the total number of items in the
542 * - the selection generation may be changed to match the current generation
545 * -1 -- error
546 * 0 -- selected devices are unchanged
547 * 1 -- selected devices changed
566 return(-1); in devstat_selectdevs()
573 * In this case, we haven't selected devices before. in devstat_selectdevs()
582 * In this case, we have selected devices before, but the device in devstat_selectdevs()
583 * list has changed since we last selected devices, so we need to in devstat_selectdevs()
592 * In this case, we've selected devices before, and the selection in devstat_selectdevs()
605 return(-1); in devstat_selectdevs()
609 * If we're in "only" mode, we want to clear out the selected in devstat_selectdevs()
610 * variable since we're going to select exactly what the user wants in devstat_selectdevs()
617 * In all cases, we want to back up the number of selected devices. in devstat_selectdevs()
618 * It is a quick and accurate way to determine whether the selected in devstat_selectdevs()
639 return(-1); in devstat_selectdevs()
660 (*dev_select)[i].device_name[DEVSTAT_NAME_LEN - 1]='\0'; in devstat_selectdevs()
667 (*dev_select)[i].selected = 0; in devstat_selectdevs()
676 * Look through any devices the user specified on the command line in devstat_selectdevs()
691 * if it hasn't already been selected. in devstat_selectdevs()
699 * ones to be selected. If we're in remove in devstat_selectdevs()
700 * mode, we de-select the specified device and in devstat_selectdevs()
706 if ((*dev_select)[i].selected) in devstat_selectdevs()
710 (*dev_select)[i].selected = in devstat_selectdevs()
715 (*dev_select)[i].selected = 0; in devstat_selectdevs()
716 (*num_selected)--; in devstat_selectdevs()
722 num_dev_selections--; in devstat_selectdevs()
731 * Go through the user's device type expressions and select devices in devstat_selectdevs()
733 * selected is less than the maximum number we can show. in devstat_selectdevs()
750 * - the device type check in devstat_selectdevs()
751 * - the device interface check in devstat_selectdevs()
752 * - the passthrough check in devstat_selectdevs()
767 && (--num_match_categories == 0)) in devstat_selectdevs()
776 && (--num_match_categories == 0)) in devstat_selectdevs()
779 && (--num_match_categories == 0))) { in devstat_selectdevs()
782 * This is probably a non-optimal solution in devstat_selectdevs()
813 * if it hasn't already been selected. If in devstat_selectdevs()
814 * it has already been selected, we leave in devstat_selectdevs()
817 * devices have already been selected, and in devstat_selectdevs()
820 * mode, we de-select the given device and in devstat_selectdevs()
821 * decrement the selected count. in devstat_selectdevs()
827 if ((*dev_select)[k].selected != 0) in devstat_selectdevs()
829 (*dev_select)[k].selected = in devstat_selectdevs()
834 (*dev_select)[k].selected = 0; in devstat_selectdevs()
835 (*num_selected)--; in devstat_selectdevs()
845 * selected (not selection number, just the fact that they are in devstat_selectdevs()
846 * selected!) and the number of bytes in the "bytes" field of the in devstat_selectdevs()
848 * by the user. In the future, it may be maintained by library in devstat_selectdevs()
849 * functions, but for now the user has to do the work. in devstat_selectdevs()
852 * select every device in the case where the user hasn't specified in devstat_selectdevs()
855 * when we're in "add" or "only" mode, and the user hasn't in devstat_selectdevs()
857 * selected, so the only criterion used to sort them will be their in devstat_selectdevs()
859 * all devices will be selected, so again selection won't matter. in devstat_selectdevs()
871 * isn't already selected. Because the 'selected' in devstat_selectdevs()
874 * the devices that were selected first. in devstat_selectdevs()
877 if ((*dev_select)[i].selected == 0) { in devstat_selectdevs()
878 (*dev_select)[i].selected = in devstat_selectdevs()
886 if ((*dev_select)[i].selected != 0) { in devstat_selectdevs()
887 (*dev_select)[i].selected = in devstat_selectdevs()
896 * selected maxshowdevs number of devices, go through the array and in devstat_selectdevs()
898 * obviously don't want to select anything other than what the user in devstat_selectdevs()
901 * end up selecting something that the user wants removed. Through in devstat_selectdevs()
908 if ((*dev_select)[i].selected == 0) { in devstat_selectdevs()
909 (*dev_select)[i].selected = ++selection_number; in devstat_selectdevs()
915 * Look at the number of devices that have been selected. If it in devstat_selectdevs()
918 * selection list to see if the selected devices have changed. in devstat_selectdevs()
937 && ((*dev_select)[i].selected == in devstat_selectdevs()
938 old_dev_select[i].selected)) in devstat_selectdevs()
977 && ((*dev_select)[i].selected == in devstat_selectdevs()
978 old_dev_select[j].selected)){ in devstat_selectdevs()
999 * backwards -- generally, it should return a value to indicate whether
1004 * has been selected. If one of them has, and the other one has not, the
1005 * selected device is automatically more important than the unselected
1006 * device. If neither device is selected, we judge the devices based upon
1012 if ((((const struct device_selection *)arg1)->selected) in compare_select()
1013 && (((const struct device_selection *)arg2)->selected == 0)) in compare_select()
1014 return(-1); in compare_select()
1015 else if ((((const struct device_selection *)arg1)->selected == 0) in compare_select()
1016 && (((const struct device_selection *)arg2)->selected)) in compare_select()
1018 else if (((const struct device_selection *)arg2)->bytes < in compare_select()
1019 ((const struct device_selection *)arg1)->bytes) in compare_select()
1020 return(-1); in compare_select()
1021 else if (((const struct device_selection *)arg2)->bytes > in compare_select()
1022 ((const struct device_selection *)arg1)->bytes) in compare_select()
1045 return(-1); in devstat_buildmatch()
1059 /* The user gave us too many type arguments */ in devstat_buildmatch()
1063 return(-1); in devstat_buildmatch()
1075 return(-1); in devstat_buildmatch()
1082 * Step through the arguments the user gave us and build a device in devstat_buildmatch()
1098 tempstr3 = &tempstr2[strlen(tempstr2) - 1]; in devstat_buildmatch()
1103 tempstr3--; in devstat_buildmatch()
1107 * Go through the match table comparing the user's in devstat_buildmatch()
1112 * We do case-insensitive matching, in case someone in devstat_buildmatch()
1117 * a super-long match expression. in devstat_buildmatch()
1122 * Make sure the user hasn't specified two in devstat_buildmatch()
1133 return(-1); in devstat_buildmatch()
1150 * not, that means the user entered an invalid device type in devstat_buildmatch()
1157 return(-1); in devstat_buildmatch()
1172 * 0 -- success
1173 * -1 -- failure
1205 #define BINTIME_SCALE 5.42101086242752217003726400434970855712890625e-20
1212 etime = cur_time->sec; in devstat_compute_etime()
1213 etime += cur_time->frac * BINTIME_SCALE; in devstat_compute_etime()
1215 etime -= prev_time->sec; in devstat_compute_etime()
1216 etime -= prev_time->frac * BINTIME_SCALE; in devstat_compute_etime()
1222 (current->field[(index)] - (previous ? previous->field[(index)] : 0))
1225 devstat_compute_etime(¤t->field, \
1226 (previous ? &previous->field : NULL))
1252 return(-1); in devstat_compute_statistics()
1272 if (current->block_size > 0) { in devstat_compute_statistics()
1273 totalblocks /= current->block_size; in devstat_compute_statistics()
1274 totalblocksread /= current->block_size; in devstat_compute_statistics()
1275 totalblockswrite /= current->block_size; in devstat_compute_statistics()
1276 totalblocksfree /= current->block_size; in devstat_compute_statistics()
1302 retval = -1; in devstat_compute_statistics()
1317 retval = -1; in devstat_compute_statistics()
1547 *destu64 = current->start_count - current->end_count; in devstat_compute_statistics()
1579 retval = -1; in devstat_compute_statistics()
1596 if (kvm_read(kd, addr, buf, nbytes) == -1) { in readkmem()
1600 return(-1); in readkmem()
1613 if (kvm_nlist(kd, nl) == -1) { in readkmem_nl()
1617 return(-1); in readkmem_nl()
1639 if (KREADNL(kd, X_DEVICE_STATQ, dhead) == -1) in get_devstat_kvm()
1658 if (readkmem(kd, (long)nds, &ds, sizeof(ds)) == -1) { in get_devstat_kvm()