smalloc: oom cleanups
authorJens Axboe <axboe@kernel.dk>
Thu, 22 Mar 2018 14:34:48 +0000 (08:34 -0600)
committerJens Axboe <axboe@kernel.dk>
Thu, 22 Mar 2018 14:34:48 +0000 (08:34 -0600)
Signed-off-by: Jens Axboe <axboe@kernel.dk>
backend.c
cgroup.c
filesetup.c
gettime-thread.c

index a92b1e3..fc83ed1 100644 (file)
--- 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);
index 380e37e..629047b 100644 (file)
--- 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)
index c115f7b..b246e0f 100644 (file)
@@ -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;
                }
 
index eb535a0..0a2cc6c 100644 (file)
@@ -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)