[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20131213131349.D8DE9E0090@blue.fi.intel.com>
Date: Fri, 13 Dec 2013 15:13:49 +0200 (EET)
From: "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>
To: Alex Thorlton <athorlton@....com>
Cc: linux-mm@...ck.org, Andrew Morton <akpm@...ux-foundation.org>,
"Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Rik van Riel <riel@...hat.com>,
Wanpeng Li <liwanp@...ux.vnet.ibm.com>,
Mel Gorman <mgorman@...e.de>,
Michel Lespinasse <walken@...gle.com>,
Benjamin LaHaise <bcrl@...ck.org>,
Oleg Nesterov <oleg@...hat.com>,
"Eric W. Biederman" <ebiederm@...ssion.com>,
Andy Lutomirski <luto@...capital.net>,
Al Viro <viro@...iv.linux.org.uk>,
David Rientjes <rientjes@...gle.com>,
Zhang Yanfei <zhangyanfei@...fujitsu.com>,
Peter Zijlstra <peterz@...radead.org>,
Johannes Weiner <hannes@...xchg.org>,
Michal Hocko <mhocko@...e.cz>,
Jiang Liu <jiang.liu@...wei.com>,
Cody P Schafer <cody@...ux.vnet.ibm.com>,
Glauber Costa <glommer@...allels.com>,
Kamezawa Hiroyuki <kamezawa.hiroyu@...fujitsu.com>,
Naoya Horiguchi <n-horiguchi@...jp.nec.com>,
linux-kernel@...r.kernel.org, linux-mm@...ck.org
Subject: RE: [RFC PATCH 3/3] Change THP behavior
Alex Thorlton wrote:
> + /*
> + * now that we've done the accounting work, we check to see if
> + * we've exceeded our threshold
> + */
> + if (temp_thp->ref_count >= mm->thp_threshold) {
> + pmd_t pmd_entry;
> + pgtable_t pgtable;
> +
> + /*
> + * we'll do all of the following beneath the big ptl for now
> + * this will need to be modified to work with the split ptl
> + */
> + spin_lock(&mm->page_table_lock);
> +
> + /*
> + * once we get past the lock we have to make sure that somebody
> + * else hasn't already turned this guy into a THP, if they have,
> + * then the page we need is already faulted in as part of the THP
> + * they created
> + */
> + if (PageTransHuge(temp_thp->page)) {
> + spin_unlock(&mm->page_table_lock);
> + return 0;
> + }
> +
> + pgtable = pte_alloc_one(mm, haddr);
> + if (unlikely(!pgtable)) {
> + spin_unlock(&mm->page_table_lock);
> + return VM_FAULT_OOM;
> + }
> +
> + /* might wanna move this? */
> + __SetPageUptodate(temp_thp->page);
> +
> + /* turn the pages into one compound page */
> + make_compound_page(temp_thp->page, HPAGE_PMD_ORDER);
> +
> + /* set up the pmd */
> + pmd_entry = mk_huge_pmd(temp_thp->page, vma->vm_page_prot);
> + pmd_entry = maybe_pmd_mkwrite(pmd_mkdirty(pmd_entry), vma);
> +
> + /* remap the new page since we cleared the mappings */
> + page_add_anon_rmap(temp_thp->page, vma, address);
> +
> + /* deposit the thp */
> + pgtable_trans_huge_deposit(mm, pmd, pgtable);
> +
> + set_pmd_at(mm, haddr, pmd, pmd_entry);
> + add_mm_counter(mm, MM_ANONPAGES, HPAGE_PMD_NR - mm->thp_threshold + 1);
> + /* mm->nr_ptes++; */
> +
> + /* delete the reference to this compound page from our list */
> + spin_lock(&mm->thp_list_lock);
> + list_del(&temp_thp->list);
> + spin_unlock(&mm->thp_list_lock);
> +
> + spin_unlock(&mm->page_table_lock);
> + return 0;
Hm. I think this part is not correct: you collapse temp thp page
into real one only for current procees. What will happen if a process with
temp thp pages was forked?
And I don't think this problem is an easy one. khugepaged can't collapse
pages with page->_count != 1 for the same reason: to make it properly you
need to take mmap_sem for all processes and collapse all pages at once.
And if a page is pinned, we also can't collapse.
Sorry, I don't think the whole idea has much potential. :(
--
Kirill A. Shutemov
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists