Merge tag 'armsoc-soc' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc
[linux-2.6-block.git] / mm / memcontrol.c
index 4f05735b02d3fb7a3a5ecccf601a21eaa653ddde..cdbb7a84cb6e186242afeebb32f4c5c7fb2d0639 100644 (file)
@@ -695,12 +695,15 @@ void __mod_memcg_state(struct mem_cgroup *memcg, int idx, int val)
        if (mem_cgroup_disabled())
                return;
 
-       __this_cpu_add(memcg->vmstats_local->stat[idx], val);
-
        x = val + __this_cpu_read(memcg->vmstats_percpu->stat[idx]);
        if (unlikely(abs(x) > MEMCG_CHARGE_BATCH)) {
                struct mem_cgroup *mi;
 
+               /*
+                * Batch local counters to keep them in sync with
+                * the hierarchical ones.
+                */
+               __this_cpu_add(memcg->vmstats_local->stat[idx], x);
                for (mi = memcg; mi; mi = parent_mem_cgroup(mi))
                        atomic_long_add(x, &mi->vmstats[idx]);
                x = 0;
@@ -749,13 +752,15 @@ void __mod_lruvec_state(struct lruvec *lruvec, enum node_stat_item idx,
        /* Update memcg */
        __mod_memcg_state(memcg, idx, val);
 
-       /* Update lruvec */
-       __this_cpu_add(pn->lruvec_stat_local->count[idx], val);
-
        x = val + __this_cpu_read(pn->lruvec_stat_cpu->count[idx]);
        if (unlikely(abs(x) > MEMCG_CHARGE_BATCH)) {
                struct mem_cgroup_per_node *pi;
 
+               /*
+                * Batch local counters to keep them in sync with
+                * the hierarchical ones.
+                */
+               __this_cpu_add(pn->lruvec_stat_local->count[idx], x);
                for (pi = pn; pi; pi = parent_nodeinfo(pi, pgdat->node_id))
                        atomic_long_add(x, &pi->lruvec_stat[idx]);
                x = 0;
@@ -777,12 +782,15 @@ void __count_memcg_events(struct mem_cgroup *memcg, enum vm_event_item idx,
        if (mem_cgroup_disabled())
                return;
 
-       __this_cpu_add(memcg->vmstats_local->events[idx], count);
-
        x = count + __this_cpu_read(memcg->vmstats_percpu->events[idx]);
        if (unlikely(x > MEMCG_CHARGE_BATCH)) {
                struct mem_cgroup *mi;
 
+               /*
+                * Batch local counters to keep them in sync with
+                * the hierarchical ones.
+                */
+               __this_cpu_add(memcg->vmstats_local->events[idx], x);
                for (mi = memcg; mi; mi = parent_mem_cgroup(mi))
                        atomic_long_add(x, &mi->vmevents[idx]);
                x = 0;
@@ -4908,7 +4916,7 @@ enum mc_target_type {
 static struct page *mc_handle_present_pte(struct vm_area_struct *vma,
                                                unsigned long addr, pte_t ptent)
 {
-       struct page *page = _vm_normal_page(vma, addr, ptent, true);
+       struct page *page = vm_normal_page(vma, addr, ptent);
 
        if (!page || !page_mapped(page))
                return NULL;
@@ -5109,8 +5117,8 @@ out:
  *   2(MC_TARGET_SWAP): if the swap entry corresponding to this pte is a
  *     target for charge migration. if @target is not NULL, the entry is stored
  *     in target->ent.
- *   3(MC_TARGET_DEVICE): like MC_TARGET_PAGE  but page is MEMORY_DEVICE_PUBLIC
- *     or MEMORY_DEVICE_PRIVATE (so ZONE_DEVICE page and thus not on the lru).
+ *   3(MC_TARGET_DEVICE): like MC_TARGET_PAGE  but page is MEMORY_DEVICE_PRIVATE
+ *     (so ZONE_DEVICE page and thus not on the lru).
  *     For now we such page is charge like a regular page would be as for all
  *     intent and purposes it is just special memory taking the place of a
  *     regular page.
@@ -5144,8 +5152,7 @@ static enum mc_target_type get_mctgt_type(struct vm_area_struct *vma,
                 */
                if (page->mem_cgroup == mc.from) {
                        ret = MC_TARGET_PAGE;
-                       if (is_device_private_page(page) ||
-                           is_device_public_page(page))
+                       if (is_device_private_page(page))
                                ret = MC_TARGET_DEVICE;
                        if (target)
                                target->page = page;
@@ -5216,8 +5223,8 @@ static int mem_cgroup_count_precharge_pte_range(pmd_t *pmd,
        if (ptl) {
                /*
                 * Note their can not be MC_TARGET_DEVICE for now as we do not
-                * support transparent huge page with MEMORY_DEVICE_PUBLIC or
-                * MEMORY_DEVICE_PRIVATE but this might change.
+                * support transparent huge page with MEMORY_DEVICE_PRIVATE but
+                * this might change.
                 */
                if (get_mctgt_type_thp(vma, addr, *pmd, NULL) == MC_TARGET_PAGE)
                        mc.precharge += HPAGE_PMD_NR;