Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1169841
| Path | csiph.com!aioe.org!bofh.it!news.nic.it!robomod |
|---|---|
| From | "Kirill A. Shutemov" <kirill@shutemov.name> |
| Newsgroups | linux.kernel |
| Subject | Re: [PATCHv6 29/36] thp: implement split_huge_pmd() |
| Date | Mon, 22 Jun 2015 13:20:02 +0200 |
| Message-ID | <pE7VE-22X-3@gated-at.bofh.it> (permalink) |
| References | <pxkkW-7sr-9@gated-at.bofh.it> <pxkuD-7Ey-33@gated-at.bofh.it> <pA7rd-1YG-23@gated-at.bofh.it> |
| X-Original-To | Vlastimil Babka <vbabka@suse.cz> |
| Razorgate-Kas | Rate: 5 |
| Razorgate-Kas | {RECEIVED: dynamic ip detected} |
| Razorgate-Kas | Envelope from: |
| Razorgate-Kas | Version: 5.5.3 |
| Razorgate-Kas | LuaCore: 215 2015-05-29_17-31-22 60ae4a1b4d01d14f868b20a55aced8d7df7b2e28 |
| Razorgate-Kas | Method: none |
| Razorgate-Kas | Lua profiles 78662 [Jun 02 2015] |
| Razorgate-Kas | Status: not_detected |
| Dkim-Signature | v=1; a=rsa-sha256; c=simple/simple; d=shutemov.name; s=default; t=1434971674; bh=ChyG827U5aau2mZaalzU7IptO9FndxBHYF1DcG9QZ2w=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=jdtupYSTlPoH0YpOPPB8MGFtpfEcKsuCAiNui/tEVqBLBfRSsEDDCH/AtCekZQUVc 9XgCkxELdqNYgKpvPUTyyLO0zDAgwXdiKbNJr03qqPfakGluJqqhID5Uxd6+n1HSxv HHi8QED5S4aKnTEyTfsI453k1mfXshcnVh5mXZpU= |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Content-Disposition | inline |
| User-Agent | Mutt/1.5.23.1 (2014-03-12) |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 89 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>, Andrew Morton <akpm@linux-foundation.org>, Andrea Arcangeli <aarcange@redhat.com>, Hugh Dickins <hughd@google.com>, Dave Hansen <dave.hansen@intel.com>, Mel Gorman <mgorman@suse.de>, Rik van Riel <riel@redhat.com>, Christoph Lameter <cl@gentwo.org>, Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>, Steve Capper <steve.capper@linaro.org>, "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>, Johannes Weiner <hannes@cmpxchg.org>, Michal Hocko <mhocko@suse.cz>, Jerome Marchand <jmarchan@redhat.com>, Sasha Levin <sasha.levin@oracle.com>, linux-kernel@vger.kernel.org, linux-mm@kvack.org |
| X-Original-Date | Mon, 22 Jun 2015 14:14:34 +0300 |
| X-Original-Message-ID | <20150622111434.GC7934@node.dhcp.inet.fi> |
| X-Original-References | <1433351167-125878-1-git-send-email-kirill.shutemov@linux.intel.com> <1433351167-125878-30-git-send-email-kirill.shutemov@linux.intel.com> <557959BC.5000303@suse.cz> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | aioe.org linux.kernel:1169841 |
Show key headers only | View raw
On Thu, Jun 11, 2015 at 11:49:48AM +0200, Vlastimil Babka wrote:
> On 06/03/2015 07:06 PM, Kirill A. Shutemov wrote:
> >Original split_huge_page() combined two operations: splitting PMDs into
> >tables of PTEs and splitting underlying compound page. This patch
> >implements split_huge_pmd() which split given PMD without splitting
> >other PMDs this page mapped with or underlying compound page.
> >
> >Without tail page refcounting, implementation of split_huge_pmd() is
> >pretty straight-forward.
> >
> >Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> >Tested-by: Sasha Levin <sasha.levin@oracle.com>
>
> [...]
>
> >+
> >+ if (atomic_add_negative(-1, compound_mapcount_ptr(page))) {
> >+ /* Last compound_mapcount is gone. */
> >+ __dec_zone_page_state(page, NR_ANON_TRANSPARENT_HUGEPAGES);
> >+ if (PageDoubleMap(page)) {
> >+ /* No need in mapcount reference anymore */
> >+ ClearPageDoubleMap(page);
> >+ for (i = 0; i < HPAGE_PMD_NR; i++)
> >+ atomic_dec(&page[i]._mapcount);
> >+ }
> >+ } else if (!TestSetPageDoubleMap(page)) {
> >+ /*
> >+ * The first PMD split for the compound page and we still
> >+ * have other PMD mapping of the page: bump _mapcount in
> >+ * every small page.
> >+ * This reference will go away with last compound_mapcount.
> >+ */
> >+ for (i = 0; i < HPAGE_PMD_NR; i++)
> >+ atomic_inc(&page[i]._mapcount);
>
> The order of actions here means that between TestSetPageDoubleMap() and the
> atomic incs, anyone calling page_mapcount() on one of the pages not
> processed by the for loop yet, will see a value lower by 1 from what he
> should see. I wonder if that can cause any trouble somewhere, especially if
> there's only one other compound mapping and page_mapcount() will return 0
> instead of 1?
Good catch. Thanks.
What about this?
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 0f1f5731a893..cd0e6addb662 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -2636,15 +2636,25 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd,
for (i = 0; i < HPAGE_PMD_NR; i++)
atomic_dec(&page[i]._mapcount);
}
- } else if (!TestSetPageDoubleMap(page)) {
+ } else if (!PageDoubleMap(page)) {
/*
* The first PMD split for the compound page and we still
* have other PMD mapping of the page: bump _mapcount in
* every small page.
+ *
* This reference will go away with last compound_mapcount.
+ *
+ * Note, we need to increment mapcounts before setting
+ * PG_double_map to avoid false-negative page_mapped().
*/
for (i = 0; i < HPAGE_PMD_NR; i++)
atomic_inc(&page[i]._mapcount);
+
+ if (TestSetPageDoubleMap(page)) {
+ /* Race with another __split_huge_pmd() for the page */
+ for (i = 0; i < HPAGE_PMD_NR; i++)
+ atomic_dec(&page[i]._mapcount);
+ }
}
smp_wmb(); /* make pte visible before pmd */
> Conversely, when clearing PageDoubleMap() above (or in one of those rmap
> functions IIRC), one could see mapcount inflated by one. But I guess that's
> less dangerous.
I think it's safe.
--
Kirill A. Shutemov
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
Re: [PATCHv6 29/36] thp: implement split_huge_pmd() Vlastimil Babka <vbabka@suse.cz> - 2015-06-11 12:00 +0200 Re: [PATCHv6 29/36] thp: implement split_huge_pmd() "Kirill A. Shutemov" <kirill@shutemov.name> - 2015-06-22 13:20 +0200
csiph-web