From patchwork Fri Oct 18 13:07:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Capper X-Patchwork-Id: 3066561 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id DB9C7BF925 for ; Fri, 18 Oct 2013 13:08:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BF03B204E0 for ; Fri, 18 Oct 2013 13:08:50 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EF69D20461 for ; Fri, 18 Oct 2013 13:08:45 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VX9mz-0004aB-Kd; Fri, 18 Oct 2013 13:08:25 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VX9mq-0002Q5-RA; Fri, 18 Oct 2013 13:08:16 +0000 Received: from mail-wg0-f41.google.com ([74.125.82.41]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VX9mb-0002NC-FF for linux-arm-kernel@lists.infradead.org; Fri, 18 Oct 2013 13:08:02 +0000 Received: by mail-wg0-f41.google.com with SMTP id b13so2045617wgh.2 for ; Fri, 18 Oct 2013 06:07:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=a55hPtfSTBIMQBknhdw13fc2gSRQ/nctjHnzi0pSHBo=; b=CNGd24egrxlgbrk23oWN2JM7a3JGH2WKcjy3Iq5pbEfEYBUpbxrNJW1VAlcaRsSE3P LKJk10MOb+AGxWQf35Z7ymbPWd8gElSt52OngQo1opN63/8Y92/yId9/ELcK0eYqvD3g NMmsz5YunS/I3BuWUFtlHnG+XHcv4bactw9HEILi8Ol2ZgTVaYy+SuHVXgfZ1W7NAWd3 XLfS96WHYbbOpv//Kf6v3wvifMu3yxL6jaNzdMCJui8kDJJ2MiD3fbP5FeanL9HYE7Jz hXdsOZ+p68vX6EOTgP05tO+2WgTDnSCEr+uw23RY2lSEXhVYxPa3t6OzzVNCG3f8EmK3 zgoA== X-Gm-Message-State: ALoCoQnDEkprdtRW+pRChqDGQAE98jazZpwLp5AB4UFy5nVpoiUgAp6DbrmHe/Q1WlCKnJvBk4M+ X-Received: by 10.180.210.243 with SMTP id mx19mr2789188wic.35.1382101656097; Fri, 18 Oct 2013 06:07:36 -0700 (PDT) Received: from marmot.wormnet.eu (marmot.wormnet.eu. [188.246.204.87]) by mx.google.com with ESMTPSA id b13sm26895389wic.9.2013.10.18.06.07.35 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Oct 2013 06:07:35 -0700 (PDT) From: Steve Capper To: linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org Subject: [RFC PATCH 1/2] thp: Introduce arch_(un)block_thp_split Date: Fri, 18 Oct 2013 14:07:12 +0100 Message-Id: <1382101634-4723-2-git-send-email-steve.capper@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1382101634-4723-1-git-send-email-steve.capper@linaro.org> References: <1382101634-4723-1-git-send-email-steve.capper@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131018_090801_644917_D62C1629 X-CRM114-Status: GOOD ( 12.49 ) X-Spam-Score: -2.6 (--) Cc: Andrea Arcangeli , Zi Shen Lim , Russell King , patches@linaro.org, Will Deacon , linaro-kernel@lists.linaro.org, Steve Capper , Christoffer Dall X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In kernel/futex.c an assumption is made in the THP tail pinning code that disabling the irqs is sufficient to block the THP splitting code from completing. Architectures such as ARM do hardware TLB broadcasts so disabling the irqs will not prevent a THP split from completing. This patch introduces: arch_block_thp_split and arch_unblock_thp_split, and provides stock implementations that observe the original irq enable and disable behaviour. One can then define these macros themselves to implement architecture specific behaviour. Signed-off-by: Steve Capper --- include/linux/huge_mm.h | 16 ++++++++++++++++ kernel/futex.c | 6 +++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index 3935428..35fb742 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -177,6 +177,14 @@ static inline struct page *compound_trans_head(struct page *page) extern int do_huge_pmd_numa_page(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long addr, pmd_t pmd, pmd_t *pmdp); +#ifndef arch_block_thp_split +#define arch_block_thp_split(mm) local_irq_disable() +#endif + +#ifndef arch_unblock_thp_split +#define arch_unblock_thp_split(mm) local_irq_enable() +#endif + #else /* CONFIG_TRANSPARENT_HUGEPAGE */ #define HPAGE_PMD_SHIFT ({ BUILD_BUG(); 0; }) #define HPAGE_PMD_MASK ({ BUILD_BUG(); 0; }) @@ -227,6 +235,14 @@ static inline int do_huge_pmd_numa_page(struct mm_struct *mm, struct vm_area_str return 0; } +#ifndef arch_block_thp_split +#define arch_block_thp_split(mm) do { } while (0) +#endif + +#ifndef arch_unblock_thp_split +#define arch_unblock_thp_split(mm) do { } while (0) +#endif + #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ #endif /* _LINUX_HUGE_MM_H */ diff --git a/kernel/futex.c b/kernel/futex.c index c3a1a55..e016ff2 100644 --- a/kernel/futex.c +++ b/kernel/futex.c @@ -287,7 +287,7 @@ again: if (unlikely(PageTail(page))) { put_page(page); /* serialize against __split_huge_page_splitting() */ - local_irq_disable(); + arch_block_thp_split(mm); if (likely(__get_user_pages_fast(address, 1, 1, &page) == 1)) { page_head = compound_head(page); /* @@ -304,9 +304,9 @@ again: get_page(page_head); put_page(page); } - local_irq_enable(); + arch_unblock_thp_split(mm); } else { - local_irq_enable(); + arch_unblock_thp_split(mm); goto again; } }