git: ab259b19bd81 - stable/14 - amd64: also limit printings of EFIRT page faults

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Wed, 16 Apr 2025 01:39:08 UTC
The branch stable/14 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=ab259b19bd8105d779ec79a0cc00cf7f1feaf434

commit ab259b19bd8105d779ec79a0cc00cf7f1feaf434
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2025-04-09 07:35:56 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2025-04-16 01:38:33 +0000

    amd64: also limit printings of EFIRT page faults
    
    PR:     285797
    
    (cherry picked from commit 99332926f6fc6d1e4bb850a2b26744b948b14014)
---
 sys/amd64/amd64/trap.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c
index 692491ecfc5a..1877aedee17a 100644
--- a/sys/amd64/amd64/trap.c
+++ b/sys/amd64/amd64/trap.c
@@ -895,8 +895,13 @@ after_vmfault:
 	if (td->td_intr_nesting_level == 0 &&
 	    curpcb->pcb_onfault != NULL) {
 		if ((td->td_pflags2 & TDP2_EFIRT) != 0) {
-			trap_diag(frame, eva);
-			printf("EFI RT page fault\n");
+			u_long cnt = atomic_fetchadd_long(&cnt_efirt_faults, 1);
+
+			if ((print_efirt_faults == 1 && cnt == 1) ||
+			    print_efirt_faults == 2) {
+				trap_diag(frame, eva);
+				printf("EFI RT page fault\n");
+			}
 		}
 		frame->tf_rip = (long)curpcb->pcb_onfault;
 		return (0);