From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932233AbcBZKdC (ORCPT ); Fri, 26 Feb 2016 05:33:02 -0500 Received: from mail-wm0-f53.google.com ([74.125.82.53]:37447 "EHLO mail-wm0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751350AbcBZKc5 (ORCPT ); Fri, 26 Feb 2016 05:32:57 -0500 Date: Fri, 26 Feb 2016 13:32:53 +0300 From: "Kirill A. Shutemov" To: Andrea Arcangeli Cc: Mel Gorman , Andrew Morton , Vlastimil Babka , Rik van Riel , Johannes Weiner , Linux-MM , LKML Subject: Re: [PATCH 1/1] mm: thp: Redefine default THP defrag behaviour disable it by default Message-ID: <20160226103253.GA22450@node.shutemov.name> References: <1456420339-29709-1-git-send-email-mgorman@techsingularity.net> <20160225190144.GE1180@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160225190144.GE1180@redhat.com> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 25, 2016 at 08:01:44PM +0100, Andrea Arcangeli wrote: > Another problem is that khugepaged isn't able to collapse shared > readonly anon pages, mostly because of the rmap complexities. I agree > with Kirill we should be looking into how make this work, although I > doubt the simpler refcounting is going to help much in this regard as > the problem is in dealing with rmap, not so much with refcounts. Could you elaborate on problems with rmap? I have looked into this deeply yet. Do you see anything what would prevent following basic scheme: - Identify series of small pages as candidate for collapsing into a compound page. Not sure how difficult it would be. I guess it can be done by looking for adjacent pages which belong to the same anon_vma. - Setup migration entries for pte which maps these pages. - Collapse small pages into compound page. IIUC, it only will be possible if these pages are not pinned. - Replace migration entries with ptes which point to subpages of the new compound page. - Scan over all vmas mapping this compound page, looking for VMA suitable for huge page. We cannot collapse it right away due lock inversion of anon_vma->rwsem vs. mmap_sem. - For found VMAs, collapse page table into PMD one VMA a time under down_write(mmap_sem). Even if would fail to create any PMDs, we would reduce LRU pressure by collapsing small pages into compound one. -- Kirill A. Shutemov