<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/drivers/virtio, branch v2.6.28</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v2.6.28</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v2.6.28'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2008-08-25T14:19:25Z</updated>
<entry>
<title>virtio_balloon: fix towards_target when deflating balloon</title>
<updated>2008-08-25T14:19:25Z</updated>
<author>
<name>Anthony Liguori</name>
<email>aliguori@us.ibm.com</email>
</author>
<published>2008-08-18T22:15:31Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=532a6086e35fa3b5761e68af36d4e42a550eba15'/>
<id>urn:sha1:532a6086e35fa3b5761e68af36d4e42a550eba15</id>
<content type='text'>
Both v and vb-&gt;num_pages are u32 and unsigned int respectively.  If v is less
than vb-&gt;num_pages (and it is, when deflating the balloon), the result is a
very large 32-bit number.  Since we're returning a s64, instead of getting the
same negative number we desire, we get a very large positive number.

This handles the case where v &lt; vb-&gt;num_pages and ensures we get a small,
negative, s64 as the result.

Rusty: please push this for 2.6.27-rc4.  It's probably appropriate for the
stable tree too as it will cause an unexpected OOM when ballooning.

Signed-off-by: Anthony Liguori &lt;aliguori@us.ibm.com&gt;
Signed-off-by: Rusty Russell &lt;rusty@rustcorp.com.au&gt; (simplified)
</content>
</entry>
<entry>
<title>virtio: Add transport feature handling stub for virtio_ring.</title>
<updated>2008-07-25T02:06:14Z</updated>
<author>
<name>Rusty Russell</name>
<email>rusty@rustcorp.com.au</email>
</author>
<published>2008-07-25T17:06:13Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=e34f87256794b87e7f4a8f1812538be7b7b5214c'/>
<id>urn:sha1:e34f87256794b87e7f4a8f1812538be7b7b5214c</id>
<content type='text'>
To prepare for virtio_ring transport feature bits, hook in a call in
all the users to manipulate them.  This currently just clears all the
bits, since it doesn't understand any features.

Signed-off-by: Rusty Russell &lt;rusty@rustcorp.com.au&gt;
</content>
</entry>
<entry>
<title>virtio: Rename set_features to finalize_features</title>
<updated>2008-07-25T02:06:12Z</updated>
<author>
<name>Rusty Russell</name>
<email>rusty@rustcorp.com.au</email>
</author>
<published>2008-07-25T17:06:07Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=c624896e488ba2bff5ae497782cfb265c8b00646'/>
<id>urn:sha1:c624896e488ba2bff5ae497782cfb265c8b00646</id>
<content type='text'>
Rather than explicitly handing the features to the lower-level, we just
hand the virtio_device and have it set the features.  This make it clear
that it has the chance to manipulate the features of the device at this
point (and that all feature negotiation is already done).

Signed-off-by: Rusty Russell &lt;rusty@rustcorp.com.au&gt;
</content>
</entry>
<entry>
<title>virtio: Formally reserve bits 28-31 to be 'transport' features.</title>
<updated>2008-07-25T02:06:07Z</updated>
<author>
<name>Rusty Russell</name>
<email>rusty@rustcorp.com.au</email>
</author>
<published>2008-07-25T17:06:07Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=dd7c7bc46211785a1aa7d70feb15830f62682b3c'/>
<id>urn:sha1:dd7c7bc46211785a1aa7d70feb15830f62682b3c</id>
<content type='text'>
We assign feature bits as required, but it makes sense to reserve some
for the particular transport, rather than the particular device.

Signed-off-by: Rusty Russell &lt;rusty@rustcorp.com.au&gt;
</content>
</entry>
<entry>
<title>virtio: Use bus_type probe and remove methods</title>
<updated>2008-07-25T02:06:05Z</updated>
<author>
<name>Mark McLoughlin</name>
<email>markmc@redhat.com</email>
</author>
<published>2008-06-13T12:46:40Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=e962fa660d391fc9b90988e6538c94c858c099f9'/>
<id>urn:sha1:e962fa660d391fc9b90988e6538c94c858c099f9</id>
<content type='text'>
Hook up to the probe() and remove() methods in bus_type
rather than device_driver. The latter has been preferred
since 2.6.16.

Signed-off-by: Mark McLoughlin &lt;markmc@redhat.com&gt;
Signed-off-by: Rusty Russell &lt;rusty@rustcorp.com.au&gt;
</content>
</entry>
<entry>
<title>virtio: don't always force a notification when ring is full</title>
<updated>2008-07-25T02:06:04Z</updated>
<author>
<name>Rusty Russell</name>
<email>rusty@rustcorp.com.au</email>
</author>
<published>2008-07-25T17:06:04Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=44653eae1407f79dff6f52fcf594ae84cb165ec4'/>
<id>urn:sha1:44653eae1407f79dff6f52fcf594ae84cb165ec4</id>
<content type='text'>
We force notification when the ring is full, even if the host has
indicated it doesn't want to know.  This seemed like a good idea at
the time: if we fill the transmit ring, we should tell the host
immediately.

