static int workers_active;
static int worker_count;
+static int job_notify_fd[2];
+
static int run_work_on_queue(struct work_queue *queue)
{
struct work_struct *work;
* ensures next time we start spawning worker threads
* the first thread will have number zero on its name.
*/
- if (!workers_active)
+ if (!workers_active) {
worker_count = 0;
+ /*
+ * Kick the job poller, just to print the time of next
+ * update on the logs
+ */
+ notify_job_request();
+ }
+
mutex_unlock(&work_stats_mutex);
return NULL;
return 0;
}
+static int job_notify_handler(struct event_handler *h)
+{
+ int ret;
+ char buf[64];
+
+ ret = read(job_notify_fd[0], buf, sizeof(buf));
+ if (ret < 0)
+ pr_err("Failed to read: %m\n");
+
+ return 0;
+}
+
/*
* Initialize the jobcontrol.
*
*/
int init_jobcontrol(int max_jobs_requested)
{
+ static struct event_handler ev;
FILE *file;
int ret;
char buf[256];
max_jobs++;
}
+ ret = pipe(job_notify_fd);
+ if (ret) {
+ pr_err("pipe() failed: %m\n");
+ return ret;
+ }
+
+ ev.fd = job_notify_fd[0];
+ ev.events = EPOLLIN;
+ ev.handle_event = job_notify_handler;
+ ev.name = "job_notify";
+ register_event_handler(&ev, EPOLL_CTL_ADD);
+
open_fail:
read_fail:
fclose(file);
return ret;
}
+int notify_job_request(void)
+{
+ int ret;
+ char byte = 0;
+
+ ret = write(job_notify_fd[1], &byte, sizeof(byte));
+ if (ret < 0)
+ pr_err("Failed to write: %m\n");
+
+ return 0;
+}
+
int do_fork(void)
{
int child;
int init_jobcontrol(int max_jobs_requested);
int poll_job_requests(int timeout);
+int notify_job_request(void);
int do_fork(void);
int run(const char *p, char *const argv[]);
int clear_zombie(int pid);