From patchwork Wed Sep 26 20:57:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Soheil Hassas Yeganeh X-Patchwork-Id: 975397 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="cOQRMr5q"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42L9HC2rTKz9s3l for ; Thu, 27 Sep 2018 06:57:11 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727038AbeI0DL5 (ORCPT ); Wed, 26 Sep 2018 23:11:57 -0400 Received: from mail-qt1-f196.google.com ([209.85.160.196]:37442 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726877AbeI0DL4 (ORCPT ); Wed, 26 Sep 2018 23:11:56 -0400 Received: by mail-qt1-f196.google.com with SMTP id n6-v6so470938qtl.4 for ; Wed, 26 Sep 2018 13:57:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BBfD4E8/wVG1Eldp2zHwtm3qBcMjNCHxScBkWgoj9Hg=; b=cOQRMr5qw9ffxXBt/rNR2nxiVS//fWp3PbaYTPV8GjkzcRiU51m8i2OVR3wo6wqsPu Uq3NpSMIkJK/1HSWOr/XTV9Nwh8FPOS54ZtjDm1349WkRifg9wo0xmEeL009s0WhI93+ AcskYZQ4R9cfpV6/RLw9AUC/rwmL917a0bS5EbYta2EX9S89LEqvZuWGr9OzvyYdQRAd jNO5HzwTEE8aiNvdI+f5pNfkQCMhOH59ltMlmcAZ/pcaRp5IGbZCxcgljrq15Y+YPHUJ PjZhMRr7H7mZigzVB85OSyT8cqA4y03n5iOVoOS6GlVRU944ta3y1pcaAffoolXkkI92 g6NA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BBfD4E8/wVG1Eldp2zHwtm3qBcMjNCHxScBkWgoj9Hg=; b=lJzyQ/st8ON0KXQ8GoKVYjM7LJ7eAdyFGNjV9iFYGbUhnc+sEiF1aHnirJQvkg9XL1 euRgCzYIFeZjjHvn9iHHSkgRi9IT86jWj4gwP3gset4BJIIPWLONQzHmV2oIaKs/40HW Pg5e2zJevB6XvhxpTLDeOUmF+LSVQVEOmK8P0Crn4ofxMTHFZGWzxsGsc00bO9xGZwIa dCb6A83RuR8Fh3ntC7lW8ajpXyws4o0jxzmG3AV2zX6AdY+0Hp2cGRwSg7f1c8A51VLj aL1OYHyzadNBaOSTYbBBl+oDLw9HZ7q5/M2BQhbIMCfGLt+Ftx2jOiW+Uo/OASgFqK5h axqA== X-Gm-Message-State: ABuFfoj906iDHWLjCwzdK15pyT1aDYooyvlVZuXUQXrs1H8cYAew8LLo NkTpM5XOyjfW4x3LuyVQMLrM1+Vg X-Google-Smtp-Source: ACcGV61WVd0nYETf/RvsfpyXRVokehDW7WTCWicvVYLGMN0GsdxHz9uv/1KsKapLIso1CLEtDI5tNg== X-Received: by 2002:a0c:d48d:: with SMTP id u13-v6mr5700154qvh.165.1537995428143; Wed, 26 Sep 2018 13:57:08 -0700 (PDT) Received: from z.nyc.corp.google.com ([2620:0:1003:315:9c67:ffa0:44c0:d273]) by smtp.gmail.com with ESMTPSA id a50-v6sm20237qtc.93.2018.09.26.13.57.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Sep 2018 13:57:07 -0700 (PDT) From: Soheil Hassas Yeganeh To: davem@davemloft.net, netdev@vger.kernel.org Cc: edumazet@google.com, Soheil Hassas Yeganeh Subject: [PATCH net-next 2/2] tcp: adjust rcv zerocopy hints based on frag sizes Date: Wed, 26 Sep 2018 16:57:04 -0400 Message-Id: <20180926205704.42754-2-soheil.kdev@gmail.com> X-Mailer: git-send-email 2.19.0.605.g01d371f741-goog In-Reply-To: <20180926205704.42754-1-soheil.kdev@gmail.com> References: <20180926205704.42754-1-soheil.kdev@gmail.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Soheil Hassas Yeganeh When SKBs are coalesced, we can have SKBs with different frag sizes. Some with PAGE_SIZE and some not with PAGE_SIZE. Since recv_skip_hint is always set to the full SKB size, it can overestimate the amount that should be read using normal read for coalesced packets. Change the recv_skip_hint so that it only includes the first frags that are not of PAGE_SIZE. Signed-off-by: Soheil Hassas Yeganeh Signed-off-by: Eric Dumazet --- net/ipv4/tcp.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 3e17501fc1a1..cdbd423bdeb4 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -1805,8 +1805,17 @@ static int tcp_zerocopy_receive(struct sock *sk, frags++; } } - if (frags->size != PAGE_SIZE || frags->page_offset) + if (frags->size != PAGE_SIZE || frags->page_offset) { + int remaining = zc->recv_skip_hint; + + while (remaining && (frags->size != PAGE_SIZE || + frags->page_offset)) { + remaining -= frags->size; + frags++; + } + zc->recv_skip_hint -= remaining; break; + } ret = vm_insert_page(vma, address + length, skb_frag_page(frags)); if (ret)