tree:   https://git.kernel.org/pub/scm/linux/kernel/git/josef/btrfs-next.git 
blk-iolatency
head:   657e770d4d6e3b03c3d4b96e427b30d6f766e2e2
commit: 90f955bbc57765617e3e99f784f3239c3d8f0360 [7/13] memcontrol: schedule 
throttling if we are congested
config: x86_64-randconfig-x018-201820 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
        git checkout 90f955bbc57765617e3e99f784f3239c3d8f0360
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   In file included from include/linux/kernel.h:10:0,
                    from include/linux/list.h:9,
                    from include/linux/smp.h:12,
                    from include/linux/kernel_stat.h:5,
                    from mm/memory.c:41:
   mm/memory.c: In function 'wp_page_copy':
   mm/memory.c:2497:6: error: implicit declaration of function 
'mem_cgroup_try_charge_delay'; did you mean 'mem_cgroup_try_charge_swap'? 
[-Werror=implicit-function-declaration]
     if (mem_cgroup_try_charge_delay(new_page, mm, GFP_KERNEL, &memcg, false))
         ^
   include/linux/compiler.h:58:30: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                 ^~~~
>> mm/memory.c:2497:2: note: in expansion of macro 'if'
     if (mem_cgroup_try_charge_delay(new_page, mm, GFP_KERNEL, &memcg, false))
     ^~
   Cyclomatic Complexity 5 include/linux/compiler.h:__read_once_size
   Cyclomatic Complexity 5 include/linux/compiler.h:__write_once_size
   Cyclomatic Complexity 1 include/linux/kasan-checks.h:kasan_check_read
   Cyclomatic Complexity 1 include/linux/kasan-checks.h:kasan_check_write
   Cyclomatic Complexity 1 arch/x86/include/asm/bitops.h:__set_bit
   Cyclomatic Complexity 3 arch/x86/include/asm/bitops.h:clear_bit
   Cyclomatic Complexity 1 arch/x86/include/asm/bitops.h:test_and_set_bit
   Cyclomatic Complexity 1 arch/x86/include/asm/bitops.h:test_and_set_bit_lock
   Cyclomatic Complexity 1 arch/x86/include/asm/bitops.h:constant_test_bit
   Cyclomatic Complexity 1 arch/x86/include/asm/bitops.h:variable_test_bit
   Cyclomatic Complexity 1 arch/x86/include/asm/bitops.h:fls64
   Cyclomatic Complexity 1 include/linux/bitops.h:fls_long
   Cyclomatic Complexity 1 include/linux/log2.h:__rounddown_pow_of_two
   Cyclomatic Complexity 2 include/linux/list.h:__list_add
   Cyclomatic Complexity 1 include/linux/list.h:list_add
   Cyclomatic Complexity 1 include/linux/list.h:list_empty
   Cyclomatic Complexity 2 arch/x86/include/asm/jump_label.h:arch_static_branch
   Cyclomatic Complexity 1 include/linux/jump_label.h:static_key_false
   Cyclomatic Complexity 2 include/linux/string.h:kbasename
   Cyclomatic Complexity 1 arch/x86/include/asm/atomic.h:arch_atomic_read
   Cyclomatic Complexity 1 arch/x86/include/asm/atomic.h:arch_atomic_inc
   Cyclomatic Complexity 1 arch/x86/include/asm/atomic.h:arch_atomic_dec
   Cyclomatic Complexity 1 
arch/x86/include/asm/atomic.h:arch_atomic_dec_and_test
   Cyclomatic Complexity 1 arch/x86/include/asm/atomic64_64.h:arch_atomic64_read
   Cyclomatic Complexity 1 arch/x86/include/asm/atomic64_64.h:arch_atomic64_add
   Cyclomatic Complexity 1 arch/x86/include/asm/atomic64_64.h:arch_atomic64_sub
   Cyclomatic Complexity 1 arch/x86/include/asm/atomic64_64.h:arch_atomic64_inc
   Cyclomatic Complexity 1 arch/x86/include/asm/atomic64_64.h:arch_atomic64_dec
   Cyclomatic Complexity 1 include/asm-generic/atomic-instrumented.h:atomic_read
   Cyclomatic Complexity 1 
include/asm-generic/atomic-instrumented.h:atomic64_read
   Cyclomatic Complexity 1 include/asm-generic/atomic-instrumented.h:atomic_inc
   Cyclomatic Complexity 1 
include/asm-generic/atomic-instrumented.h:atomic64_inc
   Cyclomatic Complexity 1 include/asm-generic/atomic-instrumented.h:atomic_dec
   Cyclomatic Complexity 1 
include/asm-generic/atomic-instrumented.h:atomic64_dec
   Cyclomatic Complexity 1 
include/asm-generic/atomic-instrumented.h:atomic64_add
   Cyclomatic Complexity 1 
include/asm-generic/atomic-instrumented.h:atomic64_sub
   Cyclomatic Complexity 1 
include/asm-generic/atomic-instrumented.h:atomic_dec_and_test
   Cyclomatic Complexity 1 include/asm-generic/atomic-long.h:atomic_long_read
   Cyclomatic Complexity 1 include/asm-generic/atomic-long.h:atomic_long_inc
   Cyclomatic Complexity 1 include/asm-generic/atomic-long.h:atomic_long_dec
   Cyclomatic Complexity 1 include/asm-generic/atomic-long.h:atomic_long_add
   Cyclomatic Complexity 1 include/asm-generic/atomic-long.h:atomic_long_sub
   Cyclomatic Complexity 1 include/linux/smp.h:up_smp_call_function
   Cyclomatic Complexity 1 arch/x86/include/asm/current.h:get_current
   Cyclomatic Complexity 2 arch/x86/include/asm/page_64.h:__phys_addr_nodebug
   Cyclomatic Complexity 1 arch/x86/include/asm/page_64.h:clear_page
   Cyclomatic Complexity 1 arch/x86/include/asm/page.h:copy_user_page
   Cyclomatic Complexity 1 arch/x86/include/asm/pgtable_types.h:native_pgd_val
   Cyclomatic Complexity 1 include/asm-generic/pgtable-nop4d.h:pgd_none
   Cyclomatic Complexity 1 include/asm-generic/pgtable-nop4d.h:pgd_bad
   Cyclomatic Complexity 1 include/asm-generic/pgtable-nop4d.h:pgd_clear
   Cyclomatic Complexity 1 include/asm-generic/pgtable-nop4d.h:p4d_offset
   Cyclomatic Complexity 1 arch/x86/include/asm/pgtable_types.h:native_p4d_val
   Cyclomatic Complexity 1 arch/x86/include/asm/pgtable_types.h:native_pud_val
   Cyclomatic Complexity 1 arch/x86/include/asm/pgtable_types.h:native_pmd_val
   Cyclomatic Complexity 1 arch/x86/include/asm/pgtable_types.h:p4d_pfn_mask
   Cyclomatic Complexity 1 arch/x86/include/asm/pgtable_types.h:p4d_flags_mask
   Cyclomatic Complexity 1 arch/x86/include/asm/pgtable_types.h:p4d_flags
   Cyclomatic Complexity 2 arch/x86/include/asm/pgtable_types.h:pud_pfn_mask
   Cyclomatic Complexity 1 arch/x86/include/asm/pgtable_types.h:pud_flags_mask
   Cyclomatic Complexity 1 arch/x86/include/asm/pgtable_types.h:pud_flags
   Cyclomatic Complexity 2 arch/x86/include/asm/pgtable_types.h:pmd_pfn_mask
   Cyclomatic Complexity 1 arch/x86/include/asm/pgtable_types.h:pmd_flags_mask
   Cyclomatic Complexity 1 arch/x86/include/asm/pgtable_types.h:pmd_flags
   Cyclomatic Complexity 1 arch/x86/include/asm/pgtable_types.h:native_make_pte
   Cyclomatic Complexity 1 arch/x86/include/asm/pgtable_types.h:native_pte_val
   Cyclomatic Complexity 1 arch/x86/include/asm/pgtable_types.h:pte_flags
   Cyclomatic Complexity 1 arch/x86/include/asm/paravirt.h:paravirt_alloc_pte
   Cyclomatic Complexity 1 arch/x86/include/asm/paravirt.h:paravirt_alloc_pmd
   Cyclomatic Complexity 1 arch/x86/include/asm/paravirt.h:paravirt_alloc_pud
   Cyclomatic Complexity 1 arch/x86/include/asm/paravirt.h:__pte
   Cyclomatic Complexity 1 arch/x86/include/asm/paravirt.h:pte_val
   Cyclomatic Complexity 1 arch/x86/include/asm/paravirt.h:__pgd
   Cyclomatic Complexity 1 arch/x86/include/asm/paravirt.h:pgd_val
   Cyclomatic Complexity 1 
arch/x86/include/asm/paravirt.h:ptep_modify_prot_start
   Cyclomatic Complexity 1 
