diff mbox series

[RFC,9/9] virtiofsd: (work around) Comment qsort in inflight I/O tracking

Message ID 20201215162119.27360-10-zhangjiachen.jaycee@bytedance.com (mailing list archive)
State New, archived
Headers show
Series Support for Virtio-fs daemon crash reconnection | expand

Commit Message

Jiachen Zhang Dec. 15, 2020, 4:21 p.m. UTC
This is a work around. The qsort function will malloc memory instead of use
stack memory when the resubmit_num is larger than 64 (total size larger than
1024 Bytes). This will cause seccomp kill virtiofsd, so we comment qsort.
This work around will not affect the correctness of inflight I/O tracking.

Signed-off-by: Jiachen Zhang <zhangjiachen.jaycee@bytedance.com>
Signed-off-by: Xie Yongji <xieyongji@bytedance.com>
---
 contrib/libvhost-user/libvhost-user.c | 18 ------------------
 1 file changed, 18 deletions(-)

Comments

Dr. David Alan Gilbert Feb. 4, 2021, 12:15 p.m. UTC | #1
* Jiachen Zhang (zhangjiachen.jaycee@bytedance.com) wrote:
> This is a work around. The qsort function will malloc memory instead of use
> stack memory when the resubmit_num is larger than 64 (total size larger than
> 1024 Bytes). This will cause seccomp kill virtiofsd, so we comment qsort.
> This work around will not affect the correctness of inflight I/O tracking.
> 
> Signed-off-by: Jiachen Zhang <zhangjiachen.jaycee@bytedance.com>
> Signed-off-by: Xie Yongji <xieyongji@bytedance.com>

That's an odd hack!   Just follow the audit log to see what seccomp was
upset by and add the right syscall.

Dave

> ---
>  contrib/libvhost-user/libvhost-user.c | 18 ------------------
>  1 file changed, 18 deletions(-)
> 
> diff --git a/contrib/libvhost-user/libvhost-user.c b/contrib/libvhost-user/libvhost-user.c
> index 8c97013e59..c226d5d915 100644
> --- a/contrib/libvhost-user/libvhost-user.c
> +++ b/contrib/libvhost-user/libvhost-user.c
> @@ -1167,20 +1167,6 @@ vu_check_queue_msg_file(VuDev *dev, VhostUserMsg *vmsg)
>      return true;
>  }
>  
> -static int
> -inflight_desc_compare(const void *a, const void *b)
> -{
> -    VuVirtqInflightDesc *desc0 = (VuVirtqInflightDesc *)a,
> -                        *desc1 = (VuVirtqInflightDesc *)b;
> -
> -    if (desc1->counter > desc0->counter &&
> -        (desc1->counter - desc0->counter) < VIRTQUEUE_MAX_SIZE * 2) {
> -        return 1;
> -    }
> -
> -    return -1;
> -}
> -
>  static int
>  vu_check_queue_inflights(VuDev *dev, VuVirtq *vq)
>  {
> @@ -1236,10 +1222,6 @@ vu_check_queue_inflights(VuDev *dev, VuVirtq *vq)
>              }
>          }
>  
> -        if (vq->resubmit_num > 1) {
> -            qsort(vq->resubmit_list, vq->resubmit_num,
> -                  sizeof(VuVirtqInflightDesc), inflight_desc_compare);
> -        }
>          vq->counter = vq->resubmit_list[0].counter + 1;
>      }
>  
> -- 
> 2.20.1
>
Jiachen Zhang Feb. 4, 2021, 2:20 p.m. UTC | #2
On Thu, Feb 4, 2021 at 8:16 PM Dr. David Alan Gilbert <dgilbert@redhat.com>
wrote:

