MCPcopy Create free account
hub / github.com/F-Stack/f-stack / update_threshold

Function update_threshold

freebsd/x86/x86/mca.c:642–691  ·  view source on GitHub ↗

* Update the interrupt threshold for a CMCI. The strategy is to use * a low trigger that interrupts as soon as the first event occurs. * However, if a steady stream of events arrive, the threshold is * increased until the interrupts are throttled to once every * cmc_throttle seconds or the periodic scan. If a periodic scan * finds that the threshold is too high, it is lowered. */

Source from the content-addressed store, hash-verified

640 * finds that the threshold is too high, it is lowered.
641 */
642static int
643update_threshold(enum scan_mode mode, int valid, int last_intr, int count,
644 int cur_threshold, int max_threshold)
645{
646 u_int delta;
647 int limit;
648
649 delta = (u_int)(time_uptime - last_intr);
650 limit = cur_threshold;
651
652 /*
653 * If an interrupt was received less than cmc_throttle seconds
654 * since the previous interrupt and the count from the current
655 * event is greater than or equal to the current threshold,
656 * double the threshold up to the max.
657 */
658 if (mode == CMCI && valid) {
659 if (delta < cmc_throttle && count >= limit &&
660 limit < max_threshold) {
661 limit = min(limit << 1, max_threshold);
662 }
663 return (limit);
664 }
665
666 /*
667 * When the banks are polled, check to see if the threshold
668 * should be lowered.
669 */
670 if (mode != POLLED)
671 return (limit);
672
673 /* If a CMCI occured recently, do nothing for now. */
674 if (delta < cmc_throttle)
675 return (limit);
676
677 /*
678 * Compute a new limit based on the average rate of events per
679 * cmc_throttle seconds since the last interrupt.
680 */
681 if (valid) {
682 limit = count * cmc_throttle / delta;
683 if (limit <= 0)
684 limit = 1;
685 else if (limit > max_threshold)
686 limit = max_threshold;
687 } else {
688 limit = 1;
689 }
690 return (limit);
691}
692
693static void
694cmci_update(enum scan_mode mode, int bank, int valid, struct mca_record *rec)

Callers 2

cmci_updateFunction · 0.85
amd_thresholding_updateFunction · 0.85

Calls 1

minFunction · 0.85

Tested by

no test coverage detected