From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=hhrSV8kd; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTPS id A03D05A0271 for ; Tue, 29 Jul 2025 09:05:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1753772699; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tbmO7clq8qaqCLpQFsNZ1BKBxy8VAfrfg2XvRbTvh8g=; b=hhrSV8kdk8EVtvHp61yHID3iOCZfJ5cunnV5kDooJsd7QkZXKrGsrcTX99ubpr9qYzElH3 RJrifE2ZrEmfKnKqfwsJFC5e58C9+5v3ayowyBd3wkXypKP+xZxZef4gFN+2NiXreZB8yW KuL9oPC6uYNd2yYIbaiRqIOtMehfoHI= Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-553-ez8QvI9DNxqXCPsOIZs9Lg-1; Tue, 29 Jul 2025 03:04:57 -0400 X-MC-Unique: ez8QvI9DNxqXCPsOIZs9Lg-1 X-Mimecast-MFC-AGG-ID: ez8QvI9DNxqXCPsOIZs9Lg_1753772697 Received: by mail-pj1-f71.google.com with SMTP id 98e67ed59e1d1-3141f9ce4e2so8450478a91.1 for ; Tue, 29 Jul 2025 00:04:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753772697; x=1754377497; 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=tbmO7clq8qaqCLpQFsNZ1BKBxy8VAfrfg2XvRbTvh8g=; b=iQQxrRRRqzVd4TuSYDQdt7PojcTeuegHdkxh0zv79fNnbKxnttlCAKHtCfui95/YDI L/b08Bd9OttlIc73pkfDt70a3JZmEZ/ei998aSK44GQ++Wu7zr1zJU2gynVIoFgSn8V9 URAin2+kcDrAXoOTHv66UNepzzNcs8LJKAAS9q0zemCE9Vnvzz+SIs33KhzyUiGxNHCo BIM6cm8Wt7n5VXNhriCHNzPGpHFAjXt9oRBTUpTGV9E3Pc1pj86dma5Y1zTAt+Cc/LjF WISzg16C6kn96T+Rpu7KvpWct7+oYGkPw/9VfVF3EjKaeecBwsvSFZhBl0cmu3afjweM wK6g== X-Gm-Message-State: AOJu0YxV2JFJXE5ziqjZoV3S/eaVYDU4kn6kjpkoAQe3LCUpAQMla2hg xsGCfg7IFNbyFaVKRl4+GkKYa0DYdsZRixiR2pGG0DwiSeY7cpaw8kE/t92cKrhfRAZfNtR2TH3 Xtx91JHuTeFywUX6jzKQw0g8reAJFHc4CC0eETrucxGN2H4OORP6BZeZrotppnCcmBSHcVbuL32 qVUEITu4CE+bqhoSugN+qr7/E2H1wC X-Gm-Gg: ASbGncuSurk5PxK3aeCE9dVapgc7JdEwArmHDl1pyF+ycVq+smj4r0FoEdYX4uCeC1b keGDTRuNpNA2bci8U3pfRaXhx05BLgM7qfSicdU18ehY3GNP10aHO0lt9oHh+G+e0tkAV5qnqx/ nYSyhq89iqXp6wUHSfW49j X-Received: by 2002:a17:90a:e7d1:b0:31e:4033:9e87 with SMTP id 98e67ed59e1d1-31e77a2f7acmr21736930a91.10.1753772696722; Tue, 29 Jul 2025 00:04:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFwssZWORB+cl8wyyG/qoXlicwoOhWAG/2pJHJRrt5ummmD50SrJ4atbP4HuwMXTsIXmUq51lF47WiS6FBgeMY= X-Received: by 2002:a17:90a:e7d1:b0:31e:4033:9e87 with SMTP id 98e67ed59e1d1-31e77a2f7acmr21736896a91.10.1753772696316; Tue, 29 Jul 2025 00:04:56 -0700 (PDT) MIME-Version: 1.0 References: <20250709174748.3514693-1-eperezma@redhat.com> <20250709174748.3514693-11-eperezma@redhat.com> In-Reply-To: From: Eugenio Perez Martin Date: Tue, 29 Jul 2025 09:04:19 +0200 X-Gm-Features: Ac12FXx4pGIHTleIwWdGOdbwSRiNgjYMeiVAWYzzY4p4ptdUSu1ROJPgkpFKQf0 Message-ID: Subject: Re: [RFC v2 10/11] tap: add poll(2) to used_idx To: David Gibson X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 66pg_Am8E36gerF3d6Nnp8IAfeV2LUi2Ms3-29pwQVs_1753772697 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Message-ID-Hash: FGYVAAL4TY44B246YY2DFA6RYVHQG26G X-Message-ID-Hash: FGYVAAL4TY44B246YY2DFA6RYVHQG26G X-MailFrom: eperezma@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top, jasowang@redhat.com X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Tue, Jul 29, 2025 at 2:33=E2=80=AFAM David Gibson wrote: > > On Mon, Jul 28, 2025 at 07:03:12PM +0200, Eugenio Perez Martin wrote: > > On Thu, Jul 24, 2025 at 3:21=E2=80=AFAM David Gibson > > wrote: > > > > > > On Wed, Jul 09, 2025 at 07:47:47PM +0200, Eugenio P=C3=A9rez wrote: > > > > From ~13Gbit/s to ~11.5Gbit/s. > > > > > > Again, I really don't know what you're comparing to what here. > > > > > > > When the buffer is full I'm using poll() to wait until vhost free some > > buffers, instead of actively checking the used index. This is the cost > > of the syscall. > > Ah, right. So.. I'm not sure if it's so much the cost of the syscall > itself, as the fact that you're actively waiting for free buffers, > rather than returning to the main epoll loop so you can maybe make > progress on something else before returning to the Tx path. > Previous patch also wait for free buffers, but it does it burning a CPU for that. The next patch is the one that allows to continue progress as long as there are enough free buffers, instead of always wait until all the buffer has been sent. But there are situations where this conversion needs other code changes. In particular, all the calls to tcp_payload_flush after checking that we have enough buffers like: if (tcp_payload_sock_used > TCP_FRAMES_MEM - 2) { tcp_buf_free_old_tap_xmit(c, 2); tcp_payload_flush(c); ... } Seems like coroutines would be a good fix here, but maybe there are simpler ways to go back to the main loop while keeping the tcp socket "ready to read" by epoll POV. Out of curiosity, what do you think about setjmp()? :).