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/mp_startup.c
          +++ new/usr/src/uts/i86pc/os/mp_startup.c
↓ open down ↓ 19 lines elided ↑ open up ↑
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
  24   24   */
  25   25  /*
  26   26   * Copyright (c) 2010, Intel Corporation.
  27   27   * All rights reserved.
  28   28   */
  29   29  /*
  30      - * Copyright 2015 Joyent, Inc.
       30 + * Copyright 2016 Joyent, Inc.
  31   31   * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
  32   32   */
  33   33  
  34   34  #include <sys/types.h>
  35   35  #include <sys/thread.h>
  36   36  #include <sys/cpuvar.h>
  37   37  #include <sys/cpu.h>
  38   38  #include <sys/t_lock.h>
  39   39  #include <sys/param.h>
  40   40  #include <sys/proc.h>
↓ open down ↓ 199 lines elided ↑ open up ↑
 240  240                   * resume() sets this value to the base of the threads stack
 241  241                   * via a context handler.
 242  242                   */
 243  243                  wrmsr(MSR_INTC_SEP_ESP, 0);
 244  244                  wrmsr(MSR_INTC_SEP_EIP, (uint64_t)(uintptr_t)sys_sysenter);
 245  245          }
 246  246  
 247  247          kpreempt_enable();
 248  248  }
 249  249  
      250 +#if !defined(__xpv)
 250  251  /*
      252 + * Configure per-cpu ID GDT
      253 + */
      254 +static void
      255 +init_cpu_id_gdt(struct cpu *cp)
      256 +{
      257 +        /* Write cpu_id into limit field of GDT for usermode retrieval */
      258 +#if defined(__amd64)
      259 +        set_usegd(&cp->cpu_gdt[GDT_CPUID], SDP_SHORT, NULL, cp->cpu_id,
      260 +            SDT_MEMRODA, SEL_UPL, SDP_BYTES, SDP_OP32);
      261 +#elif defined(__i386)
      262 +        set_usegd(&cp->cpu_gdt[GDT_CPUID], NULL, cp->cpu_id, SDT_MEMRODA,
      263 +            SEL_UPL, SDP_BYTES, SDP_OP32);
      264 +#endif
      265 +}
      266 +#endif /* !defined(__xpv) */
      267 +
      268 +/*
 251  269   * Multiprocessor initialization.
 252  270   *
 253  271   * Allocate and initialize the cpu structure, TRAPTRACE buffer, and the
 254  272   * startup and idle threads for the specified CPU.
 255  273   * Parameter boot is true for boot time operations and is false for CPU
 256  274   * DR operations.
 257  275   */
 258  276  static struct cpu *
 259  277  mp_cpu_configure_common(int cpun, boolean_t boot)
 260  278  {
↓ open down ↓ 162 lines elided ↑ open up ↑
 423  441          if (is_x86_feature(x86_featureset, X86FSET_MWAIT) &&
 424  442              idle_cpu_prefer_mwait) {
 425  443                  cp->cpu_m.mcpu_mwait = cpuid_mwait_alloc(cp);
 426  444                  cp->cpu_m.mcpu_idle_cpu = cpu_idle_mwait;
 427  445          } else
 428  446  #endif
 429  447                  cp->cpu_m.mcpu_idle_cpu = cpu_idle;
 430  448  
 431  449          init_cpu_info(cp);
 432  450  
      451 +#if !defined(__xpv)
      452 +        init_cpu_id_gdt(cp);
      453 +#endif
      454 +
 433  455          /*
 434  456           * alloc space for ucode_info
 435  457           */
 436  458          ucode_alloc_space(cp);
 437  459          xc_init_cpu(cp);
 438  460          hat_cpu_online(cp);
 439  461  
 440  462  #ifdef TRAPTRACE
 441  463          /*
 442  464           * If this is a TRAPTRACE kernel, allocate TRAPTRACE buffers
↓ open down ↓ 1036 lines elided ↑ open up ↑
1479 1501          _NOTE(ARGUNUSED(cprboot));
1480 1502  
1481 1503          uint_t who;
1482 1504          uint_t bootcpuid = 0;
1483 1505  
1484 1506          /*
1485 1507           * Initialize our own cpu_info.
1486 1508           */
1487 1509          init_cpu_info(CPU);
1488 1510  
     1511 +#if !defined(__xpv)
     1512 +        init_cpu_id_gdt(CPU);
     1513 +#endif
     1514 +
1489 1515          cmn_err(CE_CONT, "?cpu%d: %s\n", CPU->cpu_id, CPU->cpu_idstr);
1490 1516          cmn_err(CE_CONT, "?cpu%d: %s\n", CPU->cpu_id, CPU->cpu_brandstr);
1491 1517  
1492 1518          /*
1493 1519           * Initialize our syscall handlers
1494 1520           */
1495 1521          init_cpu_syscall(CPU);
1496 1522  
1497 1523          /*
1498 1524           * Take the boot cpu out of the mp_cpus set because we know
↓ open down ↓ 561 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX