From: "Xu, Like" <like.xu@intel.com> To: lkp <lkp@intel.com>, "Kang, Luwei" <luwei.kang@intel.com> Cc: "kbuild-all@lists.01.org" <kbuild-all@lists.01.org>, "x86@kernel.org" <x86@kernel.org>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, "kvm@vger.kernel.org" <kvm@vger.kernel.org>, "peterz@infradead.org" <peterz@infradead.org>, "mingo@redhat.com" <mingo@redhat.com>, "acme@kernel.org" <acme@kernel.org>, "mark.rutland@arm.com" <mark.rutland@arm.com>, "alexander.shishkin@linux.intel.com" <alexander.shishkin@linux.intel.com>, "jolsa@redhat.com" <jolsa@redhat.com>, "namhyung@kernel.org" <namhyung@kernel.org>, "tglx@linutronix.de" <tglx@linutronix.de>, "bp@alien8.de" <bp@alien8.de>, "hpa@zytor.com" <hpa@zytor.com>, "pbonzini@redhat.com" <pbonzini@redhat.com>, "Christopherson, Sean J" <sean.j.christopherson@intel.com>, "vkuznets@redhat.com" <vkuznets@redhat.com>, "wanpengli@tencent.com" <wanpengli@tencent.com>, "jmattson@google.com" <jmattson@google.com>, "joro@8bytes.org" <joro@8bytes.org>, "pawan.kumar.gupta@linux.intel.com" <pawan.kumar.gupta@linux.intel.com>, "ak@linux.intel.com" <ak@linux.intel.com>, "thomas.lendacky@amd.com" <thomas.lendacky@amd.com>, "Yu, Fenghua" <fenghua.yu@intel.com>, "kan.liang@linux.intel.com" <kan.liang@linux.intel.com>, "like.xu@linux.intel.com" <like.xu@linux.intel.com> Subject: RE: [PATCH v1 05/11] KVM: x86/pmu: Add support to reprogram PEBS event for guest counters Date: Mon, 9 Mar 2020 00:58:47 +0000 [thread overview] Message-ID: <F7FC466FA1E455449AD0F9063BBE758E0C868500@shsmsx102.ccr.corp.intel.com> (raw) In-Reply-To: <202003070038.amFy5Etu%lkp@intel.com> > -----Original Message----- > From: kbuild test robot <lkp@intel.com> > Sent: Saturday, March 7, 2020 12:28 AM > To: Luwei Kang <luwei.kang@intel.com> > Cc: kbuild-all@lists.01.org; x86@kernel.org; linux-kernel@vger.kernel.org; > kvm@vger.kernel.org; peterz@infradead.org; mingo@redhat.com; > acme@kernel.org; mark.rutland@arm.com; > alexander.shishkin@linux.intel.com; jolsa@redhat.com; > namhyung@kernel.org; tglx@linutronix.de; bp@alien8.de; hpa@zytor.com; > pbonzini@redhat.com; sean.j.christopherson@intel.com; > vkuznets@redhat.com; wanpengli@tencent.com; jmattson@google.com; > joro@8bytes.org; pawan.kumar.gupta@linux.intel.com; ak@linux.intel.com; > thomas.lendacky@amd.com; fenghua.yu@intel.com; > kan.liang@linux.intel.com; like.xu@linux.intel.com > Subject: Re: [PATCH v1 05/11] KVM: x86/pmu: Add support to reprogram PEBS > event for guest counters > > Hi Luwei, > > Thank you for the patch! Yet something to improve: > > [auto build test ERROR on kvm/linux-next] [also build test ERROR on > tip/perf/core tip/auto-latest v5.6-rc4 next-20200306] [if your patch is applied to > the wrong git tree, please drop us a note to help improve the system. BTW, we > also suggest to use '--base' option to specify the base tree in git format-patch, > please see https://stackoverflow.com/a/37406982] > > url: > https://github.com/0day-ci/linux/commits/Luwei-Kang/PEBS-virtualization-ena > bling-via-DS/20200306-013049 > base: https://git.kernel.org/pub/scm/virt/kvm/kvm.git linux-next > config: x86_64-randconfig-h003-20200305 (attached as .config) > compiler: gcc-7 (Debian 7.5.0-5) 7.5.0 > reproduce: > # save the attached .config to linux build tree > make ARCH=x86_64 > > If you fix the issue, kindly add following tag > Reported-by: kbuild test robot <lkp@intel.com> > > All errors (new ones prefixed by >>): > > ld: arch/x86/kvm/pmu.o: in function `pmc_reprogram_counter': > >> arch/x86/kvm/pmu.c:199: undefined reference to > `perf_x86_pmu_unset_auto_reload' Since we may not lose PEBS functionality for other x86 vendors on KVM and we already have defined PERF_X86_EVENT_AUTO_RELOAD in the general arch/x86/events/perf_event.h, one of the ways to fix this issue is to move the definition of perf_x86_pmu_unset_auto_reload() to the end of arch/x86/events/core.c instead of making it Intel specific in previous patch "perf/x86: Expose a function to disable auto-reload." Thanks, Like Xu > > vim +199 arch/x86/kvm/pmu.c > > 101 > 102 static void pmc_reprogram_counter(struct kvm_pmc *pmc, u32 type, > 103 unsigned config, bool exclude_user, > 104 bool exclude_kernel, bool intr, > 105 bool in_tx, bool in_tx_cp) > 106 { > 107 struct kvm_pmu *pmu = vcpu_to_pmu(pmc->vcpu); > 108 struct perf_event *event; > 109 struct perf_event_attr attr = { > 110 .type = type, > 111 .size = sizeof(attr), > 112 .pinned = true, > 113 .exclude_idle = true, > 114 .exclude_host = 1, > 115 .exclude_user = exclude_user, > 116 .exclude_kernel = exclude_kernel, > 117 .config = config, > 118 .disabled = 1, > 119 }; > 120 bool pebs = test_bit(pmc->idx, (unsigned long > *)&pmu->pebs_enable); > 121 > 122 attr.sample_period = (-pmc->counter) & pmc_bitmask(pmc); > 123 > 124 if (in_tx) > 125 attr.config |= HSW_IN_TX; > 126 if (in_tx_cp) { > 127 /* > 128 * HSW_IN_TX_CHECKPOINTED is not supported with > nonzero > 129 * period. Just clear the sample period so at least > 130 * allocating the counter doesn't fail. > 131 */ > 132 attr.sample_period = 0; > 133 attr.config |= HSW_IN_TX_CHECKPOINTED; > 134 } > 135 > 136 if (pebs) { > 137 /* > 138 * Host never knows the precision level set by guest. > 139 * Force Host's PEBS event to precision level 1, which will > 140 * not impact the accuracy of the results for guest PEBS > events. > 141 * Because, > 142 * - For most cases, there is no difference among precision > 143 * level 1 to 3 for PEBS events. > 144 * - The functions as below checks the precision level in > host. > 145 * But the results from these functions in host are > replaced > 146 * by guest when sampling the guest. > 147 * The accuracy for guest PEBS events will not be > impacted. > 148 * -- event_constraints() impacts the index of counter. > 149 * The index for host event is exactly the same as guest. > 150 * It's decided by guest. > 151 * -- pebs_update_adaptive_cfg() impacts the value of > 152 * MSR_PEBS_DATA_CFG. When guest is switched in, > 153 * the MSR value will be replaced by the value from > guest. > 154 * -- setup_sample () impacts the output of a PEBS > record. > 155 * Guest handles the PEBS records. > 156 */ > 157 attr.precise_ip = 1; > 158 /* > 159 * When the host's PMI handler completes, it's going to > 160 * enter the guest and trigger the guest's PMI handler. > 161 * > 162 * At this moment, this function may be called by > 163 * kvm_pmu_handle_event(). However the next > sample_period > 164 * hasn't been determined by guest yet and the left period, > 165 * which probably be 0, is used for current sample_period. > 166 * > 167 * In this case, perf will mistakenly treat it as non > 168 * sampling events. The PEBS event will error out. > 169 * > 170 * Fill it with maximum period to prevent the error out. > 171 * The guest PMI handler will soon reprogram the counter. > 172 */ > 173 if (!attr.sample_period) > 174 attr.sample_period = (-1ULL) & pmc_bitmask(pmc); > 175 } > 176 > 177 event = perf_event_create_kernel_counter(&attr, -1, current, > 178 (intr || pebs) ? > 179 kvm_perf_overflow_intr : > 180 kvm_perf_overflow, pmc); > 181 if (IS_ERR(event)) { > 182 pr_debug_ratelimited("kvm_pmu: event creation failed %ld > for pmc->idx = %d\n", > 183 PTR_ERR(event), pmc->idx); > 184 return; > 185 } > 186 > 187 if (pebs) { > 188 event->guest_dedicated_idx = pmc->idx; > 189 /* > 190 * For guest PEBS events, guest takes the responsibility to > 191 * drain PEBS buffers, and load proper values to reset > counters. > 192 * > 193 * Host will unconditionally set auto-reload flag for PEBS > 194 * events with fixed period which is not necessary. Host > should > 195 * do nothing in drain_pebs() but inject the PMI into the > guest. > 196 * > 197 * Unset the auto-reload flag for guest PEBS events. > 198 */ > > 199 perf_x86_pmu_unset_auto_reload(event); > 200 } > 201 pmc->perf_event = event; > 202 pmc_to_pmu(pmc)->event_count++; > 203 perf_event_enable(event); > 204 clear_bit(pmc->idx, pmc_to_pmu(pmc)->reprogram_pmi); > 205 } > 206 > > --- > 0-DAY CI Kernel Test Service, Intel Corporation > https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
WARNING: multiple messages have this Message-ID (diff)
From: Xu, Like <like.xu@intel.com> To: kbuild-all@lists.01.org Subject: Re: [PATCH v1 05/11] KVM: x86/pmu: Add support to reprogram PEBS event for guest counters Date: Mon, 09 Mar 2020 00:58:47 +0000 [thread overview] Message-ID: <F7FC466FA1E455449AD0F9063BBE758E0C868500@shsmsx102.ccr.corp.intel.com> (raw) In-Reply-To: <202003070038.amFy5Etu%lkp@intel.com> [-- Attachment #1: Type: text/plain, Size: 7350 bytes --] > -----Original Message----- > From: kbuild test robot <lkp@intel.com> > Sent: Saturday, March 7, 2020 12:28 AM > To: Luwei Kang <luwei.kang@intel.com> > Cc: kbuild-all(a)lists.01.org; x86(a)kernel.org; linux-kernel(a)vger.kernel.org; > kvm(a)vger.kernel.org; peterz(a)infradead.org; mingo(a)redhat.com; > acme(a)kernel.org; mark.rutland(a)arm.com; > alexander.shishkin(a)linux.intel.com; jolsa(a)redhat.com; > namhyung(a)kernel.org; tglx(a)linutronix.de; bp(a)alien8.de; hpa(a)zytor.com; > pbonzini(a)redhat.com; sean.j.christopherson(a)intel.com; > vkuznets(a)redhat.com; wanpengli(a)tencent.com; jmattson(a)google.com; > joro(a)8bytes.org; pawan.kumar.gupta(a)linux.intel.com; ak(a)linux.intel.com; > thomas.lendacky(a)amd.com; fenghua.yu(a)intel.com; > kan.liang(a)linux.intel.com; like.xu(a)linux.intel.com > Subject: Re: [PATCH v1 05/11] KVM: x86/pmu: Add support to reprogram PEBS > event for guest counters > > Hi Luwei, > > Thank you for the patch! Yet something to improve: > > [auto build test ERROR on kvm/linux-next] [also build test ERROR on > tip/perf/core tip/auto-latest v5.6-rc4 next-20200306] [if your patch is applied to > the wrong git tree, please drop us a note to help improve the system. BTW, we > also suggest to use '--base' option to specify the base tree in git format-patch, > please see https://stackoverflow.com/a/37406982] > > url: > https://github.com/0day-ci/linux/commits/Luwei-Kang/PEBS-virtualization-ena > bling-via-DS/20200306-013049 > base: https://git.kernel.org/pub/scm/virt/kvm/kvm.git linux-next > config: x86_64-randconfig-h003-20200305 (attached as .config) > compiler: gcc-7 (Debian 7.5.0-5) 7.5.0 > reproduce: > # save the attached .config to linux build tree > make ARCH=x86_64 > > If you fix the issue, kindly add following tag > Reported-by: kbuild test robot <lkp@intel.com> > > All errors (new ones prefixed by >>): > > ld: arch/x86/kvm/pmu.o: in function `pmc_reprogram_counter': > >> arch/x86/kvm/pmu.c:199: undefined reference to > `perf_x86_pmu_unset_auto_reload' Since we may not lose PEBS functionality for other x86 vendors on KVM and we already have defined PERF_X86_EVENT_AUTO_RELOAD in the general arch/x86/events/perf_event.h, one of the ways to fix this issue is to move the definition of perf_x86_pmu_unset_auto_reload() to the end of arch/x86/events/core.c instead of making it Intel specific in previous patch "perf/x86: Expose a function to disable auto-reload." Thanks, Like Xu > > vim +199 arch/x86/kvm/pmu.c > > 101 > 102 static void pmc_reprogram_counter(struct kvm_pmc *pmc, u32 type, > 103 unsigned config, bool exclude_user, > 104 bool exclude_kernel, bool intr, > 105 bool in_tx, bool in_tx_cp) > 106 { > 107 struct kvm_pmu *pmu = vcpu_to_pmu(pmc->vcpu); > 108 struct perf_event *event; > 109 struct perf_event_attr attr = { > 110 .type = type, > 111 .size = sizeof(attr), > 112 .pinned = true, > 113 .exclude_idle = true, > 114 .exclude_host = 1, > 115 .exclude_user = exclude_user, > 116 .exclude_kernel = exclude_kernel, > 117 .config = config, > 118 .disabled = 1, > 119 }; > 120 bool pebs = test_bit(pmc->idx, (unsigned long > *)&pmu->pebs_enable); > 121 > 122 attr.sample_period = (-pmc->counter) & pmc_bitmask(pmc); > 123 > 124 if (in_tx) > 125 attr.config |= HSW_IN_TX; > 126 if (in_tx_cp) { > 127 /* > 128 * HSW_IN_TX_CHECKPOINTED is not supported with > nonzero > 129 * period. Just clear the sample period so at least > 130 * allocating the counter doesn't fail. > 131 */ > 132 attr.sample_period = 0; > 133 attr.config |= HSW_IN_TX_CHECKPOINTED; > 134 } > 135 > 136 if (pebs) { > 137 /* > 138 * Host never knows the precision level set by guest. > 139 * Force Host's PEBS event to precision level 1, which will > 140 * not impact the accuracy of the results for guest PEBS > events. > 141 * Because, > 142 * - For most cases, there is no difference among precision > 143 * level 1 to 3 for PEBS events. > 144 * - The functions as below checks the precision level in > host. > 145 * But the results from these functions in host are > replaced > 146 * by guest when sampling the guest. > 147 * The accuracy for guest PEBS events will not be > impacted. > 148 * -- event_constraints() impacts the index of counter. > 149 * The index for host event is exactly the same as guest. > 150 * It's decided by guest. > 151 * -- pebs_update_adaptive_cfg() impacts the value of > 152 * MSR_PEBS_DATA_CFG. When guest is switched in, > 153 * the MSR value will be replaced by the value from > guest. > 154 * -- setup_sample () impacts the output of a PEBS > record. > 155 * Guest handles the PEBS records. > 156 */ > 157 attr.precise_ip = 1; > 158 /* > 159 * When the host's PMI handler completes, it's going to > 160 * enter the guest and trigger the guest's PMI handler. > 161 * > 162 * At this moment, this function may be called by > 163 * kvm_pmu_handle_event(). However the next > sample_period > 164 * hasn't been determined by guest yet and the left period, > 165 * which probably be 0, is used for current sample_period. > 166 * > 167 * In this case, perf will mistakenly treat it as non > 168 * sampling events. The PEBS event will error out. > 169 * > 170 * Fill it with maximum period to prevent the error out. > 171 * The guest PMI handler will soon reprogram the counter. > 172 */ > 173 if (!attr.sample_period) > 174 attr.sample_period = (-1ULL) & pmc_bitmask(pmc); > 175 } > 176 > 177 event = perf_event_create_kernel_counter(&attr, -1, current, > 178 (intr || pebs) ? > 179 kvm_perf_overflow_intr : > 180 kvm_perf_overflow, pmc); > 181 if (IS_ERR(event)) { > 182 pr_debug_ratelimited("kvm_pmu: event creation failed %ld > for pmc->idx = %d\n", > 183 PTR_ERR(event), pmc->idx); > 184 return; > 185 } > 186 > 187 if (pebs) { > 188 event->guest_dedicated_idx = pmc->idx; > 189 /* > 190 * For guest PEBS events, guest takes the responsibility to > 191 * drain PEBS buffers, and load proper values to reset > counters. > 192 * > 193 * Host will unconditionally set auto-reload flag for PEBS > 194 * events with fixed period which is not necessary. Host > should > 195 * do nothing in drain_pebs() but inject the PMI into the > guest. > 196 * > 197 * Unset the auto-reload flag for guest PEBS events. > 198 */ > > 199 perf_x86_pmu_unset_auto_reload(event); > 200 } > 201 pmc->perf_event = event; > 202 pmc_to_pmu(pmc)->event_count++; > 203 perf_event_enable(event); > 204 clear_bit(pmc->idx, pmc_to_pmu(pmc)->reprogram_pmi); > 205 } > 206 > > --- > 0-DAY CI Kernel Test Service, Intel Corporation > https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
next prev parent reply other threads:[~2020-03-09 0:58 UTC|newest] Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-03-05 17:56 [PATCH v1 00/11] PEBS virtualization enabling via DS Luwei Kang 2020-03-05 16:51 ` Paolo Bonzini 2020-03-05 17:56 ` [PATCH v1 01/11] perf/x86/core: Support KVM to assign a dedicated counter for guest PEBS Luwei Kang 2020-03-06 13:53 ` Peter Zijlstra 2020-03-06 14:42 ` Liang, Kan 2020-03-09 10:04 ` Peter Zijlstra 2020-03-09 13:12 ` Liang, Kan 2020-03-09 15:05 ` Peter Zijlstra 2020-03-09 19:28 ` Liang, Kan 2020-03-12 10:28 ` Kang, Luwei 2020-03-26 14:03 ` Liang, Kan 2020-04-07 12:34 ` Kang, Luwei 2020-06-12 5:28 ` Kang, Luwei 2020-06-19 9:30 ` Kang, Luwei 2020-08-20 3:32 ` Like Xu 2020-03-09 15:44 ` Andi Kleen 2020-03-05 17:56 ` [PATCH v1 02/11] perf/x86/ds: Handle guest PEBS events overflow and inject fake PMI Luwei Kang 2020-03-05 17:56 ` [PATCH v1 03/11] perf/x86: Expose a function to disable auto-reload Luwei Kang 2020-03-05 17:56 ` [PATCH v1 04/11] KVM: x86/pmu: Decouple event enablement from event creation Luwei Kang 2020-03-05 17:56 ` [PATCH v1 05/11] KVM: x86/pmu: Add support to reprogram PEBS event for guest counters Luwei Kang 2020-03-06 16:28 ` kbuild test robot 2020-03-06 16:28 ` kbuild test robot 2020-03-09 0:58 ` Xu, Like [this message] 2020-03-09 0:58 ` Xu, Like 2020-03-05 17:57 ` [PATCH v1 06/11] KVM: x86/pmu: Implement is_pebs_via_ds_supported pmu ops Luwei Kang 2020-03-05 17:57 ` [PATCH v1 07/11] KVM: x86/pmu: Expose CPUIDs feature bits PDCM, DS, DTES64 Luwei Kang 2020-03-05 17:57 ` [PATCH v1 08/11] KVM: x86/pmu: PEBS MSRs emulation Luwei Kang 2020-03-05 17:57 ` [PATCH v1 09/11] KVM: x86/pmu: Expose PEBS feature to guest Luwei Kang 2020-03-05 17:57 ` [PATCH v1 10/11] KVM: x86/pmu: Introduce the mask value for fixed counter Luwei Kang 2020-03-05 17:57 ` [PATCH v1 11/11] KVM: x86/pmu: Adaptive PEBS virtualization enabling Luwei Kang 2020-03-05 22:48 ` [PATCH v1 00/11] PEBS virtualization enabling via DS Andi Kleen 2020-03-06 5:37 ` Kang, Luwei
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=F7FC466FA1E455449AD0F9063BBE758E0C868500@shsmsx102.ccr.corp.intel.com \ --to=like.xu@intel.com \ --cc=acme@kernel.org \ --cc=ak@linux.intel.com \ --cc=alexander.shishkin@linux.intel.com \ --cc=bp@alien8.de \ --cc=fenghua.yu@intel.com \ --cc=hpa@zytor.com \ --cc=jmattson@google.com \ --cc=jolsa@redhat.com \ --cc=joro@8bytes.org \ --cc=kan.liang@linux.intel.com \ --cc=kbuild-all@lists.01.org \ --cc=kvm@vger.kernel.org \ --cc=like.xu@linux.intel.com \ --cc=linux-kernel@vger.kernel.org \ --cc=lkp@intel.com \ --cc=luwei.kang@intel.com \ --cc=mark.rutland@arm.com \ --cc=mingo@redhat.com \ --cc=namhyung@kernel.org \ --cc=pawan.kumar.gupta@linux.intel.com \ --cc=pbonzini@redhat.com \ --cc=peterz@infradead.org \ --cc=sean.j.christopherson@intel.com \ --cc=tglx@linutronix.de \ --cc=thomas.lendacky@amd.com \ --cc=vkuznets@redhat.com \ --cc=wanpengli@tencent.com \ --cc=x86@kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.