From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E330E364B2 for ; Wed, 6 Dec 2023 17:51:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="iDHqvkco" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4514C433C8; Wed, 6 Dec 2023 17:51:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701885110; bh=YMA3TAsSiUul57FlmdTimYbCUDIjWoEz6/pHObLXG7Q=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=iDHqvkcoAXQo1mrhbAIkDpwA0Pez0mmJTk0fEIJi2jFFE6O/CGvrguCIeT8PEIa/6 hzI6RV7iU6NxKEuLQzhac8mPU/xN3wdnoPElZSxiF5jARVzMB7do7e/hVTztB2wsx0 GaW5Va9v5AeLvvrHH6w/yA84FOGsWxXbVRFfeA18OuYkh4e2u7gYRWvKCaOIDY0fbO qT9Dur0ozn6JuwNDUZpOaFB48PvVrA1LTIa1hnTQZ5XpIcnsI+5HdNvNyoREXrkgK8 EHGDgEO6WH1SSzU3Xq7zAhLu9xawZgXsSxXnGWvIwWKN7LO2Kgu9AkwK4wXlgdGbD9 MX4sfAL5N7Tfg== Message-ID: Date: Wed, 6 Dec 2023 10:51:49 -0700 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] neighbour: Don't let neigh_forced_gc() disable preemption for long Content-Language: en-US To: Stephen Hemminger , Judy Hsiao Cc: Eric Dumazet , Simon Horman , Douglas Anderson , Brian Haley , "David S. Miller" , Jakub Kicinski , Joel Granados , Julian Anastasov , Leon Romanovsky , Paolo Abeni , linux-kernel@vger.kernel.org, netdev@vger.kernel.org References: <20231206033913.1290566-1-judyhsiao@chromium.org> <20231206093917.04fd57b5@hermes.local> From: David Ahern In-Reply-To: <20231206093917.04fd57b5@hermes.local> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 12/6/23 10:39 AM, Stephen Hemminger wrote: > On Wed, 6 Dec 2023 03:38:33 +0000 > Judy Hsiao wrote: > >> diff --git a/net/core/neighbour.c b/net/core/neighbour.c >> index df81c1f0a570..552719c3bbc3 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 = atomic_read(&tbl->gc_entries) - >> READ_ONCE(tbl->gc_thresh2); >> + u64 tmax = ktime_get_ns() + NSEC_PER_MSEC; >> unsigned long tref = jiffies - 5 * HZ; >> struct neighbour *n, *tmp; >> int shrunk = 0; >> + int loop = 0; >> >> NEIGH_CACHE_STAT_INC(tbl, forced_gc_runs); >> >> @@ -278,11 +280,16 @@ static int neigh_forced_gc(struct neigh_table *tbl) >> shrunk++; >> if (shrunk >= max_clean) >> break; >> + if (++loop == 16) { > > Overall looks good. > Minor comments: > - loop count should probably be unsigned > - the magic constant 16 should be a sysctl tuneable A tunable is needed here; the loop counter is just to keep the overhead of the ktime_get_ns call in check.