From 399f1d12697590860476422a5484eaef6db9ac16 Mon Sep 17 00:00:00 2001 From: zhanghc Date: Tue, 7 Jul 2009 16:08:58 +0000 Subject: [PATCH] b=16774 cache the extent lock gotten before doing I/O in "ll_file_aio_read" and "ll_file_aio_write", then "ll_read_page", "ll_read_ahead_page" and "ll_writepage" will save much time spent on "ldlm_lock_match" (in cache_add_extent) to find the appropriate extent lock 1, using current->journal_info to store the locks(struct ll_thread_data) 2, replace o_reget_short_lock, o_release_short_lock with o_get_lock in obd_ops i=johann@sun.com i=oleg.drokin@sun.com --- lnet/include/libcfs/libcfs.h | 15 +++++++++++++++ lnet/libcfs/linux/linux-mem.c | 22 ++++++++++++++++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/lnet/include/libcfs/libcfs.h b/lnet/include/libcfs/libcfs.h index d25c3b0..0672f11 100644 --- a/lnet/include/libcfs/libcfs.h +++ b/lnet/include/libcfs/libcfs.h @@ -598,6 +598,21 @@ static inline cfs_duration_t cfs_timeout_cap(cfs_duration_t timeout) return timeout; } +#define LTD_MAGIC 0x0BD0BD0B +#define JOURNAL_ENTER() ({ \ + int *info = current->journal_info; \ + if (info && *info == LTD_MAGIC) \ + current->journal_info = NULL; \ + else \ + info = NULL; \ + info; \ +}) + +#define JOURNAL_EXIT(info) do { \ + if (info != NULL) \ + current->journal_info = info; \ +} while(0); + /* * Universal memory allocator API */ diff --git a/lnet/libcfs/linux/linux-mem.c b/lnet/libcfs/linux/linux-mem.c index 04ccd4e..8ac341a 100644 --- a/lnet/libcfs/linux/linux-mem.c +++ b/lnet/libcfs/linux/linux-mem.c @@ -75,10 +75,14 @@ void * cfs_alloc(size_t nr_bytes, u_int32_t flags) { void *ptr = NULL; + int *ltd = JOURNAL_ENTER(); ptr = kmalloc(nr_bytes, cfs_alloc_flags_to_gfp(flags)); if (ptr != NULL && (flags & CFS_ALLOC_ZERO)) memset(ptr, 0, nr_bytes); + + JOURNAL_EXIT(ltd); + return ptr; } @@ -102,11 +106,18 @@ cfs_free_large(void *addr) cfs_page_t *cfs_alloc_pages(unsigned int flags, unsigned int order) { + cfs_page_t *pages = NULL; + int *ltd = JOURNAL_ENTER(); + /* * XXX nikita: do NOT call portals_debug_msg() (CDEBUG/ENTRY/EXIT) * from here: this will lead to infinite recursion. */ - return alloc_pages(cfs_alloc_flags_to_gfp(flags), order); + pages = alloc_pages(cfs_alloc_flags_to_gfp(flags), order); + + JOURNAL_EXIT(ltd); + + return pages; } void __cfs_free_pages(cfs_page_t *page, unsigned int order) @@ -139,7 +150,14 @@ cfs_mem_cache_destroy (cfs_mem_cache_t * cachep) void * cfs_mem_cache_alloc(cfs_mem_cache_t *cachep, int flags) { - return kmem_cache_alloc(cachep, cfs_alloc_flags_to_gfp(flags)); + void *obj = NULL; + int *ltd = JOURNAL_ENTER(); + + obj = kmem_cache_alloc(cachep, cfs_alloc_flags_to_gfp(flags)); + + JOURNAL_EXIT(ltd); + + return obj; } void -- 1.8.3.1