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 a92b1e3c025e1f7f2d4a5500a669f6bea0f7166e..fc83ed178a05eca587570d7de5495a0182930c3f 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));
        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);
 
 
        run_threads(sk_out);
 
@@ -2507,8 +2508,10 @@ int fio_backend(struct sk_out *sk_out)
        }
 
        free_disk_util();
        }
 
        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);
        sfree(cgroup_mnt);
 
        fio_sem_remove(startup_sem);
index 380e37e4870684e9c1dec67d4ccbef85150a4ff4..629047b495b33c145ca545ac4856efdecaf78df5 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;
 
 {
        char *root;
 
+       if (!clist)
+               return 1;
+
        if (!*mnt) {
                *mnt = find_cgroup_mnt(td);
                if (!*mnt)
        if (!*mnt) {
                *mnt = find_cgroup_mnt(td);
                if (!*mnt)
index c115f7b16863a88f411427a424be06f3f558e56a..b246e0f951e99c6534ad201e960b5ba7262812ad 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);
                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);
 
 
        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);
                                __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;
                }
 
                        __f->filetype = f->filetype;
                }
 
index eb535a07cf041250064decdeb1cc9d74f1252703..0a2cc6c451d533d1a5c56ce2ce857c85a7b31de2 100644 (file)
@@ -15,8 +15,6 @@ void fio_gtod_init(void)
                return;
 
        fio_ts = smalloc(sizeof(*fio_ts));
                return;
 
        fio_ts = smalloc(sizeof(*fio_ts));
-       if (!fio_ts)
-               log_err("fio: smalloc pool exhausted\n");
 }
 
 static void fio_gtod_update(void)
 }
 
 static void fio_gtod_update(void)