From patchwork Wed Sep 26 20:57:03 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: 975396 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="bJDIfrMC"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42L9HB4bvDz9s3Z for ; Thu, 27 Sep 2018 06:57:10 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726968AbeI0DLz (ORCPT ); Wed, 26 Sep 2018 23:11:55 -0400 Received: from mail-qt1-f193.google.com ([209.85.160.193]:40821 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726848AbeI0DLz (ORCPT ); Wed, 26 Sep 2018 23:11:55 -0400 Received: by mail-qt1-f193.google.com with SMTP id e9-v6so447848qtp.7 for ; Wed, 26 Sep 2018 13:57:07 -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:mime-version :content-transfer-encoding; bh=DYMzdWpD4qsWMyOkYW5wkKcZpow7CG7sby7vB1Y3Fyo=; b=bJDIfrMCw9jy94fhOuqtk6RZzgukL0S137p1yuf0EMWcn45Ahyj4n8hxzMb+AVPVnq deXrUmQlodNur9ne9hizBs5Yvtw9YCqjGuTOKMG/ePavm1Q7O91bjnhw6SsTGpV2t1XR vJ9u2G1ufVr6fKxUmoxVsRKzHb2yxP0Dd1tMFq5b18Yd6MJBvYZft0E+4iLJyaO/6C3Q Sn5BsDL2NqfDihM3WiX0xPz73WWHbr8Ei/Y2ELU+p282Pc/QlivlC2ZCS5m/+76JZyNK qnrG1Sd2ITc4jV6+3AROHiQFHAfhGaIa42fC9RfuDhxNsvoznFW8Gt9S9l44dhObmxER 78hA== 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:mime-version :content-transfer-encoding; bh=DYMzdWpD4qsWMyOkYW5wkKcZpow7CG7sby7vB1Y3Fyo=; b=r+SodEgsnJipQgfAYAxvRf6zXIoO39Tq/OfuIlOEo/FbWsd5qItPjrvEZ7v1KMmbes iQMvdqzu4famj5XfysDB8olpajp4HMGTsQGIUu3q2xjUnIw8CwQdgeUaF43Kkk1iFJPB 1ejS9h8ADluq9om0s4xLvDi2cillpBHdA4IXMIGE1DPfFQa7Ti1ukgCKuj3PtKOSOIBv c/jp08cM/IUM1XqZbDwI7bVbM1rcCHRd33a/T0n1tJeuPj2p5BDP+Ag7A1oQ79A5QUhW xzV3DUOfLI+MqUgfsjyZB4klKu6UnkwGo5Gh4u2Hz4NDVLiqszKNFzcYkEJ28RgVQUp5 5Fsw== X-Gm-Message-State: ABuFfoj/dAhawyuUFl2YnbiJRcprAe4W3zZnzIQu1WtFBeVfDLldLqhR 9zWc6IoJGLnHJp00D57MygGgDnt7 X-Google-Smtp-Source: ACcGV60jXy3vBs/j21VWp7YHr5fxmo9lJ91P3xqNUnHNSr10EGgCV9ud1t5Db4VHUcsWmHPKQ5C3gw== X-Received: by 2002:a0c:98cf:: with SMTP id g15-v6mr1839813qvd.178.1537995427549; Wed, 26 Sep 2018 13:57:07 -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.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Sep 2018 13:57:06 -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 1/2] tcp: set recv_skip_hint when tcp_inq is less than PAGE_SIZE Date: Wed, 26 Sep 2018 16:57:03 -0400 Message-Id: <20180926205704.42754-1-soheil.kdev@gmail.com> X-Mailer: git-send-email 2.19.0.605.g01d371f741-goog 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 we have less than PAGE_SIZE of data on receive queue, we set recv_skip_hint to 0. Instead, set it to the actual number of bytes available. Signed-off-by: Soheil Hassas Yeganeh Signed-off-by: Eric Dumazet --- net/ipv4/tcp.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 69c236943f56..3e17501fc1a1 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -1753,6 +1753,7 @@ static int tcp_zerocopy_receive(struct sock *sk, struct vm_area_struct *vma; struct sk_buff *skb = NULL; struct tcp_sock *tp; + int inq; int ret; if (address & (PAGE_SIZE - 1) || address != zc->address) @@ -1773,12 +1774,15 @@ static int tcp_zerocopy_receive(struct sock *sk, tp = tcp_sk(sk); seq = tp->copied_seq; - zc->length = min_t(u32, zc->length, tcp_inq(sk)); + inq = tcp_inq(sk); + zc->length = min_t(u32, zc->length, inq); zc->length &= ~(PAGE_SIZE - 1); - - zap_page_range(vma, address, zc->length); - - zc->recv_skip_hint = 0; + if (zc->length) { + zap_page_range(vma, address, zc->length); + zc->recv_skip_hint = 0; + } else { + zc->recv_skip_hint = inq; + } ret = 0; while (length + PAGE_SIZE <= zc->length) { if (zc->recv_skip_hint < PAGE_SIZE) { 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)