Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp883087rdb; Fri, 1 Dec 2023 00:39:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IGFnq5T8soydeE02iX96VEPCtM7K/QRSiYTLdf572dI7jglkYl0mm76KdFzOVgEP/rs7CvX X-Received: by 2002:a05:6a21:81a9:b0:18b:cd15:b832 with SMTP id pd41-20020a056a2181a900b0018bcd15b832mr21646426pzb.42.1701419990528; Fri, 01 Dec 2023 00:39:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701419990; cv=none; d=google.com; s=arc-20160816; b=M2ED0fWZsTkhc1t6bPvFN/NwpaCvRKof07rXzTJxTovMS2WPoeBw1y6g6CIl6xBOrx g6OFuzjRHFQA4h3zkUof7ElMCk3NvVzKez7q8RWBBRLZPr7VD2wo84vu8hUXdqJCB7a0 kCKqx2higPoqUKUJw4cfAXU5rObWYCiPy9cU9YIqf3RF2OO1jIbcP1m2PMC1rqays66H Hb2t2Db0Az61+ijiTSOa3nPkC+9F3f8mG70SApu6OPZ8LLrDYXhcxDbHSKK0+vmog5Mo wUa0/QSMhx6JDd5AXTds8JvMUYJBFHF0AJDh89X0TNC4+bHnMSS1VD8VmNGOxc5ew8gL I6Bw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=HAD/BJOp3KfcAEwToEpZAFOpfcfSAx6mao3aBhe0GVs=; fh=FYZyqATEJdlqBXPmjGMtXBxaURsE15CvO8Dd61IpEAk=; b=tD5qjcsHBhcGCFaW83VKt6iJL+L1jPFYHvgLb9X8c073IZq59YnHkTUHun+SwcaLQ1 5rzZ8DIZLTgY+7S8F1Zk74LYzA9qVSgmkEcAI1FSL8prE5c8AU2A2SyjilIv+9C9+20v kb8CaDoal75QMJqf50ZNRoWEztXc1TmxkvMdTZJKMgFnS7r8pOv3oS/EK58RIsvXpBRP UcUwBj4E/iXKN5oDnjmrXLdOO+/LnaSYBoIAE3EljxR+DZu55S7LWQnW39VG5VgU561Q iwzdLM7aZLeJ0VYMxl+4R2NiNxSvSdlFqlmf2h6EITcksWSo0yXASH1NBQeKyx8wUB7Y 26ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=fOftkOdj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id ck24-20020a056a02091800b005c5fe3ad1fdsi2969133pgb.357.2023.12.01.00.39.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 00:39:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=fOftkOdj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 602B380EA837; Fri, 1 Dec 2023 00:39:49 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229500AbjLAIjh (ORCPT + 99 others); Fri, 1 Dec 2023 03:39:37 -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-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: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 01 Dec 2023 00:39:49 -0800 (PST) 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=1000 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 = jiffies - 5 * HZ; struct neighbour *n, *tmp; int shrunk = 0; + bool finish = true; + unsigned long timeout = jiffies + msecs_to_jiffies(1); /* timeout in 1ms */ NEIGH_CACHE_STAT_INC(tbl, forced_gc_runs); @@ -278,10 +280,14 @@ static int neigh_forced_gc(struct neigh_table *tbl) shrunk++; if (shrunk >= max_clean) break; + if (time_after(jiffies, timeout)) { + finish = false; + break; + } } } - - WRITE_ONCE(tbl->last_flush, jiffies); + if (finish) + WRITE_ONCE(tbl->last_flush, jiffies); write_unlock_bh(&tbl->lock); -- 2.43.0.rc2.451.g8631bc7472-goog