From patchwork Sun Oct 27 13:53:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Russell King - ARM Linux X-Patchwork-Id: 3099421 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 07AD69F432 for ; Sun, 27 Oct 2013 13:54:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DF8F520259 for ; Sun, 27 Oct 2013 13:54: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 E767920233 for ; Sun, 27 Oct 2013 13:54:49 +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 1VaQnc-0008HP-7G; Sun, 27 Oct 2013 13:54: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 1VaQnZ-0007rd-Lb; Sun, 27 Oct 2013 13:54:33 +0000 Received: from [2002:4e20:1eda::1] (helo=caramon.arm.linux.org.uk) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VaQnX-0007qG-TM for linux-arm-kernel@lists.infradead.org; Sun, 27 Oct 2013 13:54:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=arm.linux.org.uk; s=caramon; h=Sender:In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=bzdjsJVsxO7ZbSFJkOsjob8jY9m+L1+Ag2CstliSGUk=; b=XPbsIpxeie1QvYdPkb6VjsRMCqMAlvmy/Ytsdr4xk4G/WxsUFiN3d7WTxyduKX5/o/vT7x0QFOXFD++h0GpXjWe+BrMaLZbb2Vdtf3ZMUwHctuYXcpnga0Xxak3Dy1bwx4UQh4az4uKFA3FnUcPeGUqvtg7/yujCVIHtapXsnZQ=; Received: from n2100.arm.linux.org.uk ([2002:4e20:1eda:1:214:fdff:fe10:4f86]:50521) by caramon.arm.linux.org.uk with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.76) (envelope-from ) id 1VaQmo-0003h2-BE; Sun, 27 Oct 2013 13:53:46 +0000 Received: from linux by n2100.arm.linux.org.uk with local (Exim 4.76) (envelope-from ) id 1VaQmm-0007e4-PR; Sun, 27 Oct 2013 13:53:44 +0000 Date: Sun, 27 Oct 2013 13:53:44 +0000 From: Russell King - ARM Linux To: Ming Lei Subject: Re: ARM/kirkwood: v3.12-rc6: kernel BUG at mm/util.c:390! Message-ID: <20131027135344.GD16735@n2100.arm.linux.org.uk> References: <20131024200730.GB17447@blackmetal.musicnaut.iki.fi> <20131026143617.GA14034@mudshark.cambridge.arm.com> <20131027195115.208f40f3@tom-ThinkPad-T410> <20131027125036.GJ17447@blackmetal.musicnaut.iki.fi> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.19 (2009-01-05) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131027_095432_392564_B0E20E42 X-CRM114-Status: GOOD ( 23.75 ) X-Spam-Score: -1.0 (-) Cc: Jens Axboe , Simon Baatz , Aaro Koskinen , Catalin Marinas , Will Deacon , "linux-kernel@vger.kernel.org" , "James E.J. Bottomley" , FUJITA Tomonori , "linux-mm@kvack.org" , Tejun Heo , Andrew Morton , "linux-arm-kernel@lists.infradead.org" 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: , 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,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,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 On Sun, Oct 27, 2013 at 09:16:53PM +0800, Ming Lei wrote: > On Sun, Oct 27, 2013 at 8:50 PM, Aaro Koskinen wrote: > > > > On ARM v3.9 or older kernels do not trigger this BUG, at seems it only > > started to appear with the following commit (bisected): > > > > commit 1bc39742aab09248169ef9d3727c9def3528b3f3 > > Author: Simon Baatz > > Date: Mon Jun 10 21:10:12 2013 +0100 > > > > ARM: 7755/1: handle user space mapped pages in flush_kernel_dcache_page > > The above commit only starts to implement the helper on ARM, > but according to Documentation/cachetlb.txt, looks caller of > flush_kernel_dcache_page() should make sure the passed > 'page' is a user space page. I think your terminology is off. flush_kernel_dcache_page() is passed a struct page. These exist for every physical RAM page in the system which is under the control of the kernel. There's no such thing as a "user space page" - pages are shared from kernel space into userspace. Secondly, flush_kernel_dcache_page() gets used on such pages whether or not they're already mapped into userspace (normally they won't be if this is the first read of the page.) This function is only expected to deal with kernel-side addresses of the page, ensuring that data in the page is visible to the underlying memory. The last thing to realise is that we already have a function which deals with the presence of userspace mappings. It's called flush_dcache_page(). If flush_kernel_dcache_page() had to make that decision, then there's no point in flush_kernel_dcache_page() existing - we might as well just call flush_dcache_page() directly. So... flush_kernel_dcache_page() is expected to take a struct page pointer. This struct page pointer is part of the kernel's array of struct pages which identifies every single physical page under the control of the kernel. Arguably, it should not crash if passed a page which has been allocated to the slab cache; as this is not a page cache page, flush_kernel_dcache_page() should merely ignore the call to it and simply return on these. So this makes total sense: arch/arm/mm/flush.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/arch/arm/mm/flush.c b/arch/arm/mm/flush.c index 6d5ba9afb16a..eebb275a67fb 100644 --- a/arch/arm/mm/flush.c +++ b/arch/arm/mm/flush.c @@ -316,6 +316,10 @@ EXPORT_SYMBOL(flush_dcache_page); */ void flush_kernel_dcache_page(struct page *page) { + /* Ignore slab pages */ + if (PageSlab(page)) + return; + if (cache_is_vivt() || cache_is_vipt_aliasing()) { struct address_space *mapping;