Merge branch 'linus' into perf/core
authorIngo Molnar <mingo@kernel.org>
Thu, 29 Aug 2013 10:02:08 +0000 (12:02 +0200)
committerIngo Molnar <mingo@kernel.org>
Thu, 29 Aug 2013 10:02:08 +0000 (12:02 +0200)
Pick up the latest upstream fixes.

Signed-off-by: Ingo Molnar <mingo@kernel.org>
1  2 
arch/x86/kernel/cpu/perf_event_intel_uncore.c
include/linux/sched.h
kernel/sched/core.c
kernel/sched/fair.c

@@@ -6,8 -6,6 +6,8 @@@ static struct intel_uncore_type **pci_u
  /* pci bus to socket mapping */
  static int pcibus_to_physid[256] = { [0 ... 255] = -1, };
  
 +static struct pci_dev *extra_pci_dev[UNCORE_SOCKET_MAX][UNCORE_EXTRA_PCI_DEV_MAX];
 +
  static DEFINE_RAW_SPINLOCK(uncore_box_lock);
  
  /* mask of cpus that collect uncore events */
@@@ -47,24 -45,6 +47,24 @@@ DEFINE_UNCORE_FORMAT_ATTR(filter_band0
  DEFINE_UNCORE_FORMAT_ATTR(filter_band1, filter_band1, "config1:8-15");
  DEFINE_UNCORE_FORMAT_ATTR(filter_band2, filter_band2, "config1:16-23");
  DEFINE_UNCORE_FORMAT_ATTR(filter_band3, filter_band3, "config1:24-31");
 +DEFINE_UNCORE_FORMAT_ATTR(match_rds, match_rds, "config1:48-51");
 +DEFINE_UNCORE_FORMAT_ATTR(match_rnid30, match_rnid30, "config1:32-35");
 +DEFINE_UNCORE_FORMAT_ATTR(match_rnid4, match_rnid4, "config1:31");
 +DEFINE_UNCORE_FORMAT_ATTR(match_dnid, match_dnid, "config1:13-17");
 +DEFINE_UNCORE_FORMAT_ATTR(match_mc, match_mc, "config1:9-12");
 +DEFINE_UNCORE_FORMAT_ATTR(match_opc, match_opc, "config1:5-8");
 +DEFINE_UNCORE_FORMAT_ATTR(match_vnw, match_vnw, "config1:3-4");
 +DEFINE_UNCORE_FORMAT_ATTR(match0, match0, "config1:0-31");
 +DEFINE_UNCORE_FORMAT_ATTR(match1, match1, "config1:32-63");
 +DEFINE_UNCORE_FORMAT_ATTR(mask_rds, mask_rds, "config2:48-51");
 +DEFINE_UNCORE_FORMAT_ATTR(mask_rnid30, mask_rnid30, "config2:32-35");
 +DEFINE_UNCORE_FORMAT_ATTR(mask_rnid4, mask_rnid4, "config2:31");
 +DEFINE_UNCORE_FORMAT_ATTR(mask_dnid, mask_dnid, "config2:13-17");
 +DEFINE_UNCORE_FORMAT_ATTR(mask_mc, mask_mc, "config2:9-12");
 +DEFINE_UNCORE_FORMAT_ATTR(mask_opc, mask_opc, "config2:5-8");
 +DEFINE_UNCORE_FORMAT_ATTR(mask_vnw, mask_vnw, "config2:3-4");
 +DEFINE_UNCORE_FORMAT_ATTR(mask0, mask0, "config2:0-31");
 +DEFINE_UNCORE_FORMAT_ATTR(mask1, mask1, "config2:32-63");
  
  static u64 uncore_msr_read_counter(struct intel_uncore_box *box, struct perf_event *event)
  {
@@@ -301,7 -281,7 +301,7 @@@ static struct attribute *snbep_uncore_c
  };
  
  static struct attribute *snbep_uncore_pcu_formats_attr[] = {
 -      &format_attr_event.attr,
 +      &format_attr_event_ext.attr,
        &format_attr_occ_sel.attr,
        &format_attr_edge.attr,
        &format_attr_inv.attr,
@@@ -321,24 -301,6 +321,24 @@@ static struct attribute *snbep_uncore_q
        &format_attr_edge.attr,
        &format_attr_inv.attr,
        &format_attr_thresh8.attr,
 +      &format_attr_match_rds.attr,
 +      &format_attr_match_rnid30.attr,
 +      &format_attr_match_rnid4.attr,
 +      &format_attr_match_dnid.attr,
 +      &format_attr_match_mc.attr,
 +      &format_attr_match_opc.attr,
 +      &format_attr_match_vnw.attr,
 +      &format_attr_match0.attr,
 +      &format_attr_match1.attr,
 +      &format_attr_mask_rds.attr,
 +      &format_attr_mask_rnid30.attr,
 +      &format_attr_mask_rnid4.attr,
 +      &format_attr_mask_dnid.attr,
 +      &format_attr_mask_mc.attr,
 +      &format_attr_mask_opc.attr,
 +      &format_attr_mask_vnw.attr,
 +      &format_attr_mask0.attr,
 +      &format_attr_mask1.attr,
        NULL,
  };
  
@@@ -352,8 -314,8 +352,8 @@@ static struct uncore_event_desc snbep_u
  static struct uncore_event_desc snbep_uncore_qpi_events[] = {
        INTEL_UNCORE_EVENT_DESC(clockticks,       "event=0x14"),
        INTEL_UNCORE_EVENT_DESC(txl_flits_active, "event=0x00,umask=0x06"),
-       INTEL_UNCORE_EVENT_DESC(drs_data,         "event=0x02,umask=0x08"),
-       INTEL_UNCORE_EVENT_DESC(ncb_data,         "event=0x03,umask=0x04"),
+       INTEL_UNCORE_EVENT_DESC(drs_data,         "event=0x102,umask=0x08"),
+       INTEL_UNCORE_EVENT_DESC(ncb_data,         "event=0x103,umask=0x04"),
        { /* end: all zeroes */ },
  };
  
@@@ -394,16 -356,13 +394,16 @@@ static struct intel_uncore_ops snbep_un
        SNBEP_UNCORE_MSR_OPS_COMMON_INIT(),
  };
  
 +#define SNBEP_UNCORE_PCI_OPS_COMMON_INIT()                    \
 +      .init_box       = snbep_uncore_pci_init_box,            \
 +      .disable_box    = snbep_uncore_pci_disable_box,         \
 +      .enable_box     = snbep_uncore_pci_enable_box,          \
 +      .disable_event  = snbep_uncore_pci_disable_event,       \
 +      .read_counter   = snbep_uncore_pci_read_counter
 +
  static struct intel_uncore_ops snbep_uncore_pci_ops = {
 -      .init_box       = snbep_uncore_pci_init_box,
 -      .disable_box    = snbep_uncore_pci_disable_box,
 -      .enable_box     = snbep_uncore_pci_enable_box,
 -      .disable_event  = snbep_uncore_pci_disable_event,
 -      .enable_event   = snbep_uncore_pci_enable_event,
 -      .read_counter   = snbep_uncore_pci_read_counter,
 +      SNBEP_UNCORE_PCI_OPS_COMMON_INIT(),
 +      .enable_event   = snbep_uncore_pci_enable_event,        \
  };
  
  static struct event_constraint snbep_uncore_cbox_constraints[] = {
@@@ -767,61 -726,6 +767,61 @@@ static struct intel_uncore_type *snbep_
        NULL,
  };
  
 +enum {
 +      SNBEP_PCI_QPI_PORT0_FILTER,
 +      SNBEP_PCI_QPI_PORT1_FILTER,
 +};
 +
 +static int snbep_qpi_hw_config(struct intel_uncore_box *box, struct perf_event *event)
 +{
 +      struct hw_perf_event *hwc = &event->hw;
 +      struct hw_perf_event_extra *reg1 = &hwc->extra_reg;
 +      struct hw_perf_event_extra *reg2 = &hwc->branch_reg;
 +
 +      if ((hwc->config & SNBEP_PMON_CTL_EV_SEL_MASK) == 0x38) {
 +              reg1->idx = 0;
 +              reg1->reg = SNBEP_Q_Py_PCI_PMON_PKT_MATCH0;
 +              reg1->config = event->attr.config1;
 +              reg2->reg = SNBEP_Q_Py_PCI_PMON_PKT_MASK0;
 +              reg2->config = event->attr.config2;
 +      }
 +      return 0;
 +}
 +
 +static void snbep_qpi_enable_event(struct intel_uncore_box *box, struct perf_event *event)
 +{
 +      struct pci_dev *pdev = box->pci_dev;
 +      struct hw_perf_event *hwc = &event->hw;
 +      struct hw_perf_event_extra *reg1 = &hwc->extra_reg;
 +      struct hw_perf_event_extra *reg2 = &hwc->branch_reg;
 +
 +      if (reg1->idx != EXTRA_REG_NONE) {
 +              int idx = box->pmu->pmu_idx + SNBEP_PCI_QPI_PORT0_FILTER;
 +              struct pci_dev *filter_pdev = extra_pci_dev[box->phys_id][idx];
 +              WARN_ON_ONCE(!filter_pdev);
 +              if (filter_pdev) {
 +                      pci_write_config_dword(filter_pdev, reg1->reg,
 +                                              (u32)reg1->config);
 +                      pci_write_config_dword(filter_pdev, reg1->reg + 4,
 +                                              (u32)(reg1->config >> 32));
 +                      pci_write_config_dword(filter_pdev, reg2->reg,
 +                                              (u32)reg2->config);
 +                      pci_write_config_dword(filter_pdev, reg2->reg + 4,
 +                                              (u32)(reg2->config >> 32));
 +              }
 +      }
 +
 +      pci_write_config_dword(pdev, hwc->config_base, hwc->config | SNBEP_PMON_CTL_EN);
 +}
 +
 +static struct intel_uncore_ops snbep_uncore_qpi_ops = {
 +      SNBEP_UNCORE_PCI_OPS_COMMON_INIT(),
 +      .enable_event           = snbep_qpi_enable_event,
 +      .hw_config              = snbep_qpi_hw_config,
 +      .get_constraint         = uncore_get_constraint,
 +      .put_constraint         = uncore_put_constraint,
 +};
 +
  #define SNBEP_UNCORE_PCI_COMMON_INIT()                                \
        .perf_ctr       = SNBEP_PCI_PMON_CTR0,                  \
        .event_ctl      = SNBEP_PCI_PMON_CTL0,                  \
