Source-Changes-D archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/sys/dev/acpi



Looks reasonable to me.

In the man-page update, please refer to "an already scheduled function" (insert the word "an").


On Tue, 4 Jan 2011, Jukka Ruohonen wrote:

On Tue, Jan 04, 2011 at 05:48:49AM +0000, Jukka Ruohonen wrote:
  "Do not queue functions via sysmon_taskq(9) in the pmf(9) resume hooks.
   There is a small and unlikely race when the drivers are loaded as modules;
   suspend, resume, queue a function, and immediately unload the module."

Anything against adding for instance the following to sysmon_taskq(9)? Or
better ideas how this should be handled?

- Jukka.

Index: sysmon_taskq.c
===================================================================
RCS file: /cvsroot/src/sys/dev/sysmon/sysmon_taskq.c,v
retrieving revision 1.14
diff -u -p -r1.14 sysmon_taskq.c
--- sysmon_taskq.c      5 Sep 2008 22:06:52 -0000       1.14
+++ sysmon_taskq.c      4 Jan 2011 06:17:45 -0000
@@ -209,3 +209,30 @@ sysmon_task_queue_sched(u_int pri, void

        return 0;
}
+
+/*
+ * sysmon_task_queue_cancel:
+ *
+ *     Cancel a scheduled task.
+ */
+int
+sysmon_task_queue_cancel(void (*func)(void *))
+{
+       struct sysmon_task *st;
+
+       if (func == NULL)
+               return EINVAL;
+
+       mutex_enter(&sysmon_task_queue_mtx);
+       TAILQ_FOREACH(st, &sysmon_task_queue, st_list) {
+               if (st->st_func == func) {
+                       TAILQ_REMOVE(&sysmon_task_queue, st, st_list);
+                       mutex_exit(&sysmon_task_queue_mtx);
+                       free(st, M_TEMP);
+                       mutex_enter(&sysmon_task_queue_mtx);
+               }
+       }
+       mutex_exit(&sysmon_task_queue_mtx);
+
+       return 0;
+}
Index: sysmon_taskq.h
===================================================================
RCS file: /cvsroot/src/sys/dev/sysmon/sysmon_taskq.h,v
retrieving revision 1.2
diff -u -p -r1.2 sysmon_taskq.h
--- sysmon_taskq.h      21 Jul 2007 23:15:17 -0000      1.2
+++ sysmon_taskq.h      4 Jan 2011 06:17:45 -0000
@@ -42,5 +42,6 @@ void  sysmon_task_queue_preinit(void);
void    sysmon_task_queue_init(void);
void    sysmon_task_queue_fini(void);
int     sysmon_task_queue_sched(u_int, void (*)(void *), void *);
+int    sysmon_task_queue_cancel(void (*func)(void *));

#endif /* _DEV_SYSMON_SYSMON_TASKQ_H_ */
Index: sysmon_taskq.9
===================================================================
RCS file: /cvsroot/src/share/man/man9/sysmon_taskq.9,v
retrieving revision 1.6
diff -u -p -r1.6 sysmon_taskq.9
--- sysmon_taskq.9      26 Jan 2010 08:48:39 -0000      1.6
+++ sysmon_taskq.9      4 Jan 2011 06:18:23 -0000
@@ -43,6 +43,8 @@
.Fn sysmon_task_queue_fini "void"
.Ft int
.Fn sysmon_task_queue_sched "u_int pri" "void (*func)(void *)" "void *arg"
+.Ft int
+.Fn sysmon_task_queue_cancel "void (*func)(void *)"
.Sh DESCRIPTION
The machine-independent
.Nm
@@ -78,10 +80,15 @@ The single argument passed to
.Fa func
is specified by
.Fa arg .
+The
+.Fn sysmon_task_queue_cancel
+function can be used to cancel the execution of already scheduled function.
.Sh RETURN VALUES
-Upon successful completion,
+Both
.Fn sysmon_task_queue_sched
-returns 0.
+and
+.Fn sysmon_task_queue_cancel
+return 0 upon successful completion,
Otherwise, the following error values are returned:
.Bl -tag -width [EINVAL]
.It Bq Er EINVAL

!DSPAM:4d22bca92344589720801!




-------------------------------------------------------------------------
| Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:       |
| Customer Service | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com    |
| Network Engineer | 0786 F758 55DE 53BA 7731 | pgoyette at juniper.net |
| Kernel Developer |                          | pgoyette at netbsd.org  |
-------------------------------------------------------------------------


Home | Main Index | Thread Index | Old Index