From: Jason Wang <jasowang@redhat.com>
To: Xianting Tian <xianting.tian@linux.alibaba.com>
Cc: virtualization@lists.linux-foundation.org,
"Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: Report a possible vhost bug in stable branches
Date: Fri, 13 Oct 2023 09:31:17 +0800 [thread overview]
Message-ID: <CACGkMEu4G3_w6qHLo_baRjpt7E_JBh49JnGu-qqwgqFmAzuQGQ@mail.gmail.com> (raw)
In-Reply-To: <b51b8498-c7de-2946-fee2-beee058e1e41@linux.alibaba.com>
On Thu, Oct 12, 2023 at 6:44 PM Xianting Tian
<xianting.tian@linux.alibaba.com> wrote:
>
>
> 在 2023/10/12 下午3:55, Jason Wang 写道:
> > On Thu, Oct 12, 2023 at 9:43 AM Xianting Tian
> > <xianting.tian@linux.alibaba.com> wrote:
> >> cgroup attach work and dev flush work will both be added to dev work
> >> list in vhost_attach_cgroups() when set dev owner:
> >> static int vhost_attach_cgroups(struct vhost_dev *dev)
> >> {
> >> struct vhost_attach_cgroups_struct attach;
> >>
> >> attach.owner = current;
> >> vhost_work_init(&attach.work,
> >> vhost_attach_cgroups_work);
> >> vhost_work_queue(dev, &attach.work); // add cgroup
> >> attach work
> >> vhost_work_dev_flush(dev); // add dev
> >> flush work
> >> return attach.ret;
> >> }
> >>
> >> And dev kworker will be waken up to handle the two works in
> >> vhost_worker():
> >> node = llist_del_all(&dev->work_list);
> >> node = llist_reverse_order(node);
> >> llist_for_each_entry_safe{
> >> work->fn(work);
> >> }
> >>
> >> As the list is reversed before processing in vhost_worker(), so it is
> >> possible
> >> that dev flush work is processed before cgroup attach work.
> > This sounds weird. It's llist not list so when adding the new entry
> > was added to the head that why we need llist_reverse_order() to
> > recover the order.
> >
> > Have you ever reproduced these issues?
>
> Sorry for the disturb, No issue now.
>
> It caused by our internal changes.
If it's an optimization or features, you are welcomed to post them.
Developing new features upstream has a lot of benefits.
Thanks
>
> >
> > Thanks
> >
> >> If so,
> >> vhost_attach_cgroups
> >> may return "attach.ret" before cgroup attach work is handled, but
> >> "attach.ret" is random
> >> value as it is in stack.
> >>
> >> The possible fix maybe:
> >>
> >> static int vhost_attach_cgroups(struct vhost_dev *dev)
> >> {
> >> struct vhost_attach_cgroups_struct attach;
> >>
> >> attach.ret = 0;
> >> attach.owner = current;
> >> vhost_work_init(&attach.work, vhost_attach_cgroups_work);
> >> vhost_work_queue(dev, &attach.work);
> >> vhost_work_dev_flush(dev);
> >> return attach.ret;
> >> }
> >>
> >> So this fix is just to initialize the attach.ret to 0, this fix may
> >> not the final fix,
> >> We just want you experts know this issue exists, and we met it
> >> recently in our test.
> >>
> >> And the issue exists in may stable branches.
> >>
>
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
prev parent reply other threads:[~2023-10-13 1:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <a8dadf64-7723-926d-290f-945df04df194@linux.alibaba.com>
2023-10-12 7:55 ` Report a possible vhost bug in stable branches Jason Wang
[not found] ` <b51b8498-c7de-2946-fee2-beee058e1e41@linux.alibaba.com>
2023-10-13 1:31 ` Jason Wang [this message]
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=CACGkMEu4G3_w6qHLo_baRjpt7E_JBh49JnGu-qqwgqFmAzuQGQ@mail.gmail.com \
--to=jasowang@redhat.com \
--cc=mst@redhat.com \
--cc=virtualization@lists.linux-foundation.org \
--cc=xianting.tian@linux.alibaba.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).