@@@ -851,18 -755,17 +851,18 @@@ static struct intel_uncore_type snbep_u
  };
  
  static struct intel_uncore_type snbep_uncore_qpi = {
 -      .name           = "qpi",
 -      .num_counters   = 4,
 -      .num_boxes      = 2,
 -      .perf_ctr_bits  = 48,
 -      .perf_ctr       = SNBEP_PCI_PMON_CTR0,
 -      .event_ctl      = SNBEP_PCI_PMON_CTL0,
 -      .event_mask     = SNBEP_QPI_PCI_PMON_RAW_EVENT_MASK,
 -      .box_ctl        = SNBEP_PCI_PMON_BOX_CTL,
 -      .ops            = &snbep_uncore_pci_ops,
 -      .event_descs    = snbep_uncore_qpi_events,
 -      .format_group   = &snbep_uncore_qpi_format_group,
 +      .name                   = "qpi",
 +      .num_counters           = 4,
 +      .num_boxes              = 2,
 +      .perf_ctr_bits          = 48,
 +      .perf_ctr               = SNBEP_PCI_PMON_CTR0,
 +      .event_ctl              = SNBEP_PCI_PMON_CTL0,
 +      .event_mask             = SNBEP_QPI_PCI_PMON_RAW_EVENT_MASK,
 +      .box_ctl                = SNBEP_PCI_PMON_BOX_CTL,
 +      .num_shared_regs        = 1,
 +      .ops                    = &snbep_uncore_qpi_ops,
 +      .event_descs            = snbep_uncore_qpi_events,
 +      .format_group           = &snbep_uncore_qpi_format_group,
  };
  
  
