From 93962ee39a6d48380b8487b81fc20514cda074cf Mon Sep 17 00:00:00 2001 From: Johann Lombardi Date: Fri, 4 Jun 2010 12:19:47 +0200 Subject: [PATCH] b=21556 release cpu if needed while removing extents i=oleg i=vitaly cache_remove_extents_from_lock() can hog cpu for too long. add a call to cond_resched(). --- lnet/include/libcfs/darwin/darwin-prim.h | 5 +++++ lnet/include/libcfs/linux/linux-prim.h | 9 +-------- lnet/include/libcfs/user-prim.h | 3 ++- lnet/include/libcfs/winnt/winnt-prim.h | 5 +++++ lustre/ChangeLog | 5 +++++ lustre/osc/cache.c | 3 +++ 6 files changed, 21 insertions(+), 9 deletions(-) diff --git a/lnet/include/libcfs/darwin/darwin-prim.h b/lnet/include/libcfs/darwin/darwin-prim.h index 55ed1b3..ee14b84 100644 --- a/lnet/include/libcfs/darwin/darwin-prim.h +++ b/lnet/include/libcfs/darwin/darwin-prim.h @@ -286,6 +286,11 @@ static inline int cfs_schedule_timeout(int state, int64_t timeout) * unefficient and can be harmful if we have many elements to process */ #define cfs_cond_resched() cfs_schedule_timeout(CFS_TASK_INTERRUPTIBLE, 1) +static inline int cfs_cond_resched_lock(cfs_spinlock_t *lock) +{ + return 0; +} + #define __wait_event(wq, condition) \ do { \ struct cfs_waitlink __wait; \ diff --git a/lnet/include/libcfs/linux/linux-prim.h b/lnet/include/libcfs/linux/linux-prim.h index 754e036..fe7c7ea 100644 --- a/lnet/include/libcfs/linux/linux-prim.h +++ b/lnet/include/libcfs/linux/linux-prim.h @@ -159,15 +159,8 @@ typedef long cfs_task_state_t; #define cfs_schedule() schedule() #define cfs_kthread_run(fn, data, fmt, arg...) kthread_run(fn, data, fmt, ##arg) -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) -static inline void cfs_cond_resched(void) -{ - if (current->need_resched) - schedule(); -} -#else #define cfs_cond_resched() cond_resched() -#endif +#define cfs_cond_resched_lock(lock) cond_resched_lock(lock) /* Kernel thread */ typedef int (*cfs_thread_t)(void *); diff --git a/lnet/include/libcfs/user-prim.h b/lnet/include/libcfs/user-prim.h index dc679a7..21a91f3 100644 --- a/lnet/include/libcfs/user-prim.h +++ b/lnet/include/libcfs/user-prim.h @@ -99,7 +99,8 @@ int64_t cfs_waitq_timedwait(struct cfs_waitlink *link, int state, int64_t timeou cfs_waitlink_t l; \ cfs_waitq_timedwait(&l, s, t); \ } while (0) -#define cfs_cond_resched() do {} while(0) +#define cfs_cond_resched() do {} while(0) +#define cfs_cond_resched_lock(l) (0) #define CFS_TASK_INTERRUPTIBLE (0) #define CFS_TASK_UNINT (0) diff --git a/lnet/include/libcfs/winnt/winnt-prim.h b/lnet/include/libcfs/winnt/winnt-prim.h index abcf379..e62662e 100644 --- a/lnet/include/libcfs/winnt/winnt-prim.h +++ b/lnet/include/libcfs/winnt/winnt-prim.h @@ -549,6 +549,11 @@ static inline void cfs_cond_resched() schedule_timeout(1i64); } +static inline int cfs_cond_resched_lock(cfs_spinlock_t *lock) +{ + return 0; +} + #define CFS_DECL_JOURNAL_DATA #define CFS_PUSH_JOURNAL do {;} while(0) #define CFS_POP_JOURNAL do {;} while(0) diff --git a/lustre/ChangeLog b/lustre/ChangeLog index e92cc9e..60c1e53 100644 --- a/lustre/ChangeLog +++ b/lustre/ChangeLog @@ -166,6 +166,11 @@ Description: exp->exp_nid_stats == NULL in filter_tally() Details : fix race with per-nid stats by delaying procfs cleanup until exp_refcount == 0 +Severity : normal +Bugzilla : 21556 +Description: extent lock cancellation on client can keep the cpu busy for too + long. + ------------------------------------------------------------------------------- 2010-04-30 Oracle, Inc. diff --git a/lustre/osc/cache.c b/lustre/osc/cache.c index ae1a547..7a5d6c7 100644 --- a/lustre/osc/cache.c +++ b/lustre/osc/cache.c @@ -340,6 +340,9 @@ static int cache_remove_extents_from_lock(struct lustre_cache *cache, spin_lock(&lock->l_extents_list_lock); while (!list_empty(&lock->l_extents_list)) { + if (unlikely(cfs_cond_resched_lock(&lock->l_extents_list_lock))) + continue; + extent = list_entry(lock->l_extents_list.next, struct osc_async_page, oap_page_list); -- 1.8.3.1