Print this page
OS-4937 lxbrand ptracer count updates can race
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Joshua M. Clulow <jmc@joyent.com>
OS-2834 ship lx brand

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/os/pid.c
          +++ new/usr/src/uts/common/os/pid.c
↓ open down ↓ 13 lines elided ↑ open up ↑
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
       24 + * Copyright 2015 Joyent, Inc.
  24   25   */
  25   26  
  26   27  /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
  27   28  /*        All Rights Reserved   */
  28   29  
  29   30  #include <sys/types.h>
  30   31  #include <sys/param.h>
  31   32  #include <sys/sysmacros.h>
  32   33  #include <sys/proc.h>
  33   34  #include <sys/kmem.h>
↓ open down ↓ 71 lines elided ↑ open up ↑
 105  106  
 106  107          for (pidp = HASHPID(pid); pidp; pidp = pidp->pid_link) {
 107  108                  if (pidp->pid_id == pid) {
 108  109                          ASSERT(pidp->pid_ref > 0);
 109  110                          break;
 110  111                  }
 111  112          }
 112  113          return (pidp);
 113  114  }
 114  115  
      116 +struct pid *
      117 +pid_find(pid_t pid)
      118 +{
      119 +        struct pid *pidp;
      120 +
      121 +        mutex_enter(&pidlinklock);
      122 +        pidp = pid_lookup(pid);
      123 +        mutex_exit(&pidlinklock);
      124 +
      125 +        return (pidp);
      126 +}
      127 +
 115  128  void
 116  129  pid_setmin(void)
 117  130  {
 118  131          if (jump_pid && jump_pid > mpid)
 119  132                  minpid = mpid = jump_pid;
 120  133          else
 121  134                  minpid = mpid;
 122  135  }
 123  136  
 124  137  /*
↓ open down ↓ 389 lines elided ↑ open up ↑
 514  527          }
 515  528  
 516  529          ASSERT(p->p_proc_flag & P_PR_LOCK);
 517  530          ASSERT(MUTEX_HELD(&p->p_lock));
 518  531  
 519  532          cv_signal(&pr_pid_cv[p->p_slot]);
 520  533          p->p_proc_flag &= ~P_PR_LOCK;
 521  534          mutex_exit(&p->p_lock);
 522  535          THREAD_KPRI_RELEASE();
 523  536  }
      537 +
      538 +/*
      539 + * Undo effects of sprlock but without dropping p->p_lock
      540 + */
      541 +void
      542 +sprunprlock(proc_t *p)
      543 +{
      544 +        ASSERT(p->p_proc_flag & P_PR_LOCK);
      545 +        ASSERT(MUTEX_HELD(&p->p_lock));
      546 +
      547 +        cv_signal(&pr_pid_cv[p->p_slot]);
      548 +        p->p_proc_flag &= ~P_PR_LOCK;
      549 +        THREAD_KPRI_RELEASE();
      550 +}
 524  551  
 525  552  void
 526  553  pid_init(void)
 527  554  {
 528  555          int i;
 529  556  
 530  557          pid_hashsz = 1 << highbit(v.v_proc / pid_hashlen);
 531  558  
 532  559          pidhash = kmem_zalloc(sizeof (struct pid *) * pid_hashsz, KM_SLEEP);
 533  560          procdir = kmem_alloc(sizeof (union procent) * v.v_proc, KM_SLEEP);
↓ open down ↓ 259 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX