From eb9c36973cc92e2f0d1a45d511bf1e7c1eccc508 Mon Sep 17 00:00:00 2001 From: yangsheng Date: Fri, 13 Feb 2009 14:50:01 +0000 Subject: [PATCH] Branch b1_6 b=16579 i=shadow, zhen.liang Use RCU lock to enable stack dump. --- lnet/autoconf/lustre-lnet.m4 | 19 +++++++++++++++++++ lnet/libcfs/watchdog.c | 23 +++++++++++++---------- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/lnet/autoconf/lustre-lnet.m4 b/lnet/autoconf/lustre-lnet.m4 index a9bbaf1..5ca3cfc 100644 --- a/lnet/autoconf/lustre-lnet.m4 +++ b/lnet/autoconf/lustre-lnet.m4 @@ -1188,6 +1188,24 @@ LB_LINUX_TRY_COMPILE([ ]) +# check if task_struct with rcu memeber +AC_DEFUN([LN_TASK_RCU], +[AC_MSG_CHECKING([if task_struct has a rcu field]) +LB_LINUX_TRY_COMPILE([ + #include +],[ + struct task_struct tsk; + + tsk.rcu.next = NULL; +],[ + AC_MSG_RESULT([yes]) + AC_DEFINE(HAVE_TASK_RCU, 1, + [task_struct has rcu field]) +],[ + AC_MSG_RESULT([no]) +]) +]) + # LN_TASKLIST_LOCK # 2.6.18 remove tasklist_lock export AC_DEFUN([LN_TASKLIST_LOCK], @@ -1409,6 +1427,7 @@ LN_U64_LONG_LONG LN_SSIZE_T_LONG LN_SIZE_T_LONG LN_LE_TYPES +LN_TASK_RCU # 2.6.18 LN_TASKLIST_LOCK # 2.6.19 diff --git a/lnet/libcfs/watchdog.c b/lnet/libcfs/watchdog.c index b007c28..92f3565 100644 --- a/lnet/libcfs/watchdog.c +++ b/lnet/libcfs/watchdog.c @@ -102,14 +102,20 @@ static cfs_time_t lcw_last_watchdog_time; static int lcw_recent_watchdog_count; static spinlock_t lcw_last_watchdog_lock = SPIN_LOCK_UNLOCKED; -#ifdef HAVE_TASKLIST_LOCK static void lcw_dump(struct lc_watchdog *lcw) { cfs_task_t *tsk; +#if defined(HAVE_TASKLIST_LOCK) + read_lock(&tasklist_lock); +#elif defined(HAVE_TASK_RCU) + rcu_read_lock(); +#else + CERROR("unable to dump stack because of missing export\n"); + return; +#endif ENTRY; - read_lock(&tasklist_lock); tsk = find_task_by_pid(lcw->lcw_pid); if (tsk == NULL) { @@ -121,17 +127,14 @@ lcw_dump(struct lc_watchdog *lcw) } else { libcfs_debug_dumpstack(tsk); } - + +#if defined(HAVE_TASKLIST_LOCK) read_unlock(&tasklist_lock); +#elif defined(HAVE_TASK_RCU) + rcu_read_unlock(); +#endif EXIT; } -#else -static void -lcw_dump(struct lc_watchdog *lcw) -{ - CERROR("unable to dump stack because of missing export\n"); -} -#endif static void lcw_cb(unsigned long data) { -- 1.8.3.1