Lines Matching defs:queue
40 token_idx_t token_free_idx = 0; /* head of free queue */
43 * be added onto token queue */
61 static token_idx_t vm_purgeable_token_remove_first(purgeable_q_t queue);
65 vm_purgeable_token_check_queue(purgeable_q_t queue)
68 token_idx_t token = queue->token_q_head;
74 assert(queue->token_q_unripe);
76 assert(token == queue->token_q_unripe);
82 assert(queue->token_q_tail == token);
89 assert(queue->token_q_unripe == unripe);
90 assert(token_cnt == queue->debug_count_tokens);
92 /* obsolete queue doesn't maintain token counts */
93 if(queue->type != PURGEABLE_Q_TYPE_OBSOLETE)
95 our_inactive_count = page_cnt + queue->new_pages + token_new_pagecount;
103 vm_purgeable_token_add(purgeable_q_t queue)
133 /* Drop page queue lock so we can allocate */
194 if (queue->type != PURGEABLE_Q_TYPE_OBSOLETE)
195 tokens[token].count = queue->new_pages;
199 queue->new_pages = 0;
203 if (queue->token_q_tail == 0) {
204 assert(queue->token_q_head == 0 && queue->token_q_unripe == 0);
205 queue->token_q_head = token;
207 tokens[queue->token_q_tail].next = token;
209 if (queue->token_q_unripe == 0) { /* only ripe tokens (token
210 * count == 0) in queue */
212 queue->token_q_unripe = token; /* first unripe token */
217 queue->token_q_tail = token;
220 queue->debug_count_tokens++;
226 queue->type,
229 queue->debug_count_tokens,
238 * Remove first token from queue and return its index. Add its count to the
242 vm_purgeable_token_remove_first(purgeable_q_t queue)
245 token = queue->token_q_head;
250 assert(queue->token_q_tail);
251 if (queue->token_q_head == queue->token_q_unripe) {
253 queue->token_q_unripe = tokens[token].next;
260 if (queue->token_q_tail == queue->token_q_head)
263 queue->token_q_head = tokens[token].next;
264 if (queue->token_q_head) {
265 tokens[queue->token_q_head].count += tokens[token].count;
267 /* currently no other tokens in the queue */
272 queue->new_pages += tokens[token].count;
274 queue->token_q_tail = 0;
278 queue->debug_count_tokens--;
279 vm_purgeable_token_check_queue(queue);
282 queue->type,
283 tokens[queue->token_q_head].count, /* num pages on new
294 /* Delete first token from queue. Return token to token queue. */
296 vm_purgeable_token_delete_first(purgeable_q_t queue)
298 token_idx_t token = vm_purgeable_token_remove_first(queue);
301 /* stick removed token on free queue */
311 /* check queue counters - if they get really large, scale them back.
312 * They tend to get that large when there is no purgeable queue action */
333 * No need to advance obsolete queue - all items are ripe there,
337 purgeable_q_t queue = &purgeable_queues[i];
341 while (queue->token_q_unripe) {
342 if (tokens[queue->token_q_unripe].count && num_pages)
344 tokens[queue->token_q_unripe].count -= 1;
348 if (tokens[queue->token_q_unripe].count == 0) {
349 queue->token_q_unripe = tokens[queue->token_q_unripe].next;
352 queue->type,
353 tokens[queue->token_q_head].count, /* num pages on new
367 * if there are no unripe tokens in the queue, decrement the
369 * canceled out by token_new_pagecount -- since inactive queue as a
372 if (!queue->token_q_unripe) {
373 queue->new_pages -= num_pages;
374 assert((int32_t) token_new_pagecount + queue->new_pages >= 0);
377 vm_purgeable_token_check_queue(queue);
383 * grab any ripe object and purge it obsolete queue first. then, go through
384 * each volatile group. Select a queue with a ripe token.
386 * 1. Look at queue. Is there an object?
388 * No - check other queue. Is there an object?
391 * token from other queue and migrate unripe token from this
392 * queue to other queue.
395 vm_purgeable_token_remove_ripe(purgeable_q_t queue)
397 assert(queue->token_q_head && tokens[queue->token_q_head].count == 0);
399 token_idx_t new_head = tokens[queue->token_q_head].next;
400 tokens[queue->token_q_head].next = token_free_idx;
401 token_free_idx = queue->token_q_head;
402 queue->token_q_head = new_head;
404 queue->token_q_tail = 0;
407 queue->debug_count_tokens--;
408 vm_purgeable_token_check_queue(queue);
416 * Delete a ripe token from the given queue. If there are no ripe tokens on
417 * that queue, delete a ripe token from queue2, and migrate an unripe token
418 * from queue to queue2
421 vm_purgeable_token_choose_and_delete_ripe(purgeable_q_t queue, purgeable_q_t queue2)
423 assert(queue->token_q_head);
425 if (tokens[queue->token_q_head].count == 0) {
426 /* This queue has a ripe token. Remove. */
427 vm_purgeable_token_remove_ripe(queue);
432 * from queue to queue2.
440 assert(queue->token_q_unripe == queue->token_q_head); /* queue1 had no unripe
442 token = vm_purgeable_token_remove_first(queue);
489 vm_purgeable_object_find_and_lock(purgeable_q_t queue, int group)
492 * Usually we would pick the first element from a queue. However, we
498 for (object = (vm_object_t) queue_first(&queue->objq[group]);
499 !queue_end(&queue->objq[group], (queue_entry_t) object);
503 queue_remove(&queue->objq[group], object,
508 queue->debug_count_objects--;
523 purgeable_q_t queue, queue2;
528 queue = &purgeable_queues[i];
531 * Are there any ripe tokens on this queue? If yes, we'll
534 if (!(queue->token_q_head && tokens[queue->token_q_head].count == 0))
536 * queue */
541 * fail). If locking is successful, we can drop the queue
545 if (!queue_empty(&queue->objq[group]) &&
546 (object = vm_purgeable_object_find_and_lock(queue, group))) {
548 vm_purgeable_token_choose_and_delete_ripe(queue, 0);
561 vm_purgeable_token_choose_and_delete_ripe(queue2, queue);
565 assert(queue->debug_count_objects >= 0);
591 vm_purgeable_object_add(vm_object_t object, purgeable_q_t queue, int group)
595 if (queue->type == PURGEABLE_Q_TYPE_OBSOLETE)
597 if (queue->type != PURGEABLE_Q_TYPE_LIFO) /* fifo and obsolete are
599 queue_enter(&queue->objq[group], object, vm_object_t, objq); /* last to die */
601 queue_enter_first(&queue->objq[group], object, vm_object_t, objq); /* first to die */
604 queue->debug_count_objects++;
607 tokens[queue->token_q_head].count,
608 queue->type,
616 /* Look for object. If found, remove from purgeable queue. */
625 purgeable_q_t queue = &purgeable_queues[i];
628 for (o = (vm_object_t) queue_first(&queue->objq[group]);
629 !queue_end(&queue->objq[group], (queue_entry_t) o);
632 queue_remove(&queue->objq[group], object,
635 queue->debug_count_objects--;
638 tokens[queue->token_q_head].count,
639 queue->type,