> * Jiachen Zhang (zhangjiachen.jaycee@bytedance.com) wrote:
> > This is a work around. The qsort function will malloc memory instead of
> use
> > stack memory when the resubmit_num is larger than 64 (total size larger
> than
> > 1024 Bytes). This will cause seccomp kill virtiofsd, so we comment qsort.
> > This work around will not affect the correctness of inflight I/O
> tracking.
> >
> > Signed-off-by: Jiachen Zhang <zhangjiachen.jaycee@bytedance.com>
> > Signed-off-by: Xie Yongji <xieyongji@bytedance.com>
>
> That's an odd hack!   Just follow the audit log to see what seccomp was
> upset by and add the right syscall.
>
> Dave
>
>
We recently found the cause is sysinfo (2). We will revert this and add
sysinfo to the
whitelist in the 2nd version patchset. Thanks!

Jiachen



> > ---
> >  contrib/libvhost-user/libvhost-user.c | 18 ------------------
> >  1 file changed, 18 deletions(-)
> >
> > diff --git a/contrib/libvhost-user/libvhost-user.c
> b/contrib/libvhost-user/libvhost-user.c
> > index 8c97013e59..c226d5d915 100644
> > --- a/contrib/libvhost-user/libvhost-user.c
> > +++ b/contrib/libvhost-user/libvhost-user.c
> > @@ -1167,20 +1167,6 @@ vu_check_queue_msg_file(VuDev *dev, VhostUserMsg
> *vmsg)
> >      return true;
> >  }
> >
> > -static int
> > -inflight_desc_compare(const void *a, const void *b)
> > -{
> > -    VuVirtqInflightDesc *desc0 = (VuVirtqInflightDesc *)a,
> > -                        *desc1 = (VuVirtqInflightDesc *)b;
> > -
> > -    if (desc1->counter > desc0->counter &&
> > -        (desc1->counter - desc0->counter) < VIRTQUEUE_MAX_SIZE * 2) {
> > -        return 1;
> > -    }
> > -
> > -    return -1;
> > -}
> > -
> >  static int
> >  vu_check_queue_inflights(VuDev *dev, VuVirtq *vq)
> >  {
> > @@ -1236,10 +1222,6 @@ vu_check_queue_inflights(VuDev *dev, VuVirtq *vq)
> >              }
> >          }
> >
> > -        if (vq->resubmit_num > 1) {
> > -            qsort(vq->resubmit_list, vq->resubmit_num,
> > -                  sizeof(VuVirtqInflightDesc), inflight_desc_compare);
> > -        }
> >          vq->counter = vq->resubmit_list[0].counter + 1;
> >      }
> >
> > --
> > 2.20.1
> >
> --
> Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
>
>
diff mbox series

Patch

diff --git a/contrib/libvhost-user/libvhost-user.c b/contrib/libvhost-user/libvhost-user.c
index 8c97013e59..c226d5d915 100644
--- a/contrib/libvhost-user/libvhost-user.c
+++ b/contrib/libvhost-user/libvhost-user.c
@@ -1167,20 +1167,6 @@  vu_check_queue_msg_file(VuDev *dev, VhostUserMsg *vmsg)
     return true;
 }
 
-static int
-inflight_desc_compare(const void *a, const void *b)
-{
-    VuVirtqInflightDesc *desc0 = (VuVirtqInflightDesc *)a,
-                        *desc1 = (VuVirtqInflightDesc *)b;
-
-    if (desc1->counter > desc0->counter &&
-        (desc1->counter - desc0->counter) < VIRTQUEUE_MAX_SIZE * 2) {
-        return 1;
-    }
-
-    return -1;
-}
-
 static int
 vu_check_queue_inflights(VuDev *dev, VuVirtq *vq)
 {
@@ -1236,10 +1222,6 @@  vu_check_queue_inflights(VuDev *dev, VuVirtq *vq)
             }
         }
 
-        if (vq->resubmit_num > 1) {
-            qsort(vq->resubmit_list, vq->resubmit_num,
-                  sizeof(VuVirtqInflightDesc), inflight_desc_compare);
-        }
         vq->counter = vq->resubmit_list[0].counter + 1;
     }