From b2e6494cd9b2195d8df250444d750d10f61a12b5 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 22 Mar 2018 08:34:48 -0600 Subject: [PATCH] smalloc: oom cleanups Signed-off-by: Jens Axboe --- backend.c | 9 ++++++--- cgroup.c | 3 +++ filesetup.c | 9 +++++---- gettime-thread.c | 2 -- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/backend.c b/backend.c index a92b1e3c..fc83ed17 100644 --- a/backend.c +++ b/backend.c @@ -2477,7 +2477,8 @@ int fio_backend(struct sk_out *sk_out) helper_thread_create(startup_sem, sk_out); cgroup_list = smalloc(sizeof(*cgroup_list)); - INIT_FLIST_HEAD(cgroup_list); + if (cgroup_list) + INIT_FLIST_HEAD(cgroup_list); run_threads(sk_out); @@ -2507,8 +2508,10 @@ int fio_backend(struct sk_out *sk_out) } free_disk_util(); - cgroup_kill(cgroup_list); - sfree(cgroup_list); + if (cgroup_list) { + cgroup_kill(cgroup_list); + sfree(cgroup_list); + } sfree(cgroup_mnt); fio_sem_remove(startup_sem); diff --git a/cgroup.c b/cgroup.c index 380e37e4..629047b4 100644 --- a/cgroup.c +++ b/cgroup.c @@ -147,6 +147,9 @@ int cgroup_setup(struct thread_data *td, struct flist_head *clist, char **mnt) { char *root; + if (!clist) + return 1; + if (!*mnt) { *mnt = find_cgroup_mnt(td); if (!*mnt) diff --git a/filesetup.c b/filesetup.c index c115f7b1..b246e0f9 100644 --- a/filesetup.c +++ b/filesetup.c @@ -1608,8 +1608,9 @@ int add_file(struct thread_data *td, const char *fname, int numjob, int inc) f->file_name = strdup(file_name); else f->file_name = smalloc_strdup(file_name); - if (!f->file_name) - assert(0); + + /* can't handle smalloc failure from here */ + assert(f->file_name); get_file_type(f); @@ -1814,9 +1815,9 @@ void dup_files(struct thread_data *td, struct thread_data *org) __f->file_name = strdup(f->file_name); else __f->file_name = smalloc_strdup(f->file_name); - if (!__f->file_name) - assert(0); + /* can't handle smalloc failure from here */ + assert(__f->file_name); __f->filetype = f->filetype; } diff --git a/gettime-thread.c b/gettime-thread.c index eb535a07..0a2cc6c4 100644 --- a/gettime-thread.c +++ b/gettime-thread.c @@ -15,8 +15,6 @@ void fio_gtod_init(void) return; fio_ts = smalloc(sizeof(*fio_ts)); - if (!fio_ts) - log_err("fio: smalloc pool exhausted\n"); } static void fio_gtod_update(void) -- 2.25.1