From patchwork Mon Oct 28 16:20:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 3103191 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 0DFA2BF924 for ; Mon, 28 Oct 2013 16:21:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5ECDD20149 for ; Mon, 28 Oct 2013 16:21:27 +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 183082012E for ; Mon, 28 Oct 2013 16:21:26 +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 1VapZ0-0007I8-1h; Mon, 28 Oct 2013 16:21:10 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VapYq-0001p7-90; Mon, 28 Oct 2013 16:21:00 +0000 Received: from mail-pd0-f179.google.com ([209.85.192.179]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VapYm-0001oM-PS for linux-arm-kernel@lists.infradead.org; Mon, 28 Oct 2013 16:20:57 +0000 Received: by mail-pd0-f179.google.com with SMTP id y10so7289159pdj.38 for ; Mon, 28 Oct 2013 09:20:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=from:to:cc:subject:date:message-id; bh=y9S7Q+0U+0OkdqEFb8wnhEqZV+ZNY/sf2Yd7cl6Cq2w=; b=JX5T/2KKyoq2W8B2/00HluzoyviDnoJkvdAxwrZh31dUx6isqDXQlCG3vR0opwdo6n 5fVvemqLfotr49yNMnJxbisgJIzFwEyAmXnZVHAz+dcLFz8BatwJhAI5TGBrTJXVmh0y +/PtTIKbkq5Psxb4ym/2gDA6c4adZ0BNnBOkv1eRFGEIX+R8sxLcG+yyx76thUtwxkQG mynz0zbx1b4jWCUJgS/CxIFkSy3HrNDaMyeRoqyMXXCrKb+slLew/wu59SOt4OqJpI4G UEywkmiI/5cKxr94rzLS0hvy+bME61ErwkVmv2fan2DH+ZyVtT43tj8DqmBpDzBW21OV P4Tg== X-Received: by 10.66.149.231 with SMTP id ud7mr26751604pab.8.1382977229291; Mon, 28 Oct 2013 09:20:29 -0700 (PDT) Received: from localhost ([14.155.87.20]) by mx.google.com with ESMTPSA id go4sm29536142pbb.15.2013.10.28.09.20.23 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 28 Oct 2013 09:20:28 -0700 (PDT) From: Ming Lei To: linux-kernel@vger.kernel.org, Andrew Morton Subject: [PATCH] lib/scatterlist.c: don't flush_kernel_dcache_page on slab page Date: Tue, 29 Oct 2013 00:20:05 +0800 Message-Id: <1382977205-26268-1-git-send-email-ming.lei@canonical.com> X-Mailer: git-send-email 1.7.9.5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131028_122056_918098_3840514B X-CRM114-Status: GOOD ( 15.37 ) X-Spam-Score: -1.9 (-) Cc: Jens Axboe , Russell King - ARM Linux , Simon Baatz , Aaro Koskinen , Catalin Marinas , Ming Lei , Will Deacon , "James E.J. Bottomley" , FUJITA Tomonori , Tejun Heo , 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: , 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.7 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 Commit b1adaf65ba03([SCSI] block: add sg buffer copy helper functions) introduces two sg buffer copy helpers, and calls flush_kernel_dcache_page() on pages in SG list after these pages are written to. Unfortunately, the commit may introduce a potential bug: - Before sending some SCSI commands, kmalloc() buffer may be passed to block layper, so flush_kernel_dcache_page() can see a slab page finally - According to cachetlb.txt, flush_kernel_dcache_page() is only called on "a user page", which surely can't be a slab page. - ARCH's implementation of flush_kernel_dcache_page() may use page mapping information to do optimization so page_mapping() will see the slab page, then VM_BUG_ON() is triggered. Aaro Koskinen reported the bug on ARM/kirkwood when DEBUG_VM is enabled, and this patch fixes the bug by adding test of '!PageSlab(miter->page)' before calling flush_kernel_dcache_page(). Reported-by: Aaro Koskinen Cc: Russell King - ARM Linux Cc: linux-arm-kernel@lists.infradead.org Cc: Simon Baatz Cc: Will Deacon Cc: Aaro Koskinen Cc: Catalin Marinas Cc: Andrew Morton Cc: FUJITA Tomonori Cc: Tejun Heo Cc: "James E.J. Bottomley" Cc: Jens Axboe Signed-off-by: Ming Lei Acked-by: Catalin Marinas Tested-by: Simon Baatz --- lib/scatterlist.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/scatterlist.c b/lib/scatterlist.c index a685c8a..d16fa29 100644 --- a/lib/scatterlist.c +++ b/lib/scatterlist.c @@ -577,7 +577,8 @@ void sg_miter_stop(struct sg_mapping_iter *miter) miter->__offset += miter->consumed; miter->__remaining -= miter->consumed; - if (miter->__flags & SG_MITER_TO_SG) + if ((miter->__flags & SG_MITER_TO_SG) && + !PageSlab(miter->page)) flush_kernel_dcache_page(miter->page); if (miter->__flags & SG_MITER_ATOMIC) {