From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752660AbbCKJFx (ORCPT ); Wed, 11 Mar 2015 05:05:53 -0400 Received: from cnbjrel01.sonyericsson.com ([219.141.167.165]:19717 "EHLO cnbjrel01.sonyericsson.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751646AbbCKJFu convert rfc822-to-8bit (ORCPT ); Wed, 11 Mar 2015 05:05:50 -0400 From: "Wang, Yalin" To: "'Minchan Kim'" , Andrew Morton CC: "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , Michal Hocko , Johannes Weiner , Mel Gorman , Rik van Riel , Shaohua Li Date: Wed, 11 Mar 2015 17:05:46 +0800 Subject: [RFC ] mm: don't ignore file map pages for madvise_free( ) Thread-Topic: [RFC ] mm: don't ignore file map pages for madvise_free( ) Thread-Index: AdBbmZ4/wzIpNB9rSCKUH/WvFhqq4AAQAaeA Message-ID: <35FD53F367049845BC99AC72306C23D10458D6173C0B@CNBJMBX05.corpusers.net> References: <1426036838-18154-1-git-send-email-minchan@kernel.org> <1426036838-18154-3-git-send-email-minchan@kernel.org> In-Reply-To: <1426036838-18154-3-git-send-email-minchan@kernel.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi I just want to explain my ideas about file map pages for madvise_free() syscall. As the following patch, For file map vma, there is 2 types: 1. private file map In this type, the pages of this vma are file map pages or anon page (when COW happened), 2. shared file map In this type, the pages of this vma are all file map pages. No matter which type file map, We can handle file map vma as the following: If the page is file map pages, We just clear its pte young bit(pte_mkold()), This will have some advantages, it will make page Reclaim path move this file map page into inactive lru list aggressively. If the page is anon map page, we just handle it in the Same way as for the pages in anon vma. --- diff --git a/mm/madvise.c b/mm/madvise.c index 6d0fcb8..8fdc82f 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -322,7 +322,8 @@ static int madvise_free_pte_range(pmd_t *pmd, unsigned long addr, ptent = ptep_get_and_clear_full(mm, addr, pte, tlb->fullmm); ptent = pte_mkold(ptent); - ptent = pte_mkclean(ptent); + if (PageAnon(page)) + ptent = pte_mkclean(ptent); set_pte_at(mm, addr, pte, ptent); tlb_remove_tlb_entry(tlb, pte, addr); } @@ -364,10 +365,6 @@ static int madvise_free_single_vma(struct vm_area_struct *vma, if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP)) return -EINVAL; - /* MADV_FREE works for only anon vma at the moment */ - if (vma->vm_file) - return -EINVAL; - start = max(vma->vm_start, start_addr); if (start >= vma->vm_end) return -EINVAL;