Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp1137146rdb; Fri, 1 Dec 2023 07:58:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IGR5f1s2haT7UrCOd5fTetZSNY3B/m5tglUBPgaQvj+2IqjUUY4wj9JJFHVmxwcePZnOHbO X-Received: by 2002:a05:6a20:1605:b0:18b:f90d:9d84 with SMTP id l5-20020a056a20160500b0018bf90d9d84mr34138677pzj.54.1701446327689; Fri, 01 Dec 2023 07:58:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701446327; cv=none; d=google.com; s=arc-20160816; b=lNmyFViJYPoWdYtNxfjNBib8y+hzj3TjKdYZUmytxnpXcQdchYVHq1xc+N/Q9BMlmq 3CQ6RZi6gCx1Plg+3joRP/pFbv23xE5chFKOwEVjZNAXlBattQUdyfuAJAhT5C4xFgCk YNkuOzxi8YR55BGW01U5oTPV3dyGKQmn+ZZW8ZoQixb9alv6dJQ9+BpYRztwyTccOeKn hYOk22ojIW8spvlnAZzmuf/CNbCSBveZjpAx4VYFTLjhdA2DcMixGZ25eKfmwJ1EZfho 76pdfmHpMBamE3TWBJdsLr+qmDbEaZuW4x4SQx+O3VE8TnMN0nOGevLV1taMa0uRiIRI 0/bQ== 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=s4XTRLCjQNY4AaZPgLHYq/6hjlTc5C/AJGeUvs9n7yQ=; fh=+AbAvQLtsvKwF6VJgHDZmQS7Y8FEvw5EhNzyjTngj3M=; b=vhekGIuLp4dxEAW8om+UULKQRcZxxplGrr4iH9lvTufB9PxV/7m3ugLnwrLlgxQN1f hqgGhksnj0xZ2ofL52+we2uSn9QP6jHrIIESxK5BGACZzdTuCJqGXEnv7O5ZHRuHeCdk wC//nYpZXAnNFZa9G1UenKwJztO7mpAmW6wdAInt7S2qUDSJkCaCk0hxIn7eKYdRFA1C JH5hfA9Sf7/ch0r1oiZUqrLJMvIW4PJGpsPEYDd2zYbSIf1MpA6qX8EVHLlaunO6pmVx 6HM9cwoUi/sH/wi2SdJozhMQo7OsW4HG9Dzajw46hRd6FMq8VkJeckso7/QdQFLUluOH mjGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=EutDptHi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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. [23.128.96.31]) by mx.google.com with ESMTPS id 127-20020a630985000000b005bd3ca6c398si3496162pgj.736.2023.12.01.07.58.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 07:58:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=EutDptHi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 29B4783797C0; Fri, 1 Dec 2023 07:58:45 -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 S229977AbjLAP6c (ORCPT + 99 others); Fri, 1 Dec 2023 10:58:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229674AbjLAP6b (ORCPT ); Fri, 1 Dec 2023 10:58:31 -0500 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D7B810DB for ; Fri, 1 Dec 2023 07:58:37 -0800 (PST) Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-54c69c61b58so4236a12.1 for ; Fri, 01 Dec 2023 07:58:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701446315; x=1702051115; 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=s4XTRLCjQNY4AaZPgLHYq/6hjlTc5C/AJGeUvs9n7yQ=; b=EutDptHiUw9rM5JuCY25WabPBKiHNyPj2O8tbnWZTfTULbh5vz19L9UJegjVgsyfFk cnKJvb6nZkgmUV/rwAMaUGJpGZd5hX+RNq71upD92ZX8d39R15O/ERxAo+csVA1cHGWe h0OnMhCRHTvVMVwlq58HGZcvhgh8dXO/L845Y5SGYxAnrGLYg1wa32vEFvVYHLTDwi74 DcqSouehddDVIVFPWQvFQpRD9HoV23wB/cSE+MA+OPlrc3s+nkEMeoP6qN9tABLvpLY8 q+dQtyl+0cpur+BJ78wT1WjMlm2YoK1B1qdFMTR9sk7jDFwd7ZhDtm4Ji3Pgeq2EcIM+ c4xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701446315; x=1702051115; 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=s4XTRLCjQNY4AaZPgLHYq/6hjlTc5C/AJGeUvs9n7yQ=; b=PkuBhbdD/Doqc/1HTyxJ5tQe+JIne2xPwCCaGnx71rqciXx2Ucwwn//45N+3wF3P5A NXJwb4BF3tD7eIBO5YmS3RnQn7eCwQggEnuuFH7ue1d9D6EzUGdhvQCq0u3CGwLj402I q9KI1NpAd5VNusg9LNnol1ZU67VTYoMhFBDOfBHwE6fuK7sD85yMhmkgIqNXAI4/pM37 jDDTqKJSLFs++xMg9dbDgIS8hNJ9S4UNZI7rpYdk+9S7X8vO5GUaNY4+ylL/9vf9MavM qISSmQc4M40S+bCTtSjw23CxMtjAo21JY+gES/mTOqNZMEDUFccTcayK/HhrnK8JhRyY Y7Nw== X-Gm-Message-State: AOJu0YyeoSV+Rnz4vNe0A8BwIUeHA30vL91bu9F5/qK7jslKhBJ+wSJW akK14THyBz0CEMTdeTj1wng3KrNyMa/U9N58xvMA2A== X-Received: by 2002:a50:d49c:0:b0:543:fb17:1a8 with SMTP id s28-20020a50d49c000000b00543fb1701a8mr83421edi.3.1701446315174; Fri, 01 Dec 2023 07:58:35 -0800 (PST) MIME-Version: 1.0 References: <20231201083926.1817394-1-judyhsiao@chromium.org> In-Reply-To: From: Eric Dumazet Date: Fri, 1 Dec 2023 16:58:21 +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]); Fri, 01 Dec 2023 07:58:45 -0800 (PST) On Fri, Dec 1, 2023 at 4:16=E2=80=AFPM 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; > > It might be nice to make the above timeout based on jiffies. On a > HZ=3D100 system it's probably OK to keep preemption disabled for 10 ms > but on a HZ=3D1000 system you'd want 1 ms. ...so maybe you'd want to use > jiffies_to_nsecs(1)? I do not think so. 10ms would be awfully long. We have nsec based time service, why downgrading to jiffies resolution ??? > > One worry might be that we disabled preemption _right before_ we were > supposed to be scheduled out. In that case we'll end up blocking some > other task for another full timeslice, but maybe there's not a lot we > can do there? Can you tell us in which scenario this gc_list can be so big, other than fuzzers ?