{
        do {
                unsigned long lrusize;
+               struct pglist_data *pgdat = lruvec_pgdat(lruvec);
 
+               spin_lock_irq(&pgdat->lru_lock);
                /* Record cost event */
                if (file)
                        lruvec->file_cost += nr_pages;
                        lruvec->file_cost /= 2;
                        lruvec->anon_cost /= 2;
                }
+               spin_unlock_irq(&pgdat->lru_lock);
        } while ((lruvec = parent_lruvec(lruvec)));
 }
 
 
        nr_reclaimed = shrink_page_list(&page_list, pgdat, sc, &stat, false);
 
        spin_lock_irq(&pgdat->lru_lock);
-
        move_pages_to_lru(lruvec, &page_list);
 
        __mod_node_page_state(pgdat, NR_ISOLATED_ANON + file, -nr_taken);
-       lru_note_cost(lruvec, file, stat.nr_pageout);
        item = current_is_kswapd() ? PGSTEAL_KSWAPD : PGSTEAL_DIRECT;
        if (!cgroup_reclaim(sc))
                __count_vm_events(item, nr_reclaimed);
        __count_memcg_events(lruvec_memcg(lruvec), item, nr_reclaimed);
        __count_vm_events(PGSTEAL_ANON + file, nr_reclaimed);
-
        spin_unlock_irq(&pgdat->lru_lock);
 
+       lru_note_cost(lruvec, file, stat.nr_pageout);
        mem_cgroup_uncharge_list(&page_list);
        free_unref_page_list(&page_list);
 
 
        if (workingset) {
                SetPageWorkingset(page);
                /* XXX: Move to lru_cache_add() when it supports new vs putback */
-               spin_lock_irq(&page_pgdat(page)->lru_lock);
                lru_note_cost_page(page);
-               spin_unlock_irq(&page_pgdat(page)->lru_lock);
                inc_lruvec_state(lruvec, WORKINGSET_RESTORE_BASE + file);
        }
 out: