Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1259624
| From | Shaohua Li <shli@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 1/8] mm: support madvise(MADV_FREE) |
| Date | 2015-10-30 17:50 +0100 |
| Message-ID | <qpl2j-8b8-29@gated-at.bofh.it> (permalink) |
| References | <qpbYZ-2NI-5@gated-at.bofh.it> <qpbZ0-2NI-23@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Fri, Oct 30, 2015 at 04:01:37PM +0900, Minchan Kim wrote:
> +static int madvise_free_pte_range(pmd_t *pmd, unsigned long addr,
> + unsigned long end, struct mm_walk *walk)
> +
> +{
> + struct mmu_gather *tlb = walk->private;
> + struct mm_struct *mm = tlb->mm;
> + struct vm_area_struct *vma = walk->vma;
> + spinlock_t *ptl;
> + pte_t *pte, ptent;
> + struct page *page;
> +
> + split_huge_page_pmd(vma, addr, pmd);
> + if (pmd_trans_unstable(pmd))
> + return 0;
> +
> + pte = pte_offset_map_lock(mm, pmd, addr, &ptl);
> + arch_enter_lazy_mmu_mode();
> + for (; addr != end; pte++, addr += PAGE_SIZE) {
> + ptent = *pte;
> +
> + if (!pte_present(ptent))
> + continue;
> +
> + page = vm_normal_page(vma, addr, ptent);
> + if (!page)
> + continue;
> +
> + if (PageSwapCache(page)) {
> + if (!trylock_page(page))
> + continue;
> +
> + if (!try_to_free_swap(page)) {
> + unlock_page(page);
> + continue;
> + }
> +
> + ClearPageDirty(page);
> + unlock_page(page);
> + }
> +
> + /*
> + * Some of architecture(ex, PPC) don't update TLB
> + * with set_pte_at and tlb_remove_tlb_entry so for
> + * the portability, remap the pte with old|clean
> + * after pte clearing.
> + */
> + ptent = ptep_get_and_clear_full(mm, addr, pte,
> + tlb->fullmm);
> + ptent = pte_mkold(ptent);
> + ptent = pte_mkclean(ptent);
> + set_pte_at(mm, addr, pte, ptent);
> + tlb_remove_tlb_entry(tlb, pte, addr);
The orginal ptent might not be dirty. In that case, the tlb_remove_tlb_entry
is unnecessary, so please add a check. In practice, I saw more TLB flush with
FREE compared to DONTNEED because of this issue.
Thanks,
Shaohua
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/8] MADV_FREE support Minchan Kim <minchan@kernel.org> - 2015-10-30 08:10 +0100
[PATCH 3/8] arch: uapi: asm: mman.h: Let MADV_FREE have same value for all architectures Minchan Kim <minchan@kernel.org> - 2015-10-30 08:10 +0100
Re: [PATCH 3/8] arch: uapi: asm: mman.h: Let MADV_FREE have same value for all architectures Hugh Dickins <hughd@google.com> - 2015-11-02 01:10 +0100
Re: [PATCH 3/8] arch: uapi: asm: mman.h: Let MADV_FREE have same value for all architectures Minchan Kim <minchan@kernel.org> - 2015-11-03 03:40 +0100
Re: [PATCH 3/8] arch: uapi: asm: mman.h: Let MADV_FREE have same value for all architectures David Miller <davem@davemloft.net> - 2015-11-03 04:40 +0100
Re: [PATCH 3/8] arch: uapi: asm: mman.h: Let MADV_FREE have same value for all architectures Minchan Kim <minchan@kernel.org> - 2015-11-03 05:40 +0100
Re: [PATCH 3/8] arch: uapi: asm: mman.h: Let MADV_FREE have same value for all architectures Minchan Kim <minchan@kernel.org> - 2015-11-03 03:40 +0100
[PATCH 1/8] mm: support madvise(MADV_FREE) Minchan Kim <minchan@kernel.org> - 2015-10-30 08:10 +0100
Re: [PATCH 1/8] mm: support madvise(MADV_FREE) Shaohua Li <shli@kernel.org> - 2015-10-30 17:50 +0100
Re: [PATCH 1/8] mm: support madvise(MADV_FREE) Minchan Kim <minchan@kernel.org> - 2015-11-03 01:20 +0100
[PATCH 6/8] mm: lru_deactivate_fn should clear PG_referenced Minchan Kim <minchan@kernel.org> - 2015-10-30 08:10 +0100
Re: [PATCH 6/8] mm: lru_deactivate_fn should clear PG_referenced Michal Hocko <mhocko@kernel.org> - 2015-10-30 13:50 +0100
Re: [PATCH 6/8] mm: lru_deactivate_fn should clear PG_referenced Minchan Kim <minchan@kernel.org> - 2015-11-03 02:20 +0100
Re: [PATCH 6/8] mm: lru_deactivate_fn should clear PG_referenced Michal Hocko <mhocko@kernel.org> - 2015-11-04 09:30 +0100
[PATCH 4/8] mm: free swp_entry in madvise_free Minchan Kim <minchan@kernel.org> - 2015-10-30 08:10 +0100
Re: [PATCH 4/8] mm: free swp_entry in madvise_free Michal Hocko <mhocko@kernel.org> - 2015-10-30 13:30 +0100
Re: [PATCH 4/8] mm: free swp_entry in madvise_free Minchan Kim <minchan@kernel.org> - 2015-11-03 02:00 +0100
Re: [PATCH 0/8] MADV_FREE support David Rientjes <rientjes@google.com> - 2015-11-01 06:00 +0100
Re: [PATCH 0/8] MADV_FREE support Daniel Micay <danielmicay@gmail.com> - 2015-11-01 07:40 +0100
Re: [PATCH 0/8] MADV_FREE support Minchan Kim <minchan@kernel.org> - 2015-11-03 03:30 +0100
Re: [PATCH 0/8] MADV_FREE support David Rientjes <rientjes@google.com> - 2015-11-04 21:20 +0100
csiph-web