Commit 4a06a7f4 authored by Maria Matejka's avatar Maria Matejka Committed by Maria Matejka
Browse files

TMP

parent 4a52e828
Loading
Loading
Loading
Loading
+20 −1
Original line number Diff line number Diff line
@@ -166,7 +166,7 @@ class BIRDWQStateLogPrinter(BIRDPrinter):
    typeTag = "worker_queue_state"

    def queueval(self):
        return "%(worker) 4d %(what)s: running %(running)s, workers %(workers)s, max_workers %(max_workers)s, stop %(stop)s, pending %(pending)s" % {
        return "%(worker) 4d %(what)s: running %(running)s, workers %(workers)s, max_workers %(max_workers)s, stop %(stop)s, pending %(pending)s, blocked %(blocked)s, postponed %(postponed)s" % {
                "worker": self.val['worker_id'],
                "what": str(self.val['what']),
                "running": str(self.val['queue']['running']),
@@ -174,6 +174,8 @@ class BIRDWQStateLogPrinter(BIRDPrinter):
                "max_workers": str(self.val['queue']['max_workers']),
                "stop": str(self.val['queue']['stop']),
                "pending": str(self.val['queue']['pending']),
                "blocked": str(self.val['queue']['blocked']),
                "postponed": str(self.val['queue']['postponed']),
                }

    def semval(self):
@@ -227,6 +229,19 @@ class BIRDWQStateLogPrinter(BIRDPrinter):
                "lockstate": self.lockstate(),
                }

    def taskval(self):
        return "%(worker) 4d %(what)s: %(execute)s with%(out)s flags %(tf_exclusive)s%(tf_tail)s%(tf_idempotent)s%(tf_prepended)son %(domain)s" % {
                "worker": self.val['worker_id'],
                "what": str(self.val["what"]),
                "execute": str(self.val["task"]["execute"]),
                "domain": str(self.val["domain"]["domain"]),
                "out": "out" if self.val["task"]["flags"] == 0 else "",
                "tf_exclusive": "TF_EXCLUSIVE " if self.val["task"]["flags"] & 0x1 == 0x1 else "",
                "tf_tail": "TF_TAIL " if self.val["task"]["flags"] & 0x2 == 0x2 else "",
                "tf_idempotent": "TF_IDEMPOTENT " if self.val["task"]["flags"] & 0x4 == 0x4 else "",
                "tf_prepended": "TF_PREPENDED " if self.val["task"]["flags"] & 0x100 == 0x100 else "",
                }

    def nothing(self):
        return "nothing"

@@ -252,6 +267,10 @@ class BIRDWQStateLogPrinter(BIRDPrinter):
                "WQS_DOMAIN_WRUNLOCK_REQUEST": self.domval,
                "WQS_DOMAIN_RDUNLOCK_DONE": self.domval,
                "WQS_DOMAIN_WRUNLOCK_DONE": self.domval,
                "WQS_TASK_PUSHED": self.taskval,
                "WQS_TASK_BLOCKED": self.taskval,
                "WQS_TASK_STARTED": self.taskval,
                "WQS_TASK_DONE": self.taskval,
                }[str(self.val['what'])]()

def register_printers(objfile):
+6 −4
Original line number Diff line number Diff line
@@ -109,15 +109,17 @@ uint list_length(list *);
}

#define TNODE(n) (n)->node
#define THEAD(list) list.head
#define TTAIL(list) list.tail
#define THEAD(list) (list)->head
#define TNEXT(n) (n)->_tln.next
#define TPREV(n) (n)->_tln.prev
#define TTAIL(list) (list)->tail
#define TNODE_IN_LIST(n) (((n)->_tln.next) && ((n)->_tln.prev))

#define TLIST_NODE_TYPE(l) typeof(*(l.head))
#define TLIST_NODE_TYPE(l) typeof(*((l)->head))

#define TLIST_EMPTY(list) ((list)->head == ((list)->tail_node.node))

#define WALK_TLIST(n_, list) for (n_ = (list).head; n_->_tln.next; n_ = n_->_tln.next)
#define WALK_TLIST(n_, list) for (n_ = THEAD(list); n_->_tln.next; n_ = n_->_tln.next)
#define WALK_TLIST_DELSAFE(n_, list) for (typeof(n_) next_ = n_ = THEAD(list); next_ = n_->_tln.next; n_ = next_)

