From patchwork Thu Mar 14 06:42:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 160310 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp15145232jad; Wed, 13 Mar 2019 23:43:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqwQaXb8cvrIyIqJ4QrZdv9TstaI9Qvgk8YWJhwm2jAkq6fyRCc7UGv1H9x1Bko2zKLXwhxn X-Received: by 2002:aa7:8205:: with SMTP id k5mr46872964pfi.86.1552545805774; Wed, 13 Mar 2019 23:43:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552545805; cv=none; d=google.com; s=arc-20160816; b=oTaL4CrGEyCQQNhO0ZLj0ph1f8plHOjX1uHnKRAVEh7m9Hfrqy+JOohNU3cpAJUOsP ENbnji7DMITKw0Dl8Jy4DLFbJhOecrtyryvIOQJ478/R5yM0vYrz1XOhhGe9Xx/TRE/Q ngaz5p7lCgu9jdZV6m3vegccnqPOpSf6EcX3rR93kvHDKMLyAYMzbAptU5KFiTNB35Xq OfNkbzlBbkbDPWwm1zjzhuDFzMfPrGFmKQKxmCfATSsNCOszwQ7gDUx4hb823CuShjFH YaxVE+ybReFR/8m7QjFUxPsgZfqZuSLjRka0FLCd/LW0mmkDySRqrJ0G807e+4QB716g YwGw== 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=M1KeKtW8OOVXttXpveVwFNNHfJ6vG6L+djJBTEnEfMQ=; b=C3GOBNObXgn4lZ4kkZUbmiknnafow6MKEJxqnlRtnewTrMKq0U6h1hpWfK8dvyT7BW DScBWxhFZWB+8rcxB84zxBLM68zytzn/7d9AYRWS5E5sB4H0rOXhWwetuETe10kzU/Dq KSWa+3E7jrcaOCj/wEKF0ddO3Cl38fJWKbfVZGTUFzmcq5KVHOPldc+aB5KhI6LUPkBd zkEGvOULG4a+hzfJjVv46D2KyNlfM/QNulPnWdvsMA81dlvOpVOHzkGupMYG4h5C/Xp4 imZj6+NwqL72b2QnYu2bWo1z1bqC2HBnTjDMNIuCVGP/uUSe/eDUSvW1aaO6Q0m+zwx9 Gy0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OhJKZ8Hz; 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 d20si13001228plr.388.2019.03.13.23.43.25; Wed, 13 Mar 2019 23:43:25 -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=OhJKZ8Hz; 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 S1727179AbfCNGnW (ORCPT + 31 others); Thu, 14 Mar 2019 02:43:22 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:37503 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726799AbfCNGnU (ORCPT ); Thu, 14 Mar 2019 02:43:20 -0400 Received: by mail-pf1-f196.google.com with SMTP id s22so3190438pfh.4 for ; Wed, 13 Mar 2019 23:43:20 -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=M1KeKtW8OOVXttXpveVwFNNHfJ6vG6L+djJBTEnEfMQ=; b=OhJKZ8HzWWRt15fJOKm9vDrXq5pNgxk/2d97kSc8oig307pQ4dcZkd47hI1qZ6pt5z v16ywi7oEG6oCruVyYuvu1JUXRudMVjyhDmFWNGW6e5A7cenWOUwpXkI5hpy3YyRE5d5 ipFkGOXp32rRG2dHIfRrUfGCXvtsUfz0+orK2ZjEX6Wznrhf35QxKxA7amrNMbzG+m8Y LlTON707sSV+KWwjX4KEzLJgBjhS5NWrgZYk/eWrY/MpLPKT5uSzXauWt2a3wiFne9O3 cKbr5eA9ozMiFoKK7v7X08x/mjG7txnmNKEWzzB6t12/qbDn1iHyEGnDzXPJ0QNylBTy sZdw== 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=M1KeKtW8OOVXttXpveVwFNNHfJ6vG6L+djJBTEnEfMQ=; b=L30vxdNX+dH6gaB9dG2HTxEFajCBYjn6d9X5au0DJ9d64j/TYZzr4ZxnqXra4L+8wB BGX51LslUL4NkGwklKM6mv9DNiHVnzx4JPWk+i9XWCmIZ1xXJFqZSqlQ0zuKQ9qz6Kb/ G5q5Z/CkHK2aYRgye5ikZjKN666xTrIbvDD6aRNUSR5dpcJryi97KnJ437zgdpkTxa7p EXvikKPvz3qsTGdedeQxSMT1P+mZ7tzp9DDtP+o1c6Pyj12Dk1eNRcBFgRQFD1EinCYt wtR8uDocLlrfwuogoI+K9/2QGIoxrVnziQzCi0msBIwDZzLAHTIxeR1+pWdyFCuqK62A NAQw== X-Gm-Message-State: APjAAAVVThVDuyDIJxZszV8caGolaK90jbJWTwVlN/46dV6UpF1ecKCN rpkaRX3AYE6dQ8acnPc1f8s8EQ== X-Received: by 2002:a17:902:20e3:: with SMTP id v32mr49723750plg.213.1552545799616; Wed, 13 Mar 2019 23:43:19 -0700 (PDT) Received: from localhost ([122.166.134.37]) by smtp.gmail.com with ESMTPSA id 10sm4532975pft.83.2019.03.13.23.43.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Mar 2019 23:43:18 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , linux-kernel@vger.kernel.org Subject: [PATCH 1/7] cpufreq: Pass policy->related_cpus to transition notifiers Date: Thu, 14 Mar 2019 12:12:47 +0530 Message-Id: <3b6663b03fe837615ba608aff50b4b2a27ab2ab3.1552545525.git.viresh.kumar@linaro.org> 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 Currently we call these notifiers once for each CPU of the policy->cpus cpumask, which isn't that efficient. This patch adds a cpumask pointer to struct cpufreq_freqs and copies policy->related_cpus to it. The notifiers will have information about all the affected CPUs now with the first call itself and once all the notifier callbacks are updated to use the new field, we can remove the "cpu" field from struct cpufreq_freqs and call the notifier only once per policy. Some of the transition notifier users use per-cpu data to read and store their data and they rely on it being correct. With CPU offline/online sequences we may end up with using stale data for those CPUs (which are offlined/onlined). In order to avoid such corner cases, this patch uses policy->related_cpus instead of policy->cpus. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 1 + include/linux/cpufreq.h | 1 + 2 files changed, 2 insertions(+) -- 2.21.0.rc0.269.g1a574e7a288b diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 0e626b00053b..b1b012169f00 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -311,6 +311,7 @@ static void cpufreq_notify_transition(struct cpufreq_policy *policy, if (cpufreq_disabled()) return; + freqs->cpus = policy->related_cpus; freqs->flags = cpufreq_driver->flags; pr_debug("notification %u of frequency transition to %u kHz\n", state, freqs->new); diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index b160e98076e3..dd318363dfc2 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -43,6 +43,7 @@ enum cpufreq_table_sorting { }; struct cpufreq_freqs { + struct cpumask *cpus; unsigned int cpu; /* cpu nr */ unsigned int old; unsigned int new; From patchwork Thu Mar 14 06:42:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 160311 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp15145275jad; Wed, 13 Mar 2019 23:43:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqwkmf5sZsKhUl7+TvHUGkNyK+zNzhVFsoLCgQ7fRFbr0ibeJRhuqEfoNkI+hCxy6HxudkBY X-Received: by 2002:a17:902:b201:: with SMTP id t1mr13686855plr.55.1552545809090; Wed, 13 Mar 2019 23:43:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552545809; cv=none; d=google.com; s=arc-20160816; b=AjC8JARCUqsr2cpu1KhX8yGzvgFLYUFVVTaRShdXcn8/xk5pjmeZcLHlaUJtYNvcsM DDSG+h76txqdAspdvDAUP393aMvNvj6+jBQ3/mtLCUhYnWwamhDu+7KmVR0ax3UsL/Tw bEZexhUVIJZmcJVHls1hXOJt2OzI0ZCowBJtJ0QTxTkz9BSwO/MjQPr3GsMSznWFqoU2 g6oMr46BEbQlspUSCAXDoTX9+1CCeQq+etzEaZEKIxkk1LCu1J7UmTN3V6EEET7K5geS ZoHnWID3TAhi/TrVVbECZ7J4ecCiAlt7dxwUkHBB5KASSW6ahAEptYuS+tNd423RSn2v Od1g== 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=lorcbNHNRFiGuz7eBUCSVribuTSrEkumL8TszzbxjzE=; b=okxLDKnmASVREwjAGUtiQdTBc9zb0SFiQl7ijm0jP2pRlx8mV8eAXZVta9d9VLsDo5 e/uD/u8ROnsAAbZhK6uEa5RcywwzboPG0rUiiRjEqQwbXoVKsPQhFeVZiGOwOH7xOjA4 3flN6OmYeZ0szzOjFrOIskJJcAWOkvL9IT4VH+ClxoCG5xu/v9t84H4V9vyD254YjRG+ wullHIDLFrzEfbJhv+HG9Z++WY7CX0wsOAb2fdKSAVGipuh/GVLdiQLxfw2Bt29gZMun HwlB37OlFCRBwKVgtfRatgiWkCLFpCaLsmGigmIt5hF89WoKy8Itv7ODllUo+UJ+XCNU W8ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="RAUy/ZE/"; 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 a15si11723742pgg.560.2019.03.13.23.43.28; Wed, 13 Mar 2019 23:43:29 -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="RAUy/ZE/"; 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 S1727214AbfCNGn1 (ORCPT + 31 others); Thu, 14 Mar 2019 02:43:27 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:34311 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726805AbfCNGnX (ORCPT ); Thu, 14 Mar 2019 02:43:23 -0400 Received: by mail-pg1-f193.google.com with SMTP id v12so3347240pgq.1 for ; Wed, 13 Mar 2019 23:43:23 -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=lorcbNHNRFiGuz7eBUCSVribuTSrEkumL8TszzbxjzE=; b=RAUy/ZE/2HUVSglg0pbU6Z/RrAdT63TPxc7bUux3usECJno//O90wuudOKDCcvBCtx xTAJIZqajAEKv1st0pog2fnZG47Mxm3N3NhF7H0TNIF8kvedGrvu//HObZRKeUMkXTHw V+jmHs/DlShzFtQvesKJdHHvm9SiMcg56285396HhWSDi9pFH2bwLcxjaYQCKHevb/r+ NjAQS0v8ZaCje2Q6MUsVztwhgzGaKa2tmiqDpxW/5Q+lANxvrVLOZ/pyi3d4pIQEE/mJ OtCx9am3vcsp11RzES7y6vGGI9XQg7xAogBQiIm8p+SwrBW6POGBp+/pZzYimSv4dKa8 90Pg== 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=lorcbNHNRFiGuz7eBUCSVribuTSrEkumL8TszzbxjzE=; b=fLFXA85wHQR4CXamBJ7eBfma33wxJb3uWQx1iFvC6rNWQSODiDBH8lXQSXQu2USC72 mFt7S4EqiETFt2cSrd+rYUWXaD8XLsC4qf10lhqBLeFYx1dgxkBCeE4gCkmMsNVeYNtx LPiPTsD5UvX8doyg3G+LUXbCabaPRZD7l5V6L6JOXldcH31xJ/WdTCd2/dyznxXFGukH LS+3GWb2f6ogTpG/kqyYBpD2hOnbQX7TRkGwMvZltweLKaf5kkKNXXeMKCrtYCHv3Ld9 OK7671ZGTNqtu2SbOJXvR5NH43BUE49nN8aYUKp3Xs9Dg4TmrfNaDwYXS40+DTg/oQLi d44Q== X-Gm-Message-State: APjAAAVm3ahpBbmd8z0O/WBbTJPogTn7S5iffhqbvXEq0vAgVUtnNDE+ JtdpOmjabt2hoMLSUJ2aO1P0kQ== X-Received: by 2002:a65:41ca:: with SMTP id b10mr43786224pgq.146.1552545802717; Wed, 13 Mar 2019 23:43:22 -0700 (PDT) Received: from localhost ([122.166.134.37]) by smtp.gmail.com with ESMTPSA id k125sm46777131pgc.51.2019.03.13.23.43.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Mar 2019 23:43:22 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Russell King Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/7] ARM: smp: Update cpufreq transition notifier to handle multiple CPUs Date: Thu, 14 Mar 2019 12:12:48 +0530 Message-Id: <4bcc5e47e3b5959e9b1e21578323a84dc9a3c79a.1552545525.git.viresh.kumar@linaro.org> 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 cpufreq_callback() to use the new "cpus" field. Signed-off-by: Viresh Kumar --- arch/arm/kernel/smp.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) -- 2.21.0.rc0.269.g1a574e7a288b diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c index 1d6f5ea522f4..59ee0f4db449 100644 --- a/arch/arm/kernel/smp.c +++ b/arch/arm/kernel/smp.c @@ -758,15 +758,19 @@ static int cpufreq_callback(struct notifier_block *nb, unsigned long val, void *data) { struct cpufreq_freqs *freq = data; - int cpu = freq->cpu; + int cpu, first = cpumask_first(freq->cpus); + unsigned int lpj; if (freq->flags & CPUFREQ_CONST_LOOPS) return NOTIFY_OK; - if (!per_cpu(l_p_j_ref, cpu)) { - per_cpu(l_p_j_ref, cpu) = - per_cpu(cpu_data, cpu).loops_per_jiffy; - per_cpu(l_p_j_ref_freq, cpu) = freq->old; + if (!per_cpu(l_p_j_ref, first)) { + for_each_cpu(cpu, freq->cpus) { + per_cpu(l_p_j_ref, cpu) = + per_cpu(cpu_data, cpu).loops_per_jiffy; + per_cpu(l_p_j_ref_freq, cpu) = freq->old; + } + if (!global_l_p_j_ref) { global_l_p_j_ref = loops_per_jiffy; global_l_p_j_ref_freq = freq->old; @@ -778,10 +782,11 @@ static int cpufreq_callback(struct notifier_block *nb, loops_per_jiffy = cpufreq_scale(global_l_p_j_ref, global_l_p_j_ref_freq, freq->new); - per_cpu(cpu_data, cpu).loops_per_jiffy = - cpufreq_scale(per_cpu(l_p_j_ref, cpu), - per_cpu(l_p_j_ref_freq, cpu), - freq->new); + + lpj = cpufreq_scale(per_cpu(l_p_j_ref, first), + per_cpu(l_p_j_ref_freq, first), freq->new); + for_each_cpu(cpu, freq->cpus) + per_cpu(cpu_data, cpu).loops_per_jiffy = lpj; } return NOTIFY_OK; } From patchwork Thu Mar 14 06:42:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 160312 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp15145334jad; Wed, 13 Mar 2019 23:43:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqzx6SVyd7id3GvFUxPOghuCucBuF0pXVyN/m5NJg6nwaFxFglCsJZHPWCp0hkFOCiXhr3Qk X-Received: by 2002:a63:df09:: with SMTP id u9mr43138274pgg.299.1552545811943; Wed, 13 Mar 2019 23:43:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552545811; cv=none; d=google.com; s=arc-20160816; b=Cpj/4i3qBk2fkS28HvW69c7AXhjwYBD3Ygs+fbaWGwANooVZhJk1cnQ5vlpSDmm67f l4Ei0I3k9DfhHj68jnfpq5dxYPDAtJ7c4ZgwUB1uiCgKVs5CJOyu9GdoL2/cKK2Zg0tk m6JaCya2j8eeSOHDXEME4dGWbPqEQCZJPsC3tpDRsMwrgJ/Oc1RXPF8pPT9Nn87vpaOu 8up/qM+em3oxyIVyqc9TMk8fRhNPTvRiAJQlG1S2jse4lggggkDEzWICYqv06L3IFk9h X8U+uSnvB8UyC5R/m2C0ko+dom/AZIMgAN2NG56LF63YwqmSFJotSncMwxQdnZcVmz6L HmRw== 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=qELTA4aujWEU9keNr9yQA2v0lmekRZinbYpRGs9xFkI=; b=BgnxOC0y76iSJqmU4BfuVTh41wCuZtAHDNtkMI9FE7Bb5ciotO9xWqMzk5hOQJu28m znmB8Bd29VszVbYHReNdkj6WcChVTKiEX9fIVpvDZkTclSgmQjJFk21UFP1sqStSUc6U OEd+yab79O8H2MB0HZ5box35tAXhhQ8Fl6R/TDooVRHC5zM+wDo0pc7brVw54KO6JdkO B41ds1J5QRGxILxOxmOeeBcmnwBEQiUoviTOLGU/QOxDTdabRh5kFhs6VEViLTYGWGE/ B9WeK8x/cxFyy9J3NxC8MENXaAKWM35cL59q5TemOCwDCsiOoFibVP5+8Ys4dG5xVA/5 lXBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=u7Cwfo3H; 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 t3si12567972plq.430.2019.03.13.23.43.31; Wed, 13 Mar 2019 23:43:31 -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=u7Cwfo3H; 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 S1727239AbfCNGn3 (ORCPT + 31 others); Thu, 14 Mar 2019 02:43:29 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:43556 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726797AbfCNGn0 (ORCPT ); Thu, 14 Mar 2019 02:43:26 -0400 Received: by mail-pg1-f193.google.com with SMTP id l11so3308731pgq.10 for ; Wed, 13 Mar 2019 23:43:26 -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=qELTA4aujWEU9keNr9yQA2v0lmekRZinbYpRGs9xFkI=; b=u7Cwfo3HTNXiwKrg1Xm7VMazORbN94o2bgbSQzTbrMMH/hv2AKW3bvhAABqWicB/v4 b9asgi0FzheRGcnrFHLPLb4TWJFo6FCTgETwkXrrarLL5+LNgizsrqJnUFDCoutWuuqR 0ys3qt/rgIrjMeEOQMF1tUJbUIKoqzngo0Pw5nfz0P5pZbzD2MgMLpzU7u8vYP1AX2SE UTIQp1N9YYQv44EaDziD2yLPLUdGeRIlzbsiovemP4HQwk9YKbxdCVVb5Oquqs7roSz/ tAL1P3fwgMxIMURRzGJ2geREkGPTznTxUDRymTjz/gYQ1dthykaya/JICIL1lYNV/VBF NhsA== 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=qELTA4aujWEU9keNr9yQA2v0lmekRZinbYpRGs9xFkI=; b=R2c6Q+xCgH3dabOTGLHht7YTLDQHSIcRan6BPaw0Qb7RkWXlQcPhv5cBN2xKll4YKq 25i5bAaYtsQlbvjl0/17HvwuoOo5AzHSZU1pgpIe4uLje245Y7g8v6O2LK2N8nungfDI In+FfteHMC5mCblx0gcntJ4wCpwHIcxfb2U7P98NaXlE8NrxXSrMwVIz/c6KYvwviE1W EMR2hsVlD4sEiu8aOujDwe9048AbzRaUL6iANSC/apIdtFAzgcFIYqsX7EpKI8R+iEFm zDtZOWdHz1LHTBNUrsqm19ahHD40foadT3gM4k58X1wtxrKHeDtyGeX4yeAl3pWhnhue 3hng== X-Gm-Message-State: APjAAAU9Weuq/eHl6t5uEf+t4kVhXo6b6SfOwCUVBQBBfYpAjTUT8bBp T1LvYxPY5doBc6dzBcer8GDM7b6QF7E= X-Received: by 2002:a65:5c0b:: with SMTP id u11mr34473391pgr.352.1552545805889; Wed, 13 Mar 2019 23:43:25 -0700 (PDT) Received: from localhost ([122.166.134.37]) by smtp.gmail.com with ESMTPSA id l7sm49201244pfj.162.2019.03.13.23.43.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Mar 2019 23:43:25 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Russell King Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/7] ARM: twd: Update cpufreq transition notifier to handle multiple CPUs Date: Thu, 14 Mar 2019 12:12:49 +0530 Message-Id: <3c977305886032ba871bd266d555ede47b4576fc.1552545525.git.viresh.kumar@linaro.org> 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 twd_cpufreq_transition() to use the new "cpus" field and run twd_update_frequency() for each online CPU present in the freqs->cpus. Signed-off-by: Viresh Kumar --- arch/arm/kernel/smp_twd.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) -- 2.21.0.rc0.269.g1a574e7a288b diff --git a/arch/arm/kernel/smp_twd.c b/arch/arm/kernel/smp_twd.c index b30eafeef096..df7db45d931b 100644 --- a/arch/arm/kernel/smp_twd.c +++ b/arch/arm/kernel/smp_twd.c @@ -162,15 +162,18 @@ static int twd_cpufreq_transition(struct notifier_block *nb, unsigned long state, void *data) { struct cpufreq_freqs *freqs = data; + int cpu; /* * The twd clock events must be reprogrammed to account for the new * frequency. The timer is local to a cpu, so cross-call to the * changing cpu. */ - if (state == CPUFREQ_POSTCHANGE) - smp_call_function_single(freqs->cpu, twd_update_frequency, - NULL, 1); + if (state != CPUFREQ_POSTCHANGE) + return NOTIFY_OK; + + for_each_cpu_and(cpu, freqs->cpus, cpu_online_mask) + smp_call_function_single(cpu, twd_update_frequency, NULL, 1); return NOTIFY_OK; } From patchwork Thu Mar 14 06:42:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 160313 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp15145384jad; Wed, 13 Mar 2019 23:43:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqwlqIVVhXD4gdT1hOBN8/QCgPTEd6k2wE0yr/Mx1a++FMVW57YTEdhEoO5hL0ib2nSRnzA+ X-Received: by 2002:a63:1322:: with SMTP id i34mr43089913pgl.208.1552545815574; Wed, 13 Mar 2019 23:43:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552545815; cv=none; d=google.com; s=arc-20160816; b=tYmYiC7jyxcglB9YMzKnjcL/2882pom+NwZvGKz3uiLHpwP6qyVQTqayW/fUpAunD8 Vrn0maxQToOx907ZW3DqjS064Owm7I+2cXTXTr1DWkZBVxuh8kP9A8nllo534tJ52pBF /cu0rDHOAhj5kOdMD62qnLrXGuBwJbo4CdLw2ecxjQXF3EEk4QpcN70AloghnOOyYG86 GBCoEhvhl9iUqYScRfpjDF5T9+JVE/9y9yatflhS/gcalAmWMK4C3uzmEgMyZ/nAlAgE I74ABvXJYH3zk/tTvgt4Bul0FP2Ywo0kljx0RgvoTmX1n505Y9C+SNLxsapo7ztr8bZ6 eSiw== 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=gau8qlK9lYlCkFsnqnqItN7NoeHxD4E7ZSFErNPXgA4=; b=IU4cdXG6uspN24RpYg6p5kkMZeeopkayn0M3RB0ChLlfzQVGrlEoxovTFnH6UtVqN7 GEILyahU9r+T9ElqBu9fOvZmtbXULQl3+iwFaz4otuCPS7mdGt0+N7sx76Lz4ihxo1j1 bSHNLonNKRTsm/iXSaq5NwCkF14/Hg+g5qMKIfe5kAshdm/EgeFEMJmEots1UZgjZsEL vCvaUbpHXsciodm7IAE9BAlRAT3KMscCORxZN8RtD0MbB8D00b9BasWWUmxTlU2QZ2cr fwmgIucH6hM+xWOv96v3urrKhax+sCkdCzOW/Ikjkr3eqv6K29BZyQ5uYPo+pvNLdThZ Xpcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RLOnMQXk; 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.35; Wed, 13 Mar 2019 23:43:35 -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=RLOnMQXk; 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 S1727281AbfCNGnc (ORCPT + 31 others); Thu, 14 Mar 2019 02:43:32 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:44581 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727242AbfCNGna (ORCPT ); Thu, 14 Mar 2019 02:43:30 -0400 Received: by mail-pg1-f193.google.com with SMTP id h34so3304171pgh.11 for ; Wed, 13 Mar 2019 23:43:29 -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=gau8qlK9lYlCkFsnqnqItN7NoeHxD4E7ZSFErNPXgA4=; b=RLOnMQXkHi2HZm4bmQA0sLNXWNQW0CH3U3TiMA50yPp92jnLFhTjR+yd+dyTIWwMuX +0oeC9HkNf2ixELn3+rAYVsWVA71CR57dJ6RM1vqxcLMTFzJc/tLNTcLE7dgC2z6me8/ EBrpOdgzVVgR8sysX8SVNbf3us+Gc05qvHGJ8midp2dXjnav8aGf3zJlRaJKOZP55FRx KgjqyV7f0vib6WBR6o5z38x8tsSi7g/r0S3OXN9aSXkavdejG+uRJM4N9LLD8AG7we1s J5CtTKAcnTjLOhKxStNjuc5E0dGEu0u80Ws4jtuqScH6JUj7NVGdMfI9GmQlfxhsfyPg UDeA== 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=gau8qlK9lYlCkFsnqnqItN7NoeHxD4E7ZSFErNPXgA4=; b=MUMtlg8YDLuNaD11utaqv1GpKlW3ba3N/A2uulD5s9FG/QbZIiVJJrN9T7gXse0kdH 8LWHQa5g7lr84QZzXxnAau1Eoc88wWAPrKFgM9VHDfd87YqEzri4A9DHjbM+4nFOH2WU 56e6lE+1R9cLi0+z3cMqLAOAa9lokRQMsX7J4G9C2/cQwoxDwPnoiJOPrfn5D5Q9+IYg sD4mQwbMUrF5DMqIeFiCAd0kYHgmAUxpIvLNHhWNDcTIh4oaDctEl/DyBVrsl7ruxazr vhpJhfHD+yQb1Z4rdlCCOyMMn/1pMN08za0CINZcQNZRckAOsGEbJIkPH+4g4vzceAvD gZtA== X-Gm-Message-State: APjAAAW9B48CbrnBlJI/I3a2EJmFQrFUxUVuQmKe0BfXXTKQuTMYUGr/ sMJmVh2jivZ7NwIi/13tpxr9Yg== X-Received: by 2002:a62:b61a:: with SMTP id j26mr47461072pff.151.1552545809013; Wed, 13 Mar 2019 23:43:29 -0700 (PDT) Received: from localhost ([122.166.134.37]) by smtp.gmail.com with ESMTPSA id o5sm13049375pgc.16.2019.03.13.23.43.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Mar 2019 23:43:28 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , "David S. Miller" Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/7] sparc64: Update cpufreq transition notifier to handle multiple CPUs Date: Thu, 14 Mar 2019 12:12:50 +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 sparc64_cpufreq_notifier() to use the new "cpus" field and update per-cpu data for all the related CPUs. Signed-off-by: Viresh Kumar --- arch/sparc/kernel/time_64.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) -- 2.21.0.rc0.269.g1a574e7a288b diff --git a/arch/sparc/kernel/time_64.c b/arch/sparc/kernel/time_64.c index 3eb77943ce12..23544646695f 100644 --- a/arch/sparc/kernel/time_64.c +++ b/arch/sparc/kernel/time_64.c @@ -653,19 +653,23 @@ static int sparc64_cpufreq_notifier(struct notifier_block *nb, unsigned long val void *data) { struct cpufreq_freqs *freq = data; - unsigned int cpu = freq->cpu; - struct freq_table *ft = &per_cpu(sparc64_freq_table, cpu); + unsigned int cpu; + struct freq_table *ft; - if (!ft->ref_freq) { - ft->ref_freq = freq->old; - ft->clock_tick_ref = cpu_data(cpu).clock_tick; - } - if ((val == CPUFREQ_PRECHANGE && freq->old < freq->new) || - (val == CPUFREQ_POSTCHANGE && freq->old > freq->new)) { - cpu_data(cpu).clock_tick = - cpufreq_scale(ft->clock_tick_ref, - ft->ref_freq, - freq->new); + for_each_cpu(cpu, freq->cpus) { + ft = &per_cpu(sparc64_freq_table, cpu); + + if (!ft->ref_freq) { + ft->ref_freq = freq->old; + ft->clock_tick_ref = cpu_data(cpu).clock_tick; + } + + if ((val == CPUFREQ_PRECHANGE && freq->old < freq->new) || + (val == CPUFREQ_POSTCHANGE && freq->old > freq->new)) { + cpu_data(cpu).clock_tick = + cpufreq_scale(ft->clock_tick_ref, ft->ref_freq, + freq->new); + } } return 0; From patchwork Thu Mar 14 06:42:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 160316 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp15145649jad; Wed, 13 Mar 2019 23:43:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqxWIK5IHefNPTq3K9kxXi/5cXlbEy8Kq3INTR8PJCaxVukjQm1IupOxhTHfvY2c+fBMcz4Y X-Received: by 2002:a62:568e:: with SMTP id h14mr49613632pfj.134.1552545834006; Wed, 13 Mar 2019 23:43:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552545833; cv=none; d=google.com; s=arc-20160816; b=cG03WJPYuI6DGGUAkBs+FtXixM+8wKHIYWqkE1KFmnNX0gWH20YCCjogXD5Dlfgpdj axgQGB57/7tBkBnnGOKF6fIfPbMFkoQBWPz3TTprMhswqrI1IkKnl250yiB3aVTHbGV3 6EHND8znALrDMlB94RxsCs/DaQa/zPR5WtFLg77kE3BPiDzYMfs4sKj8Rv1zFrtMsVb3 5H6WtRQGgz6pgYRZuCQ4EDIBHBLvc00Yxs2EUBX+NoK6HZiZGNna8w6vEai9nosgBV50 OFEgN/QqRS2/IcrK4Ybzc53Q234+sNP+rNwqJJn7mnvALQYRaYRBf0QOrRv7Jxe6BXaZ tYFQ== 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=3Efw/h9eTUmSrpQZIt5XLwN4VOh2Yp4TaPqLXIdGnJE=; b=yDOGaA9rUR9b0LCje1NvVjqli8jNu4sJElah0qOTaxyUnNxiroHGSHhvXqwa6gUzgl VGhHFyyfusVjIOJzAeiegDBfX5eXPvwddsRgQaoTWcGWhPlg67vkoC4TUQy+IRvxaLSv i16IR9HEeHjjtHGkQRNQJY1iEC5+QHXjd4QWsIrV/4l9nGnYHIpsRdqhADvAyJJIxSV4 P+VPCiGOCENcoQko4kzBD547J6s7XPFX0p4cni4qgmu/rdPakESl/Wbk3HRQJJqOMawj 5gzkRTnFl3Rh1LGfX2u7g8Fq2rL8yHo/BRx3OsE7Nh00U2D4CTVs29T3gGAPZsNukXyu /lyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VcL7RStD; 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.53; Wed, 13 Mar 2019 23:43:53 -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=VcL7RStD; 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 S1727315AbfCNGng (ORCPT + 31 others); Thu, 14 Mar 2019 02:43:36 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:36394 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727277AbfCNGnd (ORCPT ); Thu, 14 Mar 2019 02:43:33 -0400 Received: by mail-pf1-f194.google.com with SMTP id n22so3192217pfa.3 for ; Wed, 13 Mar 2019 23:43:32 -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=3Efw/h9eTUmSrpQZIt5XLwN4VOh2Yp4TaPqLXIdGnJE=; b=VcL7RStD7ZUOTVl184RkW56AOC5OcqHevP735305y843u+17laziRgHfgqbGKiwE3q +aFw0iSojIYAqnB9AMwRoWtlmWGH5F3SkUBMLj1yO3rhcyomSDvrEnZkUyckXDAcIZ9i 0oqiWh25f7QEAYxUmF7FllPqrj06OP72PB2vqNEH2HirpWxjftj3Q/kiDbxUpu81X88u 2gf1ssoQwtl5f6YBbkHk4LKoU0MCWPPVt5ahTurryAHhL+C7qfqHj/8MPfH9UrdFV0g4 /TIi3GxmG3J4QV/DggNwDIAMjNe32yGBXN5TRLQX9DppzLWl47iiFN4qSlEAHcPWBRhp COAA== 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=3Efw/h9eTUmSrpQZIt5XLwN4VOh2Yp4TaPqLXIdGnJE=; b=tIpMjPNecQ6Y16cm8MckBnyKfS0g/mJe+NNUeJmfNY1CnEYPYxEPgKdICeFlwrM8fC Jsjnfy98IDSXisSQzTp/kcFmpUmXkxjyNON86UJeC77D7z6QYHa4WmO/rxJSWAxmckl0 HemtGnP2cxO37UfxzKMfWSNtnyFoESFdQkB/hTpvhORhGXgjJIllipud/wBvrrhh9Bjs pMx5B4CnJ6cyLBc/3EID6zHwj3GshTJGDG4mDyXwzvSTM8GSlIS4pC9x9UkZOhxq8lno y5vjQ+I2qMRtKlGhGjaLbpVDQYQnmSAR/G9agoA6XXg9Bx3AAhmQJzR2I9A7us3hmfeY Ullw== X-Gm-Message-State: APjAAAUQph8O8di2AEO2iDG6d2TN59ub/Ev7q6YSdBh/wT83yad9mERN woU8062qTNpFEXcPy30a7uxxMA== X-Received: by 2002:a63:6a88:: with SMTP id f130mr43285394pgc.114.1552545812067; Wed, 13 Mar 2019 23:43:32 -0700 (PDT) Received: from localhost ([122.166.134.37]) by smtp.gmail.com with ESMTPSA id q18sm21517128pgv.9.2019.03.13.23.43.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Mar 2019 23:43:31 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , linux-kernel@vger.kernel.org Subject: [PATCH 5/7] x86/tsc: Update cpufreq transition notifier to handle multiple CPUs Date: Thu, 14 Mar 2019 12:12:51 +0530 Message-Id: <8a27342332bc467242f6ccdb4d4bd4d10f8aa552.1552545525.git.viresh.kumar@linaro.org> 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 time_cpufreq_notifier() to use the new "cpus" field, update per-cpu data for all the related CPUs and call set_cyc2ns_scale() for all online related_cpus. Signed-off-by: Viresh Kumar --- arch/x86/kernel/tsc.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) -- 2.21.0.rc0.269.g1a574e7a288b diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c index 3fae23834069..587a6aa72f38 100644 --- a/arch/x86/kernel/tsc.c +++ b/arch/x86/kernel/tsc.c @@ -956,28 +956,37 @@ static int time_cpufreq_notifier(struct notifier_block *nb, unsigned long val, void *data) { struct cpufreq_freqs *freq = data; - unsigned long *lpj; - - lpj = &boot_cpu_data.loops_per_jiffy; -#ifdef CONFIG_SMP - if (!(freq->flags & CPUFREQ_CONST_LOOPS)) - lpj = &cpu_data(freq->cpu).loops_per_jiffy; -#endif + bool boot_cpu = !IS_ENABLED(CONFIG_SMP) || freq->flags & CPUFREQ_CONST_LOOPS; + unsigned long lpj; + int cpu; if (!ref_freq) { ref_freq = freq->old; - loops_per_jiffy_ref = *lpj; tsc_khz_ref = tsc_khz; + + if (boot_cpu) + loops_per_jiffy_ref = boot_cpu_data.loops_per_jiffy; + else + loops_per_jiffy_ref = cpu_data(cpumask_first(freq->cpus)).loops_per_jiffy; } + if ((val == CPUFREQ_PRECHANGE && freq->old < freq->new) || (val == CPUFREQ_POSTCHANGE && freq->old > freq->new)) { - *lpj = cpufreq_scale(loops_per_jiffy_ref, ref_freq, freq->new); - + lpj = cpufreq_scale(loops_per_jiffy_ref, ref_freq, freq->new); tsc_khz = cpufreq_scale(tsc_khz_ref, ref_freq, freq->new); + if (!(freq->flags & CPUFREQ_CONST_LOOPS)) mark_tsc_unstable("cpufreq changes"); - set_cyc2ns_scale(tsc_khz, freq->cpu, rdtsc()); + if (boot_cpu) { + boot_cpu_data.loops_per_jiffy = lpj; + } else { + for_each_cpu(cpu, freq->cpus) + cpu_data(cpu).loops_per_jiffy = lpj; + } + + for_each_cpu_and(cpu, freq->cpus, cpu_online_mask) + set_cyc2ns_scale(tsc_khz, cpu, rdtsc()); } return 0; 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; }