Module Name:    src
Committed By:   riastradh
Date:           Sun Dec 19 01:51:02 UTC 2021

Modified Files:
        src/sys/external/bsd/common/include/linux: workqueue.h
        src/sys/external/bsd/common/linux: linux_work.c

Log Message:
alloc_workqueue


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 \
    src/sys/external/bsd/common/include/linux/workqueue.h
cvs rdiff -u -r1.51 -r1.52 src/sys/external/bsd/common/linux/linux_work.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/common/include/linux/workqueue.h
diff -u src/sys/external/bsd/common/include/linux/workqueue.h:1.20 src/sys/external/bsd/common/include/linux/workqueue.h:1.21
--- src/sys/external/bsd/common/include/linux/workqueue.h:1.20	Sun Dec 19 01:41:12 2021
+++ src/sys/external/bsd/common/include/linux/workqueue.h	Sun Dec 19 01:51:02 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: workqueue.h,v 1.20 2021/12/19 01:41:12 riastradh Exp $	*/
+/*	$NetBSD: workqueue.h,v 1.21 2021/12/19 01:51:02 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013, 2018 The NetBSD Foundation, Inc.
@@ -39,6 +39,7 @@
 
 #define	INIT_DELAYED_WORK		linux_INIT_DELAYED_WORK
 #define	INIT_WORK			linux_INIT_WORK
+#define	alloc_workqueue			linux_alloc_workqueue
 #define	alloc_ordered_workqueue		linux_alloc_ordered_workqueue
 #define	cancel_delayed_work		linux_cancel_delayed_work
 #define	cancel_delayed_work_sync	linux_cancel_delayed_work_sync
@@ -85,6 +86,11 @@ struct delayed_work {
 	}				dw_state;
 };
 
+#define	WQ_FREEZABLE		__BIT(0)
+#define	WQ_HIGHPRI		__BIT(1)
+#define	WQ_MEM_RECLAIM		__BIT(2)
+#define	WQ_UNBOUND		__BIT(3)
+
 static inline struct delayed_work *
 to_delayed_work(struct work_struct *work)
 {
@@ -103,6 +109,8 @@ void	linux_workqueue_fini(void);
 	alloc_ordered_workqueue((name), 0)
 
 struct workqueue_struct *
+	alloc_workqueue(const char *, int, unsigned);
+struct workqueue_struct *
 	alloc_ordered_workqueue(const char *, int);
 void	destroy_workqueue(struct workqueue_struct *);
 void	flush_workqueue(struct workqueue_struct *);

Index: src/sys/external/bsd/common/linux/linux_work.c
diff -u src/sys/external/bsd/common/linux/linux_work.c:1.51 src/sys/external/bsd/common/linux/linux_work.c:1.52
--- src/sys/external/bsd/common/linux/linux_work.c:1.51	Sun Dec 19 01:24:13 2021
+++ src/sys/external/bsd/common/linux/linux_work.c	Sun Dec 19 01:51:02 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_work.c,v 1.51 2021/12/19 01:24:13 riastradh Exp $	*/
+/*	$NetBSD: linux_work.c,v 1.52 2021/12/19 01:51:02 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_work.c,v 1.51 2021/12/19 01:24:13 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_work.c,v 1.52 2021/12/19 01:51:02 riastradh Exp $");
 
 #include <sys/types.h>
 #include <sys/atomic.h>
@@ -224,19 +224,20 @@ linux_workqueue_fini(void)
  */
 
 /*
- * alloc_ordered_workqueue(name, flags)
+ * alloc_workqueue(name, flags, max_active)
  *
- *	Create a workqueue of the given name.  No flags are currently
- *	defined.  Return NULL on failure, pointer to struct
- *	workqueue_struct object on success.
+ *	Create a workqueue of the given name.  max_active is the
+ *	maximum number of work items in flight, or 0 for the default.
+ *	Return NULL on failure, pointer to struct workqueue_struct
+ *	object on success.
  */
 struct workqueue_struct *
-alloc_ordered_workqueue(const char *name, int flags)
+alloc_workqueue(const char *name, int flags, unsigned max_active)
 {
 	struct workqueue_struct *wq;
 	int error;
 
-	KASSERT(flags == 0);
+	KASSERT(max_active == 0 || max_active == 1);
 
 	wq = kmem_zalloc(sizeof(*wq), KM_SLEEP);
 
@@ -270,6 +271,18 @@ fail0:	KASSERT(TAILQ_EMPTY(&wq->wq_dqueu
 }
 
 /*
+ * alloc_ordered_workqueue(name, flags)
+ *
+ *	Same as alloc_workqueue(name, flags, 1).
+ */
+struct workqueue_struct *
+alloc_ordered_workqueue(const char *name, int flags)
+{
+
+	return alloc_workqueue(name, flags, 1);
+}
+
+/*
  * destroy_workqueue(wq)
  *
  *	Destroy a workqueue created with wq.  Cancel any pending

Reply via email to