From patchwork Wed Oct 19 08:26:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4682 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp212955wrs; Wed, 19 Oct 2022 02:08:47 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4oM6Ma7BcVC9WyKGk1xT9p4i/ENrX25r477VKIAlcG3jvU86w+Au1sevxhOFYzaDnf9qci X-Received: by 2002:a17:907:1608:b0:78e:1e21:6359 with SMTP id hb8-20020a170907160800b0078e1e216359mr6019230ejc.205.1666170527208; Wed, 19 Oct 2022 02:08:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666170527; cv=none; d=google.com; s=arc-20160816; b=LoJv8bDJtacQro1+PhdkWglsx73yvSJSv/SiJqAYVdqX+7QfshQsGSaU0eDBSI6wQZ E2RNcJkq1CrdjSr6kbRrw4r5Kq6OB/QySOaSjCS/k5lWH7Tj3FPmNHlUg/2znAWu18s/ GqEXFtCXET5MHHUX1wJFNeyFkAt//KfZVTVqMjFCcMCDeyU8s8rYMy80RXVe6EVwb3oE Uq71+z8e8dESkgZw67qilgvpuqm7Y5R65K2oLcqI9UF9OyMGtyjZE++6dTIAan0Nd8+Z HDLG9O2VywbhWu/dUZUkmy75V8r7JJ27h5ezQhwodQJnw+PxuUup5dBrG0zMsJFVr1tt LLFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Aek2K1xDgbBqfusdY1vSbvzwGgMJbQPVLV54V1rGFQM=; b=mb3p7Z/ir/HvF1d4SYLjRm3Np2VfEB9edIOhlSWJ1Zg8UnljWdjzo/9/TA4pEKFT0W 3UmnqdYGvtz5ZomOtv2LpLXhCKuICrlOB7scDxOgGTAmHuObhdOqj4c4z3rSWHfpOSw1 gj+weSgLe1OxCEJYtj56ihh86LXXmjNO+yvXr/wSg8FX40FMLoOcI+EJx6hECeBhfI/l 8w/HggkElNZdhC8ELdafwz5rWJezX85l0u/QW/k68oEnUb+Hn8KN6100jKS2xtBH7AGh BGNDHVl9pRvIVFtD9rzDq4f/yI8Ny5KXF2WYXJKRAj0Ctvm8U/uVL4WJOO3D4XKR9HQM /q/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2QEqDLnK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lv10-20020a170906bc8a00b00775326fb2ebsi12271254ejb.665.2022.10.19.02.08.13; Wed, 19 Oct 2022 02:08:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2QEqDLnK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232300AbiJSJDO (ORCPT + 99 others); Wed, 19 Oct 2022 05:03:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232089AbiJSJCT (ORCPT ); Wed, 19 Oct 2022 05:02:19 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12A0163F16; Wed, 19 Oct 2022 01:56:01 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 134766182C; Wed, 19 Oct 2022 08:51:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1DF6AC43470; Wed, 19 Oct 2022 08:51:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666169506; bh=ctfW1jwWyZwvrZn7RrkuwyfiafKfZcdHmUmoCiCw6cA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2QEqDLnKD2pj8N1cIuuKPnct5bGZNQhuOFRZdLg5MQJ025whklPMHVoDmPJZ5Kq6i 7USfRVD0s3TYzafJW56jbtZ+xpH6onz8kwyKVlNmsxUzAC1YaRsxWhNNz/HxbbH4Wm m0ir77HUUrOO5aBU8Lpmh9JP0At3WJJejW8rBzgM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Florian Westphal , Antoine Tenart , Sasha Levin Subject: [PATCH 6.0 301/862] netfilter: conntrack: revisit the gc initial rescheduling bias Date: Wed, 19 Oct 2022 10:26:28 +0200 Message-Id: <20221019083303.305878707@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747106426567728162?= X-GMAIL-MSGID: =?utf-8?q?1747106426567728162?= From: Antoine Tenart [ Upstream commit 2aa192757005f130b2dd3547dda6e462e761199f ] The previous commit changed the way the rescheduling delay is computed which has a side effect: the bias is now represented as much as the other entries in the rescheduling delay which makes the logic to kick in only with very large sets, as the initial interval is very large (INT_MAX). Revisit the GC initial bias to allow more frequent GC for smaller sets while still avoiding wakeups when a machine is mostly idle. We're moving from a large initial value to pretending we have 100 entries expiring at the upper bound. This way only a few entries having a small timeout won't impact much the rescheduling delay and non-idle machines will have enough entries to lower the delay when needed. This also improves readability as the initial bias is now linked to what is computed instead of being an arbitrary large value. Fixes: 2cfadb761d3d ("netfilter: conntrack: revisit gc autotuning") Suggested-by: Florian Westphal Signed-off-by: Antoine Tenart Signed-off-by: Florian Westphal Signed-off-by: Sasha Levin --- net/netfilter/nf_conntrack_core.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c index 2e6d5f1e6d63..8f261cd5b3a5 100644 --- a/net/netfilter/nf_conntrack_core.c +++ b/net/netfilter/nf_conntrack_core.c @@ -86,10 +86,12 @@ static DEFINE_MUTEX(nf_conntrack_mutex); /* clamp timeouts to this value (TCP unacked) */ #define GC_SCAN_INTERVAL_CLAMP (300ul * HZ) -/* large initial bias so that we don't scan often just because we have - * three entries with a 1s timeout. +/* Initial bias pretending we have 100 entries at the upper bound so we don't + * wakeup often just because we have three entries with a 1s timeout while still + * allowing non-idle machines to wakeup more often when needed. */ -#define GC_SCAN_INTERVAL_INIT INT_MAX +#define GC_SCAN_INITIAL_COUNT 100 +#define GC_SCAN_INTERVAL_INIT GC_SCAN_INTERVAL_MAX #define GC_SCAN_MAX_DURATION msecs_to_jiffies(10) #define GC_SCAN_EXPIRED_MAX (64000u / HZ) @@ -1477,7 +1479,7 @@ static void gc_worker(struct work_struct *work) if (i == 0) { gc_work->avg_timeout = GC_SCAN_INTERVAL_INIT; - gc_work->count = 1; + gc_work->count = GC_SCAN_INITIAL_COUNT; gc_work->start_time = start_time; }