From nobody Mon Dec 29 02:49:03 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C423C4167B for ; Fri, 1 Dec 2023 08:39:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377901AbjLAIjj (ORCPT ); Fri, 1 Dec 2023 03:39:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377878AbjLAIjd (ORCPT ); Fri, 1 Dec 2023 03:39:33 -0500 Received: from mail-oo1-xc32.google.com (mail-oo1-xc32.google.com [IPv6:2607:f8b0:4864:20::c32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 027DE1713 for ; Fri, 1 Dec 2023 00:39:40 -0800 (PST) Received: by mail-oo1-xc32.google.com with SMTP id 006d021491bc7-58d956c8c38so1047523eaf.2 for ; Fri, 01 Dec 2023 00:39:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1701419979; x=1702024779; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=HAD/BJOp3KfcAEwToEpZAFOpfcfSAx6mao3aBhe0GVs=; b=fOftkOdjSW3o0FXm6twOtVVAn04q2GIaFHpMitI+XsVqySe/WDltjjm4EpHmV6/6Vs MquYTSl8iG2kG5MJx119L/+ri8Lc1IlMUvfj4Aham58cEwbR/fwJREtIcl5GNf4VH+Vy rz1OEz9YYevRQ6pzDkWEi0G7eG/ffF7+SeTz0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701419979; x=1702024779; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=HAD/BJOp3KfcAEwToEpZAFOpfcfSAx6mao3aBhe0GVs=; b=V/0u2js1thNBTfvl5KNAj92WhKpq+rd2gyGDIEttC9SgNmXyrvMyLQCpwbUMXnAHUx V08slpg3iKcGYKS/3YjSRT/WZBe35hwlReWKXwk8yL2Xk3qFaEolVIKtpFwb5ebIgCT9 22hAomSxvGv0+fhGnJ1mnPyo5sNL/8OxgIYGmI+ApHYdY3Q1f9Bh3HzxAQuAWub+AduM F/WDtaa/IRt5/sqXuXCIf9Q/brz6L28kic0Qc2Nj8mji2ykoQW5F3hFzz2ZLmrJP9Ehu 2mmgWh78N6eJrJ1KdP4Ch4+Er5Pz4kv4MCx5K0pwYOebBjzUkRhA+n2ZLr7nb52y31b4 NrRg== X-Gm-Message-State: AOJu0Yy6e6/eBLLXNxo0iE8hPOqeiYkACIxAPILbI0oa3jEHigqBERKB KniQMMGUVo2NV4EjyObEuMxeOA== X-Google-Smtp-Source: AGHT+IFRIZi1t3+6sB5l+ZFlRb5IEgTuJyz64lMyM/xKkArWyB7tZ0RcUsK3ZoDsk1o6uNy6C/voyA== X-Received: by 2002:a05:6358:3a0e:b0:16d:d643:4800 with SMTP id g14-20020a0563583a0e00b0016dd6434800mr25665290rwe.21.1701419979280; Fri, 01 Dec 2023 00:39:39 -0800 (PST) Received: from judyhsiao0523.c.googlers.com.com (148.175.199.104.bc.googleusercontent.com. [104.199.175.148]) by smtp.gmail.com with ESMTPSA id hy7-20020a056a006a0700b0068790c41ca2sm2500089pfb.27.2023.12.01.00.39.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 00:39:38 -0800 (PST) From: Judy Hsiao To: Eric Dumazet , David Ahern , Simon Horman Cc: Douglas Anderson , Judy Hsiao , Brian Haley , "David S. Miller" , Jakub Kicinski , Joel Granados , Julian Anastasov , Leon Romanovsky , Luis Chamberlain , Paolo Abeni , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v1] neighbour: Don't let neigh_forced_gc() disable preemption for long Date: Fri, 1 Dec 2023 08:39:03 +0000 Message-ID: <20231201083926.1817394-1-judyhsiao@chromium.org> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" We are seeing cases where neigh_cleanup_and_release() is called by neigh_forced_gc() many times in a row with preemption turned off. When running on a low powered CPU at a low CPU frequency, this has been measured to keep preemption off for ~10 ms. That's not great on a system with HZ=3D1000 which expects tasks to be able to schedule in with ~1ms latency. Suggested-by: Douglas Anderson Signed-off-by: Judy Hsiao --- net/core/neighbour.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/net/core/neighbour.c b/net/core/neighbour.c index df81c1f0a570..f7a89c7a7673 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c @@ -256,6 +256,8 @@ static int neigh_forced_gc(struct neigh_table *tbl) unsigned long tref =3D jiffies - 5 * HZ; struct neighbour *n, *tmp; int shrunk =3D 0; + bool finish =3D true; + unsigned long timeout =3D jiffies + msecs_to_jiffies(1); /* timeou= t in 1ms */ =20 NEIGH_CACHE_STAT_INC(tbl, forced_gc_runs); =20 @@ -278,10 +280,14 @@ static int neigh_forced_gc(struct neigh_table *tbl) shrunk++; if (shrunk >=3D max_clean) break; + if (time_after(jiffies, timeout)) { + finish =3D false; + break; + } } } - - WRITE_ONCE(tbl->last_flush, jiffies); + if (finish) + WRITE_ONCE(tbl->last_flush, jiffies); =20 write_unlock_bh(&tbl->lock); =20 --=20 2.43.0.rc2.451.g8631bc7472-goog