From patchwork Thu Mar 14 06:42:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 160314 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp15145501jad; Wed, 13 Mar 2019 23:43:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqy4q8i5W9CSjhC3/Sal+hT4lch4pKBayqe+hy1JANjrOOBYrHJ51QVrj4wV6lWC9eoA5Iq9 X-Received: by 2002:a65:40c5:: with SMTP id u5mr43264153pgp.275.1552545825040; Wed, 13 Mar 2019 23:43:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552545825; cv=none; d=google.com; s=arc-20160816; b=Zl+JtVT0bev/DAzWxe2YtX4kQuWnJlUW76BkkXbZigd+fBp5rwjgrXGqhKNYZMZL9U m7W8+aEzUwo7vdfaCDpOmKVwUnVT7r9gHB5Jao11fNzHkYksnSniw3JDK3FGkW7Yj8sg ONExR15SrgQVUwslekOKE7w9W7Y3KLdy9tvg5wYq3WdTL+pNmrvpgvgDMsGaJty3JOGk EglVgaXl/cvdxdp+bt6/EBSlMQbsBOsVohTb3hakiM5yRTxWVSAKkB96VP+b7E9EHqIY 12BD0q5V3qaPZAY0cSe76a6ObacXoPUqw/3YDWrpS7f7iP+Z5mXJyGnBbIlpf3kCczBV zalA== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Ebmk+NLAtdOtjqPKJKqOvCw/VBxQ6uvDNPKAjmLO1T0=; b=QR26zsx4P9/5ROSFNIRCMZNoGuYH+1EHT8cB5BpuckLZ/dt+/41cTs2TabqiyaV1mT gFcdCIPUCWRojASnwJRdoy0ig7l8/3eIy5lhdNuPWuf3OC7gmqrbitw701MNm7++8k9s fSnNwksKS89RSGhM8HIVYlPQh/HThgvwGFYeLmUMFY6So2JEcAtdQeHuAvaKhJGYStRg nht7OKEE7OUERxlL1qgfJ6VFwYq749oaQnkwbYhLA4BXEkGQtMAnXOflue9jMn94wgQz teNRrnyhbM5YA6TfUfSkGgmSIr6Og+I12bp3epM00Hir/ctwY2LiNUo/k730pP/ztaLK 5xjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=w979PRkQ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v3si12780459plo.147.2019.03.13.23.43.38; Wed, 13 Mar 2019 23:43:45 -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; dkim=pass header.i=@linaro.org header.s=google header.b=w979PRkQ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727335AbfCNGnh (ORCPT + 31 others); Thu, 14 Mar 2019 02:43:37 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:38664 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727300AbfCNGng (ORCPT ); Thu, 14 Mar 2019 02:43:36 -0400 Received: by mail-pf1-f196.google.com with SMTP id n125so3181020pfn.5 for ; Wed, 13 Mar 2019 23:43:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ebmk+NLAtdOtjqPKJKqOvCw/VBxQ6uvDNPKAjmLO1T0=; b=w979PRkQFqk+b+Jq9kZ/k9zDrSk4aW4Kp02xZ0LyM2CQg/LAlLvJnjWrJYbLVN4FXT FiVieIId0tuArOO45TNRxJTV5cP9UbhZCFsJsm7/DvhUoM7JYmZWA9kY5mtStUBV9cQq i98pkDc3/c/Ztwj8N8pgBKUR71SLSnTAmdeUd5JFGaqj2F4JyrA40JHj8au9ZO3LfFfc 88ZH2JZDu7haUROjDW7YeMUZxoekMnMO/oBNTOPUdRgjQfuXXuYna/B9lnOT6NJ6IF+L tkkA46K3qSF/tXVALRKguiwBBij+LsIL7oEHWnUJyPCK4xPzicDfaD36aiaoYt2a3QLF EEbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ebmk+NLAtdOtjqPKJKqOvCw/VBxQ6uvDNPKAjmLO1T0=; b=ckxOey7rMcUJATya79K4OFsUsA1l+GsmqmmXMeTqU0Os6pK+J1UpdCRs5R99Mte/1e w4KRPFqFFIT2f6Ox9g2tGHAIqiGrUIufrRLCc/z5wFmK+3dyOUfqSPh4Aw2T+D6M4lwa wUUOH4OVd2j+SFLxBChgrl+//1n+KItV/dEfPfPcQ9xqddeNwOQQI8RiKgMqMCZwhvzx 08GGFDNR9TJsOZQS7twUk7L8JJUZl3xevynfwT1bfDzhIXofjXv+ztsotFWQlUoSP+3W A6iCkDPTeOxiEjSXh+OrV+k0MNX6ziyiuLv1YptRCbRE9UP5/pbu0IyOqgb9Yc434POY 2zeA== X-Gm-Message-State: APjAAAUPbZ8vGPp9RhcFlrEPog49NyBmkVmvMv8w/+byHaXFrwkG1CxD xe6LTGRAJiDsieN/xH6sqicrFQ== X-Received: by 2002:a17:902:361:: with SMTP id 88mr50056390pld.78.1552545815420; Wed, 13 Mar 2019 23:43:35 -0700 (PDT) Received: from localhost ([122.166.134.37]) by smtp.gmail.com with ESMTPSA id g24sm1674461pfd.7.2019.03.13.23.43.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Mar 2019 23:43:34 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Paolo Bonzini , =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/7] KVM: x86: Update cpufreq transition notifier to handle multiple CPUs Date: Thu, 14 Mar 2019 12:12:52 +0530 Message-Id: X-Mailer: git-send-email 2.21.0.rc0.269.g1a574e7a288b In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The cpufreq core currently calls the cpufreq transition notifier callback once for each affected CPU. This is going to change soon and the cpufreq core will call the callback only once for each cpufreq policy. The callback must look at the newly added field in struct cpufreq_freqs, "cpus", which contains policy->related_cpus (both online/offline CPUs) and perform per-cpu actions for them if any. This patch updates kvmclock_cpufreq_notifier() to use the new "cpus" field and perform the per-cpu activity for all online CPUs in this cpumask. Signed-off-by: Viresh Kumar --- arch/x86/kvm/x86.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) -- 2.21.0.rc0.269.g1a574e7a288b diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 941f932373d0..24eb6123391d 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -6648,10 +6648,8 @@ static void kvm_hyperv_tsc_notifier(void) } #endif -static int kvmclock_cpufreq_notifier(struct notifier_block *nb, unsigned long val, - void *data) +static void __kvmclock_cpufreq_notifier(struct cpufreq_freqs *freq, int cpu) { - struct cpufreq_freqs *freq = data; struct kvm *kvm; struct kvm_vcpu *vcpu; int i, send_ipi = 0; @@ -6695,17 +6693,12 @@ static int kvmclock_cpufreq_notifier(struct notifier_block *nb, unsigned long va * */ - if (val == CPUFREQ_PRECHANGE && freq->old > freq->new) - return 0; - if (val == CPUFREQ_POSTCHANGE && freq->old < freq->new) - return 0; - - smp_call_function_single(freq->cpu, tsc_khz_changed, freq, 1); + smp_call_function_single(cpu, tsc_khz_changed, freq, 1); spin_lock(&kvm_lock); list_for_each_entry(kvm, &vm_list, vm_list) { kvm_for_each_vcpu(i, vcpu, kvm) { - if (vcpu->cpu != freq->cpu) + if (vcpu->cpu != cpu) continue; kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu); if (vcpu->cpu != smp_processor_id()) @@ -6727,8 +6720,24 @@ static int kvmclock_cpufreq_notifier(struct notifier_block *nb, unsigned long va * guest context is entered kvmclock will be updated, * so the guest will not see stale values. */ - smp_call_function_single(freq->cpu, tsc_khz_changed, freq, 1); + smp_call_function_single(cpu, tsc_khz_changed, freq, 1); } +} + +static int kvmclock_cpufreq_notifier(struct notifier_block *nb, unsigned long val, + void *data) +{ + struct cpufreq_freqs *freq = data; + int cpu; + + if (val == CPUFREQ_PRECHANGE && freq->old > freq->new) + return 0; + if (val == CPUFREQ_POSTCHANGE && freq->old < freq->new) + return 0; + + for_each_cpu_and(cpu, freq->cpus, cpu_online_mask) + __kvmclock_cpufreq_notifier(freq, cpu); + return 0; }