From nobody Fri Nov 29 10:29:52 2024 Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.5]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 901B42581; Sun, 22 Sep 2024 15:09:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=117.135.210.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727017755; cv=none; b=HahqqQxJaOxI/9IprSRcRJBwjJZu2mcTA654L/hDh6DU6l1MNCAJw//vf7kpH9Di0hoti2BzF1v6avWVpyhvPDJchLr004A08RkNNbqLzSkdc45haDva9Udd//M3BGS/f8Di0u5iyd5RBtqGdpJAe/cfrHZbHQxpYGLBoDhPdSg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727017755; c=relaxed/simple; bh=mwoFutD8GXwZ66Wwu9oO8GGsBjXliRczAJwqjPAvDw8=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=XDMBP4sI6eoYPQWPqZSsl07jjZlp7IL2K3PgTmEeMT9+RLZ23GfVDXhHyU5N7fTUWeBf1ciUdqoR6FyvIhc0dUlWYQb8RvhfjyQqGEHHDVmiP+Q+p+W/yIvQte3eF/qCHgD0MSQGxROJQpX5qDlIClKRa5TgowDl93q89t8+VtM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=c9jvbamp; arc=none smtp.client-ip=117.135.210.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="c9jvbamp" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=2m6EA raoDl//a0mxAh04bE95Qd7Q2cA+7EgMLMpLMaA=; b=c9jvbampGQd5HVeq2HJ9S ZbKAVq91Am47SA80nL4TlTM2pEd5J3c+cdxryXKXHDXsQIimjZusp0GUlVG/YznQ q9p6tChu62gM1NBHmWj/ayKatraXoh4VXv9UAB/T22sohs7UAFB0taG9P9bNOQWf Z+B9jQMbh/13UP3MplIXN8= Received: from localhost.localdomain (unknown [124.90.105.166]) by gzga-smtp-mta-g3-5 (Coremail) with SMTP id _____wC3_y3GMvBmr3lMOQ--.42972S2; Sun, 22 Sep 2024 23:07:59 +0800 (CST) From: tao To: davem@davemloft.net Cc: edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, jiri@resnulli.us, bigeasy@linutronix.de, lorenzo@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, tao Subject: [PATCH] netdev: support netdev_budget for napi thread poll Date: Sun, 22 Sep 2024 23:07:46 +0800 Message-Id: <20240922150746.185408-1-wangtaowt166@163.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: _____wC3_y3GMvBmr3lMOQ--.42972S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7XryktF1ktw48GF1fCw13CFg_yoW8Jr48pF WUtFyUGFWkZFZrCr1UXFZ7X3W5t34kWa42k3y7C3WFgF1rAr15JryUtFy3JF1rZFZYqFy3 AFs0vryxW3yfZrJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0piCPfPUUUUU= X-CM-SenderInfo: pzdqw3xdrz3iiww6il2tof0z/1tbisA9i8mV4L6sUJgAAsE Content-Type: text/plain; charset="utf-8" For napi thread poll, we expect the net.core.netdev_budget to be available. In the loop, poll as many packets as possible to netdev_budget Signed-off-by: tao --- net/core/dev.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/net/core/dev.c b/net/core/dev.c index 1e740faf9e78..104a17642842 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -6876,6 +6876,7 @@ static void napi_threaded_poll_loop(struct napi_struc= t *napi) struct bpf_net_context __bpf_net_ctx, *bpf_net_ctx; struct softnet_data *sd; unsigned long last_qs =3D jiffies; + int budget =3D READ_ONCE(net_hotdata.netdev_budget); =20 for (;;) { bool repoll =3D false; @@ -6888,7 +6889,7 @@ static void napi_threaded_poll_loop(struct napi_struc= t *napi) sd->in_napi_threaded_poll =3D true; =20 have =3D netpoll_poll_lock(napi); - __napi_poll(napi, &repoll); + budget -=3D __napi_poll(napi, &repoll); netpoll_poll_unlock(have); =20 sd->in_napi_threaded_poll =3D false; @@ -6905,6 +6906,9 @@ static void napi_threaded_poll_loop(struct napi_struc= t *napi) if (!repoll) break; =20 + if (budget > 0) + continue; + rcu_softirq_qs_periodic(last_qs); cond_resched(); } --=20 2.25.1