Whamcloud - gitweb
LU-3055 libcfs: remove page_collection::pc_lock 60/7660/2
authorLiang Zhen <liang.zhen@intel.com>
Sun, 15 Sep 2013 15:09:53 +0000 (23:09 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 25 Oct 2013 02:22:53 +0000 (02:22 +0000)
page_collection::pc_lock is supposed to protect race between
functions called by smp_call_function(), however we don't have
this use-case for ages and page_collection only lives in stack
of thread, so it is safe to remove it.

Signed-off-by: Liang Zhen <liang.zhen@intel.com>
Change-Id: I89ca46e6593838d85fc0b91d1ff7c35cc28cf4ce
Reviewed-on: http://review.whamcloud.com/7660
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Bobi Jam <bobijam@gmail.com>
Reviewed-by: Sebastien Buisson <sebastien.buisson@bull.net>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
libcfs/libcfs/tracefile.c
libcfs/libcfs/tracefile.h

index 34565c1..e15ec68 100644 (file)
@@ -201,7 +201,6 @@ static void cfs_tcd_shrink(struct cfs_trace_cpu_data *tcd)
                       pgcount + 1, tcd->tcd_cur_pages);
 
         CFS_INIT_LIST_HEAD(&pc.pc_pages);
-       spin_lock_init(&pc.pc_lock);
 
         cfs_list_for_each_entry_safe_typed(tage, tmp, &tcd->tcd_pages,
                                            struct cfs_trace_page, linkage) {
@@ -529,7 +528,6 @@ static void collect_pages_on_all_cpus(struct page_collection *pc)
        struct cfs_trace_cpu_data *tcd;
        int i, cpu;
 
-       spin_lock(&pc->pc_lock);
         cfs_for_each_possible_cpu(cpu) {
                 cfs_tcd_for_each_type_lock(tcd, i, cpu) {
                         cfs_list_splice_init(&tcd->tcd_pages, &pc->pc_pages);
@@ -541,7 +539,6 @@ static void collect_pages_on_all_cpus(struct page_collection *pc)
                         }
                 }
         }
-       spin_unlock(&pc->pc_lock);
 }
 
 static void collect_pages(struct page_collection *pc)
@@ -562,7 +559,6 @@ static void put_pages_back_on_all_cpus(struct page_collection *pc)
         struct cfs_trace_page *tmp;
         int i, cpu;
 
-       spin_lock(&pc->pc_lock);
         cfs_for_each_possible_cpu(cpu) {
                 cfs_tcd_for_each_type_lock(tcd, i, cpu) {
                         cur_head = tcd->tcd_pages.next;
@@ -582,7 +578,6 @@ static void put_pages_back_on_all_cpus(struct page_collection *pc)
                         }
                 }
         }
-       spin_unlock(&pc->pc_lock);
 }
 
 static void put_pages_back(struct page_collection *pc)
@@ -601,7 +596,6 @@ static void put_pages_on_tcd_daemon_list(struct page_collection *pc,
        struct cfs_trace_page *tage;
        struct cfs_trace_page *tmp;
 
-       spin_lock(&pc->pc_lock);
         cfs_list_for_each_entry_safe_typed(tage, tmp, &pc->pc_pages,
                                            struct cfs_trace_page, linkage) {
 
@@ -626,7 +620,6 @@ static void put_pages_on_tcd_daemon_list(struct page_collection *pc,
                         tcd->tcd_cur_daemon_pages--;
                 }
         }
-       spin_unlock(&pc->pc_lock);
 }
 
 static void put_pages_on_daemon_list(struct page_collection *pc)
@@ -646,8 +639,6 @@ void cfs_trace_debug_print(void)
        struct cfs_trace_page *tage;
        struct cfs_trace_page *tmp;
 
-       spin_lock_init(&pc.pc_lock);
-
         pc.pc_want_daemon_pages = 1;
         collect_pages(&pc);
         cfs_list_for_each_entry_safe_typed(tage, tmp, &pc.pc_pages,
@@ -701,7 +692,6 @@ int cfs_tracefile_dump_all_pages(char *filename)
                goto out;
        }
 
-       spin_lock_init(&pc.pc_lock);
         pc.pc_want_daemon_pages = 1;
         collect_pages(&pc);
         if (cfs_list_empty(&pc.pc_pages)) {
@@ -746,8 +736,6 @@ void cfs_trace_flush_pages(void)
        struct cfs_trace_page *tage;
        struct cfs_trace_page *tmp;
 
-       spin_lock_init(&pc.pc_lock);
-
         pc.pc_want_daemon_pages = 1;
         collect_pages(&pc);
         cfs_list_for_each_entry_safe_typed(tage, tmp, &pc.pc_pages,
@@ -993,7 +981,6 @@ static int tracefiled(void *arg)
        /* we're started late enough that we pick up init's fs context */
        /* this is so broken in uml?  what on earth is going on? */
 
-       spin_lock_init(&pc.pc_lock);
        complete(&tctl->tctl_start);
 
        while (1) {
@@ -1195,7 +1182,6 @@ static void cfs_trace_cleanup(void)
        struct page_collection pc;
 
        CFS_INIT_LIST_HEAD(&pc.pc_pages);
-       spin_lock_init(&pc.pc_lock);
 
        trace_cleanup_on_all_cpus();
 
index b109e8c..513ee17 100644 (file)
@@ -205,14 +205,6 @@ extern union cfs_trace_data_union (*cfs_trace_data[TCD_MAX_TYPES])[NR_CPUS];
 struct page_collection {
        cfs_list_t      pc_pages;
        /*
-        * spin-lock protecting ->pc_pages. It is taken by smp_call_function()
-        * call-back functions. XXX nikita: Which is horrible: all processors
-        * receive NMI at the same time only to be serialized by this
-        * lock. Probably ->pc_pages should be replaced with an array of
-        * NR_CPUS elements accessed locklessly.
-        */
-       spinlock_t      pc_lock;
-       /*
         * if this flag is set, collect_pages() will spill both
         * ->tcd_daemon_pages and ->tcd_pages to the ->pc_pages. Otherwise,
         * only ->tcd_pages are spilled.