From patchwork Mon Oct 24 11:28:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9309 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp464969wru; Mon, 24 Oct 2022 06:51:37 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5j082jqSO1u4xIg73i8U2yrMgKjgfkXdExAsdDy3WRYX3hMtvLSafmMkIi35eRtZ+pKzvF X-Received: by 2002:a65:6c08:0:b0:448:c216:fe9 with SMTP id y8-20020a656c08000000b00448c2160fe9mr27823157pgu.243.1666619497558; Mon, 24 Oct 2022 06:51:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666619497; cv=none; d=google.com; s=arc-20160816; b=0Vvd9OG4lvSVrU0u96x0gPyWVEIzWlCqQ3BwlWFw+kNUAdnfCtERPvG8WIxZdQ3Hp5 NR4U3ux22j5VdOvP0PHB36NF3ohWgaWXaSdDkm7sPhSBuBKHv38VgrNfgj9YsIETnYXg 3sX9M3v43SNpG2u3C1xDl9eEIJ9hi0SFO1fVaLTgdUMfsQ4LK2/NvZHiSxXTe66vlpje dPF0mUmu8+fsE94cBt45os2qybruGJEh4ODZUnjxwuI68+0Z5B6RUsQFBBOGiMAch3f2 YssmTFjr9jR/avXWnKK9nvMR5P8cvtRB1fg7YWS461Hbd0oYSu+zQOk/A8LrYKDpEaIc 128A== 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=v2a5F85zzmTig2ZkHZ7t9JwSHOjKi2T5RWrR/bEeO+4=; b=m8f4N6ihlCgb2Yps7IZc0ZbSw4Bqg4T5qQ//4UJyauLmrAQy/BxZe6KQEsGpn84hAU T7yw0x1ZmSVa9Pw7RGPNjXJKAxwRotmdv1gGQ1wy5bdOxGazPkH+JDCUOSOQt8z6rFon sMXfz+pKhAXNlAaz2MrJUT+s5jR5/t614a8fE8yury7Dmh5iqE3m6GFeZh0UoppPPuge XNfVcjiXEzrat5BbT+PgSACNMr2VTBhknuGUlWgGEsOYnuN3PukBHmDreCO8BT18H3Wq eDqBVcLtHb46wT6lHxN5Tqrc3kUIavkxZwPZ/ZJFixkyVvbSvZqX/RFw2e42/pQMXnCu buOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pndMdStq; 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 a145-20020a621a97000000b00555463cd9e6si33366043pfa.238.2022.10.24.06.51.24; Mon, 24 Oct 2022 06:51:37 -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=pndMdStq; 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 S236505AbiJXNuc (ORCPT + 99 others); Mon, 24 Oct 2022 09:50:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236606AbiJXNtS (ORCPT ); Mon, 24 Oct 2022 09:49:18 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B437B7F5C; Mon, 24 Oct 2022 05:41:32 -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 9029161337; Mon, 24 Oct 2022 12:40:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A6421C433D7; Mon, 24 Oct 2022 12:40:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666615259; bh=FbcxVwY/7eJdCs1CnPnHTjWAkBq5YTLaLO4bfjHS09k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pndMdStqkin35F4vM8Nxfv+5ICupSf1yXackU6ou4VA7jKRYatEP8EsxdyBQ/Wc30 TB0Gu4OziYtNlUTLC64zCt9e5MS0r7aEI2gATkFjel5Wj+kNyGHEw4MeJwntsxDGuU riaa+Rf8V8BU79FH8E+eLOoZeDkiGuXtQdAePdaY= 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 5.15 182/530] netfilter: conntrack: revisit the gc initial rescheduling bias Date: Mon, 24 Oct 2022 13:28:46 +0200 Message-Id: <20221024113053.266428760@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113044.976326639@linuxfoundation.org> References: <20221024113044.976326639@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 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?1747577206666701502?= X-GMAIL-MSGID: =?utf-8?q?1747577206666701502?= 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 ee72da164190..9da5ee6c50cd 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) @@ -1450,7 +1452,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; }