arch/x86/include/asm/paravirt.h:ptep_modify_prot_commit
   Cyclomatic Complexity 1 arch/x86/include/asm/paravirt.h:set_pte_at
   Cyclomatic Complexity 1 arch/x86/include/asm/paravirt.h:set_pmd
   Cyclomatic Complexity 1 arch/x86/include/asm/paravirt.h:__pmd
   Cyclomatic Complexity 1 arch/x86/include/asm/paravirt.h:pmd_val
   Cyclomatic Complexity 1 arch/x86/include/asm/paravirt.h:set_pud
   Cyclomatic Complexity 1 arch/x86/include/asm/paravirt.h:__pud
   Cyclomatic Complexity 1 arch/x86/include/asm/paravirt.h:pud_val
   Cyclomatic Complexity 1 arch/x86/include/asm/paravirt.h:pud_clear
   Cyclomatic Complexity 1 arch/x86/include/asm/paravirt.h:set_p4d
   Cyclomatic Complexity 1 arch/x86/include/asm/paravirt.h:p4d_clear
   Cyclomatic Complexity 1 arch/x86/include/asm/paravirt.h:pte_clear
   Cyclomatic Complexity 1 arch/x86/include/asm/paravirt.h:pmd_clear
   Cyclomatic Complexity 1 
arch/x86/include/asm/paravirt.h:arch_enter_lazy_mmu_mode
   Cyclomatic Complexity 1 
arch/x86/include/asm/paravirt.h:arch_leave_lazy_mmu_mode
   Cyclomatic Complexity 1 arch/x86/include/asm/special_insns.h:__read_pkru
   Cyclomatic Complexity 1 include/linux/err.h:IS_ERR
   Cyclomatic Complexity 2 include/linux/thread_info.h:test_ti_thread_flag
   Cyclomatic Complexity 1 include/linux/thread_info.h:check_object_size
   Cyclomatic Complexity 1 arch/x86/include/asm/preempt.h:should_resched
   Cyclomatic Complexity 1 include/linux/spinlock.h:spinlock_check
   Cyclomatic Complexity 1 include/linux/spinlock.h:spin_lock
   Cyclomatic Complexity 1 include/linux/spinlock.h:spin_unlock

