From nobody Sat May 4 14:27:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1631800797; cv=none; d=zohomail.com; s=zohoarc; b=jx18Yu6ZqvdaED6lwdQDSEvKWCtlZimHXlQFwaCXrSN3sra1wKI2rIhwiI2cssJhEpYUDT2yLzsuvEYgTFbMbbMxYOC++OZYNVNsxG1CXttYllHXRiOLNlypQVXizGzxH53fgMYjC71U1wr17G5KZIccP//wcVvIvVkCVRTP7TI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631800797; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fN4a8CXPpMWNNcc6nJagJ20NV7dMZ7qMAgiIJ7asXx4=; b=ks47R9SqsrN5Nh+3m/IkyZTQId+FkwtvW+JshOuBWWV+Ii33jIfVW+TbtiXshy5e+3wRK6hQVHvmzsgvpOhPWJoKxRCbapnI/5fQK/YEbtjkWi47n8ISZlCb7zgtg55dBHkYCmBlIjZGBhRcXYAD3Z9yG6IZSbGbcY0KMzfbZRI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631800797884421.86027716382887; Thu, 16 Sep 2021 06:59:57 -0700 (PDT) Received: from localhost ([::1]:58914 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQrvg-0001H3-Ri for importer@patchew.org; Thu, 16 Sep 2021 09:59:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38298) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQrp5-0006jK-U6 for qemu-devel@nongnu.org; Thu, 16 Sep 2021 09:53:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:57083) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQrp2-0007bx-UT for qemu-devel@nongnu.org; Thu, 16 Sep 2021 09:53:06 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-112-t-isCO-7NSONmhkzL0EzNQ-1; Thu, 16 Sep 2021 09:53:02 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2842D802E29 for ; Thu, 16 Sep 2021 13:53:02 +0000 (UTC) Received: from dgilbert-t580.localhost (unknown [10.39.194.134]) by smtp.corp.redhat.com (Postfix) with ESMTP id F288A19739; Thu, 16 Sep 2021 13:53:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631800384; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fN4a8CXPpMWNNcc6nJagJ20NV7dMZ7qMAgiIJ7asXx4=; b=ikkms1Y0su8wUMOD8iORCwTJpYoU0R1oZ8UWOHyPdn2BUt74Zy0kWJFZZVU+JYBfR6DSv5 u+ySbEBJehtLNzS0eecaPiqg/TCHhvGA7ThTKcWatLvgwziWBbtf2BfAk68o1jZKQ5/+cg QycaRiCvkjiWlA3m503XyhihgvYqcR8= X-MC-Unique: t-isCO-7NSONmhkzL0EzNQ-1 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, vgoyal@redhat.com, slp@redhat.com, thuth@redhat.com Subject: [PULL 1/2] tools/virtiofsd: Add fstatfs64 syscall to the seccomp allowlist Date: Thu, 16 Sep 2021 14:52:40 +0100 Message-Id: <20210916135241.150566-2-dgilbert@redhat.com> In-Reply-To: <20210916135241.150566-1-dgilbert@redhat.com> References: <20210916135241.150566-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dgilbert@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=dgilbert@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.392, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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: stefanha@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1631800799820100001 Content-Type: text/plain; charset="utf-8" From: Thomas Huth The virtiofsd currently crashes on s390x when doing something like this in the guest: mkdir -p /mnt/myfs mount -t virtiofs myfs /mnt/myfs touch /mnt/myfs/foo.txt stat -f /mnt/myfs/foo.txt The problem is that the fstatfs64 syscall is called in this case from the virtiofsd. We have to put it on the seccomp allowlist to avoid that the daemon gets killed in this case. Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=3D2001728 Suggested-by: Vivek Goyal Signed-off-by: Thomas Huth Message-Id: <20210914123214.181885-1-thuth@redhat.com> Reviewed-by: Vivek Goyal Reviewed-by: Sergio Lopez Reviewed-by: Stefan Hajnoczi Signed-off-by: Dr. David Alan Gilbert --- tools/virtiofsd/passthrough_seccomp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/virtiofsd/passthrough_seccomp.c b/tools/virtiofsd/passth= rough_seccomp.c index f49ed94b5e..a3ce9f898d 100644 --- a/tools/virtiofsd/passthrough_seccomp.c +++ b/tools/virtiofsd/passthrough_seccomp.c @@ -51,6 +51,7 @@ static const int syscall_allowlist[] =3D { SCMP_SYS(fsetxattr), SCMP_SYS(fstat), SCMP_SYS(fstatfs), + SCMP_SYS(fstatfs64), SCMP_SYS(fsync), SCMP_SYS(ftruncate), SCMP_SYS(futex), --=20 2.31.1 From nobody Sat May 4 14:27:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1631800507; cv=none; d=zohomail.com; s=zohoarc; b=mpcOjkO1xsPPgwVltM3JU4HYqEmceRqdFEq+L0ZK9dHVjrhFbKWUYCeiag+GJI9hxCfmd88zSFY3yvwt3taRcF+jPLpXIHZhmC+SHHUHvtTe2sWOfmWXTpDb4WJZU1kh6Hi9Wg2pshDfxm6Ch3LM7LEUmswgwdinM/PdthO2/NY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631800507; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=WeVs70nP8IJqBN8vGJjlNT4eY9YWcMW2vG7HdUK5kFo=; b=T6Jk3sQMXn0atGrVGt6UknjKytQD64BX4GKh0bPAoZKmXNJxocrCtY+gw1mkufUw9a0pnArgnykhO4l2/bgvEqsagHvTl3VsdaL13ceI8DytB350FE22iaHAuRwiI23FG1Bfe0KBwjvPZj/9IC2wQPbINM674dye4CyY9NoM8Zs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631800507680197.02330351758553; Thu, 16 Sep 2021 06:55:07 -0700 (PDT) Received: from localhost ([::1]:47022 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQrr0-0001BJ-MG for importer@patchew.org; Thu, 16 Sep 2021 09:55:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38322) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQrp5-0006mr-Qa for qemu-devel@nongnu.org; Thu, 16 Sep 2021 09:53:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:29157) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQrp4-0007d9-8B for qemu-devel@nongnu.org; Thu, 16 Sep 2021 09:53:07 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-588-QQ95BtUqOE6DqYlNAjwc_w-1; Thu, 16 Sep 2021 09:53:04 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9A872100F955 for ; Thu, 16 Sep 2021 13:53:03 +0000 (UTC) Received: from dgilbert-t580.localhost (unknown [10.39.194.134]) by smtp.corp.redhat.com (Postfix) with ESMTP id 716AA19C79; Thu, 16 Sep 2021 13:53:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631800385; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WeVs70nP8IJqBN8vGJjlNT4eY9YWcMW2vG7HdUK5kFo=; b=EVJbChGPDAqhFGTzsKLTi5hnTfdRJynt8JaxxU65ah9dgoHFmUEgJCRM1EeQh2nXoKCLjy C0s8cEY8kDrLno6gk3JlibB4wevOniAdXMtVgGzmvq5o7S7C1pjHXPB/ul8Fixv0Pg/KZf urNJBadvvqW/2jFzy/ygbAQSgNPScjU= X-MC-Unique: QQ95BtUqOE6DqYlNAjwc_w-1 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, vgoyal@redhat.com, slp@redhat.com, thuth@redhat.com Subject: [PULL 2/2] virtiofsd: Reverse req_list before processing it Date: Thu, 16 Sep 2021 14:52:41 +0100 Message-Id: <20210916135241.150566-3-dgilbert@redhat.com> In-Reply-To: <20210916135241.150566-1-dgilbert@redhat.com> References: <20210916135241.150566-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dgilbert@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=dgilbert@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.392, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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: stefanha@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1631800508863100001 Content-Type: text/plain; charset="utf-8" From: Sergio Lopez With the thread pool disabled, we add the requests in the queue to a GList, processing by iterating over there afterwards. For adding them, we're using "g_list_prepend()", which is more efficient but causes the requests to be processed in reverse order, breaking the read-ahead and request-merging optimizations in the host for sequential operations. According to the documentation, if you need to process the request in-order, using "g_list_prepend()" and then reversing the list with "g_list_reverse()" is more efficient than using "g_list_append()", so let's do it that way. Testing on a spinning disk (to boost the increase of read-ahead and request-merging) shows a 4x improvement on sequential write fio test: Test: fio --directory=3D/mnt/virtio-fs --filename=3Dfio-file1 --runtime=3D20 --iodepth=3D16 --size=3D4G --direct=3D1 --blocksize=3D4K --ioengine libaio --rw write --name seqwrite-libaio Without "g_list_reverse()": ... Jobs: 1 (f=3D1): [W(1)][100.0%][w=3D22.4MiB/s][w=3D5735 IOPS][eta 00m:00s] seqwrite-libaio: (groupid=3D0, jobs=3D1): err=3D 0: pid=3D710: Tue Aug 24 1= 2:58:16 2021 write: IOPS=3D5709, BW=3D22.3MiB/s (23.4MB/s)(446MiB/20002msec); 0 zone r= esets ... With "g_list_reverse()": ... Jobs: 1 (f=3D1): [W(1)][100.0%][w=3D84.0MiB/s][w=3D21.5k IOPS][eta 00m:00s] seqwrite-libaio: (groupid=3D0, jobs=3D1): err=3D 0: pid=3D716: Tue Aug 24 1= 3:00:15 2021 write: IOPS=3D21.3k, BW=3D83.1MiB/s (87.2MB/s)(1663MiB/20001msec); 0 zone= resets ... Signed-off-by: Sergio Lopez Message-Id: <20210824131158.39970-1-slp@redhat.com> Reviewed-by: Vivek Goyal Signed-off-by: Dr. David Alan Gilbert --- tools/virtiofsd/fuse_virtio.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/virtiofsd/fuse_virtio.c b/tools/virtiofsd/fuse_virtio.c index fc2564a603..8f4fd165b9 100644 --- a/tools/virtiofsd/fuse_virtio.c +++ b/tools/virtiofsd/fuse_virtio.c @@ -716,6 +716,7 @@ static void *fv_queue_thread(void *opaque) =20 /* Process all the requests. */ if (!se->thread_pool_size && req_list !=3D NULL) { + req_list =3D g_list_reverse(req_list); g_list_foreach(req_list, fv_queue_worker, qi); g_list_free(req_list); req_list =3D NULL; --=20 2.31.1