@@@ -904,53 -807,43 +904,53 @@@ static struct intel_uncore_type *snbep_
  static DEFINE_PCI_DEVICE_TABLE(snbep_uncore_pci_ids) = {
        { /* Home Agent */
                PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_UNC_HA),
 -              .driver_data = SNBEP_PCI_UNCORE_HA,
 +              .driver_data = UNCORE_PCI_DEV_DATA(SNBEP_PCI_UNCORE_HA, 0),
        },
        { /* MC Channel 0 */
                PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_UNC_IMC0),
 -              .driver_data = SNBEP_PCI_UNCORE_IMC,
 +              .driver_data = UNCORE_PCI_DEV_DATA(SNBEP_PCI_UNCORE_IMC, 0),
        },
        { /* MC Channel 1 */
                PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_UNC_IMC1),
 -              .driver_data = SNBEP_PCI_UNCORE_IMC,
 +              .driver_data = UNCORE_PCI_DEV_DATA(SNBEP_PCI_UNCORE_IMC, 1),
        },
        { /* MC Channel 2 */
                PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_UNC_IMC2),
 -              .driver_data = SNBEP_PCI_UNCORE_IMC,
 +              .driver_data = UNCORE_PCI_DEV_DATA(SNBEP_PCI_UNCORE_IMC, 2),
        },
        { /* MC Channel 3 */
                PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_UNC_IMC3),
 -              .driver_data = SNBEP_PCI_UNCORE_IMC,
 +              .driver_data = UNCORE_PCI_DEV_DATA(SNBEP_PCI_UNCORE_IMC, 3),
        },
        { /* QPI Port 0 */
                PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_UNC_QPI0),
 -              .driver_data = SNBEP_PCI_UNCORE_QPI,
 +              .driver_data = UNCORE_PCI_DEV_DATA(SNBEP_PCI_UNCORE_QPI, 0),
        },
        { /* QPI Port 1 */
                PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_UNC_QPI1),
 -              .driver_data = SNBEP_PCI_UNCORE_QPI,
 +              .driver_data = UNCORE_PCI_DEV_DATA(SNBEP_PCI_UNCORE_QPI, 1),
        },
        { /* R2PCIe */
                PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_UNC_R2PCIE),
 -              .driver_data = SNBEP_PCI_UNCORE_R2PCIE,
 +              .driver_data = UNCORE_PCI_DEV_DATA(SNBEP_PCI_UNCORE_R2PCIE, 0),
        },
        { /* R3QPI Link 0 */
                PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_UNC_R3QPI0),
 -              .driver_data = SNBEP_PCI_UNCORE_R3QPI,
 +              .driver_data = UNCORE_PCI_DEV_DATA(SNBEP_PCI_UNCORE_R3QPI, 0),
        },
        { /* R3QPI Link 1 */
                PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_UNC_R3QPI1),
 -              .driver_data = SNBEP_PCI_UNCORE_R3QPI,
 +              .driver_data = UNCORE_PCI_DEV_DATA(SNBEP_PCI_UNCORE_R3QPI, 1),
 +      },
 +      { /* QPI Port 0 filter  */
 +              PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x3c86),
 +              .driver_data = UNCORE_PCI_DEV_DATA(UNCORE_EXTRA_PCI_DEV,
 +                                                 SNBEP_PCI_QPI_PORT0_FILTER),
 +      },
 +      { /* QPI Port 0 filter  */
 +              PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x3c96),
 +              .driver_data = UNCORE_PCI_DEV_DATA(UNCORE_EXTRA_PCI_DEV,
 +                                                 SNBEP_PCI_QPI_PORT1_FILTER),
        },
        { /* end: all zeroes */ }
  };
@@@ -1363,71 -1256,71 +1363,71 @@@ static struct intel_uncore_type *ivt_pc
  static DEFINE_PCI_DEVICE_TABLE(ivt_uncore_pci_ids) = {
        { /* Home Agent 0 */
                PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xe30),
 -              .driver_data = IVT_PCI_UNCORE_HA,
 +              .driver_data = UNCORE_PCI_DEV_DATA(IVT_PCI_UNCORE_HA, 0),
        },
        { /* Home Agent 1 */
                PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xe38),
 -              .driver_data = IVT_PCI_UNCORE_HA,
 +              .driver_data = UNCORE_PCI_DEV_DATA(IVT_PCI_UNCORE_HA, 1),
        },
        { /* MC0 Channel 0 */
                PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xeb4),
 -              .driver_data = IVT_PCI_UNCORE_IMC,
 +              .driver_data = UNCORE_PCI_DEV_DATA(IVT_PCI_UNCORE_IMC, 0),
        },
        { /* MC0 Channel 1 */
                PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xeb5),
 -              .driver_data = IVT_PCI_UNCORE_IMC,
 +              .driver_data = UNCORE_PCI_DEV_DATA(IVT_PCI_UNCORE_IMC, 1),
        },
        { /* MC0 Channel 3 */
                PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xeb0),
 -              .driver_data = IVT_PCI_UNCORE_IMC,
 +              .driver_data = UNCORE_PCI_DEV_DATA(IVT_PCI_UNCORE_IMC, 2),
        },
        { /* MC0 Channel 4 */
                PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xeb1),
 -              .driver_data = IVT_PCI_UNCORE_IMC,
 +              .driver_data = UNCORE_PCI_DEV_DATA(IVT_PCI_UNCORE_IMC, 3),
        },
        { /* MC1 Channel 0 */
                PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xef4),
 -              .driver_data = IVT_PCI_UNCORE_IMC,
 +              .driver_data = UNCORE_PCI_DEV_DATA(IVT_PCI_UNCORE_IMC, 4),
        },
        { /* MC1 Channel 1 */
                PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xef5),
 -              .driver_data = IVT_PCI_UNCORE_IMC,
 +              .driver_data = UNCORE_PCI_DEV_DATA(IVT_PCI_UNCORE_IMC, 5),
        },
        { /* MC1 Channel 3 */
                PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xef0),
 -              .driver_data = IVT_PCI_UNCORE_IMC,
 +              .driver_data = UNCORE_PCI_DEV_DATA(IVT_PCI_UNCORE_IMC, 6),
        },
        { /* MC1 Channel 4 */
                PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xef1),
 -              .driver_data = IVT_PCI_UNCORE_IMC,
 +              .driver_data = UNCORE_PCI_DEV_DATA(IVT_PCI_UNCORE_IMC, 7),
        },
        { /* QPI0 Port 0 */
                PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xe32),
 -              .driver_data = IVT_PCI_UNCORE_QPI,
 +              .driver_data = UNCORE_PCI_DEV_DATA(IVT_PCI_UNCORE_QPI, 0),
        },
        { /* QPI0 Port 1 */
                PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xe33),
 -              .driver_data = IVT_PCI_UNCORE_QPI,
 +              .driver_data = UNCORE_PCI_DEV_DATA(IVT_PCI_UNCORE_QPI, 1),
        },
        { /* QPI1 Port 2 */
                PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xe3a),
 -              .driver_data = IVT_PCI_UNCORE_QPI,
 +              .driver_data = UNCORE_PCI_DEV_DATA(IVT_PCI_UNCORE_QPI, 2),
        },
        { /* R2PCIe */
                PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xe34),
 -              .driver_data = IVT_PCI_UNCORE_R2PCIE,
 +              .driver_data = UNCORE_PCI_DEV_DATA(IVT_PCI_UNCORE_R2PCIE, 0),
        },
        { /* R3QPI0 Link 0 */
                PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xe36),
 -              .driver_data = IVT_PCI_UNCORE_R3QPI,
 +              .driver_data = UNCORE_PCI_DEV_DATA(IVT_PCI_UNCORE_R3QPI, 0),
        },
        { /* R3QPI0 Link 1 */
                PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xe37),
 -              .driver_data = IVT_PCI_UNCORE_R3QPI,
 +              .driver_data = UNCORE_PCI_DEV_DATA(IVT_PCI_UNCORE_R3QPI, 1),
        },
        { /* R3QPI1 Link 2 */
                PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xe3e),
 -              .driver_data = IVT_PCI_UNCORE_R3QPI,
 +              .driver_data = UNCORE_PCI_DEV_DATA(IVT_PCI_UNCORE_R3QPI, 2),
        },
        { /* end: all zeroes */ }
  };
