Print this page
OS-2366 ddi_periodic_add(9F) is entirely rubbish

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/i86pc/io/pcplusmp/apic.c
          +++ new/usr/src/uts/i86pc/io/pcplusmp/apic.c
↓ open down ↓ 18 lines elided ↑ open up ↑
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright (c) 1993, 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 +/*
       30 + * Copyright (c) 2013, Joyent, Inc.  All rights reserved.
       31 + */
  29   32  
  30   33  /*
  31   34   * To understand how the pcplusmp module interacts with the interrupt subsystem
  32   35   * read the theory statement in uts/i86pc/os/intr.c.
  33   36   */
  34   37  
  35   38  /*
  36   39   * PSMI 1.1 extensions are supported only in 2.6 and later versions.
  37   40   * PSMI 1.2 extensions are supported only in 2.7 and later versions.
  38   41   * PSMI 1.3 and 1.4 extensions are supported in Solaris 10.
↓ open down ↓ 27 lines elided ↑ open up ↑
  66   69  #include <sys/trap.h>
  67   70  #include <sys/machsystm.h>
  68   71  #include <sys/sysmacros.h>
  69   72  #include <sys/cpuvar.h>
  70   73  #include <sys/rm_platter.h>
  71   74  #include <sys/privregs.h>
  72   75  #include <sys/note.h>
  73   76  #include <sys/pci_intr_lib.h>
  74   77  #include <sys/spl.h>
  75   78  #include <sys/clock.h>
       79 +#include <sys/cyclic.h>
  76   80  #include <sys/dditypes.h>
  77   81  #include <sys/sunddi.h>
  78   82  #include <sys/x_call.h>
  79   83  #include <sys/reboot.h>
  80   84  #include <sys/hpet.h>
  81   85  #include <sys/apic_common.h>
  82   86  #include <sys/apic_timer.h>
  83   87  
  84   88  /*
  85   89   *      Local Function Prototypes
↓ open down ↓ 901 lines elided ↑ open up ↑
 987  991  
 988  992  /*
 989  993   * If this module needs a periodic handler for the interrupt distribution, it
 990  994   * can be added here. The argument to the periodic handler is not currently
 991  995   * used, but is reserved for future.
 992  996   */
 993  997  static void
 994  998  apic_post_cyclic_setup(void *arg)
 995  999  {
 996 1000  _NOTE(ARGUNUSED(arg))
     1001 +
     1002 +        cyc_handler_t cyh;
     1003 +        cyc_time_t cyt;
     1004 +
 997 1005          /* cpu_lock is held */
 998 1006          /* set up a periodic handler for intr redistribution */
 999 1007  
1000 1008          /*
1001 1009           * In peridoc mode intr redistribution processing is done in
1002 1010           * apic_intr_enter during clk intr processing
1003 1011           */
1004 1012          if (!apic_oneshot)
1005 1013                  return;
     1014 +
1006 1015          /*
1007 1016           * Register a periodical handler for the redistribution processing.
1008      -         * On X86, CY_LOW_LEVEL is mapped to the level 2 interrupt, so
1009      -         * DDI_IPL_2 should be passed to ddi_periodic_add() here.
     1017 +         * Though we would generally prefer to use the DDI interface for
     1018 +         * periodic handler invocation, ddi_periodic_add(9F), we are
     1019 +         * unfortunately already holding cpu_lock, which ddi_periodic_add will
     1020 +         * attempt to take for us.  Thus, we add our own cyclic directly:
1010 1021           */
1011      -        apic_periodic_id = ddi_periodic_add(
1012      -            (void (*)(void *))apic_redistribute_compute, NULL,
1013      -            apic_redistribute_sample_interval, DDI_IPL_2);
     1022 +        cyh.cyh_func = (void (*)(void *))apic_redistribute_compute;
     1023 +        cyh.cyh_arg = NULL;
     1024 +        cyh.cyh_level = CY_LOW_LEVEL;
     1025 +
     1026 +        cyt.cyt_when = 0;
     1027 +        cyt.cyt_interval = apic_redistribute_sample_interval;
     1028 +
     1029 +        apic_cyclic_id = cyclic_add(&cyh, &cyt);
1014 1030  }
1015 1031  
1016 1032  static void
1017 1033  apic_redistribute_compute(void)
1018 1034  {
1019 1035          int     i, j, max_busy;
1020 1036  
1021 1037          if (apic_enable_dynamic_migration) {
1022 1038                  if (++apic_nticks == apic_sample_factor_redistribution) {
1023 1039                          /*
↓ open down ↓ 363 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX