From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C939C433DB for ; Thu, 4 Feb 2021 14:21:10 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7D40364E0A for ; Thu, 4 Feb 2021 14:21:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7D40364E0A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:45514 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7fVM-00074F-FT for qemu-devel@archiver.kernel.org; Thu, 04 Feb 2021 09:21:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57212) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7fUf-0006TH-KP for qemu-devel@nongnu.org; Thu, 04 Feb 2021 09:20:26 -0500 Received: from mail-qk1-x72f.google.com ([2607:f8b0:4864:20::72f]:33200) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l7fUV-0008KW-FE for qemu-devel@nongnu.org; Thu, 04 Feb 2021 09:20:19 -0500 Received: by mail-qk1-x72f.google.com with SMTP id x81so3434093qkb.0 for ; Thu, 04 Feb 2021 06:20:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=aVWMu4BQWRyHyd01ehyCVpNb0rwxHTCgoW7Sb+vyrGs=; b=nnflVOw1rYD89HVoVW59Wlh+vCmKjuZ2sBSWZmQya7EHHQe9a7V+J2qE/JCFTt25yx yr1tfzKFG7KvOnSZkUUQkLfIdBG+YqK136kIBadCgOTFCUkopvwKjJzJtJeThNduUY+4 oKyQ1vV8IVFqFX1oCD9FNXcG3YlrtTt4G7TEUktkBfL/06k+ttW3P6L1CZtiEj2goEIS tKPdqkd9TTHdVeoPICBmPcV78o5pcTzyrtHO2XB5NTGzKa7V8qa5ytPGSFHQYVcgXiQj el6foHJV99w5hJ3hEEncZZ2tjLcSkLTe1G3xLtox0rkfT+kirIIHAA/GLq57JV71a11s t69g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=aVWMu4BQWRyHyd01ehyCVpNb0rwxHTCgoW7Sb+vyrGs=; b=JBg0UghqrH/VzcU+wig4kHugqLhpgwF8gDaASyejDRsRTO/Lh+5txlM5aKFGeh2Dmn OEF1h0Du61l2bxBy2cU/iUT0iR9qY9/jYC0RUeCfImJwma3c2pv1nwubKZqVXLXbLTVC 1uSOt17wKmCXDXMmE0lT2qYa2/nI1/1NH1/CKZoJBRdqTXqRMpf12BU9yD9P9bxIwaza Lu5u0hYU2jkT9MdgF/+fiwzln3/8MJ1/dMjZhVLrTMiJDXp3akbTSM4dp8zK5TZTq1qj 6wdzejCMUECefIPouDDaflJBtki7//tuSdi6gYGxydvXf+zSgaril2yCJBgc7uauwbsh Q2rg== X-Gm-Message-State: AOAM530EQm38kGH7jYOQEDyZnQo/PeMtaLuP6j2GL1DbAC9QQT/MIA9g TYYjZ+yo7vT+m90m0llg2GnQm5SPDurSKjJCBsPZEg== X-Google-Smtp-Source: ABdhPJxzkcUrGt30tFwjALZ2fpuBftaBUaeQCe9Xd0D/4jrifPFFiTb+s+ddOex4QB1pNiJ0UVFpoZAdcYBTkRpspCk= X-Received: by 2002:a37:b105:: with SMTP id a5mr7470186qkf.83.1612448414377; Thu, 04 Feb 2021 06:20:14 -0800 (PST) MIME-Version: 1.0 References: <20201215162119.27360-1-zhangjiachen.jaycee@bytedance.com> <20201215162119.27360-10-zhangjiachen.jaycee@bytedance.com> <20210204121538.GH3039@work-vm> In-Reply-To: <20210204121538.GH3039@work-vm> From: Jiachen Zhang Date: Thu, 4 Feb 2021 22:20:05 +0800 Message-ID: Subject: Re: [External] Re: [RFC PATCH 9/9] virtiofsd: (work around) Comment qsort in inflight I/O tracking To: "Dr. David Alan Gilbert" Content-Type: multipart/alternative; boundary="000000000000f54dbb05ba83661c" Received-SPF: pass client-ip=2607:f8b0:4864:20::72f; envelope-from=zhangjiachen.jaycee@bytedance.com; helo=mail-qk1-x72f.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: virtio-fs@redhat.com, Xie Yongji , QEMU , Stefan Hajnoczi , "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" --000000000000f54dbb05ba83661c Content-Type: text/plain; charset="UTF-8" On Thu, Feb 4, 2021 at 8:16 PM Dr. David Alan Gilbert 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 > > Signed-off-by: Xie Yongji > > 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 > > --000000000000f54dbb05ba83661c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Thu, Feb 4, 2021 at 8:16 PM Dr. Da= vid 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 o= f use
> stack memory when the resubmit_num is larger than 64 (total size large= r than
> 1024 Bytes). This will cause seccomp kill virtiofsd, so we comment qso= rt.
> This work around will not affect the correctness of inflight I/O track= ing.
>
> Signed-off-by: Jiachen Zhang <zhangjiachen.jaycee@bytedance.com>=
> Signed-off-by: Xie Yongji <xieyongji@bytedance.com>

That's an odd hack!=C2=A0 =C2=A0Just follow the audit log to see what s= eccomp 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
<= br>
=C2=A0
> ---
>=C2=A0 contrib/libvhost-user/libvhost-user.c | 18 ------------------ >=C2=A0 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, VhostUserMs= g *vmsg)
>=C2=A0 =C2=A0 =C2=A0 return true;
>=C2=A0 }
>=C2=A0
> -static int
> -inflight_desc_compare(const void *a, const void *b)
> -{
> -=C2=A0 =C2=A0 VuVirtqInflightDesc *desc0 =3D (VuVirtqInflightDesc *)a= ,
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 *desc1 =3D (VuVirtqInflightDesc *)b;
> -
> -=C2=A0 =C2=A0 if (desc1->counter > desc0->counter &&=
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 (desc1->counter - desc0->counter) &= lt; VIRTQUEUE_MAX_SIZE * 2) {
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 return 1;
> -=C2=A0 =C2=A0 }
> -
> -=C2=A0 =C2=A0 return -1;
> -}
> -
>=C2=A0 static int
>=C2=A0 vu_check_queue_inflights(VuDev *dev, VuVirtq *vq)
>=C2=A0 {
> @@ -1236,10 +1222,6 @@ vu_check_queue_inflights(VuDev *dev, VuVirtq *v= q)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
>=C2=A0
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (vq->resubmit_num > 1) {
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 qsort(vq->resubmit_list,= vq->resubmit_num,
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 sizeof= (VuVirtqInflightDesc), inflight_desc_compare);
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 vq->counter =3D vq->resubmit_l= ist[0].counter + 1;
>=C2=A0 =C2=A0 =C2=A0 }
>=C2=A0
> --
> 2.20.1
>
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

--000000000000f54dbb05ba83661c--