From patchwork Fri Dec 13 12:06:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Capper X-Patchwork-Id: 3339851 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 E0617C0D4A for ; Fri, 13 Dec 2013 12:08:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 583C1207BF for ; Fri, 13 Dec 2013 12:08:01 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1DD7D205D8 for ; Fri, 13 Dec 2013 12:08:00 +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 1VrRWq-0003XM-K6; Fri, 13 Dec 2013 12:07:36 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VrRWj-0004Nt-Tj; Fri, 13 Dec 2013 12:07:29 +0000 Received: from mail-wg0-f52.google.com ([74.125.82.52]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VrRWU-0004M3-Iu for linux-arm-kernel@lists.infradead.org; Fri, 13 Dec 2013 12:07:16 +0000 Received: by mail-wg0-f52.google.com with SMTP id x13so1777735wgg.7 for ; Fri, 13 Dec 2013 04:06:53 -0800 (PST) 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=MnC4Bx4j/QbKMHn+YpT5jYGXJlP2l9dBIYOVka7bQIw=; b=RGz5R9vloy21dWTLk66A9KitUl1TWCfVcBRCgcev6VBoavvRMg3iW/lYyW20YaB/PT eJE6MCurgYrHMj6RlWmtIPGKpOoNSfosTpARJEOxAS7oLVcAxQRQm6qPMX3bF6cB6Hwl 8VLQAyhiKRukCbk4V2F46bf69tZbUaOly5xRnmJj3VSFOZs4FH9jjX/oBvXweyf9CsYs rEhOeT5qBTsK1ZX/axVkgYJOANeosWfOghNeRoEFvQ53MvYmZhu9cqv/CxbZkNa6AQUv DvFC/hBtP5uZLmMp17XN9yzHBUYK8X7kYZLmNLhVeoYh2pqq4iMUh3vf0wKpFqtckneF JnmA== X-Gm-Message-State: ALoCoQmgOxnsz7tWoqCZVmI5zJm4I1RfNM6NlIDXimX/WYrcHzvE4YkIRp0oguQmbJ3nUrLmReqp X-Received: by 10.180.83.1 with SMTP id m1mr2224009wiy.9.1386936412941; Fri, 13 Dec 2013 04:06:52 -0800 (PST) Received: from marmot.wormnet.eu (marmot.wormnet.eu. [188.246.204.87]) by mx.google.com with ESMTPSA id d2sm6644929wik.11.2013.12.13.04.06.51 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Dec 2013 04:06:52 -0800 (PST) From: Steve Capper To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/2] arm: cacheflush: Fix user split-caching logic Date: Fri, 13 Dec 2013 12:06:31 +0000 Message-Id: <1386936391-30493-3-git-send-email-steve.capper@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1386936391-30493-1-git-send-email-steve.capper@linaro.org> References: <1386936391-30493-1-git-send-email-steve.capper@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131213_070714_727475_55E40CA9 X-CRM114-Status: GOOD ( 11.26 ) X-Spam-Score: -2.6 (--) Cc: will.deacon@arm.com, patches@linaro.org, linux@arm.linux.org.uk, Steve Capper , catalin.marinas@arm.com 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.2 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 The user split-caching logic in __do_cache_op divides the area to be flushed into interruptable chunks of size PAGE_SIZE. Unfortunately, there is no check to see whether or not the range to be flushed is smaller than the chunk size. This can result cache flushes for larger ranges than intended, which can result in the flush failing with a -EFAULT. I've observed slowdown and failure with the icache-hygiene test from libhugetlbfs. This patch fixes the problem by replacing chunk with the minimum of PAGE_SIZE or (end - start), thus we do not overflush. Signed-off-by: Steve Capper --- arch/arm/kernel/traps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c index 8fcda14..5d3c455 100644 --- a/arch/arm/kernel/traps.c +++ b/arch/arm/kernel/traps.c @@ -503,7 +503,7 @@ static inline int __do_cache_op(unsigned long start, unsigned long end) { int ret; - unsigned long chunk = PAGE_SIZE; + unsigned long chunk = min(end - start, PAGE_SIZE); do { if (signal_pending(current)) {