From 890466a32d3e8683a96d5a18e76c0cc704810f5f Mon Sep 17 00:00:00 2001 From: Patrick Farrell Date: Thu, 12 Aug 2021 16:28:29 -0400 Subject: [PATCH] LU-14935 tests: Use FAIL_CHECK_QUIET for fake i/o 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. Signed-off-by: Patrick Farrell Change-Id: I46a5042efd116a4f5c80eaf0d5dae7fe132f6a79 Reviewed-on: https://review.whamcloud.com/44651 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Etienne AUJAMES --- libcfs/include/libcfs/libcfs_fail.h | 6 +++--- lustre/include/obd_support.h | 1 + lustre/ofd/ofd_io.c | 2 +- lustre/osd-ldiskfs/osd_io.c | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/libcfs/include/libcfs/libcfs_fail.h b/libcfs/include/libcfs/libcfs_fail.h index 511db02..9e57506 100644 --- a/libcfs/include/libcfs/libcfs_fail.h +++ b/libcfs/include/libcfs/libcfs_fail.h @@ -81,14 +81,14 @@ 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 (quiet) { + if (quiet && failed_once) { CDEBUG(D_INFO, "*** cfs_fail_loc=%x, val=%u***\n", id, value); } else { diff --git a/lustre/include/obd_support.h b/lustre/include/obd_support.h index 4322ae2..4385468 100644 --- a/lustre/include/obd_support.h +++ b/lustre/include/obd_support.h @@ -737,6 +737,7 @@ extern char obd_jobid_var[]; /* Assign references to moved code to reduce code changes */ #define OBD_FAIL_PRECHECK(id) (unlikely(CFS_FAIL_PRECHECK(id))) #define OBD_FAIL_CHECK(id) CFS_FAIL_CHECK(id) +#define OBD_FAIL_CHECK_QUIET(id) CFS_FAIL_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/lustre/ofd/ofd_io.c b/lustre/ofd/ofd_io.c index 3b96d63..0bae6eb 100644 --- a/lustre/ofd/ofd_io.c +++ b/lustre/ofd/ofd_io.c @@ -1276,7 +1276,7 @@ ofd_commitrw_write(const struct lu_env *env, struct obd_export *exp, la->la_valid &= LA_ATIME | LA_MTIME | LA_CTIME; /* do fake write, to simulate the write case for performance testing */ - if (OBD_FAIL_CHECK(OBD_FAIL_OST_FAKE_RW)) { + if (OBD_FAIL_CHECK_QUIET(OBD_FAIL_OST_FAKE_RW)) { struct niobuf_local *last = &lnb[niocount - 1]; __u64 file_size = last->lnb_file_offset + last->lnb_len; __u64 valid = la->la_valid; diff --git a/lustre/osd-ldiskfs/osd_io.c b/lustre/osd-ldiskfs/osd_io.c index 95215d6..74b1d3f 100644 --- a/lustre/osd-ldiskfs/osd_io.c +++ b/lustre/osd-ldiskfs/osd_io.c @@ -1698,7 +1698,7 @@ static int osd_read_prep(const struct lu_env *env, struct dt_object *dt, lnb[i].lnb_rc = lnb[i].lnb_len; /* Bypass disk read if fail_loc is set properly */ - if (OBD_FAIL_CHECK(OBD_FAIL_OST_FAKE_RW)) + if (OBD_FAIL_CHECK_QUIET(OBD_FAIL_OST_FAKE_RW)) SetPageUptodate(lnb[i].lnb_page); if (PageUptodate(lnb[i].lnb_page)) { -- 1.8.3.1