FreeBSD: Use a hash table for taskqid lookups

Previously a tqent could be recycled prematurely, update the
code to use a hash table for lookups to resolve this.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Ryan Moeller <ryan@ixsystems.com>
Signed-off-by: Matt Macy <mmacy@FreeBSD.org>
Closes #10529
This commit is contained in:
Matthew Macy
2020-07-11 17:13:45 -07:00
committed by GitHub
parent 6f1db5f37e
commit 3933305eac
2 changed files with 129 additions and 53 deletions
+10 -9
View File
@@ -30,6 +30,7 @@
#include <sys/proc.h>
#include <sys/taskqueue.h>
#include <sys/thread.h>
#include <sys/ck.h>
#ifdef __cplusplus
extern "C" {
@@ -37,26 +38,26 @@ extern "C" {
#define TASKQ_NAMELEN 31
struct taskqueue;
struct taskq {
typedef struct taskq {
struct taskqueue *tq_queue;
};
} taskq_t;
typedef struct taskq taskq_t;
typedef uintptr_t taskqid_t;
typedef void (task_func_t)(void *);
typedef struct taskq_ent {
struct task tqent_task;
struct timeout_task tqent_timeout_task;
task_func_t *tqent_func;
void *tqent_arg;
struct timeout_task tqent_timeout_task;
int tqent_type;
int tqent_gen;
taskqid_t tqent_id;
CK_LIST_ENTRY(taskq_ent) tqent_hash;
uint8_t tqent_type;
uint8_t tqent_registered;
uint8_t tqent_cancelled;
volatile uint32_t tqent_rc;
} taskq_ent_t;
struct proc;
/*
* Public flags for taskq_create(): bit range 0-15
*/