From patchwork Sun Jan 6 07:31:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 209729 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id C043B2C007E for ; Sun, 6 Jan 2013 18:31:25 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750987Ab3AFHbX (ORCPT ); Sun, 6 Jan 2013 02:31:23 -0500 Received: from mail-pa0-f54.google.com ([209.85.220.54]:49498 "EHLO mail-pa0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750780Ab3AFHbV (ORCPT ); Sun, 6 Jan 2013 02:31:21 -0500 Received: by mail-pa0-f54.google.com with SMTP id bi5so10029278pad.13 for ; Sat, 05 Jan 2013 23:31:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:subject:from:to:cc:in-reply-to:references:content-type :date:message-id:mime-version:x-mailer:content-transfer-encoding; bh=V8hCWgmODGQU2mdwKGUWMkSjvUZILGk+SqrtpogziPA=; b=jBzyCseBueNsmOopETI08edl273pszVBPDO8Su7vAd+sKaZ4Z9Z4rXWMRAw8gYz5Ch DWT+jceC3nFpB9OyZpYZy1vllJ/0RtaJ4MADXGUCK/x6KAx5E6IyeLmfRnWVEIGOv0Cu /wQ9mlDd5MyvSCZ7q1ZHe13fKtM0iK821t03/USRr3JGtVaTMCpsg0hwU7k68coK2uhz BqhhCA/OSwU6UqcCLs6bjvVuhWYKJUUIMGaUDoELPQJiKDAfgyWBQ8MsCtcmuE/YvOz3 6feT0WjfVfIuDmdqDh32rGB3ZjFcCi24XwIQA+ixW0rIGGTOUptmMWsBgliqxWtSqZk7 pSlg== X-Received: by 10.68.247.39 with SMTP id yb7mr178949084pbc.15.1357457481414; Sat, 05 Jan 2013 23:31:21 -0800 (PST) Received: from [172.26.54.35] ([172.26.54.35]) by mx.google.com with ESMTPS id oi3sm35391665pbb.1.2013.01.05.23.31.19 (version=SSLv3 cipher=OTHER); Sat, 05 Jan 2013 23:31:20 -0800 (PST) Subject: [PATCH net-next] net: splice: avoid high order page splitting From: Eric Dumazet To: Willy Tarreau , David Miller Cc: netdev@vger.kernel.org In-Reply-To: <20130106025256.GY16031@1wt.eu> References: <20130105214958.GA19814@1wt.eu> <1357427926.1678.4771.camel@edumazet-glaptop> <20130105232913.GQ16031@1wt.eu> <1357430523.1678.4901.camel@edumazet-glaptop> <20130106005053.GS16031@1wt.eu> <1357435276.1678.5067.camel@edumazet-glaptop> <20130106013027.GV16031@1wt.eu> <1357436430.1678.5111.camel@edumazet-glaptop> <1357437086.1678.5135.camel@edumazet-glaptop> <1357438591.1678.5205.camel@edumazet-glaptop> <20130106025256.GY16031@1wt.eu> Date: Sat, 05 Jan 2013 23:31:18 -0800 Message-ID: <1357457478.1678.5928.camel@edumazet-glaptop> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Eric Dumazet splice() can handle pages of any order, but network code tries hard to split them in PAGE_SIZE units. Not quite successfully anyway, as __splice_segment() assumed poff < PAGE_SIZE. This is true for the skb->data part, not necessarily for the fragments. This patch removes this logic to give the pages as they are in the skb. Signed-off-by: Eric Dumazet Cc: Willy Tarreau --- net/core/skbuff.c | 38 +++++++++----------------------------- 1 file changed, 9 insertions(+), 29 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/core/skbuff.c b/net/core/skbuff.c index bc96100..b03fc0c 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -1707,20 +1707,6 @@ static bool spd_fill_page(struct splice_pipe_desc *spd, return false; } -static inline void __segment_seek(struct page **page, unsigned int *poff, - unsigned int *plen, unsigned int off) -{ - unsigned long n; - - *poff += off; - n = *poff / PAGE_SIZE; - if (n) - *page = nth_page(*page, n); - - *poff = *poff % PAGE_SIZE; - *plen -= off; -} - static bool __splice_segment(struct page *page, unsigned int poff, unsigned int plen, unsigned int *off, unsigned int *len, struct sk_buff *skb, @@ -1728,6 +1714,8 @@ static bool __splice_segment(struct page *page, unsigned int poff, struct sock *sk, struct pipe_inode_info *pipe) { + unsigned int flen; + if (!*len) return true; @@ -1738,24 +1726,16 @@ static bool __splice_segment(struct page *page, unsigned int poff, } /* ignore any bits we already processed */ - if (*off) { - __segment_seek(&page, &poff, &plen, *off); - *off = 0; - } - - do { - unsigned int flen = min(*len, plen); + poff += *off; + plen -= *off; + *off = 0; - /* the linear region may spread across several pages */ - flen = min_t(unsigned int, flen, PAGE_SIZE - poff); + flen = min(*len, plen); - if (spd_fill_page(spd, pipe, page, &flen, poff, skb, linear, sk)) - return true; - - __segment_seek(&page, &poff, &plen, flen); - *len -= flen; + if (spd_fill_page(spd, pipe, page, &flen, poff, skb, linear, sk)) + return true; - } while (*len && plen); + *len -= flen; return false; }