Otherwise we have per-job lists, and that doesn't help very much
with cleaning up.
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
#include "cgroup.h"
#include "smalloc.h"
#include "cgroup.h"
#include "smalloc.h"
-static struct flist_head *cgroup_list;
static struct fio_mutex *lock;
struct cgroup_member {
static struct fio_mutex *lock;
struct cgroup_member {
-static void add_cgroup(const char *name)
+static void add_cgroup(const char *name, struct flist_head *clist)
{
struct cgroup_member *cm;
{
struct cgroup_member *cm;
cm->root = smalloc_strdup(name);
fio_mutex_down(lock);
cm->root = smalloc_strdup(name);
fio_mutex_down(lock);
-
- if (!cgroup_list) {
- cgroup_list = smalloc(sizeof(struct flist_head));
- INIT_FLIST_HEAD(cgroup_list);
- }
-
- flist_add_tail(&cm->list, cgroup_list);
+ flist_add_tail(&cm->list, clist);
+void cgroup_kill(struct flist_head *clist)
{
struct flist_head *n, *tmp;
struct cgroup_member *cm;
fio_mutex_down(lock);
{
struct flist_head *n, *tmp;
struct cgroup_member *cm;
fio_mutex_down(lock);
- if (!cgroup_list)
- goto out;
- flist_for_each_safe(n, tmp, cgroup_list) {
+ flist_for_each_safe(n, tmp, clist) {
cm = flist_entry(n, struct cgroup_member, list);
rmdir(cm->root);
flist_del(&cm->list);
cm = flist_entry(n, struct cgroup_member, list);
rmdir(cm->root);
flist_del(&cm->list);
- sfree(cgroup_list);
- cgroup_list = NULL;
-out:
fprintf(f, "%d", td->pid);
fclose(f);
return 0;
fprintf(f, "%d", td->pid);
fclose(f);
return 0;
return cgroup_write_pid(td, td->o.cgroup_root);
}
return cgroup_write_pid(td, td->o.cgroup_root);
}
-int cgroup_setup(struct thread_data *td)
+int cgroup_setup(struct thread_data *td, struct flist_head *clist)
{
char *root, tmp[256];
FILE *f;
{
char *root, tmp[256];
FILE *f;
+ add_cgroup(root, clist);
if (td->o.cgroup_weight) {
sprintf(tmp, "%s/blkio.weight", root);
if (td->o.cgroup_weight) {
sprintf(tmp, "%s/blkio.weight", root);
static void fio_init cgroup_init(void)
{
lock = fio_mutex_init(1);
static void fio_init cgroup_init(void)
{
lock = fio_mutex_init(1);
-int cgroup_setup(struct thread_data *td);
+int cgroup_setup(struct thread_data *td, struct flist_head *list);
void cgroup_shutdown(struct thread_data *td);
void cgroup_shutdown(struct thread_data *td);
+void cgroup_kill(struct flist_head *list);
-static inline int cgroup_setup(struct thread_data *td)
+static inline int cgroup_setup(struct thread_data *td, struct flist_head *list);
{
td_verror(td, EINVAL, "cgroup_setup");
return 1;
{
td_verror(td, EINVAL, "cgroup_setup");
return 1;
+void cgroup_kill(struct flist_head *list);
static int exit_value;
static struct itimerval itimer;
static pthread_t gtod_thread;
static int exit_value;
static struct itimerval itimer;
static pthread_t gtod_thread;
+static struct flist_head *cgroup_list;
struct io_log *agg_io_log[2];
struct io_log *agg_io_log[2];
- if (td->o.cgroup_weight && cgroup_setup(td))
+ if (td->o.cgroup_weight && cgroup_setup(td, cgroup_list))
goto err;
if (nice(td->o.nice) == -1) {
goto err;
if (nice(td->o.nice) == -1) {
+ cgroup_list = smalloc(sizeof(*cgroup_list));
+ INIT_FLIST_HEAD(cgroup_list);
+
run_threads();
if (!fio_abort) {
run_threads();
if (!fio_abort) {
+ cgroup_kill(cgroup_list);
+ sfree(cgroup_list);
fio_mutex_remove(startup_mutex);
fio_mutex_remove(writeout_mutex);
fio_mutex_remove(startup_mutex);
fio_mutex_remove(writeout_mutex);