#define INIT_TLIST(list) do { \
+20 −8
Original line number Diff line number Diff line
@@ -30,6 +30,8 @@ typedef _Atomic u64 spinlock;
    bug("The spinlock is locked by worker %lu but shall be locked by %lu!", expected, worker_id); \
} while (0)

#define SPIN_INIT(_sp) atomic_store_explicit(&(_sp), NOWORKER, memory_order_relaxed);


#define LOCKED_LIST(_type) struct { \
  TLIST(_type) _llist; \
@@ -41,18 +43,28 @@ typedef _Atomic u64 spinlock;
  spinlock *_lsp; \
}

#define WLL_RETURN(list_...) return (domain_read_unlock(list_._lld), ##what)

#define INIT_LOCKED_LIST(list_) do { \
  INIT_TLIST(&((list_)->_llist)); \
  atomic_store_explicit(&((list_)->_lsp), NOWORKER, memory_order_relaxed); \
  SPIN_INIT(((list_)->_lsp)); \
} while (0)

#define LOCKED_LIST_LOCK(list_, token) do { typeof(&((list_)->_llist)) token = &((list_)->_llist); SPIN_LOCK((list_)->_lsp); do
#define LOCKED_LIST_UNLOCK(list_) while (0); SPIN_UNLOCK((list_)->_lsp); } while (0)

#define GET_HEAD_LOCKED(list_) ({ \
    TLIST_NODE_TYPE((list_)->_llist) *node_ = NULL; \
    SPIN_LOCK((list_)->_lsp); \
    if (!TLIST_EMPTY(&((list_)->_llist))) \
      node_ = THEAD(&((list_)->_llist)); \
    SPIN_UNLOCK((list_)->_lsp); \
    node_; \
    })

#define ADD_HEAD_LOCKED(list_, node_) do { \
  node_->_lsp = &(list_->_lsp); \
  SPIN_LOCK(list_->_lsp); \
  node_->_lsp = &((list_)->_lsp); \
  SPIN_LOCK((list_)->_lsp); \
  TADD_HEAD(&((list_)->_llist), node_); \
  SPIN_UNLOCK(list_->_lsp); \
  SPIN_UNLOCK((list_)->_lsp); \
} while (0)

#define ADD_TAIL_LOCKED(list_, node_) do { \
@@ -63,10 +75,10 @@ typedef _Atomic u64 spinlock;
} while (0)

#define REM_HEAD_LOCKED(list_) ({ \
    TLIST_NODE_TYPE((list_)->_llist) *node_ = NULL; \
    TLIST_NODE_TYPE(&((list_)->_llist)) *node_ = NULL; \
    SPIN_LOCK((list_)->_lsp); \
    if (!TLIST_EMPTY(&((list_)->_llist))) { \
      node_ = THEAD((list_)->_llist); \
      node_ = THEAD(&((list_)->_llist)); \
      TREM_NODE(node_); \
    } \
    SPIN_UNLOCK((list_)->_lsp); \
+1 −1
Original line number Diff line number Diff line
@@ -75,7 +75,7 @@ pool_free(resource *P)
  pool *p = (pool *) P;
  resource *r;

  WALK_TLIST_DELSAFE(r, p->inside)
  WALK_TLIST_DELSAFE(r, &(p->inside))
    {
      r->class->free(r);
      xfree(r);
+2 −0
Original line number Diff line number Diff line
@@ -30,6 +30,8 @@ void domain_assert_unlocked(struct domain *);
enum task_flags {
  /* These flags can be set by the user */
  TF_EXCLUSIVE = 0x1,		/* Lock the domain exclusively */
  TF_TAIL = 0x2,		/* This is the last task produced by current task */
  TF_IDEMPOTENT = 0x4,		/* Do nothing if task already pushed */
  TF_PUBLIC_MASK = 0xff,	/* Flags are masked by this value on task push */
  /* These flags are private for worker queue */
  TF_PREPENDED = 0x100,		/* Task is waiting for the first free worker */
Loading