From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 95890FCA168 for ; Mon, 9 Mar 2026 17:52:23 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vzem5-0005iE-10; Mon, 09 Mar 2026 13:52:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vzelj-0005Yv-M4 for qemu-devel@nongnu.org; Mon, 09 Mar 2026 13:51:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vzeld-0003aI-FD for qemu-devel@nongnu.org; Mon, 09 Mar 2026 13:51:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1773078702; h=from:from:reply-to: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=1M6NOZ00P0JnAbthNzASZGH0vsK+lJq548CT/oZbajg=; b=B2hiFfpx9qyl47C9fGF7d2bdqLhRZDRJMEEFGxwvMyNtRoChYoVifViZfXmKs/xqeu3B+N OLOV/O4nyb2cT6ZVhdCCo8yCJc7rXgb5r0l/j3rRpCcU6X3W0a2cr+uvX5J1JoJ81K9U1K NetLPOJiyOPzYFKa8S9vdT6wb1oFV8A= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-210-cP1hHaiJOPeKN7cRLf9-YQ-1; Mon, 09 Mar 2026 13:51:39 -0400 X-MC-Unique: cP1hHaiJOPeKN7cRLf9-YQ-1 X-Mimecast-MFC-AGG-ID: cP1hHaiJOPeKN7cRLf9-YQ_1773078697 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7E7EF19540C8; Mon, 9 Mar 2026 17:51:35 +0000 (UTC) Received: from redhat.com (unknown [10.44.33.95]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 31EDD19560A6; Mon, 9 Mar 2026 17:51:32 +0000 (UTC) Date: Mon, 9 Mar 2026 17:51:29 +0000 From: Daniel =?utf-8?B?UC4gQmVycmFuZ8Op?= To: Tejus GK Cc: Peter Xu , "qemu-devel@nongnu.org" , Fabiano Rosas , Eric Blake , Markus Armbruster Subject: Re: [PATCH v2 1/1] io: make zerocopy fallback accounting more accurate Message-ID: References: <20260309090907.956330-1-tejus.gk@nutanix.com> <0DF1A5F6-E20D-4A3F-9285-9205E87DE641@nutanix.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <0DF1A5F6-E20D-4A3F-9285-9205E87DE641@nutanix.com> User-Agent: Mutt/2.2.14 (2025-02-20) X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass client-ip=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -3 X-Spam_score: -0.4 X-Spam_bar: / X-Spam_report: (-0.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.819, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.903, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Daniel =?utf-8?B?UC4gQmVycmFuZ8Op?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org On Mon, Mar 09, 2026 at 05:42:08PM +0000, Tejus GK wrote: > > > > On 9 Mar 2026, at 10:47 PM, Daniel P. Berrangé wrote: > > > > !-------------------------------------------------------------------| > > CAUTION: External Email > > > > |-------------------------------------------------------------------! > > > > On Mon, Mar 09, 2026 at 12:59:44PM -0400, Peter Xu wrote: > >> On Mon, Mar 09, 2026 at 04:48:37PM +0000, Daniel P. Berrangé wrote: > >>>> @@ -881,8 +881,8 @@ static int qio_channel_socket_flush_internal(QIOChannel *ioc, > >>>> sioc->zero_copy_sent += serr->ee_data - serr->ee_info + 1; > >>>> > >>>> /* If any sendmsg() succeeded using zero copy, mark zerocopy success */ > >>>> - if (serr->ee_code != SO_EE_CODE_ZEROCOPY_COPIED) { > >>>> - sioc->new_zero_copy_sent_success = true; > >>>> + if (serr->ee_code == SO_EE_CODE_ZEROCOPY_COPIED) { > >>>> + sioc->zero_copy_fallback++; > >>> > >>> ...this is counting the number of MSG_ERRQUEUE items, which is not > >>> the same as the number of IO requests. That's why we only used it > >>> as a boolean marker originally, rather than making it a counter. > >> > >> Would the logic still work and better than before? Say, it's a counter of > >> "messages" rather than "IOs" then. > > > > IIUC it is a counter of processing notifications which is not directly > > correlated to any action by QEMU - neither bytes nor syscalls. > > Please correct me if I'm wrong about this, isn’t each notification an information > about what happened to an individual IO? If userspace hasn't read a queued notification yet, the kernel will merge new notifications with the existing queued one. The line above your change serr->ee_data - serr->ee_info + 1; records how many notifications were merged, so we now how many syscalls were processed. If ee_code is SO_EE_CODE_ZEROCOPY_COPIED though it means at least one syscall resulted in a copy, but that doesn't imply that *all* syscalls resulted in a copy. AFAICT, it could be 1 out of a 1000 syscalls resulted in a copy, or it could be 1000 out of 1000 resulted in a copy. We don't know. IIUC the kernel's merging of notifications appears lossy wrt this information. It could be partially mitigated by doing a flush for notifications really really frequently but that feels like it would have its own downsides > >> The problem with the old code was we may report fallback=0 even if there > >> can have fallback happened, as we mask that fact as long as one zerocopy > >> happened in the whole batch between two flushes. So it seems this (even if > >> the counter is not per-IO) is still better. > > > > Better for what purpose though ? > > > > If we enabled zero-copy, it is useful to know if /something/ managed > > to benefit from zero-copy. ie if /always/ fails to zero-copy then > > we can diagnose that the NIC driver isn't capable of it, or there > > is some other limitation. If something manages to zero-copy, then > > we know the feature is functionally working. > > > > What will we do with a count of notificaitons ? > > I was wondering if it can be useful for debugging live migration issues where zerocopy is > enabled. For instance, let’s say a zerocopy write failed due to the socket error queue being > full. Now it could be either due to the out of order processing we had seen before > (https://github.com/qemu/qemu/commit/84005f4a2b8745e5934f955c045a0b4311cd0992) or > due to it getting filled up because some copies getting deferred. For the latter, this stat can be > worthwile as a debugging stat. With regards, Daniel -- |: https://berrange.com ~~ https://hachyderm.io/@berrange :| |: https://libvirt.org ~~ https://entangle-photo.org :| |: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|