From patchwork Mon Oct 29 16:23:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 149682 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4348336ljp; Mon, 29 Oct 2018 09:23:41 -0700 (PDT) X-Google-Smtp-Source: AJdET5dhQp30cZTMMsk27hSXVB+HyjAFPhX4ZUYOMPxTfZdhEWTZuN63kl2FbDSxqTrpfyKMDxKh X-Received: by 2002:a17:902:bb0d:: with SMTP id l13-v6mr9308361pls.202.1540830220868; Mon, 29 Oct 2018 09:23:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540830220; cv=none; d=google.com; s=arc-20160816; b=J2MGZqt+wvoltldZcoA/ZvXs5i+G8FaLq5UM90A8A3pHD6u8Bnz30r/f1Mq6G6EnKW aE9EB5GRPoQI8by9wapNZFvgqnXj2ieTpae/+noDxz20w1qytU5nx9qdDkfeYJatScK9 nov8f+pdafu6aLXrGUwb4ZX2Xx/90TgC/615LllI9ukwm/UmUKT0K8p56pSVnQyuB2R+ 81mZQGcbTXVXs51uLrNGw4IxUgAGxqvx3Jva0O2BraBCex8wy7/tE2lr0hkwAfJLXXjy qNUQl/dv19ZdfQUipPVyKWiNhtIyXTsjv9zuHVRV7GcnlC0ax2IZgjPqEouzQwPKimJ3 X4mQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=5ufvLgLeByEO3l1UMVwBEPg+2O2CRJCS4nN3+quaAgs=; b=c5/EsMgjHd6FKQJyXVJctml/F67kADA3m5QhLftGSDHCs+7upB4/8XFnaeIigB729Y t0L41hHhIhltWyi7xyAHb0FX9dP8opH/DonWYoauynO0mX7oKveQfPFZtAeG0cfeXowX waKZgkJ8gbW+2KivKwGvgWkxipDM3v51GH0UmNHrwqaOxMBtulGtHhyPDC3VkgQndCHO yyeDnewI72+uEcDx9kKsMessCzyqmFf2VqiGyqVEYFUS6fgIzRRPZ4XvrFmlePe+z724 JPBPRQezfS/YjhKPvR9WM1bDMIoJfVO3sT81/raOUBZC8QODCjrQnnaXNwv0mNoHi7D0 fvlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bWAxYNMg; 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 n6-v6si1234318pla.245.2018.10.29.09.23.40; Mon, 29 Oct 2018 09:23:40 -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=bWAxYNMg; 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 S1728090AbeJ3BM4 (ORCPT + 32 others); Mon, 29 Oct 2018 21:12:56 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:39156 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727565AbeJ3BMz (ORCPT ); Mon, 29 Oct 2018 21:12:55 -0400 Received: by mail-wr1-f68.google.com with SMTP id r10-v6so9381597wrv.6 for ; Mon, 29 Oct 2018 09:23:37 -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; bh=5ufvLgLeByEO3l1UMVwBEPg+2O2CRJCS4nN3+quaAgs=; b=bWAxYNMgwh3WOp4jxA+QzoPwtxiZJBrZk0mz4ubZnGzLvRsRMwWfraYDmuCHwo2k9E 4+Eumo/hsz3pbTdQEzdWNoNAOY3y+xu9Wzs1W2G0T6zUJ1+w2LN11cpvcSEunEE6WpAa hyGGJY+n/3ZzEN0H+4avT6F4PWq5n6sfj9IUg= 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; bh=5ufvLgLeByEO3l1UMVwBEPg+2O2CRJCS4nN3+quaAgs=; b=CP6zz0Ymsw9fmQUm0YJskfnplsXenCst0/55FgS9XvN3TNPs7mEv2anIWDyOWpVB39 5YLEAW5QslhNA5mIdeUCDhlzaLqq+FRkZPgJ+MDwd8V2/Mnd6eW+S++051bXMtmZf9dg WHHdOxB/iV9gXwHDQ5OC9N2k88Q42R+2nW85CnphDPbNZW9HMTdhk9x544bsmKfVuVxf KUMLi6B2S+joOEqXEwsnWVnB1NQ1LyqG45mfuIEVjImZjOSyAHQSA6S1Lx/3ElTcM/2G LMO0cZql0AO2+jvynpw5fcGiqgIU0+vpJZ6ngYsz94Hd5vp+4b5DDkRFYaPWeh4NAfb1 iHtg== X-Gm-Message-State: AGRZ1gKAl27dW+QEs5Me9/AZ+fVz2Fdaqxs9tFV8BrKZJhTPpwcCqip9 CIj7d0uJ5vRhn/ZNhkKJj8uGTa+4poM= X-Received: by 2002:a5d:4609:: with SMTP id t9-v6mr3508033wrq.198.1540830216438; Mon, 29 Oct 2018 09:23:36 -0700 (PDT) Received: from localhost.localdomain (137.55.88.92.rev.sfr.net. [92.88.55.137]) by smtp.gmail.com with ESMTPSA id y19-v6sm28150499wra.60.2018.10.29.09.23.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 29 Oct 2018 09:23:35 -0700 (PDT) From: Daniel Lezcano To: rjw@rjwysocki.net Cc: vincent.guittot@linaro.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman , "Rafael J. Wysocki" Subject: [PATCH 1/4] base/drivers/arch_topology: Remove useless check Date: Mon, 29 Oct 2018 17:23:17 +0100 Message-Id: <1540830201-2947-1-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The function 'register_cpufreq_notifier' registers the init_cpu_capacity_notifier() only if raw_capacity is not NULL. Hence init_cpu_capacity_notifier() can not be called with raw_capacity set to NULL, it is pointless to check it. Remove the check. Signed-off-by: Daniel Lezcano --- drivers/base/arch_topology.c | 3 --- 1 file changed, 3 deletions(-) -- 2.7.4 diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c index e7cb0c6..204ed10 100644 --- a/drivers/base/arch_topology.c +++ b/drivers/base/arch_topology.c @@ -181,9 +181,6 @@ init_cpu_capacity_callback(struct notifier_block *nb, struct cpufreq_policy *policy = data; int cpu; - if (!raw_capacity) - return 0; - if (val != CPUFREQ_NOTIFY) return 0; From patchwork Mon Oct 29 16:23:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 149683 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4348503ljp; Mon, 29 Oct 2018 09:23:52 -0700 (PDT) X-Google-Smtp-Source: AJdET5faWWAG0PUlmtlHINLEGllsrti9Mmb8hFTGxqSVzCG+XCxBPkvgQA4X/Fsp8AmRxPTE35aF X-Received: by 2002:a63:a902:: with SMTP id u2-v6mr14534392pge.207.1540830232356; Mon, 29 Oct 2018 09:23:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540830232; cv=none; d=google.com; s=arc-20160816; b=TfTQ/W1ss5jTXdZFs9BLHUQBEszy8QyLHiBZU4om6SEONFuUPrdSrw8uuj3qtX9BkY ++d4ENa/NOzzCnF5RON11M7YR+HQGR1D2HnOe5zCDLvOsKJwrUBWcqMIwnr7F/E6VQ1Y CUOSRLIcLGMzEuN1G6rYSHFOl54JxPbcnH4UjCT6AjcC8D7211/5ofwXee+kL3+19ZW7 7U1EkB6t+gJyZ/RG1xuI+wqEGshjg/XArBqIekk8b8Ja1xeeG0M960gv/C+zT6Mlu3lo MN6Mc3E955RoS4WiTyxhzFKYksM/wNRQi4DD6P/kh58i7fyukH9biyA2gY2h1VbsF9y0 aMeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=xF7JxkKvdHK/anNbLW0P/RgEA6x91dDlC16uGRsXEpA=; b=ZDxZKxDfuj33f4IAp/fhmdQJHOM6xAlyfW6rJhWttkY4FlVCT5beJ6ZBnxI61UqebB B22BTd4h9Eevx1fT0E+tQ9T3uArJzXE9pVC29xuA79Xzamc5tT4RhavUYmT2/7wjchek Y1vdSHfELlxCTpa6AddOXSn4sff5ZNhaYM4AJgdOQyjcAdxVDpZXLfpUw4Zo/fEEga49 i33YCMDLrR+mvFQTFH5ahVnFRuu50d6tJeuXU23wjND+xR194fcO3OMEmCwzSBXi0Bf2 8KIke3nH4lFXQHWSd21FjqjVcv8/3NPonT9juQ8RCphT8/1xt9d39PnXNHTIMZiqYNK+ IBPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=I3oAfEOw; 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 63-v6si20701245pfg.178.2018.10.29.09.23.51; Mon, 29 Oct 2018 09:23:52 -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=I3oAfEOw; 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 S1728103AbeJ3BNH (ORCPT + 32 others); Mon, 29 Oct 2018 21:13:07 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:38114 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727565AbeJ3BNH (ORCPT ); Mon, 29 Oct 2018 21:13:07 -0400 Received: by mail-wr1-f68.google.com with SMTP id d10-v6so9384639wrs.5 for ; Mon, 29 Oct 2018 09:23:49 -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; bh=xF7JxkKvdHK/anNbLW0P/RgEA6x91dDlC16uGRsXEpA=; b=I3oAfEOwOHRbCq+1bEpOrnF5NMYcJDSEE7M8MADPyMAICoYRO2BM1rjUeHmo920khB ATeS1j1vfRprif6Ph3vekUkcxzeGVgu1w461KLQ18IcpJqjV5EJ7SirEMuEja8/oAWd0 55TMbF5vQdelAR5s+HcQTn9Yp3TyFiJocWQTA= 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; bh=xF7JxkKvdHK/anNbLW0P/RgEA6x91dDlC16uGRsXEpA=; b=ArEHtBXUpcECHX3AayC+g/k2L6wSylSRJX2Ic2+lOkxjX/x9ame5lB2RDJtE2y+BCJ zXCdl/qF1B3gxxGCx7md655Kidr3WohxPjv9PawU0U2K3z71UpgGqxzgdiaq7z/kVoT6 91qVi7aSY6DTxJePRCMLAv0sm90wam1vJ62lh7oK0g3/MSnpDXJo6ZXcJwdxedHYSCsz 1XzS2VgUNH5/a/f0Pa3y79mM/NWEgZ1uzLJn/9XECXYfvwXofCqBEhbKCgO3/gltdtI2 2vAreYZ0ast6AWZdzwelMRnOI6PGVj8IcTTcRUUcHms8g4N0YxL4HBJS9QpwuuU11Bpu q/7g== X-Gm-Message-State: AGRZ1gL/k1k6+SMXHw4MXv1vVGgnfntuQC1aurH4rVMjMOYY8k6rMupl Q+tBLYSDDrGRy+i032+THUNBQw== X-Received: by 2002:adf:8281:: with SMTP id 1-v6mr15560623wrc.252.1540830228052; Mon, 29 Oct 2018 09:23:48 -0700 (PDT) Received: from localhost.localdomain (137.55.88.92.rev.sfr.net. [92.88.55.137]) by smtp.gmail.com with ESMTPSA id y19-v6sm28150499wra.60.2018.10.29.09.23.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 29 Oct 2018 09:23:47 -0700 (PDT) From: Daniel Lezcano To: rjw@rjwysocki.net Cc: vincent.guittot@linaro.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman , "Rafael J. Wysocki" , Kate Stewart , Juri Lelli , Thomas Gleixner , "Peter Zijlstra (Intel)" Subject: [PATCH 2/4] base/drivers/arch_topology: Replace mutex with READ_ONCE / WRITE_ONCE Date: Mon, 29 Oct 2018 17:23:18 +0100 Message-Id: <1540830201-2947-2-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1540830201-2947-1-git-send-email-daniel.lezcano@linaro.org> References: <1540830201-2947-1-git-send-email-daniel.lezcano@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The mutex protects a per_cpu variable access. The potential race can happen only when the cpufreq governor module is loaded and at the same time the cpu capacity is changed in the sysfs. There is no real interest of using a mutex to protect a variable assignation when there is no situation where a task can take the lock and block. Replace the mutex by READ_ONCE / WRITE_ONCE. Signed-off-by: Daniel Lezcano --- drivers/base/arch_topology.c | 7 +------ include/linux/arch_topology.h | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) -- 2.7.4 Reviewed-by: Viresh Kumar diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c index 204ed10..b19d6d4 100644 --- a/drivers/base/arch_topology.c +++ b/drivers/base/arch_topology.c @@ -30,12 +30,11 @@ void arch_set_freq_scale(struct cpumask *cpus, unsigned long cur_freq, per_cpu(freq_scale, i) = scale; } -static DEFINE_MUTEX(cpu_scale_mutex); DEFINE_PER_CPU(unsigned long, cpu_scale) = SCHED_CAPACITY_SCALE; void topology_set_cpu_scale(unsigned int cpu, unsigned long capacity) { - per_cpu(cpu_scale, cpu) = capacity; + WRITE_ONCE(per_cpu(cpu_scale, cpu), capacity); } static ssize_t cpu_capacity_show(struct device *dev, @@ -67,10 +66,8 @@ static ssize_t cpu_capacity_store(struct device *dev, if (new_capacity > SCHED_CAPACITY_SCALE) return -EINVAL; - mutex_lock(&cpu_scale_mutex); for_each_cpu(i, &cpu_topology[this_cpu].core_sibling) topology_set_cpu_scale(i, new_capacity); - mutex_unlock(&cpu_scale_mutex); return count; } @@ -116,7 +113,6 @@ void topology_normalize_cpu_scale(void) return; pr_debug("cpu_capacity: capacity_scale=%u\n", capacity_scale); - mutex_lock(&cpu_scale_mutex); for_each_possible_cpu(cpu) { pr_debug("cpu_capacity: cpu=%d raw_capacity=%u\n", cpu, raw_capacity[cpu]); @@ -126,7 +122,6 @@ void topology_normalize_cpu_scale(void) pr_debug("cpu_capacity: CPU%d cpu_capacity=%lu\n", cpu, topology_get_cpu_scale(NULL, cpu)); } - mutex_unlock(&cpu_scale_mutex); } bool __init topology_parse_cpu_capacity(struct device_node *cpu_node, int cpu) diff --git a/include/linux/arch_topology.h b/include/linux/arch_topology.h index 2b70941..7c0aaa9 100644 --- a/include/linux/arch_topology.h +++ b/include/linux/arch_topology.h @@ -19,7 +19,7 @@ struct sched_domain; static inline unsigned long topology_get_cpu_scale(struct sched_domain *sd, int cpu) { - return per_cpu(cpu_scale, cpu); + return READ_ONCE(per_cpu(cpu_scale, cpu)); } void topology_set_cpu_scale(unsigned int cpu, unsigned long capacity); From patchwork Mon Oct 29 16:23:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 149684 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4348605ljp; Mon, 29 Oct 2018 09:23:58 -0700 (PDT) X-Google-Smtp-Source: AJdET5f/XHpPb6XXdRF5+jsEP8S36qXvx3kL/mrn/tPK+YR7r4QZhcoiOX4Kowk0HmZxCrZLPe7n X-Received: by 2002:a62:5287:: with SMTP id g129-v6mr9330561pfb.17.1540830238606; Mon, 29 Oct 2018 09:23:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540830238; cv=none; d=google.com; s=arc-20160816; b=egXygv+IZLbOLdfkczMAE3+POdiMtt855o1Hqm38ts25KA+KhGd0PRGyXoORxJxNLh NuwwB13fnxUFX0JAybKvYxU2c6+XBn9mwzSnFtFOqd+d8gKvlW+Uq2IgPD1cGYzO9MEK f3heTPfCU+j/SNo6EyZCkPXBAYP8L+oQwEdtVu0iXEIRmF4bIA1gLr+d7fkNFgxqIwv3 9HNAMHJSjzTAaAgVaJyKvdn7FRKewZVO1ZD/gSsPfimHHQb1/Scrx78VciwDFlGg07ZK ZeYa75Og+7A3LuVNWbTNOdASEm4kEqK2jcJ0agoG1yAhTV8v9ag8zxVez3TJFNVoFbCK Q2VA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=yJCtkrkfIFoRj9cRN8aqIPKmbD9Nc3jaK1cwdarWAHs=; b=Y9aOFIEt2CJm4msO22EBONHmiynZX8y9vz4zzGDflw6+7y2ora1qywStDBKHjNgfcD BSqvNU4DO9i9PwpAQiepZL8oCHDhS9LfN+2J4x2xuMefyH8fJarkIUUMRE9uwlb3bFxy NY3B3Xec4V2j7ML+NMN+9fgLVaArcBcjA5nM8tZJBoIu5Hzy6JgIhjjX9XXwfpw0IpR3 FzCsBLP/B+1iPqyls05zljy5INWT5lOQnNCXtXj0o6Q4bhPk+nSqBwS7Ba/cGVvrM6QI zEqiOC6TME4eXqBjywTCBkBSewtA/At9yRiOoFNiuSuKCYXEAwt9hZCDokZZ+iuHHKRd HxOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=b9l2MmIp; 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 63-v6si20701245pfg.178.2018.10.29.09.23.58; Mon, 29 Oct 2018 09:23:58 -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=b9l2MmIp; 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 S1728115AbeJ3BNO (ORCPT + 32 others); Mon, 29 Oct 2018 21:13:14 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:44659 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727565AbeJ3BNN (ORCPT ); Mon, 29 Oct 2018 21:13:13 -0400 Received: by mail-wr1-f68.google.com with SMTP id d17-v6so9081318wre.11 for ; Mon, 29 Oct 2018 09:23:55 -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; bh=yJCtkrkfIFoRj9cRN8aqIPKmbD9Nc3jaK1cwdarWAHs=; b=b9l2MmIpKRXHesHf2ofXp+b+1pZGE08G4PAHV2q0iy8mOYw7DmBHmPnxHI5pQmyaGT pblfRnf9cTpHs0a0e24oHPG5zHSCbap2kpRrYg6eUP7HJxXMaMWhi9NdjVW1nDDjFz9x zlOcJBtySx0RBYl5UYiiidYzf6roZaLuvmrRg= 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; bh=yJCtkrkfIFoRj9cRN8aqIPKmbD9Nc3jaK1cwdarWAHs=; b=fuhe/9GkHSDV5J18b4RqHbf7Gt3iv90F9ebd/rg4arVsFpRqC1ooLosnwigUHm4AkV AjxyT/VgzVB2ngzWADh12HjOKGUG0MF93NfUtM6Vn0GPzZUI1hpXqob1rSTb6p8OB89p NmHZuXH0s6s7aG8+WSwGGlWBjIH93PtuqEMSl5yEtrEUfxdT8RlcJVpNu0gjafffiX/4 4yXr1j8x92CxyZWMgjLk+3+gjwoH5mKBJY3UVMLgoXW8ZuJy0eNMyuEk4jL2CuNl79r9 ezzn+1e1NjvA3FKZhRZcIR4FglrsPMZW2ttpeyJNHfYgs/ZqIz4ObEa/T4rNCn5EYlDd 7MnQ== X-Gm-Message-State: AGRZ1gIn5ORQ2AbpM5ZJuj7pQzIXhkEyH8KLp7aoXx9KqDiMG59v+5sy Yjz/Ldjye3nSaPbfc7rpLmmIsQ== X-Received: by 2002:adf:e551:: with SMTP id z17-v6mr14524210wrm.238.1540830234197; Mon, 29 Oct 2018 09:23:54 -0700 (PDT) Received: from localhost.localdomain (137.55.88.92.rev.sfr.net. [92.88.55.137]) by smtp.gmail.com with ESMTPSA id y19-v6sm28150499wra.60.2018.10.29.09.23.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 29 Oct 2018 09:23:52 -0700 (PDT) From: Daniel Lezcano To: rjw@rjwysocki.net Cc: vincent.guittot@linaro.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman , "Rafael J. Wysocki" Subject: [PATCH 3/4] base/drivers/topology: Move instructions in the error path Date: Mon, 29 Oct 2018 17:23:19 +0100 Message-Id: <1540830201-2947-3-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1540830201-2947-1-git-send-email-daniel.lezcano@linaro.org> References: <1540830201-2947-1-git-send-email-daniel.lezcano@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When the function topology_parse_cpu_capacity() fails, we set the boolean cap_parsing_failed to true and we free the raw_capacity. This is correct as the function begins with a check against cap_parsing_failed thus protecting the function to be re-entered. However, even it is impossible that can happen with the current code, let's move in the instructions: - cap_parsing_failed = true; - free_raw_capacity(); ... in the 'else' block when the error is detected, that is more semantically correct. Signed-off-by: Daniel Lezcano --- drivers/base/arch_topology.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c index b19d6d4..7311641 100644 --- a/drivers/base/arch_topology.c +++ b/drivers/base/arch_topology.c @@ -155,9 +155,9 @@ bool __init topology_parse_cpu_capacity(struct device_node *cpu_node, int cpu) pr_err("cpu_capacity: missing %pOF raw capacity\n", cpu_node); pr_err("cpu_capacity: partial information: fallback to 1024 for all CPUs\n"); + cap_parsing_failed = true; + free_raw_capacity(); } - cap_parsing_failed = true; - free_raw_capacity(); } return !ret; From patchwork Mon Oct 29 16:23:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 149685 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4348685ljp; Mon, 29 Oct 2018 09:24:03 -0700 (PDT) X-Google-Smtp-Source: AJdET5c54evI6VYn+1DOza7CPQkrxaFpwFYz0BqVpFZ9922XnfbIvOF6jtYsP4MfH2H4FhMZJ7Hp X-Received: by 2002:a63:d52:: with SMTP id 18-v6mr14642836pgn.107.1540830243219; Mon, 29 Oct 2018 09:24:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540830243; cv=none; d=google.com; s=arc-20160816; b=HcRZkeGKznXvyRIJZsNh05ucFpcXR/F2Degnq/RPlY0WEYhCYvglD0zEDtRW9ZBNaP OQPHAny+HGmvd8iccFJi3DuPJSEm9ECzip37hlVldUywBoHQmBNUcvzFOSfi8/50WnYH I1D4SbJ9+XzRGHX9jzBdkup3O+oZ2t4xrkR9oiSxkt8tdyffyisV9eTUapSp+OkkdYUl yUl8YaTq9i6fdN/jdtIrVN60eDVRZ9BTLwbsJb2GqWzsRVptzHfhxQs56Fhb2y6fSCqy 9ivciAiogQYS8M/AcqKIZ82o1tCYK5aCoZybvZusNrrXx3aCUq45LYXHvu841jO9pfSs zYdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=EHn6ZSQVTOKaLg/bsltnbcaMuQIuilo+eLx553lzoE4=; b=ZCtCH08iHL/6Tc0PcwXhd6z5NfcAeZ3lMxCp7YGA5VsX4JK2LSSGuauluB8n9uPRIK QjHrpQuPPEfETgbMV/QWj2sBX8a4li0a2fAK2JRWs4e1T5kuTx6BDI53EjBSyRYEgVGL RfhUBJBeWlpqlu/Ut6INebypLL7dms3zIq2TOzPt1ugDgqC/kW/iaIgTReIFkSNgi+7/ 33wQAopmXSQX0cHWegQK4+LgIPeqXM2q4jzgs3dKHJ4YrbN6ZcttXJOBrOKchCzaE2G6 hvpHfgyDEZpXRobDWwxoOJrxS89l//R82K8F0Opl3Er03ec06yJ1vZefp6DPQt0wAUUA NBrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=du4esRFM; 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 63-v6si20701245pfg.178.2018.10.29.09.24.02; Mon, 29 Oct 2018 09:24:03 -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=du4esRFM; 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 S1728130AbeJ3BNT (ORCPT + 32 others); Mon, 29 Oct 2018 21:13:19 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:37103 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727793AbeJ3BNS (ORCPT ); Mon, 29 Oct 2018 21:13:18 -0400 Received: by mail-wr1-f68.google.com with SMTP id g9-v6so9385199wrq.4 for ; Mon, 29 Oct 2018 09:23:59 -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; bh=EHn6ZSQVTOKaLg/bsltnbcaMuQIuilo+eLx553lzoE4=; b=du4esRFMfsG/CHN+tAw+Upgcaeh4mGCj+P/HX/DLpbrWe1SWcZNq92SMA+NmWYcrjf dDuFTN/RB/KhTo6vZnSgXxtTQ9eeE/oMZxaXmsBqUAZMbtUJn57+/WFt97KEypsQu2he npIR3XBuoZfKUpCzVXusp+Yt//RuxWOchtKak= 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; bh=EHn6ZSQVTOKaLg/bsltnbcaMuQIuilo+eLx553lzoE4=; b=UGtefS/DIPOYgWTXg5jHml45778JNLv9m7AFIVtGevhFkPdItAehWejZqb2/oCqY5F /S0WcTgd+tYPGvtgceTHjH/iTycfFij1+UYxwzw3w9N8BSIfpINMvZ/9hTKcdHnuDBYF 10DUoEirvNS/duzI9HLJNyrUF3k0FcdgmDqsPiGj043hvuts5RUiqhEyzYWPCLvsvYOi NSJ91Z6FQMDhw1ilyMTnNRlWV/C+e5++ZovHbq3k+mpIjwOigbRhAEQGf/TLneCLtOmW M+4YRbg6TubvdKMM+2uW0aelvq0DHVR3hZi6ll7ftXRs6D82fT6m9jb+GtjvTtFBbVzY YEAg== X-Gm-Message-State: AGRZ1gKzLFBxAHJ6nErbrPBfeWAALkZtVxK3XhxA30LISsY26F8j/Sy2 EN4X4ewEhz+kPNUvQNEPFWhM4g== X-Received: by 2002:a05:6000:51:: with SMTP id k17mr14542750wrx.114.1540830238967; Mon, 29 Oct 2018 09:23:58 -0700 (PDT) Received: from localhost.localdomain (137.55.88.92.rev.sfr.net. [92.88.55.137]) by smtp.gmail.com with ESMTPSA id y19-v6sm28150499wra.60.2018.10.29.09.23.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 29 Oct 2018 09:23:58 -0700 (PDT) From: Daniel Lezcano To: rjw@rjwysocki.net Cc: vincent.guittot@linaro.org, linux-kernel@vger.kernel.org, Chris Redpath , Quentin Perret , Viresh Kumar , Amit Kucheria , Nicolas Dechesne , Niklas Cassel , Greg Kroah-Hartman , "Rafael J. Wysocki" Subject: [PATCH 4/4] base/drivers/topology: Default dmpis-mhz if they are not set in DT Date: Mon, 29 Oct 2018 17:23:20 +0100 Message-Id: <1540830201-2947-4-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1540830201-2947-1-git-send-email-daniel.lezcano@linaro.org> References: <1540830201-2947-1-git-send-email-daniel.lezcano@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In the case of assymetric SoC with the same micro-architecture, we have a group of CPUs with smaller OPPs than the other group. One example is the 96boards dragonboard 820c. There is no dmips/MHz difference between both groups, so no need to specify the values in the DT. Unfortunately, without these defined, there is no scaling capacity comutation triggered, so we need to write 'capacity-dmips-mhz' for each CPU with the same value in order to force the scaled capacity computation. Fix this by setting a default capacity to SCHED_CAPACITY_SCALE, if no 'capacity-dmips-mhz' is defined in the DT. This was tested on db820c: - specified values in the DT (correct results) - partial values defined in the DT (error + fallback to defaults) - no specified values in the DT (correct results) correct results are: cat /sys/devices/system/cpu/cpu*/cpu_capacity 758 758 1024 1024 ... respectively for CPU0, CPU1, CPU2 and CPU3. That reflects the capacity for the max frequencies 1593600 and 2150400. Cc: Chris Redpath Cc: Quentin Perret Cc: Viresh Kumar Cc: Amit Kucheria Cc: Nicolas Dechesne Cc: Niklas Cassel Signed-off-by: Daniel Lezcano --- drivers/base/arch_topology.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c index 7311641..7d594a6 100644 --- a/drivers/base/arch_topology.c +++ b/drivers/base/arch_topology.c @@ -205,6 +205,21 @@ static struct notifier_block init_cpu_capacity_notifier = { .notifier_call = init_cpu_capacity_callback, }; +static int topology_set_default_capacity(void) +{ + int cpu; + + raw_capacity = kzalloc(num_possible_cpus() * sizeof(*raw_capacity), + GFP_KERNEL); + if (!raw_capacity) + return -ENOMEM; + + for_each_possible_cpu(cpu) + raw_capacity[cpu] = SCHED_CAPACITY_SCALE; + + return 0; +} + static int __init register_cpufreq_notifier(void) { int ret; @@ -214,9 +229,19 @@ static int __init register_cpufreq_notifier(void) * until we have the necessary code to parse the cpu capacity, so * skip registering cpufreq notifier. */ - if (!acpi_disabled || !raw_capacity) + if (!acpi_disabled) return -EINVAL; + if (!raw_capacity) { + + pr_info("cpu_capacity: No capacity defined in DT, set default " + "values to %ld\n", SCHED_CAPACITY_SCALE); + + ret = topology_set_default_capacity(); + if (ret) + return ret; + } + if (!alloc_cpumask_var(&cpus_to_visit, GFP_KERNEL)) { pr_err("cpu_capacity: failed to allocate memory for cpus_to_visit\n"); return -ENOMEM;