Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5539503yba; Mon, 13 May 2019 12:40:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqwGOLsxdLnl+IuBtXyIyHusKkmU2S0S0OIII7r2lbx7E2ln2NelNYVkXzK2xdUbHG90mJ1c X-Received: by 2002:a62:30c2:: with SMTP id w185mr36067993pfw.175.1557776407011; Mon, 13 May 2019 12:40:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557776407; cv=none; d=google.com; s=arc-20160816; b=oqTLTOUCcvVF9UKYufTED/35Nrf4Z2NmWuraLYa661l2Rq188qcXctj003Id9F3RgT tVUkyCUc7C9oV3fd4TQmPPHbFfKiRGzazDd8/QRQb5kl2G0N1TIZ6m9fi4nstSYO+TQW 79T+jWB+F3ovC2bAT+GKWDrpxK/s3bapxIMmMco7tTdlhZb+AUU6SqT/RXsPpP4GQ+Xy QgEVq9v/sbumLYW3GcpXMiMY3u/aQJq3gvvNwB/OaxKvAb/f14Fpl+C2c9j8H/LIHfUh 09FssF4IZLeNXMcEuBPVVSUjrRfmRqbLsV1yHqlViq2t4OgsB7In+5DZLRx9BQisIex+ DjkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:organization:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=7fof8gmlqFrlN3tjmdJFzcPdOK3UTzw80TgmMMhQvqE=; b=OqmJCkfFS/Bbl10hWRfq2/kOaT92OE7ygFc2O2JI9gYDsyCwSfeQZDM7l4rl46/R7B 5Fp1mKeJfZmYfVoPi/IR/Ub/2DvZe8XJawpprWm2Q87ynxI51KZyaOr3w82RR3g2wBSY cbi8+a5CHOdaWPWALr2uQrRr1J6NNB/30/zJZNNGK0FXxa4Ivwrdsc0vFGN5qxFJcE8G osQX9d3AFerJVtJ/Q/WZ5Vd6Wz/O1A6RHoVWv4gDwgNq2NgTqU4HkAt+JamAp5NO4RtN uQJYyHGI3WpcwkxOSvljXlv1wJ8x3Zg0hqUxQWsbuLTAmOgwa5M/lgocY0OXRr8/DP6z GOFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=I49TIOhf; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w1si17718397plp.4.2019.05.13.12.39.50; Mon, 13 May 2019 12:40:06 -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=fail header.i=@gmail.com header.s=20161025 header.b=I49TIOhf; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732110AbfEMR7f (ORCPT + 99 others); Mon, 13 May 2019 13:59:35 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:45768 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732048AbfEMR73 (ORCPT ); Mon, 13 May 2019 13:59:29 -0400 Received: by mail-pg1-f195.google.com with SMTP id i21so7131571pgi.12; Mon, 13 May 2019 10:59:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :reply-to:organization; bh=7fof8gmlqFrlN3tjmdJFzcPdOK3UTzw80TgmMMhQvqE=; b=I49TIOhfZN2cRV3mN4hvdUtfgKnEtJgAY/P/JuQxYydABED3u3CjKLDkHZ72uA74eq h8fkN7ysc1D2nKBiu8W0Gy+byLRQ9H3LtvXhS25XyWo2Gumi7By+eOEXYiNf/WlheMYR G5sshYWBaLmrwtcLLAApxI42QAdYGSMmyxZcMs/6Oq8XAbAEvhNKZIXXZ0U39F047ijP 3RO+pIbu97EuU9VOV5NKK5OUdsaj+G3TKq7wW2wplfhwyiUcSKLrBgnwOWY89cIoom0f yEUkvtE/QsMaoq8zSY8JxNAo1qCqG8/XNs1Gk+0z3LEX4mFUtIBW6IcWy5/EhgP/2mET KOfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:reply-to:organization; bh=7fof8gmlqFrlN3tjmdJFzcPdOK3UTzw80TgmMMhQvqE=; b=q2xlEX9QpGaj8HsDlR8NnHLrtfkDD9WTPLqSKMEyeKti+51C4aS1FmI1LD8MT7RO5k +tQLxlm5SJkrcyvJHEVAtlml8eJqdW1DejhOvj6jJb1UmMIMmX53ohnaw/kEDA0iavtw 2FOaA85Pbtj23MC4/Zt6JxwvBARwspWAfgjLkYjSlot1+/12WO8m/f/vXg9qTK4G7Otv N/1NFU0g8TYZRmf1vzkJoAHMJG5OXHSYvzM1cfHjigN0elOpcgwuF5nK3I0SMtKUBNc1 2ENktd35wCLiVLZXIBPQy5W09P2DFuhAo3jP2DhKA3GPZnBD3wgia3etrlNW2Ha5WWwD rdsQ== X-Gm-Message-State: APjAAAUpQkHvu2WmINr54JUH7HRbkWqJ02NrkFFlXiTCBnsEgYhVRwHQ sugEcIv/61rmr2M0OzaznvQ= X-Received: by 2002:a62:75c6:: with SMTP id q189mr34535500pfc.98.1557770368538; Mon, 13 May 2019 10:59:28 -0700 (PDT) Received: from localhost.localdomain ([96.79.124.202]) by smtp.gmail.com with ESMTPSA id s12sm9536266pfd.152.2019.05.13.10.59.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 10:59:27 -0700 (PDT) From: Len Brown To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Zhang Rui , Len Brown , linux-pm@vger.kernel.org Subject: [PATCH 09/19] powercap/intel_rapl: Update RAPL domain name and debug messages Date: Mon, 13 May 2019 13:58:53 -0400 Message-Id: <6510b784e16374447965925588ec6e46d5d007d8.1557769318.git.len.brown@intel.com> X-Mailer: git-send-email 2.18.0-rc0 In-Reply-To: <7b23d2d26d717b8e14ba137c94b70943f1ae4b5c.1557769318.git.len.brown@intel.com> References: <7b23d2d26d717b8e14ba137c94b70943f1ae4b5c.1557769318.git.len.brown@intel.com> Reply-To: Len Brown Organization: Intel Open Source Technology Center Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zhang Rui The RAPL domain "name" attribute contains "Package-N", which is ambiguous on multi-die per-package systems. Update the name to "package-X-die-Y" on those systems. No change on systems without multi-die/package. Update driver debug messages. Signed-off-by: Zhang Rui Signed-off-by: Len Brown Acked-by: Rafael J. Wysocki Cc: linux-pm@vger.kernel.org --- drivers/powercap/intel_rapl.c | 57 ++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/drivers/powercap/intel_rapl.c b/drivers/powercap/intel_rapl.c index 9202dbcef96d..ad78c1d08260 100644 --- a/drivers/powercap/intel_rapl.c +++ b/drivers/powercap/intel_rapl.c @@ -178,12 +178,15 @@ struct rapl_domain { #define power_zone_to_rapl_domain(_zone) \ container_of(_zone, struct rapl_domain, power_zone) +/* maximum rapl package domain name: package-%d-die-%d */ +#define PACKAGE_DOMAIN_NAME_LENGTH 30 -/* Each physical package contains multiple domains, these are the common + +/* Each rapl package contains multiple domains, these are the common * data across RAPL domains within a package. */ struct rapl_package { - unsigned int id; /* physical package/socket id */ + unsigned int id; /* logical die id, equals physical 1-die systems */ unsigned int nr_domains; unsigned long domain_map; /* bit map of active domains */ unsigned int power_unit; @@ -198,6 +201,7 @@ struct rapl_package { int lead_cpu; /* one active cpu per package for access */ /* Track active cpus */ struct cpumask cpumask; + char name[PACKAGE_DOMAIN_NAME_LENGTH]; }; struct rapl_defaults { @@ -926,8 +930,8 @@ static int rapl_check_unit_core(struct rapl_package *rp, int cpu) value = (msr_val & TIME_UNIT_MASK) >> TIME_UNIT_OFFSET; rp->time_unit = 1000000 / (1 << value); - pr_debug("Core CPU package %d energy=%dpJ, time=%dus, power=%duW\n", - rp->id, rp->energy_unit, rp->time_unit, rp->power_unit); + pr_debug("Core CPU %s energy=%dpJ, time=%dus, power=%duW\n", + rp->name, rp->energy_unit, rp->time_unit, rp->power_unit); return 0; } @@ -951,8 +955,8 @@ static int rapl_check_unit_atom(struct rapl_package *rp, int cpu) value = (msr_val & TIME_UNIT_MASK) >> TIME_UNIT_OFFSET; rp->time_unit = 1000000 / (1 << value); - pr_debug("Atom package %d energy=%dpJ, time=%dus, power=%duW\n", - rp->id, rp->energy_unit, rp->time_unit, rp->power_unit); + pr_debug("Atom %s energy=%dpJ, time=%dus, power=%duW\n", + rp->name, rp->energy_unit, rp->time_unit, rp->power_unit); return 0; } @@ -1181,7 +1185,7 @@ static void rapl_update_domain_data(struct rapl_package *rp) u64 val; for (dmn = 0; dmn < rp->nr_domains; dmn++) { - pr_debug("update package %d domain %s data\n", rp->id, + pr_debug("update %s domain %s data\n", rp->name, rp->domains[dmn].name); /* exclude non-raw primitives */ for (prim = 0; prim < NR_RAW_PRIMITIVES; prim++) { @@ -1206,7 +1210,6 @@ static void rapl_unregister_powercap(void) static int rapl_package_register_powercap(struct rapl_package *rp) { struct rapl_domain *rd; - char dev_name[17]; /* max domain name = 7 + 1 + 8 for int + 1 for null*/ struct powercap_zone *power_zone = NULL; int nr_pl, ret; @@ -1217,20 +1220,16 @@ static int rapl_package_register_powercap(struct rapl_package *rp) for (rd = rp->domains; rd < rp->domains + rp->nr_domains; rd++) { if (rd->id == RAPL_DOMAIN_PACKAGE) { nr_pl = find_nr_power_limit(rd); - pr_debug("register socket %d package domain %s\n", - rp->id, rd->name); - memset(dev_name, 0, sizeof(dev_name)); - snprintf(dev_name, sizeof(dev_name), "%s-%d", - rd->name, rp->id); + pr_debug("register package domain %s\n", rp->name); power_zone = powercap_register_zone(&rd->power_zone, control_type, - dev_name, NULL, + rp->name, NULL, &zone_ops[rd->id], nr_pl, &constraint_ops); if (IS_ERR(power_zone)) { - pr_debug("failed to register package, %d\n", - rp->id); + pr_debug("failed to register power zone %s\n", + rp->name); return PTR_ERR(power_zone); } /* track parent zone in per package/socket data */ @@ -1256,8 +1255,8 @@ static int rapl_package_register_powercap(struct rapl_package *rp) &constraint_ops); if (IS_ERR(power_zone)) { - pr_debug("failed to register power_zone, %d:%s:%s\n", - rp->id, rd->name, dev_name); + pr_debug("failed to register power_zone, %s:%s\n", + rp->name, rd->name); ret = PTR_ERR(power_zone); goto err_cleanup; } @@ -1270,7 +1269,7 @@ static int rapl_package_register_powercap(struct rapl_package *rp) * failed after the first domain setup. */ while (--rd >= rp->domains) { - pr_debug("unregister package %d domain %s\n", rp->id, rd->name); + pr_debug("unregister %s domain %s\n", rp->name, rd->name); powercap_unregister_zone(control_type, &rd->power_zone); } @@ -1380,8 +1379,8 @@ static void rapl_detect_powerlimit(struct rapl_domain *rd) /* check if the domain is locked by BIOS, ignore if MSR doesn't exist */ if (!rapl_read_data_raw(rd, FW_LOCK, false, &val64)) { if (val64) { - pr_info("RAPL package %d domain %s locked by BIOS\n", - rd->rp->id, rd->name); + pr_info("RAPL %s domain %s locked by BIOS\n", + rd->rp->name, rd->name); rd->state |= DOMAIN_STATE_BIOS_LOCKED; } } @@ -1410,10 +1409,10 @@ static int rapl_detect_domains(struct rapl_package *rp, int cpu) } rp->nr_domains = bitmap_weight(&rp->domain_map, RAPL_DOMAIN_MAX); if (!rp->nr_domains) { - pr_debug("no valid rapl domains found in package %d\n", rp->id); + pr_debug("no valid rapl domains found in %s\n", rp->name); return -ENODEV; } - pr_debug("found %d domains on package %d\n", rp->nr_domains, rp->id); + pr_debug("found %d domains on %s\n", rp->nr_domains, rp->name); rp->domains = kcalloc(rp->nr_domains + 1, sizeof(struct rapl_domain), GFP_KERNEL); @@ -1446,8 +1445,8 @@ static void rapl_remove_package(struct rapl_package *rp) rd_package = rd; continue; } - pr_debug("remove package, undo power limit on %d: %s\n", - rp->id, rd->name); + pr_debug("remove package, undo power limit on %s: %s\n", + rp->name, rd->name); powercap_unregister_zone(control_type, &rd->power_zone); } /* do parent zone last */ @@ -1461,6 +1460,7 @@ static struct rapl_package *rapl_add_package(int cpu) { int id = topology_logical_die_id(cpu); struct rapl_package *rp; + struct cpuinfo_x86 *c = &cpu_data(cpu); int ret; rp = kzalloc(sizeof(struct rapl_package), GFP_KERNEL); @@ -1471,6 +1471,13 @@ static struct rapl_package *rapl_add_package(int cpu) rp->id = id; rp->lead_cpu = cpu; + if (topology_max_die_per_package() > 1) + snprintf(rp->name, PACKAGE_DOMAIN_NAME_LENGTH, + "package-%d-die-%d", c->phys_proc_id, c->cpu_die_id); + else + snprintf(rp->name, PACKAGE_DOMAIN_NAME_LENGTH, "package-%d", + c->phys_proc_id); + /* check if the package contains valid domains */ if (rapl_detect_domains(rp, cpu) || rapl_defaults->check_unit(rp, cpu)) { -- 2.18.0-rc0