mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 17:10:23 +00:00
Ports: Add fio
port
fio allows you to test various different IO subsystems and patterns. It can help us test and benchmark the I/O subsystems of Serenity. This port gets the fio bootstrapped and working, using the included .fio file, I have been able to test the file I/O performance already.
This commit is contained in:
parent
c724955d54
commit
4490668af2
Notes:
sideshowbarker
2024-07-18 02:47:59 +09:00
Author: https://github.com/bgianfo Commit: https://github.com/SerenityOS/serenity/commit/4490668af29 Pull-request: https://github.com/SerenityOS/serenity/pull/11365 Reviewed-by: https://github.com/IdanHo ✅
8 changed files with 246 additions and 0 deletions
|
@ -36,6 +36,7 @@ Please make sure to keep this list up to date when adding and updating ports. :^
|
|||
| [`emu2`](emu2/) | emu2 DOS emulator | 2021.01 | https://github.com/dmsc/emu2 |
|
||||
| [`epsilon`](epsilon/) | graphical calculator simulator | 15.5.0 | https://github.com/numworks/epsilon |
|
||||
| [`figlet`](figlet/) | FIGlet | 2.2.5 | http://www.figlet.org/ |
|
||||
| [`fio`](fio/) | fio - Flexible I/O tester | 3.29 | https://fio.readthedocs.io/en/latest/ |
|
||||
| [`flatbuffers`](flatbuffers/) | Flatbuffers | 1.12.0 | https://github.com/google/flatbuffers |
|
||||
| [`flex`](flex/) | flex | 2.6.4 | https://github.com/westes/flex |
|
||||
| [`fotaq`](fotaq/) | Flight of the Amazon Queen | 1.0 | https://www.scummvm.org/games/#games-queen |
|
||||
|
|
6
Ports/fio/basic-verify.fio
Normal file
6
Ports/fio/basic-verify.fio
Normal file
|
@ -0,0 +1,6 @@
|
|||
[write-and-verify]
|
||||
rw=readwrite
|
||||
bs=4k
|
||||
iodepth=16
|
||||
verify=crc32c
|
||||
size=100MB
|
8
Ports/fio/package.sh
Executable file
8
Ports/fio/package.sh
Executable file
|
@ -0,0 +1,8 @@
|
|||
#!/usr/bin/env -S bash ../.port_include.sh
|
||||
port=fio
|
||||
version=3.29
|
||||
files="https://brick.kernel.dk/snaps/${port}-${version}.tar.gz ${port}-${version}.tar.gz bea42d6f9d6c009f951135591e99787ff5fa9bc1425596d3d3b19339afc7bb0e"
|
||||
auth_type=sha256
|
||||
depends=("zlib")
|
||||
|
||||
export LDFLAGS=-ldl
|
|
@ -0,0 +1,27 @@
|
|||
From d59316cb9bc616b4b44d432d1ad363afa69f67eb Mon Sep 17 00:00:00 2001
|
||||
From: Brian Gianforcaro <b.gianfo@gmail.com>
|
||||
Date: Tue, 21 Dec 2021 23:41:47 -0800
|
||||
Subject: [PATCH 1/4] Port: fio, remove non existent header sys/ipc.h
|
||||
|
||||
Serenity doesn't currently have this header, and
|
||||
it doesn't appear to be needed on our platform so
|
||||
remove it for the port.
|
||||
---
|
||||
init.c | 1 -
|
||||
1 file changed, 1 deletion(-)
|
||||
|
||||
diff --git a/init.c b/init.c
|
||||
index 5f069d9..81c4771 100644
|
||||
--- a/init.c
|
||||
+++ b/init.c
|
||||
@@ -7,7 +7,6 @@
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
-#include <sys/ipc.h>
|
||||
#include <sys/types.h>
|
||||
#include <dlfcn.h>
|
||||
#ifdef CONFIG_VALGRIND_DEV
|
||||
--
|
||||
2.32.0
|
||||
|
128
Ports/fio/patches/0002-fio-add-serenityos-platform-support.patch
Normal file
128
Ports/fio/patches/0002-fio-add-serenityos-platform-support.patch
Normal file
|
@ -0,0 +1,128 @@
|
|||
From 50d3ac3b6faa9d117ec26296067aecee988dbd8c Mon Sep 17 00:00:00 2001
|
||||
From: Brian Gianforcaro <b.gianfo@gmail.com>
|
||||
Date: Tue, 21 Dec 2021 23:47:36 -0800
|
||||
Subject: [PATCH 2/4] Port: fio - Add SerenityOS platform support
|
||||
|
||||
---
|
||||
os/os-serenity.h | 87 ++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
os/os.h | 3 ++
|
||||
2 files changed, 90 insertions(+)
|
||||
create mode 100644 os/os-serenity.h
|
||||
|
||||
diff --git a/os/os-serenity.h b/os/os-serenity.h
|
||||
new file mode 100644
|
||||
index 0000000..941bf09
|
||||
--- /dev/null
|
||||
+++ b/os/os-serenity.h
|
||||
@@ -0,0 +1,87 @@
|
||||
+#ifndef FIO_OS_SERENITY_H
|
||||
+#define FIO_OS_SERENITY_H
|
||||
+
|
||||
+#define FIO_OS os_serenity
|
||||
+
|
||||
+#include <sys/param.h>
|
||||
+#include <sys/statvfs.h>
|
||||
+#include <sys/utsname.h>
|
||||
+#include <sys/mman.h>
|
||||
+#include <sys/select.h>
|
||||
+#include <netinet/in.h>
|
||||
+
|
||||
+#include "../file.h"
|
||||
+
|
||||
+#define FIO_NO_HAVE_SHM_H
|
||||
+#define FIO_USE_GENERIC_INIT_RANDOM_STATE
|
||||
+#define FIO_HAVE_FS_STAT
|
||||
+#define FIO_HAVE_GETTID
|
||||
+
|
||||
+#define OS_MAP_ANON MAP_ANON
|
||||
+
|
||||
+/* Serenity doesn't support:
|
||||
+ * - MADV_RANDOM
|
||||
+ * - MADV_SEQUENTIAL
|
||||
+ *
|
||||
+ * So any values will work for these defines.
|
||||
+ */
|
||||
+#ifndef POSIX_MADV_RANDOM
|
||||
+#define POSIX_MADV_RANDOM 0
|
||||
+#endif
|
||||
+
|
||||
+#ifndef POSIX_MADV_SEQUENTIAL
|
||||
+#define POSIX_MADV_SEQUENTIAL 0
|
||||
+#endif
|
||||
+
|
||||
+/*
|
||||
+ * Serenity doesn't have O_SYNC, so define it here so it can be
|
||||
+ * rejected at runtime instead.
|
||||
+ */
|
||||
+#define O_SYNC 0x2000000
|
||||
+
|
||||
+static inline int blockdev_size(struct fio_file *f, unsigned long long *bytes)
|
||||
+{
|
||||
+ // TODO: Implement
|
||||
+ return ENOTSUP;
|
||||
+}
|
||||
+
|
||||
+static inline int blockdev_invalidate_cache(struct fio_file *f)
|
||||
+{
|
||||
+ // TODO: Implement
|
||||
+ return ENOTSUP;
|
||||
+}
|
||||
+
|
||||
+static inline unsigned long long os_phys_mem(void)
|
||||
+{
|
||||
+ // TODO: Implement
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static inline int nice(int incr)
|
||||
+{
|
||||
+ // TODO: Implement
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static inline unsigned long long get_fs_free_size(const char *path)
|
||||
+{
|
||||
+ unsigned long long ret;
|
||||
+ struct statvfs s;
|
||||
+
|
||||
+ if (statvfs(path, &s) < 0)
|
||||
+ return -1ULL;
|
||||
+
|
||||
+ ret = s.f_frsize;
|
||||
+ ret *= (unsigned long long) s.f_bfree;
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static inline in_addr_t inet_network(const char *cp)
|
||||
+{
|
||||
+ in_addr_t hbo;
|
||||
+ in_addr_t nbo = inet_addr(cp);
|
||||
+ hbo = ((nbo & 0xFF) << 24) + ((nbo & 0xFF00) << 8) + ((nbo & 0xFF0000) >> 8) + ((nbo & 0xFF000000) >> 24);
|
||||
+ return hbo;
|
||||
+}
|
||||
+
|
||||
+#endif
|
||||
diff --git a/os/os.h b/os/os.h
|
||||
index 5965d7b..46604f7 100644
|
||||
--- a/os/os.h
|
||||
+++ b/os/os.h
|
||||
@@ -24,6 +24,7 @@ enum {
|
||||
os_windows,
|
||||
os_android,
|
||||
os_dragonfly,
|
||||
+ os_serenity,
|
||||
|
||||
os_nr,
|
||||
};
|
||||
@@ -55,6 +56,8 @@ typedef enum {
|
||||
#include "os-windows.h"
|
||||
#elif defined (__DragonFly__)
|
||||
#include "os-dragonfly.h"
|
||||
+#elif defined (__serenity__)
|
||||
+#include "os-serenity.h"
|
||||
#else
|
||||
#error "unsupported os"
|
||||
#endif
|
||||
--
|
||||
2.32.0
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
From 99f1cf657e539078c7347c3ddc4a1537d5332e15 Mon Sep 17 00:00:00 2001
|
||||
From: Brian Gianforcaro <b.gianfo@gmail.com>
|
||||
Date: Tue, 21 Dec 2021 23:48:09 -0800
|
||||
Subject: [PATCH 3/4] Port: Add SerenityOS support to configure
|
||||
|
||||
---
|
||||
configure | 3 +++
|
||||
1 file changed, 3 insertions(+)
|
||||
|
||||
diff --git a/configure b/configure
|
||||
index 84ccce0..04bac14 100755
|
||||
--- a/configure
|
||||
+++ b/configure
|
||||
@@ -323,6 +323,9 @@ elif check_define __NetBSD__ ; then
|
||||
elif check_define __sun__ ; then
|
||||
targetos='SunOS'
|
||||
CFLAGS="$CFLAGS -D_REENTRANT"
|
||||
+elif check_define __serenity__ ; then
|
||||
+ targetos='SerenityOS'
|
||||
+ no_shm="yes"
|
||||
elif check_define _WIN32 ; then
|
||||
targetos='CYGWIN'
|
||||
else
|
||||
--
|
||||
2.32.0
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
From fdf16439ed5ecb36f762dc2b66102424920e26c1 Mon Sep 17 00:00:00 2001
|
||||
From: Brian Gianforcaro <b.gianfo@gmail.com>
|
||||
Date: Tue, 21 Dec 2021 23:48:46 -0800
|
||||
Subject: [PATCH 4/4] Port: fio - Disable rdtsc support for serenity
|
||||
|
||||
---
|
||||
arch/arch-x86.h | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/arch/arch-x86.h b/arch/arch-x86.h
|
||||
index c6bcb54..c1005b1 100644
|
||||
--- a/arch/arch-x86.h
|
||||
+++ b/arch/arch-x86.h
|
||||
@@ -35,6 +35,7 @@ static inline unsigned long long get_cpu_clock(void)
|
||||
}
|
||||
|
||||
#define ARCH_HAVE_FFZ
|
||||
-#define ARCH_HAVE_CPU_CLOCK
|
||||
+// Serenity OS doesn't allow you to read rdtsc.
|
||||
+// #define ARCH_HAVE_CPU_CLOCK
|
||||
|
||||
#endif
|
||||
--
|
||||
2.32.0
|
||||
|
25
Ports/fio/patches/ReadMe.md
Normal file
25
Ports/fio/patches/ReadMe.md
Normal file
|
@ -0,0 +1,25 @@
|
|||
# Patches for fio 3.29 on SerenityOS
|
||||
|
||||
## `0001-fio-remove-non-existent-header-sys-ipc.patch`
|
||||
|
||||
Serenity currently doesn't have a <sys/ipc.h> header, so we have to patch the include out.
|
||||
|
||||
## `0002-fio-add-serenityos-platform-support.patch`
|
||||
|
||||
`fio` abstracts individual operating system support out into to an `os/os-<name>.h` header
|
||||
where you can select which platform features are available and implement missing function
|
||||
stubs for our operating system.
|
||||
|
||||
This patch implements basic OS support for Serenity just to get fio up and running.
|
||||
|
||||
## `0003-fio-add-serenityos-support-to-configure.patch`
|
||||
|
||||
This patch implements targetos detection for serenity, and also disables shared memory
|
||||
support automatically for serenity, as it's not currently supported.
|
||||
|
||||
## `0004-fio-disable-rdtsc-support-for-serenityos.patch`
|
||||
|
||||
This patch disables the function which uses `rdtsc` to get the current clock time,
|
||||
as that instruction isn't allowed to be called from user space by serenity.
|
||||
|
||||
If you did attempt to call it you would trip a segfault.
|
Loading…
Reference in a new issue