From 562a15affc56c9d6e3ff69fb594524971d38ecb8 Mon Sep 17 00:00:00 2001 From: Anway De Date: Tue, 9 Apr 2024 22:56:00 +0000 Subject: [PATCH] shmem: use unified mount path --- src/app/fdctl/config.c | 16 ++++++++++++++-- src/app/fdctl/config.h | 1 + src/app/fdctl/config/default.toml | 18 ++++++++---------- src/app/fdctl/main1.c | 10 +++++++++- 4 files changed, 32 insertions(+), 13 deletions(-) diff --git a/src/app/fdctl/config.c b/src/app/fdctl/config.c index ba57e4491c..9e13e2d9a4 100644 --- a/src/app/fdctl/config.c +++ b/src/app/fdctl/config.c @@ -238,8 +238,7 @@ static int parse_key_value( config_t * config, ENTRY_UINT ( ., layout, bank_tile_count ); ENTRY_UINT ( ., layout, shred_tile_count ); - ENTRY_STR ( ., hugetlbfs, gigantic_page_mount_path ); - ENTRY_STR ( ., hugetlbfs, huge_page_mount_path ); + ENTRY_STR ( ., hugetlbfs, mount_path ); ENTRY_STR ( ., tiles.net, interface ); ENTRY_STR ( ., tiles.net, xdp_mode ); @@ -921,6 +920,19 @@ config_parse( int * pargc, if( FD_UNLIKELY( getgid() != 0 && config->gid != getgid() ) ) FD_LOG_ERR(( "running as gid %i, but config specifies gid %i", getgid(), config->gid )); + ulong len = strlen( config->hugetlbfs.mount_path ); + if( FD_UNLIKELY( !len ) ) FD_LOG_ERR(( "[hugetlbfs.mount_path] must be non-empty in your configuration file" )); + FD_TEST( fd_cstr_printf_check( config->hugetlbfs.gigantic_page_mount_path, + sizeof(config->hugetlbfs.gigantic_page_mount_path), + NULL, + "%s/.gigantic", + config->hugetlbfs.mount_path ) ); + FD_TEST( fd_cstr_printf_check( config->hugetlbfs.huge_page_mount_path, + sizeof(config->hugetlbfs.huge_page_mount_path), + NULL, + "%s/.huge", + config->hugetlbfs.mount_path ) ); + replace( config->log.path, "{user}", config->user ); replace( config->log.path, "{name}", config->name ); if( FD_LIKELY( !strcmp( "auto", config->log.colorize ) ) ) config->log.colorize1 = 2; diff --git a/src/app/fdctl/config.h b/src/app/fdctl/config.h index b124c6c355..bb062c8a76 100644 --- a/src/app/fdctl/config.h +++ b/src/app/fdctl/config.h @@ -128,6 +128,7 @@ typedef struct { struct { char gigantic_page_mount_path[ PATH_MAX ]; char huge_page_mount_path[ PATH_MAX ]; + char mount_path[ PATH_MAX ]; } hugetlbfs; struct { diff --git a/src/app/fdctl/config/default.toml b/src/app/fdctl/config/default.toml index a16bc8496b..40e18bdabc 100644 --- a/src/app/fdctl/config/default.toml +++ b/src/app/fdctl/config/default.toml @@ -578,16 +578,14 @@ dynamic_port_range = "8900-9000" # +-- scratch2.wksp [hugetlbfs] # The absolute path to a directory in the filesystem. Firedancer - # will mount the hugetlbfs filesystem for gigantic pages at this - # path, or if the path already exists, will use it as-is. If the - # mount already exists it should be writable by the Firedancer user. - gigantic_page_mount_path = "/mnt/.fd/.gigantic" - - # The absolute path to a directory in the filesystem. Firedancer - # will mount the hugetlbfs filesystem for huge pages at this path, - # or if the path already exists, will use it as-is. If the mount - # already exists it should be writable by the Firedancer user. - huge_page_mount_path = "/mnt/.fd/.huge" + # will mount the hugetlbfs filesystem for gigantic pages at a + # subdirectory named .gigantic under this path, or if the entire + # path already exists, will use it as-is. Firedancer will also + # mount the hugetlbfs filesystem for huge pages at a subdirectory + # named .huge under this path, or if the entire path already exists, + # will use it as-is. If the mount already exists it should be + # writable by the Firedancer user. + mount_path = "/mnt/.fd" # Tiles are described in detail in the layout section above. While the # layout configuration determines how many of each tile to place on diff --git a/src/app/fdctl/main1.c b/src/app/fdctl/main1.c index 344063dfa2..c4bf630129 100644 --- a/src/app/fdctl/main1.c +++ b/src/app/fdctl/main1.c @@ -170,6 +170,14 @@ fdctl_boot( int * pargc, strncpy( config->log.path, log_path, sizeof( config->log.path ) - 1 ); } + char * shmem_args[ 3 ]; + /* pass in --shmem-path value from the config */ + shmem_args[ 0 ] = "--shmem-path"; + shmem_args[ 1 ] = config->hugetlbfs.mount_path; + shmem_args[ 2 ] = NULL; + char ** argv = shmem_args; + int argc = 2; + int * log_lock = map_log_memfd( config->log.lock_fd ); ulong pid = fd_sandbox_getpid(); /* Need to read /proc since we might be in a PID namespace now */; @@ -199,7 +207,7 @@ fdctl_boot( int * pargc, config->log.log_fd, log_path ); config->log.log_fd = fd_log_private_logfile_fd(); - fd_shmem_private_boot( pargc, pargv );; + fd_shmem_private_boot( &argc, &argv ); fd_tile_private_boot( 0, NULL ); /* Kind of a hack but initializing NUMA config depends on shmem, which