Ok. thx
On 27 December 2016 at 16:21, Maxim Uvarov <maxim.uva...@linaro.org> wrote: > I merged it with my review. > > Maxim. > > On 27 December 2016 at 17:57, Christophe Milard > <christophe.mil...@linaro.org> wrote: >> >> It needs review, but yes: it is not driver related, i.e. it is >> candidate for next. >> >> Christophe. >> >> On 27 December 2016 at 15:55, Maxim Uvarov <maxim.uva...@linaro.org> >> wrote: >> > Thanks, >> > >> > that is what we discussed. I think that can go to 'next' also, right? >> > >> > Maxim. >> > >> > On 12/21/16 14:11, Christophe Milard wrote: >> >> The size of the shared memory and its user flag set, as given at >> >> reserve >> >> time, are exported and imported so that odp_shm_info() return proper >> >> values on imported blocks >> >> >> >> Signed-off-by: Christophe Milard <christophe.mil...@linaro.org> >> >> --- >> >> platform/linux-generic/_ishm.c | 38 >> >> +++++++++++++++++----- >> >> .../validation/api/shmem/shmem_linux.c | 14 ++++++-- >> >> 2 files changed, 42 insertions(+), 10 deletions(-) >> >> >> >> diff --git a/platform/linux-generic/_ishm.c >> >> b/platform/linux-generic/_ishm.c >> >> index 449e357..8b32709 100644 >> >> --- a/platform/linux-generic/_ishm.c >> >> +++ b/platform/linux-generic/_ishm.c >> >> @@ -124,7 +124,9 @@ >> >> #define EXPORT_FILE_LINE3_FMT "file: %s" >> >> #define EXPORT_FILE_LINE4_FMT "length: %" PRIu64 >> >> #define EXPORT_FILE_LINE5_FMT "flags: %" PRIu32 >> >> -#define EXPORT_FILE_LINE6_FMT "align: %" PRIu32 >> >> +#define EXPORT_FILE_LINE6_FMT "user_length: %" PRIu64 >> >> +#define EXPORT_FILE_LINE7_FMT "user_flags: %" PRIu32 >> >> +#define EXPORT_FILE_LINE8_FMT "align: %" PRIu32 >> >> /* >> >> * A fragment describes a piece of the shared virtual address space, >> >> * and is allocated only when allocation is done with the >> >> _ODP_ISHM_SINGLE_VA >> >> @@ -477,7 +479,11 @@ static int create_file(int block_index, >> >> huge_flag_t huge, uint64_t len, >> >> new_block->filename); >> >> fprintf(export_file, EXPORT_FILE_LINE4_FMT "\n", >> >> len); >> >> fprintf(export_file, EXPORT_FILE_LINE5_FMT "\n", >> >> flags); >> >> - fprintf(export_file, EXPORT_FILE_LINE6_FMT "\n", >> >> align); >> >> + fprintf(export_file, EXPORT_FILE_LINE6_FMT "\n", >> >> + new_block->user_len); >> >> + fprintf(export_file, EXPORT_FILE_LINE7_FMT "\n", >> >> + new_block->user_flags); >> >> + fprintf(export_file, EXPORT_FILE_LINE8_FMT "\n", >> >> align); >> >> >> >> fclose(export_file); >> >> } >> >> @@ -800,6 +806,10 @@ int _odp_ishm_reserve(const char *name, uint64_t >> >> size, int fd, >> >> else >> >> new_block->name[0] = 0; >> >> >> >> + /* save user data: */ >> >> + new_block->user_flags = user_flags; >> >> + new_block->user_len = size; >> >> + >> >> /* If a file descriptor is provided, get the real size and map: >> >> */ >> >> if (fd >= 0) { >> >> fstat(fd, &statbuf); >> >> @@ -911,9 +921,11 @@ int _odp_ishm_find_exported(const char >> >> *remote_name, pid_t external_odp_pid, >> >> FILE *export_file; >> >> uint64_t len; >> >> uint32_t flags; >> >> + uint64_t user_len; >> >> + uint32_t user_flags; >> >> uint32_t align; >> >> int fd; >> >> - int ret; >> >> + int block_index; >> >> >> >> /* try to read the block description file: */ >> >> snprintf(export_filename, ISHM_FILENAME_MAXLEN, >> >> @@ -943,7 +955,13 @@ int _odp_ishm_find_exported(const char >> >> *remote_name, pid_t external_odp_pid, >> >> if (fscanf(export_file, EXPORT_FILE_LINE5_FMT " ", &flags) != 1) >> >> goto error_exp_file; >> >> >> >> - if (fscanf(export_file, EXPORT_FILE_LINE6_FMT " ", &align) != 1) >> >> + if (fscanf(export_file, EXPORT_FILE_LINE6_FMT " ", &user_len) != >> >> 1) >> >> + goto error_exp_file; >> >> + >> >> + if (fscanf(export_file, EXPORT_FILE_LINE7_FMT " ", &user_flags) >> >> != 1) >> >> + goto error_exp_file; >> >> + >> >> + if (fscanf(export_file, EXPORT_FILE_LINE8_FMT " ", &align) != 1) >> >> goto error_exp_file; >> >> >> >> fclose(export_file); >> >> @@ -960,13 +978,17 @@ int _odp_ishm_find_exported(const char >> >> *remote_name, pid_t external_odp_pid, >> >> flags &= ~(uint32_t)_ODP_ISHM_EXPORT; >> >> >> >> /* reserve the memory, providing the opened file descriptor: */ >> >> - ret = _odp_ishm_reserve(local_name, 0, fd, align, flags, 0); >> >> - if (ret < 0) { >> >> + block_index = _odp_ishm_reserve(local_name, 0, fd, align, flags, >> >> 0); >> >> + if (block_index < 0) { >> >> close(fd); >> >> - return ret; >> >> + return block_index; >> >> } >> >> >> >> - return ret; >> >> + /* set inherited info: */ >> >> + ishm_tbl->block[block_index].user_flags = user_flags; >> >> + ishm_tbl->block[block_index].user_len = user_len; >> >> + >> >> + return block_index; >> >> >> >> error_exp_file: >> >> fclose(export_file); >> >> diff --git a/test/linux-generic/validation/api/shmem/shmem_linux.c >> >> b/test/linux-generic/validation/api/shmem/shmem_linux.c >> >> index 39473f3..2f4c762 100644 >> >> --- a/test/linux-generic/validation/api/shmem/shmem_linux.c >> >> +++ b/test/linux-generic/validation/api/shmem/shmem_linux.c >> >> @@ -102,7 +102,8 @@ >> >> */ >> >> static int read_shmem_attribues(uint64_t ext_odp_pid, const char >> >> *blockname, >> >> char *filename, uint64_t *len, >> >> - uint32_t *flags, uint32_t *align) >> >> + uint32_t *flags, uint64_t *user_len, >> >> + uint32_t *user_flags, uint32_t *align) >> >> { >> >> char shm_attr_filename[PATH_MAX]; >> >> FILE *export_file; >> >> @@ -130,6 +131,12 @@ static int read_shmem_attribues(uint64_t >> >> ext_odp_pid, const char *blockname, >> >> if (fscanf(export_file, "flags: %" PRIu32 " ", flags) != 1) >> >> goto export_file_read_err; >> >> >> >> + if (fscanf(export_file, "user_length: %" PRIu64 " ", user_len) != >> >> 1) >> >> + goto export_file_read_err; >> >> + >> >> + if (fscanf(export_file, "user_flags: %" PRIu32 " ", user_flags) >> >> != 1) >> >> + goto export_file_read_err; >> >> + >> >> if (fscanf(export_file, "align: %" PRIu32 " ", align) != 1) >> >> goto export_file_read_err; >> >> >> >> @@ -192,6 +199,8 @@ int main(int argc __attribute__((unused)), char >> >> *argv[]) >> >> char shm_filename[PATH_MAX];/* shared mem device name, under >> >> /dev/shm */ >> >> uint64_t len; >> >> uint32_t flags; >> >> + uint64_t user_len; >> >> + uint32_t user_flags; >> >> uint32_t align; >> >> int shm_fd; >> >> test_shared_linux_data_t *addr; >> >> @@ -231,7 +240,8 @@ int main(int argc __attribute__((unused)), char >> >> *argv[]) >> >> >> >> /* read the shared memory attributes (includes the shm filename): >> >> */ >> >> if (read_shmem_attribues(odp_app1, ODP_SHM_NAME, >> >> - shm_filename, &len, &flags, &align) != >> >> 0) >> >> + shm_filename, &len, &flags, >> >> + &user_len, &user_flags, &align) != 0) >> >> test_failure(fifo_name, fifo_fd, odp_app1); >> >> >> >> /* open the shm filename (which is either on /tmp or on >> >> hugetlbfs) >> >> >> > > >