Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp125140rdb; Tue, 5 Dec 2023 00:01:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IFna4yNN9VDyDaxs4AcRSgUrg2cbMlqn9ZoSYPhoBrmdu8/zA56AAsW8Zb6vmVl/pd6Ijyn X-Received: by 2002:a05:6358:938c:b0:170:8ef:d223 with SMTP id h12-20020a056358938c00b0017008efd223mr6434826rwb.25.1701763316092; Tue, 05 Dec 2023 00:01:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701763316; cv=none; d=google.com; s=arc-20160816; b=T+1CSu4r9wJ/Q5yEai9JgsiZl/6+3jKYNGrlip/TO3hdyHVfRLZ2vib6qXgppqh2eg hg5388TRC3cVx5MqzcH0S7aE+QWyoj+dllOeYl8SEchhAWGBMgxfdFucShLUb07ThPeO Lu3JZ/ZvJiY6lrx85ddLf91bGP3P7WsjGQrV6M5md+yk8b6kmIgtsjyDOyVbrL/a3fNG NojnDAn2wRCAN/7HI+E44rLOjYv0STshQFhQu7NN2q8bAH4+dpSHNfbSJb0r5in4TbTp tSjaA8NX2ukxKg7o1fifn0bawb2lGLwgnDZl2pLdLlONKtOHDS7Va44rvgOv1QbccMlA 2i2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=YBrtDZnHhmERsGfSGwxcZ4uuPk1wFk1eYV41lFIXMNo=; fh=+AbAvQLtsvKwF6VJgHDZmQS7Y8FEvw5EhNzyjTngj3M=; b=FWLvTXsKZQx67z8t700ZzSdnwj8knK6/PTbXqs0+/7ENUsZvNQ5NbeCffLaOrIxYsx sQ4MyRY2vVWqj+o+7QVPWLbEiPRClb4JaYYaUWbgIcp+gjhJnvbZikh7bEmUQuQEJrsM UyEsvh/NKJbJWP/Q3iWnutNHNAQwIZXsRR3/tUefJhGx3jZ207vwz4/FLkY+H/k36M9x u6Pt82/kvfH+lVmiWHr9p0rk+By0kH5UB/0ugSJv4piUX5woU7L0Q5iL9Jmj0Fo9rj0t U3VuKsQd8z5Ez0pNDFrksUp171bIXDi993ouZHSuJA0xGqnKMdSnoKXiuBf2r02Zk1Fs aFbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Uy9b9I83; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id g23-20020a63fa57000000b005c218df2842si8954299pgk.900.2023.12.05.00.01.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 00:01:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Uy9b9I83; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id ED3D68095F71; Tue, 5 Dec 2023 00:01:03 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229980AbjLEIAn (ORCPT + 99 others); Tue, 5 Dec 2023 03:00:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229641AbjLEIAm (ORCPT ); Tue, 5 Dec 2023 03:00:42 -0500 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FA9283 for ; Tue, 5 Dec 2023 00:00:48 -0800 (PST) Received: by mail-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-54c77d011acso5745a12.1 for ; Tue, 05 Dec 2023 00:00:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701763247; x=1702368047; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=YBrtDZnHhmERsGfSGwxcZ4uuPk1wFk1eYV41lFIXMNo=; b=Uy9b9I83ywXItaYKX4J8cmHn+kuK5+SNHwscNxVyO1VKJTW7giMNGd3vNOYC2aez2B aSN6FTzpjzAxllhXssG3AOM/uGgrbc0aKyjc/IybLJZBlkc8ITfGrmtYjh8pv9opCc0j Ccr5RmSTzHewUbpATt3LewszcSnzbhkB/sOZEADyiz0mbfe7V1uJiJOa9maOmUPNfUBT d3x94cBC4POIiW/dN2f1jxnNnn7sWG93LLnTP1I0FGVtZWBB++YZWGBxaNvFEFus8QxE 0V7UepPuU/Zt8EsmeXw0BQhbtY5jxDCOnxjxtaIZXcPgOcWDEVKW8eIppECdK3iCFQRM rp6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701763247; x=1702368047; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YBrtDZnHhmERsGfSGwxcZ4uuPk1wFk1eYV41lFIXMNo=; b=rIwXMqp1iJw77IH0A2SsWNAUlvKxbx4BARdJtIct6OAsEiWNUuQ6VqYih8zKReflk/ pbBqIWPd1zD4gdq5flqcputdPNZJm8gzdPhmiPL7AQ4YdMZy1HWeWNMGkGJRyrkIM64n nCzp7lUi0CZ5/4rpof/nbfP8PIZhH8y5B4UYNuN+O+bzQVveu2PG/PZ0axiZ/Fd5h/Zc 4aQeS9/fTxk9Xm9vTG3GypUHBl1jU7WSNl37zyf6Dk1wEWEsNXw79fFxPlux4Iaq1Mss S0CANXs6bPTN/d8XWHRDhrzRxMtM7H3zYyX7UVk9xS21LorwfKd5OL4oRv7lYknBhsi1 27eQ== X-Gm-Message-State: AOJu0YwhZZs8PUJZoKqWJlSE79bHwFesDCd1c18ku8O0Wlr5p0a2+ONn I2NHPXhFUlM1t9sAuvwIJuIewtFOVJrzACgOaGLHOo5jlT5whRU5y5Q= X-Received: by 2002:a50:99de:0:b0:54a:ee8b:7a99 with SMTP id n30-20020a5099de000000b0054aee8b7a99mr406156edb.0.1701763246503; Tue, 05 Dec 2023 00:00:46 -0800 (PST) MIME-Version: 1.0 References: <20231201083926.1817394-1-judyhsiao@chromium.org> In-Reply-To: From: Eric Dumazet Date: Tue, 5 Dec 2023 09:00:33 +0100 Message-ID: Subject: Re: [PATCH v1] neighbour: Don't let neigh_forced_gc() disable preemption for long To: Doug Anderson Cc: Judy Hsiao , David Ahern , Simon Horman , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email 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 (morse.vger.email [0.0.0.0]); Tue, 05 Dec 2023 00:01:04 -0800 (PST) On Tue, Dec 5, 2023 at 12:40=E2=80=AFAM Doug Anderson wrote: > > Hi, > > On Fri, Dec 1, 2023 at 1:10=E2=80=AFAM Eric Dumazet = wrote: > > > > On Fri, Dec 1, 2023 at 9:39=E2=80=AFAM Judy Hsiao wrote: > > > > > > 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. > > > > This will not work in general, because this code runs with BH blocked. > > > > jiffies will stay untouched for many more ms on systems with only one C= PU. > > > > I would rather not rely on jiffies here but ktime_get_ns() [1] > > > > Also if we break the loop based on time, we might be unable to purge > > the last elements in gc_list. > > We might need to use a second list to make sure to cycle over all > > elements eventually. > > > > > > [1] > > diff --git a/net/core/neighbour.c b/net/core/neighbour.c > > index df81c1f0a57047e176b7c7e4809d2dae59ba6be5..e2340e6b07735db8cf6e75d= 23ef09bb4b0db53b4 > > 100644 > > --- a/net/core/neighbour.c > > +++ b/net/core/neighbour.c > > @@ -253,9 +253,11 @@ static int neigh_forced_gc(struct neigh_table *tbl= ) > > { > > int max_clean =3D atomic_read(&tbl->gc_entries) - > > READ_ONCE(tbl->gc_thresh2); > > + u64 tmax =3D ktime_get_ns() + NSEC_PER_MSEC; > > unsigned long tref =3D jiffies - 5 * HZ; > > struct neighbour *n, *tmp; > > int shrunk =3D 0; > > + int loop =3D 0; > > > > NEIGH_CACHE_STAT_INC(tbl, forced_gc_runs); > > > > @@ -279,10 +281,16 @@ static int neigh_forced_gc(struct neigh_table *tb= l) > > if (shrunk >=3D max_clean) > > break; > > } > > + if (++loop =3D=3D 16) { > > + if (ktime_get_ns() > tmax) > > + goto unlock; > > + loop =3D 0; > > + } > > } > > > > WRITE_ONCE(tbl->last_flush, jiffies); > > > > +unlock: > > write_unlock_bh(&tbl->lock); > > I'm curious what the plan here is. Your patch looks OK to me and I > could give it a weak Reviewed-by, but I don't know the code well > enough to know if we also need to address your second comment that we > need to "use a second list to make sure to cycle over all elements > eventually". Is that something you'd expect to get resolved before > landing? Please Judy send a V2 of the patch. I gave feedback, my intention was not to author the patch. This is standard procedure, I now realize this was Judy first contribution, sorry for not making this clear. I will simply add a "Reviewed-by: ..." tag when I agree with the result.