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 BF87E1B96D; Thu, 18 Jan 2024 10:54:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705575276; cv=none; b=QeoOGD3JzRuw4IksDkrISouK7RetaI2l46vfJVo1ZaGvGbXjBMNjW5tIuv76Dmo4XPko4YeQG/Ix8X+sKM5Zb13PV+J4SYCTpKTS0S/17F7t+g5bAZ6lNDwcnyMryJdvHG2KqIhLAIMlELQDB33Le1zFgH1vEYj2tb1PE4ZSUJo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705575276; c=relaxed/simple; bh=PckjyMaVOXETQFl0M6NBcTs/q7KptsMPShrBAUbf46k=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:User-Agent:X-stable: X-Patchwork-Hint:MIME-Version:Content-Transfer-Encoding; b=jMhfVeNom3+YbL7tkwazqariBnHaMokz+kCph4yYu83WPzt2FjR1L/AqPt7fZ61j8OAYhxSbTaduxkaFiXxOILVT+/2uICXbDDGwxq7QgSE6bNm8XWpbknXKHO1JMqzpZGcrt7E+iQhedAaU49VcbQOiemvn9yX4o671Yx3QltM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Z+IN/ign; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Z+IN/ign" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 42EB8C43390; Thu, 18 Jan 2024 10:54:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1705575276; bh=PckjyMaVOXETQFl0M6NBcTs/q7KptsMPShrBAUbf46k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z+IN/ignL3/SGbMGGXRgyWUeFDGwQ5LA1RI/sMc3bsA16V7RsfzmdTxBfUpTxhDwj BIFmBzbmC21Hkj5tqHAXXP3Yiud/hzS/V+jztir+bx8GeBFbC2bn3ZtmDRGugH2LZv pK2StvgF5UsiIg8W7uHklptH+huGnKA4vjyBf7h0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Douglas Anderson , Judy Hsiao , David Ahern , Eric Dumazet , "David S. Miller" , Sasha Levin Subject: [PATCH 6.6 075/150] neighbour: Dont let neigh_forced_gc() disable preemption for long Date: Thu, 18 Jan 2024 11:48:17 +0100 Message-ID: <20240118104323.457984868@linuxfoundation.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118104320.029537060@linuxfoundation.org> References: <20240118104320.029537060@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Judy Hsiao [ Upstream commit e5dc5afff62f3e97e86c3643ec9fcad23de4f2d3 ] 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 Reviewed-by: David Ahern Reviewed-by: Eric Dumazet Reviewed-by: Douglas Anderson Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/core/neighbour.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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) { + if (ktime_get_ns() > tmax) + goto unlock; + loop = 0; + } } } WRITE_ONCE(tbl->last_flush, jiffies); - +unlock: write_unlock_bh(&tbl->lock); return shrunk; -- 2.43.0