Unfortunately this logic also applies to the receiving ring, which is
refilled constantly.  We should introduce real notification thesholds
to replace this logic.  Meanwhile, removing the logic altogether breaks
the heuristics which KVM uses, so we use a hack: only notify if there are
outgoing parts of the new buffer.

Here are the number of exits with lguest's crappy network implementation:
Before:
	network xmit 7859051 recv 236420
After:
	network xmit 7858610 recv 118136

Signed-off-by: Rusty Russell &lt;rusty@rustcorp.com.au&gt;
</content>
</entry>
<entry>
<title>virtio: Complete feature negotation before updating status</title>
<updated>2008-06-15T20:46:16Z</updated>
<author>
<name>Mark McLoughlin</name>
<email>markmc@redhat.com</email>
</author>
<published>2008-06-15T13:20:50Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=b92dea67cc66970cda6b5b11895d08e35b4618e7'/>
<id>urn:sha1:b92dea67cc66970cda6b5b11895d08e35b4618e7</id>
<content type='text'>
lguest (in rusty's use-tun-ringfd patch) assumes that the
guest has updated its feature bits before setting its status
to VIRTIO_CONFIG_S_DRIVER_OK.

That's pretty reasonable, so let's make it so.

Signed-off-by: Mark McLoughlin &lt;markmc@redhat.com&gt;
Signed-off-by: Rusty Russell &lt;rusty@rustcorp.com.au&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>virtio: force callback on empty.</title>
<updated>2008-05-30T05:09:46Z</updated>
<author>
<name>Rusty Russell</name>
<email>rusty@rustcorp.com.au</email>
</author>
<published>2008-05-30T20:09:45Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=b4f68be6c5d507afdcd74f5be3df0b1209cda503'/>
<id>urn:sha1:b4f68be6c5d507afdcd74f5be3df0b1209cda503</id>
<content type='text'>
virtio allows drivers to suppress callbacks (ie. interrupts) for
efficiency (no locking, it's just an optimization).

There's a similar mechanism for the host to suppress notifications
coming from the guest: in that case, we ignore the suppression if the
ring is completely full.

It turns out that life is simpler if the host similarly ignores
callback suppression when the ring is completely empty: the network
driver wants to free up old packets in a timely manner, and otherwise
has to use a timer to poll.

We have to remove the code which ignores interrupts when the driver
has disabled them (again, it had no locking and hence was unreliable
anyway).

Signed-off-by: Rusty Russell &lt;rusty@rustcorp.com.au&gt;
</content>
</entry>
<entry>
<title>virtio_net: another race with virtio_net and enable_cb</title>
<updated>2008-05-30T05:09:45Z</updated>
<author>
<name>Christian Borntraeger</name>
<email>borntraeger@de.ibm.com</email>
</author>
<published>2008-05-26T09:29:27Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=52a3a05f3ab82655ffa4c9bf6835565c98a3c2e5'/>
<id>urn:sha1:52a3a05f3ab82655ffa4c9bf6835565c98a3c2e5</id>
<content type='text'>
Hello Rusty,

seems that we still have a problem with virtio_net and the enable_cb callback.
During a long running network stress tests with virtio and got the following
oops:

------------[ cut here ]------------
kernel BUG at drivers/virtio/virtio_ring.c:230!
illegal operation: 0001 [#1] SMP
Modules linked in:
CPU: 0 Not tainted 2.6.26-rc2-kvm-00436-gc94c08b-dirty #34
Process netserver (pid: 2582, task: 000000000fbc4c68, ksp: 000000000f42b990)
Krnl PSW : 0704c00180000000 00000000002d0ec8 (vring_enable_cb+0x1c/0x60)
           R:0 T:1 IO:1 EX:1 Key:0 M:1 W:0 P:0 AS:3 CC:0 PM:0 EA:3
Krnl GPRS: 0000000000000000 0000000000000000 000000000ef3d000 0000000010009800
           0000000000000000 0000000000419ce0 0000000000000080 000000000000007b
           000000000adb5538 000000000ef40900 000000000ef40000 000000000ef40920
           0000000000000000 0000000000000005 000000000029c1b0 000000000fea7d18
Krnl Code: 00000000002d0ebc: a7110001           tmll    %r1,1
           00000000002d0ec0: a7740004           brc     7,2d0ec8
           00000000002d0ec4: a7f40001           brc     15,2d0ec6
          &gt;00000000002d0ec8: a517fffe           nill    %r1,65534
           00000000002d0ecc: 40103000           sth     %r1,0(%r3)
           00000000002d0ed0: 07f0               bcr     15,%r0
           00000000002d0ed2: e31020380004       lg      %r1,56(%r2)
           00000000002d0ed8: a7480000           lhi     %r4,0
Call Trace:
([&lt;000000000029c0fc&gt;] virtnet_poll+0x290/0x3b8)
 [&lt;0000000000333fb8&gt;] net_rx_action+0x9c/0x1b8
 [&lt;00000000001394bc&gt;] __do_softirq+0x74/0x108
 [&lt;000000000010d16a&gt;] do_softirq+0x92/0xac
 [&lt;0000000000139826&gt;] irq_exit+0x72/0xc8
 [&lt;000000000010a7b6&gt;] do_extint+0xe2/0x104
 [&lt;0000000000110508&gt;] ext_no_vtime+0x16/0x1a
Last Breaking-Event-Address:
 [&lt;00000000002d0ec4&gt;] vring_enable_cb+0x18/0x60

I looked into the virtio_net code for some time and I think the following
scenario happened. Please look at virtnet_poll:
[...]
        /* Out of packets? */
        if (received &lt; budget) {
                netif_rx_complete(vi-&gt;dev, napi);
                if (unlikely(!vi-&gt;rvq-&gt;vq_ops-&gt;enable_cb(vi-&gt;rvq))
                    &amp;&amp; napi_schedule_prep(napi)) {
                        vi-&gt;rvq-&gt;vq_ops-&gt;disable_cb(vi-&gt;rvq);
                        __netif_rx_schedule(vi-&gt;dev, napi);
                        goto again;
                }
        }

If an interrupt arrives after netif_rx_complete, a second poll routine can run
on a different cpu. The second check for napi_schedule_prep would prevent any
harm in the network stack, but we have called enable_cb possibly after the
disable_cb in skb_recv_done.

static void skb_recv_done(struct virtqueue *rvq)
{
        struct virtnet_info *vi = rvq-&gt;vdev-&gt;priv;
        /* Schedule NAPI, Suppress further interrupts if successful. */
        if (netif_rx_schedule_prep(vi-&gt;dev, &amp;vi-&gt;napi)) {
                rvq-&gt;vq_ops-&gt;disable_cb(rvq);
                __netif_rx_schedule(vi-&gt;dev, &amp;vi-&gt;napi);
        }
}

That means that the second poll routine runs with interrupts enabled, which is
ok, since we can handle additional interrupts. The problem is now that the
second poll routine might also call enable_cb, triggering the BUG.

The only solution I can come up with, is to remove the BUG statement in
enable_cb - similar to disable_cb. Opinions or better ideas where the oops
could come from?

Signed-off-by: Christian Borntraeger &lt;borntraeger@de.ibm.com&gt;
Signed-off-by: Rusty Russell &lt;rusty@rustcorp.com.au&gt;
</content>
</entry>
<entry>
<title>virtio: set device index in common code.</title>
<updated>2008-05-30T05:09:42Z</updated>
<author>
<name>Rusty Russell</name>
<email>rusty@rustcorp.com.au</email>
</author>
<published>2008-05-30T20:09:42Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=b769f579081943f14e0ff03b7b0bd3a11cf14625'/>
<id>urn:sha1:b769f579081943f14e0ff03b7b0bd3a11cf14625</id>
<content type='text'>
Anthony Liguori points out that three different transports use the virtio code,
but each one keeps its own counter to set the virtio_device's index field.  In
theory (though not in current practice) this means that names could be
duplicated, and that risk grows as more transports are created.

So we move the selection of the unique virtio_device.index into the common code
in virtio.c, which has the side-benefit of removing duplicate code.

The only complexity is that lguest and S/390 use the index to uniquely identify
the device in case of catastrophic failure before register_virtio_device() is
called: now we use the offset within the descriptor page as a unique identifier
for the printks.

Signed-off-by: Rusty Russell &lt;rusty@rustcorp.com.au&gt;
Cc: Christian Borntraeger &lt;borntraeger@de.ibm.com&gt;
Cc: Martin Schwidefsky &lt;schwidefsky@de.ibm.com&gt;
Cc: Carsten Otte &lt;cotte@de.ibm.com&gt;
Cc: Heiko Carstens &lt;heiko.carstens@de.ibm.com&gt;
Cc: Chris Lalancette &lt;clalance@redhat.com&gt;
Cc: Anthony Liguori &lt;anthony@codemonkey.ws&gt;
</content>
</entry>
</feed>