@@@ -3274,24 -3167,16 +3274,24 @@@ static bool pcidrv_registered
  /*
   * add a pci uncore device
   */
 -static int uncore_pci_add(struct intel_uncore_type *type, struct pci_dev *pdev)
 +static int uncore_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
  {
        struct intel_uncore_pmu *pmu;
        struct intel_uncore_box *box;
 -      int i, phys_id;
 +      struct intel_uncore_type *type;
 +      int phys_id;
  
        phys_id = pcibus_to_physid[pdev->bus->number];
        if (phys_id < 0)
                return -ENODEV;
  
 +      if (UNCORE_PCI_DEV_TYPE(id->driver_data) == UNCORE_EXTRA_PCI_DEV) {
 +              extra_pci_dev[phys_id][UNCORE_PCI_DEV_IDX(id->driver_data)] = pdev;
 +              pci_set_drvdata(pdev, NULL);
 +              return 0;
 +      }
 +
 +      type = pci_uncores[UNCORE_PCI_DEV_TYPE(id->driver_data)];
        box = uncore_alloc_box(type, 0);
        if (!box)
                return -ENOMEM;
         * for performance monitoring unit with multiple boxes,
         * each box has a different function id.
         */
 -      for (i = 0; i < type->num_boxes; i++) {
 -              pmu = &type->pmus[i];
 -              if (pmu->func_id == pdev->devfn)
 -                      break;
 -              if (pmu->func_id < 0) {
 -                      pmu->func_id = pdev->devfn;
 -                      break;
 -              }
 -              pmu = NULL;
 -      }
 -
 -      if (!pmu) {
 -              kfree(box);
 -              return -EINVAL;
 -      }
 +      pmu = &type->pmus[UNCORE_PCI_DEV_IDX(id->driver_data)];
 +      if (pmu->func_id < 0)
 +              pmu->func_id = pdev->devfn;
 +      else
 +              WARN_ON_ONCE(pmu->func_id != pdev->devfn);
  
        box->phys_id = phys_id;
        box->pci_dev = pdev;
  static void uncore_pci_remove(struct pci_dev *pdev)
  {
        struct intel_uncore_box *box = pci_get_drvdata(pdev);
 -      struct intel_uncore_pmu *pmu = box->pmu;
 -      int cpu, phys_id = pcibus_to_physid[pdev->bus->number];
 +      struct intel_uncore_pmu *pmu;
 +      int i, cpu, phys_id = pcibus_to_physid[pdev->bus->number];
  
 +      box = pci_get_drvdata(pdev);
 +      if (!box) {
 +              for (i = 0; i < UNCORE_EXTRA_PCI_DEV_MAX; i++) {
 +                      if (extra_pci_dev[phys_id][i] == pdev) {
 +                              extra_pci_dev[phys_id][i] = NULL;
 +                              break;
 +                      }
 +              }
 +              WARN_ON_ONCE(i >= UNCORE_EXTRA_PCI_DEV_MAX);
 +              return;
 +      }
 +
 +      pmu = box->pmu;
        if (WARN_ON_ONCE(phys_id != box->phys_id))
                return;
  
        kfree(box);
  }
  
 -static int uncore_pci_probe(struct pci_dev *pdev,
 -                          const struct pci_device_id *id)
 -{
 -      return uncore_pci_add(pci_uncores[id->driver_data], pdev);
 -}
 -
  static int __init uncore_pci_init(void)
  {
        int ret;
diff --combined include/linux/sched.h
@@@ -1034,9 -1034,6 +1034,9 @@@ struct task_struct 
  #ifdef CONFIG_SMP
        struct llist_node wake_entry;
        int on_cpu;
 +      struct task_struct *last_wakee;
 +      unsigned long wakee_flips;
 +      unsigned long wakee_flip_decay_ts;
  #endif
        int on_rq;
  
@@@ -1535,6 -1532,8 +1535,8 @@@ static inline pid_t task_pgrp_nr(struc
   * Test if a process is not yet dead (at most zombie state)
   * If pid_alive fails, then pointers within the task structure
   * can be stale and must not be dereferenced.
+  *
+  * Return: 1 if the process is alive. 0 otherwise.
   */
  static inline int pid_alive(struct task_struct *p)
  {
   * @tsk: Task structure to be checked.
   *
   * Check if a task structure is the first user space task the kernel created.
+  *
+  * Return: 1 if the task structure is init. 0 otherwise.
   */
  static inline int is_global_init(struct task_struct *tsk)
  {
@@@ -1897,6 -1898,8 +1901,8 @@@ extern struct task_struct *idle_task(in
  /**
   * is_idle_task - is the specified task an idle task?
   * @p: the task in question.
+  *
+  * Return: 1 if @p is an idle task. 0 otherwise.
   */
  static inline bool is_idle_task(const struct task_struct *p)
  {
diff --combined kernel/sched/core.c
@@@ -933,6 -933,8 +933,8 @@@ static int effective_prio(struct task_s
  /**
   * task_curr - is this task currently executing on a CPU?
   * @p: the task in question.
+  *
+  * Return: 1 if the task is currently executing. 0 otherwise.
   */
  inline int task_curr(const struct task_struct *p)
  {
@@@ -1482,7 -1484,7 +1484,7 @@@ static void ttwu_queue(struct task_stru
   * the simpler "current->state = TASK_RUNNING" to mark yourself
   * runnable without the overhead of this.
   *
-  * Returns %true if @p was woken up, %false if it was already running
+  * Return: %true if @p was woken up, %false if it was already running.
   * or @state didn't match @p's state.
   */
  static int
@@@ -1491,7 -1493,13 +1493,13 @@@ try_to_wake_up(struct task_struct *p, u
        unsigned long flags;
        int cpu, success = 0;
  
-       smp_wmb();
+       /*
+        * If we are going to wake up a thread waiting for CONDITION we
+        * need to ensure that CONDITION=1 done by the caller can not be
+        * reordered with p->state check below. This pairs with mb() in
+        * set_current_state() the waiting thread does.
+        */
+       smp_mb__before_spinlock();
        raw_spin_lock_irqsave(&p->pi_lock, flags);
        if (!(p->state & state))
                goto out;
@@@ -1577,8 -1585,9 +1585,9 @@@ out
   * @p: The process to be woken up.
   *
   * Attempt to wake up the nominated process and move it to the set of runnable
-  * processes.  Returns 1 if the process was woken up, 0 if it was already
-  * running.
+  * processes.
+  *
+  * Return: 1 if the process was woken up, 0 if it was already running.
   *
   * It may be assumed that this function implies a write memory barrier before
   * changing the task state if and only if any tasks are woken up.
@@@ -2191,6 -2200,8 +2200,8 @@@ void scheduler_tick(void
   * This makes sure that uptime, CFS vruntime, load
   * balancing, etc... continue to move forward, even
   * with a very low granularity.
+  *
+  * Return: Maximum deferment in nanoseconds.
   */
  u64 scheduler_tick_max_deferment(void)
  {
@@@ -2394,6 -2405,12 +2405,12 @@@ need_resched
        if (sched_feat(HRTICK))
                hrtick_clear(rq);
  
+       /*
+        * Make sure that signal_pending_state()->signal_pending() below
+        * can't be reordered with __set_current_state(TASK_INTERRUPTIBLE)
+        * done by the caller to avoid the race with signal_wake_up().
+        */
+       smp_mb__before_spinlock();
        raw_spin_lock_irq(&rq->lock);
  
        switch_count = &prev->nivcsw;
@@@ -2796,8 -2813,8 +2813,8 @@@ EXPORT_SYMBOL(wait_for_completion)
   * specified timeout to expire. The timeout is in jiffies. It is not
   * interruptible.
   *
-  * The return value is 0 if timed out, and positive (at least 1, or number of
-  * jiffies left till timeout) if completed.
+  * Return: 0 if timed out, and positive (at least 1, or number of jiffies left
+  * till timeout) if completed.
   */
  unsigned long __sched
  wait_for_completion_timeout(struct completion *x, unsigned long timeout)
@@@ -2829,8 -2846,8 +2846,8 @@@ EXPORT_SYMBOL(wait_for_completion_io)
   * specified timeout to expire. The timeout is in jiffies. It is not
   * interruptible. The caller is accounted as waiting for IO.
   *
-  * The return value is 0 if timed out, and positive (at least 1, or number of
-  * jiffies left till timeout) if completed.
+  * Return: 0 if timed out, and positive (at least 1, or number of jiffies left
+  * till timeout) if completed.
   */
  unsigned long __sched
  wait_for_completion_io_timeout(struct completion *x, unsigned long timeout)
@@@ -2846,7 -2863,7 +2863,7 @@@ EXPORT_SYMBOL(wait_for_completion_io_ti
   * This waits for completion of a specific task to be signaled. It is
   * interruptible.
   *
-  * The return value is -ERESTARTSYS if interrupted, 0 if completed.
+  * Return: -ERESTARTSYS if interrupted, 0 if completed.
   */
  int __sched wait_for_completion_interruptible(struct completion *x)
  {
@@@ -2865,8 -2882,8 +2882,8 @@@ EXPORT_SYMBOL(wait_for_completion_inter
   * This waits for either a completion of a specific task to be signaled or for a
   * specified timeout to expire. It is interruptible. The timeout is in jiffies.
   *
-  * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
-  * positive (at least 1, or number of jiffies left till timeout) if completed.
+  * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
+  * or number of jiffies left till timeout) if completed.
   */
  long __sched
  wait_for_completion_interruptible_timeout(struct completion *x,
@@@ -2883,7 -2900,7 +2900,7 @@@ EXPORT_SYMBOL(wait_for_completion_inter
   * This waits to be signaled for completion of a specific task. It can be
   * interrupted by a kill signal.
   *
-  * The return value is -ERESTARTSYS if interrupted, 0 if completed.
+  * Return: -ERESTARTSYS if interrupted, 0 if completed.
   */
  int __sched wait_for_completion_killable(struct completion *x)
  {
@@@ -2903,8 -2920,8 +2920,8 @@@ EXPORT_SYMBOL(wait_for_completion_killa
   * signaled or for a specified timeout to expire. It can be
   * interrupted by a kill signal. The timeout is in jiffies.
   *
-  * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
-  * positive (at least 1, or number of jiffies left till timeout) if completed.
+  * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
+  * or number of jiffies left till timeout) if completed.
   */
  long __sched
  wait_for_completion_killable_timeout(struct completion *x,
@@@ -2918,7 -2935,7 +2935,7 @@@ EXPORT_SYMBOL(wait_for_completion_killa
   *    try_wait_for_completion - try to decrement a completion without blocking
   *    @x:     completion structure
   *
-  *    Returns: 0 if a decrement cannot be done without blocking
+  *    Return: 0 if a decrement cannot be done without blocking
   *             1 if a decrement succeeded.
   *
   *    If a completion is being used as a counting completion,
@@@ -2945,7 -2962,7 +2962,7 @@@ EXPORT_SYMBOL(try_wait_for_completion)
   *    completion_done - Test to see if a completion has any waiters
   *    @x:     completion structure
   *
-  *    Returns: 0 if there are waiters (wait_for_completion() in progress)
+  *    Return: 0 if there are waiters (wait_for_completion() in progress)
   *             1 if there are no waiters.
   *
   */
@@@ -3182,7 -3199,7 +3199,7 @@@ SYSCALL_DEFINE1(nice, int, increment
   * task_prio - return the priority value of a given task.
   * @p: the task in question.
   *
-  * This is the priority value as seen by users in /proc.
+  * Return: The priority value as seen by users in /proc.
   * RT tasks are offset by -200. Normal tasks are centered
   * around 0, value goes from -16 to +15.
   */
@@@ -3194,6 -3211,8 +3211,8 @@@ int task_prio(const struct task_struct 
  /**
   * task_nice - return the nice value of a given task.
   * @p: the task in question.
+  *
+  * Return: The nice value [ -20 ... 0 ... 19 ].
   */
  int task_nice(const struct task_struct *p)
  {
@@@ -3204,6 -3223,8 +3223,8 @@@ EXPORT_SYMBOL(task_nice)
  /**
   * idle_cpu - is a given cpu idle currently?
   * @cpu: the processor in question.
+  *
+  * Return: 1 if the CPU is currently idle. 0 otherwise.
   */
  int idle_cpu(int cpu)
  {
  /**
   * idle_task - return the idle task for a given cpu.
   * @cpu: the processor in question.
+  *
+  * Return: The idle task for the cpu @cpu.
   */
  struct task_struct *idle_task(int cpu)
  {
  /**
   * find_process_by_pid - find a process with a matching PID value.
   * @pid: the pid in question.
+  *
+  * The task of @pid, if found. %NULL otherwise.
   */
  static struct task_struct *find_process_by_pid(pid_t pid)
  {
@@@ -3432,6 -3457,8 +3457,8 @@@ recheck
   * @policy: new policy.
   * @param: structure containing the new RT priority.
   *
+  * Return: 0 on success. An error code otherwise.
+  *
   * NOTE that the task may be already dead.
   */
  int sched_setscheduler(struct task_struct *p, int policy,
@@@ -3451,6 -3478,8 +3478,8 @@@ EXPORT_SYMBOL_GPL(sched_setscheduler)
   * current context has permission.  For example, this is needed in
   * stop_machine(): we create temporary high priority worker threads,
   * but our caller might not have that capability.
+  *
+  * Return: 0 on success. An error code otherwise.
   */
  int sched_setscheduler_nocheck(struct task_struct *p, int policy,
                               const struct sched_param *param)
@@@ -3485,6 -3514,8 +3514,8 @@@ do_sched_setscheduler(pid_t pid, int po
   * @pid: the pid in question.
   * @policy: new policy.
   * @param: structure containing the new RT priority.
+  *
+  * Return: 0 on success. An error code otherwise.
   */
  SYSCALL_DEFINE3(sched_setscheduler, pid_t, pid, int, policy,
                struct sched_param __user *, param)
   * sys_sched_setparam - set/change the RT priority of a thread
   * @pid: the pid in question.
   * @param: structure containing the new RT priority.
+  *
+  * Return: 0 on success. An error code otherwise.
   */
  SYSCALL_DEFINE2(sched_setparam, pid_t, pid, struct sched_param __user *, param)
  {
  /**
   * sys_sched_getscheduler - get the policy (scheduling class) of a thread
   * @pid: the pid in question.
+  *
+  * Return: On success, the policy of the thread. Otherwise, a negative error
+  * code.
   */
  SYSCALL_DEFINE1(sched_getscheduler, pid_t, pid)
  {
   * sys_sched_getparam - get the RT priority of a thread
   * @pid: the pid in question.
   * @param: structure containing the RT priority.
+  *
+  * Return: On success, 0 and the RT priority is in @param. Otherwise, an error
+  * code.
   */
  SYSCALL_DEFINE2(sched_getparam, pid_t, pid, struct sched_param __user *, param)
  {
@@@ -3659,6 -3698,8 +3698,8 @@@ static int get_user_cpu_mask(unsigned l
   * @pid: pid of the process
   * @len: length in bytes of the bitmask pointed to by user_mask_ptr
   * @user_mask_ptr: user-space pointer to the new cpu mask
+  *
+  * Return: 0 on success. An error code otherwise.
   */
  SYSCALL_DEFINE3(sched_setaffinity, pid_t, pid, unsigned int, len,
                unsigned long __user *, user_mask_ptr)
@@@ -3710,6 -3751,8 +3751,8 @@@ out_unlock
   * @pid: pid of the process
   * @len: length in bytes of the bitmask pointed to by user_mask_ptr
   * @user_mask_ptr: user-space pointer to hold the current cpu mask
+  *
+  * Return: 0 on success. An error code otherwise.
   */
  SYSCALL_DEFINE3(sched_getaffinity, pid_t, pid, unsigned int, len,
                unsigned long __user *, user_mask_ptr)
   *
   * This function yields the current CPU to other tasks. If there are no
   * other threads running on this CPU then this function will return.
+  *
+  * Return: 0.
   */
  SYSCALL_DEFINE0(sched_yield)
  {
@@@ -3869,7 -3914,7 +3914,7 @@@ EXPORT_SYMBOL(yield)
   * It's the caller's job to ensure that the target task struct
   * can't go away on us before we can do any checks.
   *
-  * Returns:
+  * Return:
   *    true (>0) if we indeed boosted the target task.
   *    false (0) if we failed to boost the target.
   *    -ESRCH if there's no task to yield to.
@@@ -3972,8 -4017,9 +4017,9 @@@ long __sched io_schedule_timeout(long t
   * sys_sched_get_priority_max - return maximum RT priority.
   * @policy: scheduling class.
   *
-  * this syscall returns the maximum rt_priority that can be used
-  * by a given scheduling class.
+  * Return: On success, this syscall returns the maximum
+  * rt_priority that can be used by a given scheduling class.
+  * On failure, a negative error code is returned.
   */
  SYSCALL_DEFINE1(sched_get_priority_max, int, policy)
  {
   * sys_sched_get_priority_min - return minimum RT priority.
   * @policy: scheduling class.
   *
-  * this syscall returns the minimum rt_priority that can be used
-  * by a given scheduling class.
+  * Return: On success, this syscall returns the minimum
+  * rt_priority that can be used by a given scheduling class.
+  * On failure, a negative error code is returned.
   */
  SYSCALL_DEFINE1(sched_get_priority_min, int, policy)
  {
   *
   * this syscall writes the default timeslice value of a given process
   * into the user-space timespec buffer. A value of '0' means infinity.
+  *
+  * Return: On success, 0 and the timeslice is in @interval. Otherwise,
+  * an error code.
   */
  SYSCALL_DEFINE2(sched_rr_get_interval, pid_t, pid,
                struct timespec __user *, interval)
@@@ -5083,23 -5133,18 +5133,23 @@@ static void destroy_sched_domains(struc
   * two cpus are in the same cache domain, see cpus_share_cache().
   */
  DEFINE_PER_CPU(struct sched_domain *, sd_llc);
 +DEFINE_PER_CPU(int, sd_llc_size);
  DEFINE_PER_CPU(int, sd_llc_id);
  
  static void update_top_cache_domain(int cpu)
  {
        struct sched_domain *sd;
        int id = cpu;
 +      int size = 1;
  
        sd = highest_flag_domain(cpu, SD_SHARE_PKG_RESOURCES);
 -      if (sd)
 +      if (sd) {
                id = cpumask_first(sched_domain_span(sd));
 +              size = cpumask_weight(sched_domain_span(sd));
 +      }
  
        rcu_assign_pointer(per_cpu(sd_llc, cpu), sd);
 +      per_cpu(sd_llc_size, cpu) = size;
        per_cpu(sd_llc_id, cpu) = id;
  }
  
@@@ -6637,6 -6682,8 +6687,8 @@@ void normalize_rt_tasks(void
   * @cpu: the processor in question.
   *
   * ONLY VALID WHEN THE WHOLE SYSTEM IS STOPPED!
+  *
+  * Return: The current task for @cpu.
   */
  struct task_struct *curr_task(int cpu)
  {
diff --combined kernel/sched/fair.c
@@@ -2032,6 -2032,7 +2032,7 @@@ entity_tick(struct cfs_rq *cfs_rq, stru
         */
        update_entity_load_avg(curr, 1);
        update_cfs_rq_blocked_load(cfs_rq, 1);
+       update_cfs_shares(cfs_rq);
  
  #ifdef CONFIG_SCHED_HRTICK
        /*
@@@ -3017,23 -3018,6 +3018,23 @@@ static unsigned long cpu_avg_load_per_t
        return 0;
  }
  
 +static void record_wakee(struct task_struct *p)
 +{
 +      /*
 +       * Rough decay (wiping) for cost saving, don't worry
 +       * about the boundary, really active task won't care
 +       * about the loss.
 +       */
 +      if (jiffies > current->wakee_flip_decay_ts + HZ) {
 +              current->wakee_flips = 0;
 +              current->wakee_flip_decay_ts = jiffies;
 +      }
 +
 +      if (current->last_wakee != p) {
 +              current->last_wakee = p;
 +              current->wakee_flips++;
 +      }
 +}
  
  static void task_waking_fair(struct task_struct *p)
  {
  #endif
  
        se->vruntime -= min_vruntime;
 +      record_wakee(p);
  }
  
  #ifdef CONFIG_FAIR_GROUP_SCHED
@@@ -3173,28 -3156,6 +3174,28 @@@ static inline unsigned long effective_l
  
  #endif
  
 +static int wake_wide(struct task_struct *p)
 +{
 +      int factor = this_cpu_read(sd_llc_size);
 +
 +      /*
 +       * Yeah, it's the switching-frequency, could means many wakee or
 +       * rapidly switch, use factor here will just help to automatically
 +       * adjust the loose-degree, so bigger node will lead to more pull.
 +       */
 +      if (p->wakee_flips > factor) {
 +              /*
 +               * wakee is somewhat hot, it needs certain amount of cpu
 +               * resource, so if waker is far more hot, prefer to leave
 +               * it alone.
 +               */
 +              if (current->wakee_flips > (factor * p->wakee_flips))
 +                      return 1;
 +      }
 +
 +      return 0;
 +}
 +
  static int wake_affine(struct sched_domain *sd, struct task_struct *p, int sync)
  {
        s64 this_load, load;
        unsigned long weight;
        int balanced;
  
 +      /*
 +       * If we wake multiple tasks be careful to not bounce
 +       * ourselves around too much.
 +       */
 +      if (wake_wide(p))
 +              return 0;
 +
        idx       = sd->wake_idx;
        this_cpu  = smp_processor_id();
        prev_cpu  = task_cpu(p);
@@@ -4218,48 -4172,47 +4219,48 @@@ static void update_blocked_averages(in
  }
  
  /*
 - * Compute the cpu's hierarchical load factor for each task group.
 + * Compute the hierarchical load factor for cfs_rq and all its ascendants.
   * This needs to be done in a top-down fashion because the load of a child
   * group is a fraction of its parents load.
   */
 -static int tg_load_down(struct task_group *tg, void *data)
 -{
 -      unsigned long load;
 -      long cpu = (long)data;
 -
 -      if (!tg->parent) {
 -              load = cpu_rq(cpu)->avg.load_avg_contrib;
 -      } else {
 -              load = tg->parent->cfs_rq[cpu]->h_load;
 -              load = div64_ul(load * tg->se[cpu]->avg.load_avg_contrib,
 -                              tg->parent->cfs_rq[cpu]->runnable_load_avg + 1);
 -      }
 -
 -      tg->cfs_rq[cpu]->h_load = load;
 -
 -      return 0;
 -}
 -
 -static void update_h_load(long cpu)
 +static void update_cfs_rq_h_load(struct cfs_rq *cfs_rq)
  {
 -      struct rq *rq = cpu_rq(cpu);
 +      struct rq *rq = rq_of(cfs_rq);
 +      struct sched_entity *se = cfs_rq->tg->se[cpu_of(rq)];
        unsigned long now = jiffies;
 +      unsigned long load;
  
 -      if (rq->h_load_throttle == now)
 +      if (cfs_rq->last_h_load_update == now)
                return;
  
 -      rq->h_load_throttle = now;
 +      cfs_rq->h_load_next = NULL;
 +      for_each_sched_entity(se) {
 +              cfs_rq = cfs_rq_of(se);
 +              cfs_rq->h_load_next = se;
 +              if (cfs_rq->last_h_load_update == now)
 +                      break;
 +      }
  
 -      rcu_read_lock();
 -      walk_tg_tree(tg_load_down, tg_nop, (void *)cpu);
 -      rcu_read_unlock();
 +      if (!se) {
 +              cfs_rq->h_load = rq->avg.load_avg_contrib;
 +              cfs_rq->last_h_load_update = now;
 +      }
 +
 +      while ((se = cfs_rq->h_load_next) != NULL) {
 +              load = cfs_rq->h_load;
 +              load = div64_ul(load * se->avg.load_avg_contrib,
 +                              cfs_rq->runnable_load_avg + 1);
 +              cfs_rq = group_cfs_rq(se);
 +              cfs_rq->h_load = load;
 +              cfs_rq->last_h_load_update = now;
 +      }
  }
  
  static unsigned long task_h_load(struct task_struct *p)
  {
        struct cfs_rq *cfs_rq = task_cfs_rq(p);
  
 +      update_cfs_rq_h_load(cfs_rq);
        return div64_ul(p->se.avg.load_avg_contrib * cfs_rq->h_load,
                        cfs_rq->runnable_load_avg + 1);
  }
@@@ -4268,6 -4221,10 +4269,6 @@@ static inline void update_blocked_avera
  {
  }
  
 -static inline void update_h_load(long cpu)
 -{
 -}
 -
  static unsigned long task_h_load(struct task_struct *p)
  {
        return p->se.avg.load_avg_contrib;
@@@ -4324,6 -4281,8 +4325,8 @@@ struct sg_lb_stats 
   * get_sd_load_idx - Obtain the load index for a given sched domain.
   * @sd: The sched_domain whose load_idx is to be obtained.
   * @idle: The Idle status of the CPU for whose sd load_icx is obtained.
+  *
+  * Return: The load index.
   */
  static inline int get_sd_load_idx(struct sched_domain *sd,
                                        enum cpu_idle_type idle)
@@@ -4618,6 -4577,9 +4621,9 @@@ static inline void update_sg_lb_stats(s
   *
   * Determine if @sg is a busier group than the previously selected
   * busiest group.
+  *
+  * Return: %true if @sg is a busier group than the previously selected
+  * busiest group. %false otherwise.
   */
  static bool update_sd_pick_busiest(struct lb_env *env,
                                   struct sd_lb_stats *sds,
@@@ -4735,7 -4697,7 +4741,7 @@@ static inline void update_sd_lb_stats(s
   * assuming lower CPU number will be equivalent to lower a SMT thread
   * number.
   *
-  * Returns 1 when packing is required and a task should be moved to
+  * Return: 1 when packing is required and a task should be moved to
   * this CPU.  The amount of the imbalance is returned in *imbalance.
   *
   * @env: The load balancing environment.
@@@ -4913,7 -4875,7 +4919,7 @@@ static inline void calculate_imbalance(
   * @balance: Pointer to a variable indicating if this_cpu
   *    is the appropriate cpu to perform load balancing at this_level.
   *
-  * Returns:   - the busiest group if imbalance exists.
+  * Return:    - The busiest group if imbalance exists.
   *            - If no imbalance and user has opted for power-savings balance,
   *               return the least loaded group whose CPUs can be
   *               put to idle by rebalancing its tasks onto our group.
@@@ -5152,6 -5114,7 +5158,6 @@@ redo
                env.src_rq    = busiest;
                env.loop_max  = min(sysctl_sched_nr_migrate, busiest->nr_running);
  
 -              update_h_load(env.src_cpu);
  more_balance:
                local_irq_save(flags);
                double_rq_lock(env.dst_rq, busiest);