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>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/i86pc/os/mlsetup.c
          +++ new/usr/src/uts/i86pc/os/mlsetup.c
↓ open down ↓ 15 lines elided ↑ open up ↑
  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   * Copyright (c) 2012 Gary Mills
  23   23   *
  24   24   * Copyright (c) 1993, 2010, Oracle and/or its affiliates. All rights reserved.
  25   25   * Copyright (c) 2011 by Delphix. All rights reserved.
       26 + * Copyright 2016 Joyent, Inc.
  26   27   */
  27   28  /*
  28   29   * Copyright (c) 2010, Intel Corporation.
  29   30   * All rights reserved.
  30   31   */
  31   32  
  32   33  #include <sys/types.h>
  33   34  #include <sys/sysmacros.h>
  34   35  #include <sys/disp.h>
  35   36  #include <sys/promif.h>
↓ open down ↓ 18 lines elided ↑ open up ↑
  54   55  #include <sys/privregs.h>
  55   56  #include <sys/machsystm.h>
  56   57  #include <sys/ontrap.h>
  57   58  #include <sys/bootconf.h>
  58   59  #include <sys/boot_console.h>
  59   60  #include <sys/kdi_machimpl.h>
  60   61  #include <sys/archsystm.h>
  61   62  #include <sys/promif.h>
  62   63  #include <sys/pci_cfgspace.h>
  63   64  #include <sys/bootvfs.h>
       65 +#include <sys/tsc.h>
  64   66  #ifdef __xpv
  65   67  #include <sys/hypervisor.h>
  66   68  #else
  67   69  #include <sys/xpv_support.h>
  68   70  #endif
  69   71  
  70   72  /*
  71   73   * some globals for patching the result of cpuid
  72   74   * to solve problems w/ creative cpu vendors
  73   75   */
↓ open down ↓ 146 lines elided ↑ open up ↑
 220  222           * instruction serialization nature of mfence instruction.
 221  223           * Note: tsc_read is not patched for x86 processors which do
 222  224           * not support "mfence". By default tsc_read will use cpuid for
 223  225           * serialization in such cases.
 224  226           *
 225  227           * The Xen hypervisor does not correctly report whether rdtscp is
 226  228           * supported or not, so we must assume that it is not.
 227  229           */
 228  230          if ((get_hwenv() & HW_XEN_HVM) == 0 &&
 229  231              is_x86_feature(x86_featureset, X86FSET_TSCP))
 230      -                patch_tsc_read(X86_HAVE_TSCP);
      232 +                patch_tsc_read(TSC_TSCP);
 231  233          else if (cpuid_getvendor(CPU) == X86_VENDOR_AMD &&
 232  234              cpuid_getfamily(CPU) <= 0xf &&
 233  235              is_x86_feature(x86_featureset, X86FSET_SSE2))
 234      -                patch_tsc_read(X86_TSC_MFENCE);
      236 +                patch_tsc_read(TSC_RDTSC_MFENCE);
 235  237          else if (cpuid_getvendor(CPU) == X86_VENDOR_Intel &&
 236  238              cpuid_getfamily(CPU) <= 6 &&
 237  239              is_x86_feature(x86_featureset, X86FSET_SSE2))
 238      -                patch_tsc_read(X86_TSC_LFENCE);
      240 +                patch_tsc_read(TSC_RDTSC_LFENCE);
 239  241  
 240  242  #endif  /* !__xpv */
 241  243  
 242  244  #if defined(__i386) && !defined(__xpv)
 243  245          /*
 244  246           * Some i386 processors do not implement the rdtsc instruction,
 245  247           * or at least they do not implement it correctly. Patch them to
 246  248           * return 0.
 247  249           */
 248  250          if (!is_x86_feature(x86_featureset, X86FSET_TSC))
 249      -                patch_tsc_read(X86_NO_TSC);
      251 +                patch_tsc_read(TSC_NONE);
 250  252  #endif  /* __i386 && !__xpv */
 251  253  
 252  254  #if defined(__amd64) && !defined(__xpv)
 253  255          patch_memops(cpuid_getvendor(CPU));
 254  256  #endif  /* __amd64 && !__xpv */
 255  257  
 256  258  #if !defined(__xpv)
 257  259          /* XXPV what, if anything, should be dorked with here under xen? */
 258  260  
 259  261          /*
↓ open down ↓ 253 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX