Re: [PATCH v5 3/6] vhost: Add the cgroup related function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jan 2, 2025 at 11:29 AM Jason Wang <jasowang@xxxxxxxxxx> wrote:
>
> On Mon, Dec 30, 2024 at 8:45 PM Cindy Lu <lulu@xxxxxxxxxx> wrote:
> >
> > Reintroduce the previously removed functions vhost_attach_cgroups_work()
> > and vhost_attach_cgroups() to support kthread mode. Rename
> > vhost_attach_cgroups() to vhost_attach_task_to_cgroups(), and include
> > the implementation of the old function vhost_dev_flush() in this
> > new function.
> >
> > These function was removed in
> > commit 6e890c5d5021 ("vhost: use vhost_tasks for worker threads")
> >
> > Signed-off-by: Cindy Lu <lulu@xxxxxxxxxx>
> > ---
> >  drivers/vhost/vhost.c | 33 +++++++++++++++++++++++++++++++++
> >  1 file changed, 33 insertions(+)
> >
> > diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
> > index 1feba29abf95..812dfd218bc2 100644
> > --- a/drivers/vhost/vhost.c
> > +++ b/drivers/vhost/vhost.c
> > @@ -22,6 +22,7 @@
> >  #include <linux/slab.h>
> >  #include <linux/vmalloc.h>
> >  #include <linux/kthread.h>
> > +#include <linux/cgroup.h>
> >  #include <linux/module.h>
> >  #include <linux/sort.h>
> >  #include <linux/sched/mm.h>
> > @@ -620,6 +621,38 @@ long vhost_dev_check_owner(struct vhost_dev *dev)
> >  }
> >  EXPORT_SYMBOL_GPL(vhost_dev_check_owner);
> >
> > +struct vhost_attach_cgroups_struct {
> > +       struct vhost_work work;
> > +       struct task_struct *owner;
> > +       int ret;
> > +};
> > +
> > +static void vhost_attach_cgroups_work(struct vhost_work *work)
> > +{
> > +       struct vhost_attach_cgroups_struct *s;
> > +
> > +       s = container_of(work, struct vhost_attach_cgroups_struct, work);
> > +       s->ret = cgroup_attach_task_all(s->owner, current);
> > +}
> > +
> > +static int vhost_attach_task_to_cgroups(struct vhost_worker *worker)
> > +{
> > +       struct vhost_flush_struct flush;
> > +       struct vhost_attach_cgroups_struct attach;
> > +
> > +       attach.owner = current;
> > +
> > +       vhost_work_init(&attach.work, vhost_attach_cgroups_work);
> > +       vhost_worker_queue(worker, &attach.work);
> > +
> > +       init_completion(&flush.wait_event);
> > +       vhost_work_init(&flush.work, vhost_flush_work);
> > +       vhost_worker_queue(worker, &flush.work);
> > +       wait_for_completion(&flush.wait_event);
> > +
> > +       return attach.ret;
> > +}
>
> This seems to be inconsistent with what you said above which is
>
> """
> > These function was removed in
> > commit 6e890c5d5021 ("vhost: use vhost_tasks for worker threads")
> """
>
> As 6e890c5d5021 had:
>
> 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);
>         vhost_dev_flush(dev);
>         return attach.ret;
> }
>
> It seems current vhost_dev_flush() will still work or the open coding
> of the flush logic needs to be explained.
>
> Thanks
>
the current vhost_dev_flush was changed to support xarray, So it does
not work here , I will add more information here
Thanks
cindy
> > +
> >  /* Caller should have device mutex */
> >  bool vhost_dev_has_owner(struct vhost_dev *dev)
> >  {
> > --
> > 2.45.0
> >
>






[Index of Archives]     [KVM Development]     [Libvirt Development]     [Libvirt Users]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux