Print this page
OS-5192 need faster clock_gettime
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Joshua M. Clulow <jmc@joyent.com>
Reviewed by: Ryan Zezeski <ryan@zinascii.com>


   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
  25  * Copyright (c) 2014 by Delphix. All rights reserved.

  26  */
  27 
  28 /*
  29  *  Copyright (c) 1990, 1991 UNIX System Laboratories, Inc.
  30  *  Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T
  31  *    All Rights Reserved
  32  */
  33 
  34 /*
  35  * Copyright (c) 2009, Intel Corporation.
  36  * All rights reserved.
  37  */
  38 
  39 /*
  40  * General assembly language routines.
  41  * It is the intent of this file to contain routines that are
  42  * independent of the specific kernel architecture, and those that are
  43  * common across kernel architectures.
  44  * As architectures diverge, and implementations of specific
  45  * architecture-dependent routines change, the routines should be moved


3573         movl    %esp, %ebx                      / %ebx = current stack pointer
3574 
3575         lea     panic_quiesce, %eax             / %eax = &panic_quiesce
3576         pushl   %eax                            / push &panic_quiesce
3577         call    dtrace_panic_trigger            / %eax = dtrace_panic_trigger()
3578         addl    $4, %esp                        / reset stack pointer
3579         jmp     vpanic_common                   / jump back to common code
3580 
3581         SET_SIZE(dtrace_vpanic)
3582 
3583 #endif  /* __i386 */
3584 #endif  /* __lint */
3585 
3586 #if defined(__lint)
3587 
3588 void
3589 hres_tick(void)
3590 {}
3591 
3592 int64_t timedelta;
3593 hrtime_t hres_last_tick;
3594 volatile timestruc_t hrestime;
3595 int64_t hrestime_adj;
3596 volatile int hres_lock;
3597 hrtime_t hrtime_base;
3598 
3599 #else   /* __lint */
3600 
3601         DGDEF3(hrestime, _MUL(2, CLONGSIZE), 8)
3602         .NWORD  0, 0
3603 
3604         DGDEF3(hrestime_adj, 8, 8)
3605         .long   0, 0
3606 
3607         DGDEF3(hres_last_tick, 8, 8)
3608         .long   0, 0
3609 
3610         DGDEF3(timedelta, 8, 8)
3611         .long   0, 0
3612 
3613         DGDEF3(hres_lock, 4, 8)
3614         .long   0
3615 
3616         /*
3617          * initialized to a non zero value to make pc_gethrtime()
3618          * work correctly even before clock is initialized
3619          */
3620         DGDEF3(hrtime_base, 8, 8)
3621         .long   _MUL(NSEC_PER_CLOCK_TICK, 6), 0
3622 
3623         DGDEF3(adj_shift, 4, 4)
3624         .long   ADJ_SHIFT
3625 
3626 #if defined(__amd64)
3627 
3628         ENTRY_NP(hres_tick)
3629         pushq   %rbp
3630         movq    %rsp, %rbp
3631 
3632         /*
3633          * We need to call *gethrtimef before picking up CLOCK_LOCK (obviously,
3634          * hres_last_tick can only be modified while holding CLOCK_LOCK).
3635          * At worst, performing this now instead of under CLOCK_LOCK may




   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
  25  * Copyright (c) 2014 by Delphix. All rights reserved.
  26  * Copyright 2016 Joyent, Inc.
  27  */
  28 
  29 /*
  30  *  Copyright (c) 1990, 1991 UNIX System Laboratories, Inc.
  31  *  Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T
  32  *    All Rights Reserved
  33  */
  34 
  35 /*
  36  * Copyright (c) 2009, Intel Corporation.
  37  * All rights reserved.
  38  */
  39 
  40 /*
  41  * General assembly language routines.
  42  * It is the intent of this file to contain routines that are
  43  * independent of the specific kernel architecture, and those that are
  44  * common across kernel architectures.
  45  * As architectures diverge, and implementations of specific
  46  * architecture-dependent routines change, the routines should be moved


3574         movl    %esp, %ebx                      / %ebx = current stack pointer
3575 
3576         lea     panic_quiesce, %eax             / %eax = &panic_quiesce
3577         pushl   %eax                            / push &panic_quiesce
3578         call    dtrace_panic_trigger            / %eax = dtrace_panic_trigger()
3579         addl    $4, %esp                        / reset stack pointer
3580         jmp     vpanic_common                   / jump back to common code
3581 
3582         SET_SIZE(dtrace_vpanic)
3583 
3584 #endif  /* __i386 */
3585 #endif  /* __lint */
3586 
3587 #if defined(__lint)
3588 
3589 void
3590 hres_tick(void)
3591 {}
3592 
3593 int64_t timedelta;




3594 hrtime_t hrtime_base;
3595 
3596 #else   /* __lint */
3597 









3598         DGDEF3(timedelta, 8, 8)
3599         .long   0, 0
3600 



3601         /*
3602          * initialized to a non zero value to make pc_gethrtime()
3603          * work correctly even before clock is initialized
3604          */
3605         DGDEF3(hrtime_base, 8, 8)
3606         .long   _MUL(NSEC_PER_CLOCK_TICK, 6), 0
3607 
3608         DGDEF3(adj_shift, 4, 4)
3609         .long   ADJ_SHIFT
3610 
3611 #if defined(__amd64)
3612 
3613         ENTRY_NP(hres_tick)
3614         pushq   %rbp
3615         movq    %rsp, %rbp
3616 
3617         /*
3618          * We need to call *gethrtimef before picking up CLOCK_LOCK (obviously,
3619          * hres_last_tick can only be modified while holding CLOCK_LOCK).
3620          * At worst, performing this now instead of under CLOCK_LOCK may