-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fs_mark dummyfs support #68
base: master
Are you sure you want to change the base?
Conversation
47236c3
to
737efe4
Compare
c31e844
to
9ca9a4a
Compare
c67a862
to
c7349d8
Compare
8ba5992
to
62d697a
Compare
To see tests results go to: phoenix-rtos/phoenix-rtos-project#802 |
62d697a
to
f84af5d
Compare
f84af5d
to
e153701
Compare
JIRA: RTOS-997
JIRA: CI-315
e153701
to
6c64d4e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have left a few comments. Passing CPPFLAGS
and differentiating targets by the NOMMU
define seems unnecessary. There are many fine-grained POSIX defines to use and maybe feature test macros could be employed in the future.
FS_MARK_VER="3.3" | ||
FS_MARK=fs_mark-${FS_MARK_VER} | ||
VER="3.3" | ||
FS_MARK="fs_mark-$VER" | ||
FS_MARK_COMMIT="2628be58146de63a13260ff64550f84275556c0e" | ||
PKG_URL="https://github.com/josefbacik/fs_mark/archive/${FS_MARK_COMMIT}.tar.gz" | ||
PKG_MIRROR_URL="https://files.phoesys.com/ports/${FS_MARK}.tar.gz" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a few utility functions (and variables from build.sh) available for ports. Take a look:
https://github.com/phoenix-rtos/phoenix-rtos-ports/blob/7c6793d75d5b3e92e309a232c7d37ca893035aec/build.subr
Example usage:
phoenix-rtos-ports/lua/build.sh
Line 13 in 7c6793d
b_port_download "https://www.lua.org/ftp/" "${archive_filename}" |
You can use them now if you want or leave that for later (all ports will be refactored some day).
do_run(my_pid); | ||
|
||
+#ifdef NOMMU | ||
+ memset(names, 0, sizeof(struct name_entry) * num_files); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed on NOMMU targets? Doesn't the "work thread" exit after returning from thread_work()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fs_mark
can run multiple loops with each calling thread_work(), so I had to reinitialize this array back to zero's after each loop
*/ | ||
df_full = get_df_full(child_tasks[0].test_dir); | ||
|
||
+ usleep(100000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed? Is this related to console output being interleaved with something else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a problem with parts of logs being lost, so I used this sleep just for now to make it work.
+ #undef MAX_NAME_PATH | ||
+ | ||
+ #define MAX_IO_BUFFER_SIZE (1024 * 32) /* Max write buffer size is 32KB */ | ||
+ #define MAX_NAME_PATH (200) /* Length of the pathname before the leaf */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess that you are trying to avoid huge static allocations on low-RAM targets. NOMMU option itself doesn't imply that the target device has a tiny pool of RAM.
I think the most flexible solution is to use calloc()
, as is the case with struct name_entry *names
. The behavior would remain the same (use DEFAULT_IO_SIZE==(16 * 1024)
bytes), but the problem of static allocation vanishes. Also, it seems to be a simple fix: change io_buffer
into a pointer and replace memset(io_buffer, 0, io_buffer_size);
with a call to calloc()
. Freeing the memory is not of concern, because the author already ignores that part (it would be important if "worker threads" used threads instead of forked children).
When it comes to MAX_NAME_PATH
and FILENAME_SIZE
, you can use defines from <limits.h>: PATH_MAX
and NAME_MAX
. They are defined per-architecture and seem to be perfect for this use case. (See: libphoenix/include/arch/*/limits.h)
int do_fill_fs = 0; /* Run until the file system is full */ | ||
int verbose_stats = 0; /* Print complete stats for each system call */ | ||
-char log_file_name[PATH_MAX] = "fs_log.txt"; /* Log file name for run */ | ||
+char log_file_name[PATH_MAX - 16] = "fs_log.txt"; /* Log file name for run, reserve space for suffix */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You subtract 16 to accommodate for PID suffix appended in a few places in the source file? If so, please include that information in the comment to make it clear why it is changed (i.e. that fs_mark is flaky and you fix their own bugs) and note that there is
strncpy(log_file_name, optarg, PATH_MAX);
in -l
option handling code which also has to be changed.
|
||
+#ifdef NOMMU | ||
+ #define FORK vfork | ||
+ file_count = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is file_count = 0
needed on NOMMU targets?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
names
and file_count
are two variables that I need to reset after each loop, because NOMMU use vfork()
to run thread_work()
+ | ||
for (i = 0; i < num_threads; i++) { | ||
- if ((child_tasks[i].child_pid = fork()) == -1) { | ||
+ if ((child_tasks[i].child_pid = FORK()) == -1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using vfork()
actually defeats the whole purpose of running fs_mark with multiple "child tasks", i.e. concurrent operations on files. vfork()
, as opposed to fork()
, causes the parent to suspend execution until its vforked child exits or execs, so every "child task" is executed sequentially.
I don't see any test commands (phoenix-rtos/phoenix-rtos-tests#233) to use more than one thread, so maybe this can be left unimplemented for now on NOMMU targets. fs_mark could use actual threads (via pthreads) instead of forking, but there are so many globals that refactoring would be quite cumbersome.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make it work with threads instead of processes on NOMMU can be a tedious task, so I wanted to make it run with just a 1 thread.
Description
Motivation and Context
Types of changes
How Has This Been Tested?
Checklist:
Special treatment