Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1096449ybi; Wed, 3 Jul 2019 09:25:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqxIrXjHcl7QsZflzK5o2nEZJ3rfyKw9kImmxNw23+YIDYD4Af+YMMmtAQ64lJyNPz7g7A0c X-Received: by 2002:a63:a1a:: with SMTP id 26mr1739965pgk.265.1562171151072; Wed, 03 Jul 2019 09:25:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562171151; cv=none; d=google.com; s=arc-20160816; b=FXnvYpsFoHpYW19SnGzadXfi2AxVypQOJNPTvylMhylutGAC6pJyQ6pSm2qi2Jeo/O UQTE8/az6yP6g58gvvP4WaV+PC5a6WMAKxN/MxhUl2U4dZAmbLv2KC8fv19YYJsk31+s OCsLQU6B1kN107Qnk+bCleUvbGWIFqQWmMkYpgFXczCoo8wcpJSDjXCUUpCfgiL1nzVC h+0+H7Cpc7AsnZAxYzQGs/FeWs4niZA2zfoQd4hzWPt6FtNX+QQAY9K2sHv0UiICP6mE oKnPWof60znRmVE4falPKOSqMq2H6GRzdiquLVYTc57dhJ6WbicdPnWB8Z9RyQHqIpFa zDTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=ikRLK3Ph+biXIkYRKj5FiXXJi2K3aKBPVe0fP3FxzK8=; b=UMrWqtZGId1noqRhM2ZIXHDRfieQ65y5uO2eeE7c8Mkb8y/IfKs9a3Sij5HHGUIBBd qW0+styDu2YoaQvgd0gDPBGBzfG513lZEM8sySuXTemTniRkDaaPlwhb9eOfYYq+dVbp MfwhMr/j2nJhkgozcLz/9hZLTH8atHwvDWnqIbbn8vpw9/4OKTSgfsEkhOcRFt9iI0jT 6OsnfwnkI6uCdcCZoJLzci+RdeKC2STxLRNBgcAI09GxjMSuMXKBCwaBl+L1VU5egpVV 3X1s/UCo6Bp8BDp6PEzE7fAeItGFprXV5RHqgC5LMQB3ABnK1AOqoLEc06ai6lpygG/c 3EMg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g9si2551581pgs.364.2019.07.03.09.25.35; Wed, 03 Jul 2019 09:25:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726915AbfGCQZL (ORCPT + 99 others); Wed, 3 Jul 2019 12:25:11 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:45387 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726652AbfGCQZK (ORCPT ); Wed, 3 Jul 2019 12:25:10 -0400 Received: by mail-wr1-f65.google.com with SMTP id f9so3501362wre.12 for ; Wed, 03 Jul 2019 09:25:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=ikRLK3Ph+biXIkYRKj5FiXXJi2K3aKBPVe0fP3FxzK8=; b=nO7A+HovlJJfUBZUvU8xfQEv+cyeAt7JAvrXpAPZg/rpQM2pfsn5+LcL25ScG+HJMy 4n4bMCpW7DzDZ5LWD5Z3oeBj744LNy6wqaeqPllrhadQKHpF+IupamQ+U8WZ57IaiX21 hmXRh4oun9bCSCxMUidt6ZCuZtMz4LWFdO1qdBDrryQqwsK7vN+U00yXIL6Pov5QYoKD 8PLYmhtRjHZ0rMTp8zMxyJk6xLnmKJX0brletJ/eTPD1Zh9Iyi4KE3GROm9Mk5pifz/7 Dcnobo8bvchvJV2ivJ9G74r1VbUZZvsW2chqObKQJhzPnPAPIW+G5hHolX+XbrinzPq3 7B9A== X-Gm-Message-State: APjAAAVOVW4ZbGFtFZHR3O0oJtQM5V+OJvVK1P47tGnqdnlshxHSUPX/ x53EtoWx8rdsQbQ+u1jJxssngqDtgPHuMQ== X-Received: by 2002:a5d:430c:: with SMTP id h12mr29914401wrq.163.1562171108195; Wed, 03 Jul 2019 09:25:08 -0700 (PDT) Received: from ?IPv6:2001:b07:6468:f312:6c1d:63cc:b81d:e1a9? ([2001:b07:6468:f312:6c1d:63cc:b81d:e1a9]) by smtp.gmail.com with ESMTPSA id s63sm2908489wme.17.2019.07.03.09.25.07 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Wed, 03 Jul 2019 09:25:07 -0700 (PDT) Subject: Re: [PATCH 4/4] kvm: x86: convert TSC pr_debugs to be gated by CONFIG_KVM_DEBUG To: Yi Wang Cc: rkrcmar@redhat.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, xue.zhihong@zte.com.cn, up2wing@gmail.com, wang.liang82@zte.com.cn References: <1561962071-25974-1-git-send-email-wang.yi59@zte.com.cn> <1561962071-25974-5-git-send-email-wang.yi59@zte.com.cn> From: Paolo Bonzini Message-ID: <108995bd-fac1-03f0-c3a9-822b3219be82@redhat.com> Date: Wed, 3 Jul 2019 18:25:06 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <1561962071-25974-5-git-send-email-wang.yi59@zte.com.cn> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/07/19 08:21, Yi Wang wrote: > There are some pr_debug in TSC code, which may affect > performance, so it may make sense to wrap them using a new > macro tsc_debug which takes effect only when CONFIG_KVM_DEBUG > is defined. > > Signed-off-by: Yi Wang > --- > arch/x86/kvm/x86.c | 18 ++++++++++++------ > 1 file changed, 12 insertions(+), 6 deletions(-) > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 83aefd7..1505e53 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -74,6 +74,12 @@ > #define CREATE_TRACE_POINTS > #include "trace.h" > > +#ifdef CONFIG_KVM_DEBUG > +#define tsc_debug(x...) pr_debug(x) > +#else > +#define tsc_debug(x...) > +#endif > + > #define MAX_IO_MSRS 256 > #define KVM_MAX_MCE_BANKS 32 > u64 __read_mostly kvm_mce_cap_supported = MCG_CTL_P | MCG_SER_P; > @@ -1522,7 +1528,7 @@ static void kvm_get_time_scale(uint64_t scaled_hz, uint64_t base_hz, > *pshift = shift; > *pmultiplier = div_frac(scaled64, tps32); > > - pr_debug("%s: base_hz %llu => %llu, shift %d, mul %u\n", > + tsc_debug("%s: base_hz %llu => %llu, shift %d, mul %u\n", > __func__, base_hz, scaled_hz, shift, *pmultiplier); > } Just remove this. > @@ -1603,7 +1609,7 @@ static int kvm_set_tsc_khz(struct kvm_vcpu *vcpu, u32 user_tsc_khz) > thresh_lo = adjust_tsc_khz(tsc_khz, -tsc_tolerance_ppm); > thresh_hi = adjust_tsc_khz(tsc_khz, tsc_tolerance_ppm); > if (user_tsc_khz < thresh_lo || user_tsc_khz > thresh_hi) { > - pr_debug("kvm: requested TSC rate %u falls outside tolerance [%u,%u]\n", user_tsc_khz, thresh_lo, thresh_hi); > + tsc_debug("kvm: requested TSC rate %u falls outside tolerance [%u,%u]\n", user_tsc_khz, thresh_lo, thresh_hi); This is okay as a pr_debug, it only happens once per VM and only if it is configured wrong. > use_scaling = 1; > } > return set_tsc_khz(vcpu, user_tsc_khz, use_scaling); > @@ -1766,12 +1772,12 @@ void kvm_write_tsc(struct kvm_vcpu *vcpu, struct msr_data *msr) > vcpu->arch.virtual_tsc_khz == kvm->arch.last_tsc_khz) { > if (!kvm_check_tsc_unstable()) { > offset = kvm->arch.cur_tsc_offset; > - pr_debug("kvm: matched tsc offset for %llu\n", data); > + tsc_debug("kvm: matched tsc offset for %llu\n", data); > } else { > u64 delta = nsec_to_cycles(vcpu, elapsed); > data += delta; > offset = kvm_compute_tsc_offset(vcpu, data); > - pr_debug("kvm: adjusted tsc offset by %llu\n", delta); > + tsc_debug("kvm: adjusted tsc offset by %llu\n", delta); Again just drop these, there are tracepoints for it. > } > matched = true; > already_matched = (vcpu->arch.this_tsc_generation == kvm->arch.cur_tsc_generation); > @@ -1790,7 +1796,7 @@ void kvm_write_tsc(struct kvm_vcpu *vcpu, struct msr_data *msr) > kvm->arch.cur_tsc_write = data; > kvm->arch.cur_tsc_offset = offset; > matched = false; > - pr_debug("kvm: new tsc generation %llu, clock %llu\n", > + tsc_debug("kvm: new tsc generation %llu, clock %llu\n", > kvm->arch.cur_tsc_generation, data); Drop. > } > > @@ -6860,7 +6866,7 @@ static void kvm_timer_init(void) > cpufreq_register_notifier(&kvmclock_cpufreq_notifier_block, > CPUFREQ_TRANSITION_NOTIFIER); > } > - pr_debug("kvm: max_tsc_khz = %ld\n", max_tsc_khz); > + tsc_debug("kvm: max_tsc_khz = %ld\n", max_tsc_khz); Drop. Thanks, Paolo > cpuhp_setup_state(CPUHP_AP_X86_KVM_CLK_ONLINE, "x86/kvm/clk:online", > kvmclock_cpu_online, kvmclock_cpu_down_prep); >