From patchwork Tue Sep 9 18:22:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rafael Aquini X-Patchwork-Id: 4872241 Return-Path: X-Original-To: patchwork-dmaengine@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 33A3EC0338 for ; Tue, 9 Sep 2014 18:22:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5A65B2015D for ; Tue, 9 Sep 2014 18:22:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 45A822013D for ; Tue, 9 Sep 2014 18:22:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751177AbaIISWx (ORCPT ); Tue, 9 Sep 2014 14:22:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41887 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750852AbaIISWx (ORCPT ); Tue, 9 Sep 2014 14:22:53 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s89IMpFl007716 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 9 Sep 2014 14:22:52 -0400 Received: from t510.redhat.com (ovpn-113-65.phx2.redhat.com [10.3.113.65]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s89IMmZm006144; Tue, 9 Sep 2014 14:22:49 -0400 From: Rafael Aquini To: linux-kernel@vger.kernel.org Cc: Vinod Koul , Dan Williams , dmaengine@vger.kernel.org, jstancek@redhat.com, jburke@redhat.com, jsnitsel@redhat.com, jbenc@redhat.com, davem@redhat.com Subject: [PATCH] dma: iovlock: avoid dma_pin_iovec_pages() causing page allocator warns on order >= MAX_ORDER Date: Tue, 9 Sep 2014 14:22:38 -0400 Message-Id: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Spam-Status: No, score=-9.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 dma_pin_iovec_pages() eventually causes the page allocator to stumble across it warning case when a request for contigous mem block gets order >= MAX_ORDER. trinity(11230): Randomness reseeded to 0xaf76756f trinity: trinity(11230) Randomness reseeded to 0xaf76756f [ 7442.617160] ------------[ cut here ]------------ [ 7442.621890] WARNING: at mm/page_alloc.c:2410 __alloc_pages_nodemask+0x346/0xa00() ... [ 7442.797088] Call Trace: [ 7442.799614] [] dump_stack+0x19/0x1b [ 7442.804860] [] warn_slowpath_common+0x61/0x80 [ 7442.810944] [] warn_slowpath_null+0x1a/0x20 [ 7442.816858] [] __alloc_pages_nodemask+0x346/0xa00 [ 7442.823294] [] alloc_pages_current+0xa9/0x170 [ 7442.829364] [] __get_free_pages+0xe/0x50 [ 7442.835009] [] kmalloc_order_trace+0x2e/0xa0 [ 7442.841005] [] __kmalloc+0x219/0x230 [ 7442.846284] [] dma_pin_iovec_pages+0x9b/0x240 [ 7442.852323] [] tcp_recvmsg+0x888/0xd10 ... dma_pin_iovec_pages() is actually being used for an unique callsite within tcp_recvmsg() which falls back to skb_copy_datagram_iovec() if the first routine fails to pin a DMA buffer for the iovec. The splatted calltrace is more scary than other thing, so lets just prevent it from getting out to the wild world. This patch also does a minor code style surgery on the surrounding hunk. Signed-off-by: Rafael Aquini --- drivers/dma/iovlock.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/dma/iovlock.c b/drivers/dma/iovlock.c index bb48a57..4cb8379 100644 --- a/drivers/dma/iovlock.c +++ b/drivers/dma/iovlock.c @@ -69,9 +69,10 @@ struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len) } while (iovec_len_used < len); /* single kmalloc for pinned list, page_list[], and the page arrays */ - local_list = kmalloc(sizeof(*local_list) - + (nr_iovecs * sizeof (struct dma_page_list)) - + (iovec_pages_used * sizeof (struct page*)), GFP_KERNEL); + local_list = kmalloc(sizeof(*local_list) + + (nr_iovecs * sizeof(struct dma_page_list)) + + (iovec_pages_used * sizeof(struct page *)), + GFP_KERNEL | __GFP_NOWARN); if (!local_list) goto out;