| 527 | } |
| 528 | |
| 529 | static struct lock_prof * |
| 530 | lock_profile_lookup(struct lock_object *lo, int spin, const char *file, |
| 531 | int line) |
| 532 | { |
| 533 | const char *unknown = "(unknown)"; |
| 534 | struct lock_prof_type *type; |
| 535 | struct lock_prof *lp; |
| 536 | struct lphead *head; |
| 537 | const char *p; |
| 538 | u_int hash; |
| 539 | |
| 540 | p = file; |
| 541 | if (p == NULL || *p == '\0') |
| 542 | p = unknown; |
| 543 | hash = (uintptr_t)lo->lo_name * 31 + (uintptr_t)p * 31 + line; |
| 544 | hash &= LPROF_HASH_MASK; |
| 545 | type = &LP_CPU_SELF->lpc_types[spin]; |
| 546 | head = &type->lpt_hash[hash]; |
| 547 | SLIST_FOREACH(lp, head, link) { |
| 548 | if (lp->line == line && lp->file == p && |
| 549 | lp->name == lo->lo_name) |
| 550 | return (lp); |
| 551 | } |
| 552 | lp = SLIST_FIRST(&type->lpt_lpalloc); |
| 553 | if (lp == NULL) { |
| 554 | lock_prof_rejected++; |
| 555 | return (lp); |
| 556 | } |
| 557 | SLIST_REMOVE_HEAD(&type->lpt_lpalloc, link); |
| 558 | lp->file = p; |
| 559 | lp->line = line; |
| 560 | lp->class = LOCK_CLASS(lo); |
| 561 | lp->name = lo->lo_name; |
| 562 | SLIST_INSERT_HEAD(&type->lpt_hash[hash], lp, link); |
| 563 | return (lp); |
| 564 | } |
| 565 | |
| 566 | static struct lock_profile_object * |
| 567 | lock_profile_object_lookup(struct lock_object *lo, int spin, const char *file, |
no outgoing calls
no test coverage detected