Re: Kernel falls apart under light memory pressure (i.e. linking vmlinux)

From: Minchan Kim
Date: Fri May 20 2011 - 01:36:20 EST


On Fri, May 20, 2011 at 2:08 PM, KAMEZAWA Hiroyuki
<kamezawa.hiroyu@xxxxxxxxxxxxxx> wrote:
> On Fri, 20 May 2011 13:20:15 +0900
> Minchan Kim <minchan.kim@xxxxxxxxx> wrote:
>
>> So I want to resolve your problem asap.
>> We don't have see report about that. Could you do git-bisect?
>> FYI, Recently, big change of mm is compaction,transparent huge pages.
>> Kame, could you point out thing related to memcg if you have a mind?
>>
>
> I don't doubt memcg at this stage because it never modify page->flags.
> Consdering the case, PageActive() is set against off-LRU pages after
> clear_active_flags() clears it.
>
> Hmm, I think I don't understand the lock system fully but...how do you
> think this ?
>
> ==
>
> At splitting a hugepage, the routine marks all pmd as "splitting".
>
> But assume a racy case where 2 threads run into spit at the
> same time, one thread wins compound_lock() and do split, another
> thread should not touch splitted pages.

Sorry. Now I don't have a time to review in detail.
When I look it roughly, page_lock_anon_vma have to prevent it.
But Andrea needs current this problem and he will catch something we lost. :)


>
> Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx>
> Index: mmotm-May11/mm/huge_memory.c
> ===================================================================
> --- mmotm-May11.orig/mm/huge_memory.c
> +++ mmotm-May11/mm/huge_memory.c
> @@ -1150,7 +1150,7 @@ static int __split_huge_page_splitting(s
> Â Â Â Âreturn ret;
> Â}
>
> -static void __split_huge_page_refcount(struct page *page)
> +static bool __split_huge_page_refcount(struct page *page)
> Â{
> Â Â Â Âint i;
> Â Â Â Âunsigned long head_index = page->index;
> @@ -1161,6 +1161,11 @@ static void __split_huge_page_refcount(s
> Â Â Â Âspin_lock_irq(&zone->lru_lock);
> Â Â Â Âcompound_lock(page);
>
> + Â Â Â if (!PageCompound(page)) {
> + Â Â Â Â Â Â Â compound_unlock(page);
> + Â Â Â Â Â Â Â spin_unlock_irq(&zone->lru_lock);
> + Â Â Â Â Â Â Â return false;
> + Â Â Â }
> Â Â Â Âfor (i = 1; i < HPAGE_PMD_NR; i++) {
> Â Â Â Â Â Â Â Âstruct page *page_tail = page + i;
>
> @@ -1258,6 +1263,7 @@ static void __split_huge_page_refcount(s
> Â Â Â Â * to be pinned by the caller.
> Â Â Â Â */
> Â Â Â ÂBUG_ON(page_count(page) <= 0);
> + Â Â Â return true;
> Â}
>
> Âstatic int __split_huge_page_map(struct page *page,
> @@ -1367,7 +1373,8 @@ static void __split_huge_page(struct pag
> Â Â Â Â Â Â Â Â Â Â Â mapcount, page_mapcount(page));
> Â Â Â ÂBUG_ON(mapcount != page_mapcount(page));
>
> - Â Â Â __split_huge_page_refcount(page);
> + Â Â Â if (!__split_huge_page_refcount(page))
> + Â Â Â Â Â Â Â return;
>
> Â Â Â Âmapcount2 = 0;
> Â Â Â Âlist_for_each_entry(avc, &anon_vma->head, same_anon_vma) {
>
>



--
Kind regards,
Minchan Kim
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/