From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rusty Russell Subject: Re: [PATCH] virtio-net: put virtio net header inline with data Date: Fri, 07 Jun 2013 11:42:43 +0930 Message-ID: <87hahar7ms.fsf@rustcorp.com.au> References: <20130606095456.GA7865@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20130606095456.GA7865@redhat.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: virtualization-bounces@lists.linux-foundation.org Errors-To: virtualization-bounces@lists.linux-foundation.org To: "Michael S. Tsirkin" , "David S. Miller" , Jason Wang , Cong Wang , Amos Kong , Dave Jones , virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: qemu-devel@nongnu.org List-Id: virtualization@lists.linuxfoundation.org "Michael S. Tsirkin" writes: > For small packets we can simplify xmit processing by linearizing buffers > with the header: most packets seem to have enough head room we can use > for this purpose. > > Since some older hypervisors (e.g. qemu before version 1.5) > required that header is the first s/g element, > we need a feature bit for this. OK, we know this is horrible. But I will sleep better knowing that we this feature need never make it into a final 1.0 spec, since it can be assumed at that point... > pr_debug("%s: xmit %p %pM\n", vi->dev->name, skb, dest); > + if (vi->mergeable_rx_bufs) > + hdr_len = sizeof hdr->mhdr; > + else > + hdr_len = sizeof hdr->hdr; > + > + can_push = vi->any_header_sg && > + !((unsigned long)skb->data & (__alignof__(*hdr) - 1)) && > + !skb_header_cloned(skb) && skb_headroom(skb) >= hdr_len; Idle thought: how often does this fail? Would it suck if we copied headers which didn't let us prepend data? Or could we bump dev->hard_header_len appropriately? Thanks, Rusty. From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33219) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkmxL-0002Bc-Ru for qemu-devel@nongnu.org; Thu, 06 Jun 2013 23:03:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UkmxK-00057y-Mf for qemu-devel@nongnu.org; Thu, 06 Jun 2013 23:03:11 -0400 Received: from ozlabs.org ([203.10.76.45]:39738) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkmxK-00052Q-AR for qemu-devel@nongnu.org; Thu, 06 Jun 2013 23:03:10 -0400 From: Rusty Russell In-Reply-To: <20130606095456.GA7865@redhat.com> References: <20130606095456.GA7865@redhat.com> Date: Fri, 07 Jun 2013 11:42:43 +0930 Message-ID: <87hahar7ms.fsf@rustcorp.com.au> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] [PATCH] virtio-net: put virtio net header inline with data List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" , "David S. Miller" , Jason Wang , Cong Wang , Amos Kong , Dave Jones , virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: qemu-devel@nongnu.org "Michael S. Tsirkin" writes: > For small packets we can simplify xmit processing by linearizing buffers > with the header: most packets seem to have enough head room we can use > for this purpose. > > Since some older hypervisors (e.g. qemu before version 1.5) > required that header is the first s/g element, > we need a feature bit for this. OK, we know this is horrible. But I will sleep better knowing that we this feature need never make it into a final 1.0 spec, since it can be assumed at that point... > pr_debug("%s: xmit %p %pM\n", vi->dev->name, skb, dest); > + if (vi->mergeable_rx_bufs) > + hdr_len = sizeof hdr->mhdr; > + else > + hdr_len = sizeof hdr->hdr; > + > + can_push = vi->any_header_sg && > + !((unsigned long)skb->data & (__alignof__(*hdr) - 1)) && > + !skb_header_cloned(skb) && skb_headroom(skb) >= hdr_len; Idle thought: how often does this fail? Would it suck if we copied headers which didn't let us prepend data? Or could we bump dev->hard_header_len appropriately? Thanks, Rusty.