Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3334566yba; Mon, 6 May 2019 22:41:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqzwNeJBSdNqmj4t+H+vTKjbZwf47f5+q3pOfVbW9kFwwLdhiKLbSpSM3sEvIWxH7DOU6LIJ X-Received: by 2002:a63:5012:: with SMTP id e18mr37058150pgb.383.1557207674839; Mon, 06 May 2019 22:41:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557207674; cv=none; d=google.com; s=arc-20160816; b=QlGyQu1cfhYKhd0zRqqk9tNTWE2zRF9qcFQcGPOBhkhOrb49yDtOZ+21xscFWt3tuM bjhYjXifddVkfQCQDzz88HNbWhVpHtQO4taXCDnigLvABie0EwNy7uFJ2LxMHq/ENOb2 w6fB/ua60yUqbIrl2QKFdOFO1VcpvKxPWZ2QxWLOFLHjatqibyMKbB6fI0kM56fucouk UzBI0e5CsPdG84EJaSE8bdHoxRbAHLQQ+WzEzXGRU3ycisSf009//bmuU2E21fJuk+QP BeeJ17bv2Zf3FcwwjPJ8K/aWPkaCxbWlHL6Pe8CuBuXU4K3uageGuG4AhQosj7tWRsk1 Lb0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3nTpeZyN+a3ILhiijXek5vHh6nPlUnfPAB0lNufPlLo=; b=0f+vJSylJ1+GZVN0WKSWcPBL2y7zpFB/kNbdjbBUOJpzfjE7T1a+UIxhdoKbHT76rj Yfktw/S2Bd7YKAEpJ7FpOncviCgAGBT7U8q7p+btqedVlIMshGhoeqJ+lkHjYNJtxD7H nGhJdpGWEiheLZYhdCQvaoJHqUJD8V2h02TAXYbE7gDC+LkWccNzY26QJxLHooFj3Rl0 WHfLgYshKPa0kIYm5OaRk4fnURGUexHC8b4xWGfo6Xj9YagxfdZhDMcsGv8kGaFl0KC2 4Cit9/ThD5RBIylP1L2leHR7HpdNPJjbn7Gf31oTBkFJ1kqiLHpcP6wtV//4tnDYknWr Y62w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uGXqd2G1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 61si19721994plr.51.2019.05.06.22.40.59; Mon, 06 May 2019 22:41:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uGXqd2G1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729041AbfEGFkN (ORCPT + 99 others); Tue, 7 May 2019 01:40:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:59652 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728701AbfEGFkK (ORCPT ); Tue, 7 May 2019 01:40:10 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3E046216F4; Tue, 7 May 2019 05:40:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557207609; bh=4w0e8AD+YQReA0xEyQUoCPG8YS56+1X4TPCsy+T+eMs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uGXqd2G1U40BHQjE6pMLY0txI6RrL91LbuzJpvXrBbi7JoMC71684NeFOjHSA6la3 L5VXuAl+/ckU8x9I0kN2Wr3Ts1elnQDcEhPFwbxmk8diwGc31LicA3/XVX5bTbPOFB hcLpsBIlN1TCnoQMFDD5CfkXknrEHw1XEdRGcX0c= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Paolo Abeni , Eric Dumazet , Willem de Bruijn , Eric Dumazet , "David S . Miller" , Sasha Levin , netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.14 53/95] net: don't keep lonely packets forever in the gro hash Date: Tue, 7 May 2019 01:37:42 -0400 Message-Id: <20190507053826.31622-53-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190507053826.31622-1-sashal@kernel.org> References: <20190507053826.31622-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Paolo Abeni [ Upstream commit 605108acfe6233b72e2f803aa1cb59a2af3001ca ] Eric noted that with UDP GRO and NAPI timeout, we could keep a single UDP packet inside the GRO hash forever, if the related NAPI instance calls napi_gro_complete() at an higher frequency than the NAPI timeout. Willem noted that even TCP packets could be trapped there, till the next retransmission. This patch tries to address the issue, flushing the old packets - those with a NAPI_GRO_CB age before the current jiffy - before scheduling the NAPI timeout. The rationale is that such a timeout should be well below a jiffy and we are not flushing packets eligible for sane GRO. v1 -> v2: - clarified the commit message and comment RFC -> v1: - added 'Fixes tags', cleaned-up the wording. Reported-by: Eric Dumazet Fixes: 3b47d30396ba ("net: gro: add a per device gro flush timer") Signed-off-by: Paolo Abeni Acked-by: Willem de Bruijn Acked-by: Eric Dumazet Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/core/dev.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/net/core/dev.c b/net/core/dev.c index 93a1b07990b8..90ec30d5b851 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -5308,11 +5308,14 @@ bool napi_complete_done(struct napi_struct *n, int work_done) if (work_done) timeout = n->dev->gro_flush_timeout; + /* When the NAPI instance uses a timeout and keeps postponing + * it, we need to bound somehow the time packets are kept in + * the GRO layer + */ + napi_gro_flush(n, !!timeout); if (timeout) hrtimer_start(&n->timer, ns_to_ktime(timeout), HRTIMER_MODE_REL_PINNED); - else - napi_gro_flush(n, false); } if (unlikely(!list_empty(&n->poll_list))) { /* If n->poll_list is not empty, we need to mask irqs */ -- 2.20.1