RE: [patch 04/11] x86/perf/intel_uncore: Cleanup hardware on exit

From: Liang, Kan
Date: Wed Feb 17 2016 - 16:57:46 EST



>
> > > @@ -201,6 +201,11 @@ static void nhmex_uncore_msr_init_box(st
> > > wrmsrl(NHMEX_U_MSR_PMON_GLOBAL_CTL,
> > > NHMEX_U_PMON_GLOBAL_EN_ALL); }
>
> > > +static void nhmex_uncore_msr_exit_box(struct intel_uncore_box
> *box)
> > > {
> > > + wrmsrl(NHMEX_U_MSR_PMON_GLOBAL_CTL, 0); }
>
> The reset value for this register is 0. So how is that wrong?
>
> > > +static void snb_uncore_msr_exit_box(struct intel_uncore_box *box)
> {
> > > + if (box->pmu->pmu_idx == 0)
> > > + wrmsrl(SNB_UNC_PERF_GLOBAL_CTL, 0); }
>
> Ditto.
>
> > > +static void snb_uncore_imc_exit_box(struct intel_uncore_box *box) {
> > > + iounmap(box->io_addr);
>
> That's definitely required, because it would leak a mapping.
>
> I know Intel folks do not care about error handling and a few reference
> leaks, but I care very much.
>
> If there is a single instance of exit_box() in that patch which flips the wrong
> bits, then please point it out with the proper reference in the manual and
> not with such half baken statements as above.
>

Sorry, I didn't make it clear.
For the older server platforms like nhmex and client platforms like snb, I agree
with you on nhmex_uncore_msr_exit_box and snb_uncore_imc_exit_box.

However, for newer server platforms (start from IVB server), we cannot write 0
to rsv bit of BOX control registers. The behavior is undefined.
The following codes may have issues.
It looks we also write 0 to rsv bit in box_init. We may need to fix it.

You can find all the server uncore documents here.
https://software.intel.com/en-us/blogs/2014/07/11/documentation-for-uncore-performance-monitoring-units

> +static void snbep_uncore_pci_exit_box(struct intel_uncore_box *box) {
> + struct pci_dev *pdev = box->pci_dev;
> + int box_ctl = uncore_pci_box_ctl(box);
> +
> + pci_write_config_dword(pdev, box_ctl, 0); }
> +

> +static void snbep_uncore_msr_exit_box(struct intel_uncore_box *box) {
> + unsigned msr = uncore_msr_box_ctl(box);
> +
> + if (msr)
> + wrmsrl(msr, 0);
> +}

> +static void ivbep_uncore_msr_exit_box(struct intel_uncore_box *box) {
> + unsigned msr = uncore_msr_box_ctl(box);
> +
> + if (msr)
> + wrmsrl(msr, 0);
> +}

> +static void ivbep_uncore_pci_exit_box(struct intel_uncore_box *box) {
> + struct pci_dev *pdev = box->pci_dev;
> +
> + pci_write_config_dword(pdev, SNBEP_PCI_PMON_BOX_CTL, 0); }
> +

> +static void hswep_uncore_sbox_msr_exit_box(struct intel_uncore_box
> +*box) {
> + unsigned msr = uncore_msr_box_ctl(box);
> +
> + /* CHECKME: Does this need the bit dance like init() ? */
> + if (msr)
> + wrmsrl(msr, 0);
> +}
> +

Thanks,

Kan