vim +/if +2497 mm/memory.c

  2452  
  2453  /*
  2454   * Handle the case of a page which we actually need to copy to a new 
page.
  2455   *
  2456   * Called with mmap_sem locked and the old page referenced, but
  2457   * without the ptl held.
  2458   *
  2459   * High level logic flow:
  2460   *
  2461   * - Allocate a page, copy the content of the old page to the new one.
  2462   * - Handle book keeping and accounting - cgroups, mmu-notifiers, etc.
  2463   * - Take the PTL. If the pte changed, bail out and release the 
allocated page
  2464   * - If the pte is still the way we remember it, update the page table 
and all
  2465   *   relevant references. This includes dropping the reference the 
page-table
  2466   *   held to the old page, as well as updating the rmap.
  2467   * - In any case, unlock the PTL and drop the reference we took to the 
old page.
  2468   */
  2469  static int wp_page_copy(struct vm_fault *vmf)
  2470  {
  2471          struct vm_area_struct *vma = vmf->vma;
  2472          struct mm_struct *mm = vma->vm_mm;
  2473          struct page *old_page = vmf->page;
  2474          struct page *new_page = NULL;
  2475          pte_t entry;
  2476          int page_copied = 0;
  2477          const unsigned long mmun_start = vmf->address & PAGE_MASK;
  2478          const unsigned long mmun_end = mmun_start + PAGE_SIZE;
  2479          struct mem_cgroup *memcg;
  2480  
  2481          if (unlikely(anon_vma_prepare(vma)))
  2482                  goto oom;
  2483  
  2484          if (is_zero_pfn(pte_pfn(vmf->orig_pte))) {
  2485                  new_page = alloc_zeroed_user_highpage_movable(vma,
  2486                                                                
vmf->address);
  2487                  if (!new_page)
  2488                          goto oom;
  2489          } else {
  2490                  new_page = alloc_page_vma(GFP_HIGHUSER_MOVABLE, vma,
  2491                                  vmf->address);
  2492                  if (!new_page)
  2493                          goto oom;
  2494                  cow_user_page(new_page, old_page, vmf->address, vma);
  2495          }
  2496  
> 2497          if (mem_cgroup_try_charge_delay(new_page, mm, GFP_KERNEL, 
> &memcg, false))
  2498                  goto oom_free_new;
  2499  
  2500          __SetPageUptodate(new_page);
  2501  
  2502          mmu_notifier_invalidate_range_start(mm, mmun_start, mmun_end);
  2503  
  2504          /*
  2505           * Re-check the pte - we dropped the lock
  2506           */
  2507          vmf->pte = pte_offset_map_lock(mm, vmf->pmd, vmf->address, 
&vmf->ptl);
  2508          if (likely(pte_same(*vmf->pte, vmf->orig_pte))) {
  2509                  if (old_page) {
  2510                          if (!PageAnon(old_page)) {
  2511                                  dec_mm_counter_fast(mm,
  2512                                                  
mm_counter_file(old_page));
  2513                                  inc_mm_counter_fast(mm, MM_ANONPAGES);
  2514                          }
  2515                  } else {
  2516                          inc_mm_counter_fast(mm, MM_ANONPAGES);
  2517                  }
  2518                  flush_cache_page(vma, vmf->address, 
pte_pfn(vmf->orig_pte));
  2519                  entry = mk_pte(new_page, vma->vm_page_prot);
  2520                  entry = maybe_mkwrite(pte_mkdirty(entry), vma);
  2521                  /*
  2522                   * Clear the pte entry and flush it first, before 
updating the
  2523                   * pte with the new entry. This will avoid a race 
condition
  2524                   * seen in the presence of one thread doing SMC and 
another
  2525                   * thread doing COW.
  2526                   */
  2527                  ptep_clear_flush_notify(vma, vmf->address, vmf->pte);
  2528                  page_add_new_anon_rmap(new_page, vma, vmf->address, 
false);
  2529                  mem_cgroup_commit_charge(new_page, memcg, false, false);
  2530                  lru_cache_add_active_or_unevictable(new_page, vma);
  2531                  /*
  2532                   * We call the notify macro here because, when using 
secondary
  2533                   * mmu page tables (such as kvm shadow page tables), we 
want the
  2534                   * new page to be mapped directly into the secondary 
page table.
  2535                   */
  2536                  set_pte_at_notify(mm, vmf->address, vmf->pte, entry);
  2537                  update_mmu_cache(vma, vmf->address, vmf->pte);
  2538                  if (old_page) {
  2539                          /*
  2540                           * Only after switching the pte to the new page 
may
  2541                           * we remove the mapcount here. Otherwise 
another
  2542                           * process may come and find the rmap count 
decremented
  2543                           * before the pte is switched to the new page, 
and
  2544                           * "reuse" the old page writing into it while 
our pte
  2545                           * here still points into it and can be read by 
other
  2546                           * threads.
  2547                           *
  2548                           * The critical issue is to order this
  2549                           * page_remove_rmap with the ptp_clear_flush 
above.
  2550                           * Those stores are ordered by (if nothing 
else,)
  2551                           * the barrier present in the 
atomic_add_negative
  2552                           * in page_remove_rmap.
  2553                           *
  2554                           * Then the TLB flush in ptep_clear_flush 
ensures that
  2555                           * no process can access the old page before the
  2556                           * decremented mapcount is visible. And the old 
page
  2557                           * cannot be reused until after the decremented
  2558                           * mapcount is visible. So transitively, TLBs to
  2559                           * old page will be flushed before it can be 
reused.
  2560                           */
  2561                          page_remove_rmap(old_page, false);
  2562                  }
  2563  
  2564                  /* Free the old page.. */
  2565                  new_page = old_page;
  2566                  page_copied = 1;
  2567          } else {
  2568                  mem_cgroup_cancel_charge(new_page, memcg, false);
  2569          }
  2570  
  2571          if (new_page)
  2572                  put_page(new_page);
  2573  
  2574          pte_unmap_unlock(vmf->pte, vmf->ptl);
  2575          /*
  2576           * No need to double call mmu_notifier->invalidate_range() 
callback as
  2577           * the above ptep_clear_flush_notify() did already call it.
  2578           */
  2579          mmu_notifier_invalidate_range_only_end(mm, mmun_start, 
mmun_end);
  2580          if (old_page) {
  2581                  /*
  2582                   * Don't let another task, with possibly unlocked vma,
  2583                   * keep the mlocked page.
  2584                   */
  2585                  if (page_copied && (vma->vm_flags & VM_LOCKED)) {
  2586                          lock_page(old_page);    /* LRU manipulation */
  2587                          if (PageMlocked(old_page))
  2588                                  munlock_vma_page(old_page);
  2589                          unlock_page(old_page);
  2590                  }
  2591                  put_page(old_page);
  2592          }
  2593          return page_copied ? VM_FAULT_WRITE : 0;
  2594  oom_free_new:
  2595          put_page(new_page);
  2596  oom:
  2597          if (old_page)
  2598                  put_page(old_page);
  2599          return VM_FAULT_OOM;
  2600  }
  2601  

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

Attachment: .config.gz
Description: application/gzip

Reply via email to