All of lore.kernel.org
 help / color / mirror / Atom feed
From: Amos Kong <akong@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: qemu-devel@nongnu.org, stefanha@redhat.com,
	Luiz Capitulino <lcapitulino@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 1/2] net: introduce MAC_TABLE_CHANGED event
Date: Fri, 31 May 2013 08:35:28 +0800	[thread overview]
Message-ID: <20130531003528.GA4322@t430s.nay.redhat.com> (raw)
In-Reply-To: <20130530135441.GA21440@redhat.com>

On Thu, May 30, 2013 at 04:54:41PM +0300, Michael S. Tsirkin wrote:
> On Tue, May 28, 2013 at 08:25:56AM -0400, Luiz Capitulino wrote:
> > On Tue, 28 May 2013 06:43:04 +0800
> > Amos Kong <akong@redhat.com> wrote:
> > 
> > > On Mon, May 27, 2013 at 09:24:28AM -0400, Luiz Capitulino wrote:
> > > > On Mon, 27 May 2013 09:10:11 -0400
> > > > Luiz Capitulino <lcapitulino@redhat.com> wrote:
> > > > 
> > > > > > We use the QMP event to notify management about the mac changing.
> > > > > > 
> > > > > > In this thread, we _wrongly_ considered to use qmp approach to delay
> > > > > > the event for avoiding the flooding.
> > > > > > 
> > > > > >   eg: monitor_protocol_event_throttle(NIC_RX_FILTER_CHANGED, 1000);
> > > > > > 
> > > > > > Now we have a solution (using a flag to turn on/off the notify) to avoid the
> > > > > > flooding, only emit the event if we have no un-read event.
> > > > > > 
> > > > > > If we want to (flag is on) emit the event, we wish the event be sent ASAP
> > > > > > (so event_throttle isn't needed).
> > > > > 
> > > > > Unfortunately this doesn't answer my question. I did understand why you're
> > > > > not using the event throttle API (which is because you don't want to slow down
> > > > > the guest, not the QMP client).
> > > > > 
> > > > > My point is whether coupling the event with the query command is really
> > > > > justified or even if it really fixes the problem. Two points:
> > > > > 
> > > > >  1. Coupling them is bad design, and will probably strike back, as we plan
> > > > >     for a better API for events where events can be disabled
> > > > 
> > > > I meant we may in the future, for example, introduce the ability to disable
> > > > commands (and events). One could argue that the event w/o a query command
> > > > is not that useful, as events can be lost. But loosing an event is one thing,
> > > > not having it because it got disabled by a side effect is another.
> > > 
> > > event_throttle() couples the event in QMP framework, but we use flags
> > > to disabled the event from real source (emit points/senders). 
> > > 
> > > If we set the evstate->rate to -1, we can ignore the events in
> > > monitor_protocol_event_queue(), but we could not control the event
> > > emitting of each emit point (each nic).
> > >  
> > > > But anyway, my main point in this thread is to make sure we at least
> > > > justify having this coupling. Aren't we optimizing prematurely? Aren't
> > > > we optimizing for a corner case? That's what I want to see answered.
> > > 
> > > If it's a corner case, we don't need a general API to disable event.
> > 
> > If it's a corner case, it's really worth to fix it?
> > 
> > I think that what we need a real world test-case to show us we're
> > doing the right thing.
> > 
> > > We can disable this event by a flag, and introduce a new API
> > > if we have same request from other events.
> > > 
> > > > >  2. Can you actually show the problem does exist so that we ensure this is
> > > > >     not premature optimization? Might be a good idea to have this in the
> > > > >     commit log
> > > > > 
> > > > > > > (which is to couple the event with the query command) is
> > > > > > > appropriate. We're in user-space already, many things could slow
> > > > > > > the guest down apart from the event generation.
> > > > > > > 
> > > > > > > Two questions:
> > > > > > > 
> > > > > > >  1. Do we know how slow (or how many packets are actually dropped)
> > > > > > >     if the mac is changed too often *and* the event is always sent?
> > > > > > 
> > > > > > We always disable interface first, then change the macaddr.
> > > > > > But we just have patch to allow guest to change macaddr of
> > > > > > virtio-net when the interface is running.
> > > > > > 
> > > > > > | commit 2dcd0cce551983afe2f900125457f10bb5d980ae
> > > > > > | Author: Jiri Pirko <jpirko@redhat.com>
> > > > > > | Date:   Tue Dec 11 15:33:56 2012 -0500
> > > > > > | 
> > > > > > |     [virt] virtio_net: allow to change mac when iface is running
> > > > > > 
> > > > > > >  2. Does this solution consider what happens if the QMP client does
> > > > > > >     respond timely to the event by issuing the query-rx-filter
> > > > > > >     command?
> > > > > > 
> > > > > > We assume that the QMP client (management) cares about the mac changing
> > > > > > event, and will query the latest rx-filter state and sync to macvtap
> > > > > > device.
> > > > > > 
> > > > > > 1) If QMP client respond timely to the event: that's what we expected :)
> > > > > 
> > > > > Won't this slow down the guest? If not, why?
> > > 
> > > If guest changes fx-filter configs frequently & management always query the
> > > event very timely, this will slow down the guest.
> > > 
> > > We should detect & process the abnormal behavior from management.
> > 
> > That's not abnormal. Management is doing what it should do.
> > 
> > Maybe using the event throttle API can solve the mngt side of the problem,
> > but I still think we need a reproducible test-case to ensure we're doing
> > the right thing.
> 
> I agree we should make sure this code is tested.
> It's pretty easy: run ifconfig in a loop in guest.
> 
> Amos, did you try this? Probably should otherwise
> we don't really know whether the logic works.

With v4 patch (without using event throttle)

1. continually query rx-filter from monitor
# while true; do echo "info rx-filter" | nc -U /tmp/m; done

2. change mac in guest repeatedly
# while true; do
 ifconfig eth1 down; ifconfig eth1 hw ether 12:00:00:00:00:00
 ifconfig eth1 down; ifconfig eth1 hw ether 14:00:00:00:00:00
 done

One time (down if, change mac, up) takes about 3,500,000 ns in guest
some event will be ignored by qemu. I will try to only query when it
gets NIC_RX_FILTER_CHANGE event from QMP monitor, query ASAP.

==> Resource usage:

  PID USER      PR  NI  VIRT  RES  SHR S  %CPU %MEM    TIME+  COMMAND
16387 root      20   0 2375m 326m 6684 R 104.2  4.2   8:32.16 qemu-system-x86

loop script takes about 10% guest cpu (1 core), guest is not slow

----
If we don't use the flag (same effect as that management taks 0 ns to
response & complete the query after event comming)

  PID USER      PR  NI  VIRT  RES  SHR S  %CPU %MEM    TIME+  COMMAND                                                                                                            
 4317 root      20   0 2377m 285m 6664 R 103.4  3.7   2:06.82 qemu-system-x86

guest is very slow (no response for the keyboard input), output:
clocksource tsc unstable.
 
> > > Management (qmp client) always respond timely to the event in the
> > > begining. If guest changes rx-filter very frequently & continuous.
> > > Then we increase the evstate->rate, even disable the event.
> > > 
> > > In the normal usecase, we should consider packet losing first (caused by
> > > event delay + the delay is used by management to execute the change)
> > > 
> > > ---
> > > btw, currently we could not test in real environment. If related
> > > libvirt work finishes, we can evaluate with real delays, packet
> > > losing, etc.
> > > 
> > > The worst condition is we could not accept the delay(packet losing),
> > > we need to consider other solution for mac programming of macvtap.
> > > 
> > > > > > 2) If QMP client doesn't respond timely to the event: packets might drop.
> > > > > >    If we change mac when the interface is running, we can accept trivial
> > > > > >    packets dropping.
> > > > > > 
> > > > > > For second condition, we need to test in real environment when libvirt
> > > > > > finishs the work of processing events.
> > > 

-- 
			Amos.

  reply	other threads:[~2013-05-31  0:35 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-16 11:07 [Qemu-devel] [PATCH v2 0/2] mac programming over macvtap Amos Kong
2013-05-16 11:07 ` [Qemu-devel] [PATCH v2 1/2] net: introduce MAC_TABLE_CHANGED event Amos Kong
2013-05-16 12:12   ` Michael S. Tsirkin
2013-05-16 12:17   ` Michael S. Tsirkin
2013-05-16 12:24     ` Luiz Capitulino
2013-05-16 12:45       ` Michael S. Tsirkin
2013-05-16 12:52         ` Luiz Capitulino
2013-05-16 14:58     ` Eric Blake
2013-05-16 15:03       ` Michael S. Tsirkin
2013-05-16 15:06         ` Michael S. Tsirkin
2013-05-16 15:12         ` Eric Blake
2013-05-16 15:17           ` Michael S. Tsirkin
2013-05-16 15:24             ` Eric Blake
2013-05-23 15:54             ` Luiz Capitulino
2013-05-23 17:18               ` Michael S. Tsirkin
2013-05-23 17:26                 ` Luiz Capitulino
2013-05-24 12:10                   ` Michael S. Tsirkin
2013-05-24 12:51                     ` Luiz Capitulino
2013-05-27  9:34                       ` Amos Kong
2013-05-27 13:10                         ` Luiz Capitulino
2013-05-27 13:24                           ` Luiz Capitulino
2013-05-27 22:43                             ` Amos Kong
2013-05-28 12:25                               ` Luiz Capitulino
2013-05-30 13:50                                 ` Amos Kong
2013-05-30 13:50                                   ` [Qemu-devel] " Amos Kong
2013-05-30 13:57                                   ` Michael S. Tsirkin
2013-05-30 13:57                                     ` Michael S. Tsirkin
2013-05-30 13:54                                 ` Michael S. Tsirkin
2013-05-31  0:35                                   ` Amos Kong [this message]
2013-05-31  3:02                                     ` Amos Kong
2013-06-04  6:43                                       ` Amos Kong
2013-06-04  7:42                                         ` Amos Kong
2013-06-04 11:11                                           ` Michael S. Tsirkin
2013-05-21  5:04     ` Amos Kong
2013-05-21  8:51       ` Michael S. Tsirkin
2013-05-23  6:08         ` Amos Kong
2013-05-16 14:56   ` Eric Blake
2013-05-16 15:01     ` Michael S. Tsirkin
2013-05-16 11:07 ` [Qemu-devel] [PATCH v2 2/2] net: introduce command to query mac-table information Amos Kong
2013-05-16 12:19   ` Michael S. Tsirkin
2013-05-21  3:31     ` Amos Kong
2013-05-16 15:38   ` Eric Blake
2013-05-23  4:03     ` Amos Kong
2013-05-17  7:39   ` Stefan Hajnoczi
2013-05-21  4:46     ` Amos Kong
2013-05-21  7:38       ` Stefan Hajnoczi
2013-05-29  5:31   ` Jason Wang
2013-06-05  7:18     ` Amos Kong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130531003528.GA4322@t430s.nay.redhat.com \
    --to=akong@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.