[lustre-devel] [PATCH 35/50] lnet: libcfs: Use FAIL_CHECK_QUIET for fake i/o

James Simmons jsimmons at infradead.org
Sun Mar 20 06:30:49 PDT 2022


From: Patrick Farrell <pfarrell at whamcloud.com>

Logging to the console is relatively expensive and doing it
for fake i/o is very expensive in terms of CPU time.

If we use FAIL_CHECK_QUIET, a debug message is logged only once
to the console, and the rest at D_INFO level (probably not at all).

This should hugely reduce the CPU cost of the debugging.

WC-bug-id: https://jira.whamcloud.com/browse/LU-14935
Lustre-commit: 890466a32d3e8683a ("LU-14935 tests: Use FAIL_CHECK_QUIET for fake i/o")
Signed-off-by: Patrick Farrell <pfarrell at whamcloud.com>
Reviewed-on: https://review.whamcloud.com/44651
Reviewed-by: Andreas Dilger <adilger at whamcloud.com>
Reviewed-by: Etienne AUJAMES <eaujames at ddn.com>
Signed-off-by: James Simmons <jsimmons at infradead.org>
---
 fs/lustre/include/obd_support.h    | 1 +
 include/linux/libcfs/libcfs_fail.h | 6 +++---
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/fs/lustre/include/obd_support.h b/fs/lustre/include/obd_support.h
index d57c25c..0732fe9a 100644
--- a/fs/lustre/include/obd_support.h
+++ b/fs/lustre/include/obd_support.h
@@ -524,6 +524,7 @@
 /* Assign references to moved code to reduce code changes */
 #define OBD_FAIL_PRECHECK(id)			CFS_FAIL_PRECHECK(id)
 #define OBD_FAIL_CHECK(id)			CFS_FAIL_CHECK(id)
+#define OBD_FILE_CHECK_QUIET(id)		CFS_FILE_CHECK_QUIET(id)
 #define OBD_FAIL_CHECK_VALUE(id, value)		CFS_FAIL_CHECK_VALUE(id, value)
 #define OBD_FAIL_CHECK_ORSET(id, value)		CFS_FAIL_CHECK_ORSET(id, value)
 #define OBD_FAIL_CHECK_RESET(id, value)		CFS_FAIL_CHECK_RESET(id, value)
diff --git a/include/linux/libcfs/libcfs_fail.h b/include/linux/libcfs/libcfs_fail.h
index 731401b..552aad6 100644
--- a/include/linux/libcfs/libcfs_fail.h
+++ b/include/linux/libcfs/libcfs_fail.h
@@ -87,15 +87,15 @@ static inline bool CFS_FAIL_PRECHECK(u32 id)
 		 (cfs_fail_loc & id & CFS_FAULT));
 }
 
-static inline int cfs_fail_check_set(u32 id, u32 value,
-				     int set, int quiet)
+static inline int cfs_fail_check_set(u32 id, u32 value, int set, int quiet)
 {
+	unsigned long failed_once = cfs_fail_loc & CFS_FAILED; /* ok if racy */
 	int ret = 0;
 
 	if (unlikely(CFS_FAIL_PRECHECK(id))) {
 		ret = __cfs_fail_check_set(id, value, set);
 		if (ret) {
-			if (quiet) {
+			if (quiet && failed_once) {
 				CDEBUG(D_INFO, "*** cfs_fail_loc=%x, val=%u***\n",
 				       id, value);
 			} else {
-- 
1.8.3.1



More information about the lustre-devel mailing list