Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp763293rdb; Thu, 30 Nov 2023 19:06:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IH+6cvov69/leA9/CVWbc3vEMZAaZHRMUw6YJVxDMn6vSCnqAvNeJZhP6GZPOe2BJbQTtK9 X-Received: by 2002:a9d:76c3:0:b0:6d8:5544:d0b1 with SMTP id p3-20020a9d76c3000000b006d85544d0b1mr1633030otl.10.1701399992533; Thu, 30 Nov 2023 19:06:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701399992; cv=none; d=google.com; s=arc-20160816; b=c2FsrcQjbjrk0U9eKRIjaUn3WqiB8NBgmimay1iQb/nowMJWTYijZjX1wJBSUOLeb5 dO6JRNTPNGfT+dsAOxNFRmuWbKkBJyy9uaLSdtNv3jGegH/s5W6rXT9Dywiqq7MAM3O/ D0FJmGKs695RV+fGMWGBd5OAL1kaPJh5gbqx8EaicVyE+n3w/Zp0UvbSsNoWzfWhvEBw xr9wW5Cn1aIiWVW9UZh4YF83vymK7PnC930oXrU9VFwmRyaXBdEaS/392fV3QZYWjX3r wwBbTeHSLze+4Sa5ZVxxOzAZefEXc/UNoTYw8ILpV8aVIU12g+mQjmPx4MIIKRNt/3Er +DQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:autocrypt :from:references:cc:to:content-language:subject:user-agent :mime-version:date:message-id:sender:dkim-signature; bh=HlBmXw61xz34FZu2gf3f1pqRz+gjfA0iYgscjQD41D0=; fh=jmCV/PiznD+FsXo7y/PX7/0c6FtJ/SjzfnxqQCx3D0g=; b=kKM1XlqKjkaMYW8c8pDcxl005eOWLb1UWMb0OTzom1+RZE7oybC1Bpe1FowG+5qWsL CmkkShFXSYkwc5ZUNUpxuoTD4mS65Qg6VEm2sSF51G4bC6y38WMcpbzkyva/GBDjc9LJ GE0BLs8uFdR28dLQljbNUorHUKdUhYZbobocxoVWi2FkN/N6QzNVeYBelWia1lTcA5sx y+9rsZv5wxOAUrvQcDvWH11p63GawhhRc+xL/Hzx/cDqDBotaksUyabAdpKfXI9uo9t0 izUkl2L7VVAisZnKzZkHSKZBatuRYT821/wX8AOTo9HOHLIwVg7I5bEacJt5TD6P7wjp 0f5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=eSzFICNi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id h34-20020a635322000000b00578d0d070f4si2411960pgb.844.2023.11.30.19.06.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 19:06:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=eSzFICNi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id E248380F7F21; Thu, 30 Nov 2023 19:06:29 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232286AbjLADGQ (ORCPT + 99 others); Thu, 30 Nov 2023 22:06:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232308AbjLADGO (ORCPT ); Thu, 30 Nov 2023 22:06:14 -0500 Received: from mail-oa1-x33.google.com (mail-oa1-x33.google.com [IPv6:2001:4860:4864:20::33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FDC91715; Thu, 30 Nov 2023 19:06:20 -0800 (PST) Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-1fa21f561a1so41181fac.3; Thu, 30 Nov 2023 19:06:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701399979; x=1702004779; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=HlBmXw61xz34FZu2gf3f1pqRz+gjfA0iYgscjQD41D0=; b=eSzFICNiPiCFyIuhyNu86j0qLPu38z4YgCpZY7ZLRIfFef/IbdhKjuVl58Z3PPMkUi ANYh72yHVaR3RuQl5gqPNX0iiJemAHMza2c62qV+KrEIl5GRiZUGV9GsYOjcW257xjTx Z7Kpps5Tvvx/AqbM3OA3T/WS1OfwiYQfskuf/CrLY2u9KTF/vn2R8HpYvH53rUp4/nSV p2w8lA4giUJtq3+fa4Re60zpF79NSmBXELbqOGkS0yF9kOBVeHFbRsdKqnIb0AkxhmF/ 5WLN7cF8oCxBPHnEGrLmU0LX1Ffqnhg6CX+IwXHPg5rJ2b7ieA7U+dAONcQ5A/BKC8J5 LYag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701399979; x=1702004779; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=HlBmXw61xz34FZu2gf3f1pqRz+gjfA0iYgscjQD41D0=; b=D2YmBPIyjOSvDnyYjup+aZxtxyP1i0H0bZVvdAstQBy6apWT/eaThHsegOZYlrim06 Rgu8BiVuxEOBeNWIiSCNTe6WO1oWLnPfYFGlsInU/6Havfv9bzaoCnh1sAq9XhxNKqPa jWhx4pHiZdLq8dxk+259WWn3Qn0vJaw+QDu5k7mFo/Wko3Tv8yxFpZjJEq9Tmu8VgN+Y ZlRl5b66GsIAjTD57gvL6RNhn2dvenFMMq2HhqJRMdr4FDAZHESX9CGx+MPlHcLoe+fM fyKyV3Roa53BpgtYqf+Pt2PqvcGJpots2jMkhmZh2iXy9Inps2VLfZgV65kEe2zC+jYM HgtQ== X-Gm-Message-State: AOJu0YzXKZekC05gY99vusmIodkoUhcejXnfqaeJr7rvMX3IfltR7yzR iPAZcfoIb6YXgMZ4ZS3fwwg= X-Received: by 2002:a05:6870:8921:b0:1fa:de7e:bfa2 with SMTP id i33-20020a056870892100b001fade7ebfa2mr2196755oao.51.1701399979393; Thu, 30 Nov 2023 19:06:19 -0800 (PST) Received: from ?IPV6:2600:1700:e321:62f0:329c:23ff:fee3:9d7c? ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id fu18-20020a0568705d9200b001fa8b2d3212sm596221oab.1.2023.11.30.19.06.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 30 Nov 2023 19:06:18 -0800 (PST) Sender: Guenter Roeck Message-ID: <91a3f785-8d69-4425-ad23-a6ac0ebddb07@roeck-us.net> Date: Thu, 30 Nov 2023 19:06:16 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 3/3] hwmon: (coretemp) Fix core count limitation Content-Language: en-US To: Zhang Rui , jdelvare@suse.com Cc: fenghua.yu@intel.com, linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org References: <20231127131651.476795-1-rui.zhang@intel.com> <20231127131651.476795-4-rui.zhang@intel.com> From: Guenter Roeck Autocrypt: addr=linux@roeck-us.net; keydata= xsFNBE6H1WcBEACu6jIcw5kZ5dGeJ7E7B2uweQR/4FGxH10/H1O1+ApmcQ9i87XdZQiB9cpN RYHA7RCEK2dh6dDccykQk3bC90x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QQX JqvvP09whbqrABEBAAHCwWUEGAECAA8CGwwFAlVcpi8FCRmg08MACgkQyx8mb86fmYHNRQ/+ J0OZsBYP4leJvQF8lx9zif+v4ZY/6C9tTcUv/KNAE5leyrD4IKbnV4PnbrVhjq861it/zRQW cFpWQszZyWRwNPWUUz7ejmm9lAwPbr8xWT4qMSA43VKQ7ZCeTQJ4TC8kjqtcbw41SjkjrcTG wF52zFO4bOWyovVAPncvV9eGA/vtnd3xEZXQiSt91kBSqK28yjxAqK/c3G6i7IX2rg6pzgqh hiH3/1qM2M/LSuqAv0Rwrt/k+pZXE+B4Ud42hwmMr0TfhNxG+X7YKvjKC+SjPjqp0CaztQ0H nsDLSLElVROxCd9m8CAUuHplgmR3seYCOrT4jriMFBtKNPtj2EE4DNV4s7k0Zy+6iRQ8G8ng QjsSqYJx8iAR8JRB7Gm2rQOMv8lSRdjva++GT0VLXtHULdlzg8VjDnFZ3lfz5PWEOeIMk7Rj trjv82EZtrhLuLjHRCaG50OOm0hwPSk1J64R8O3HjSLdertmw7eyAYOo4RuWJguYMg5DRnBk WkRwrSuCn7UG+qVWZeKEsFKFOkynOs3pVbcbq1pxbhk3TRWCGRU5JolI4ohy/7JV1TVbjiDI HP/aVnm6NC8of26P40Pg8EdAhajZnHHjA7FrJXsy3cyIGqvg9os4rNkUWmrCfLLsZDHD8FnU mDW4+i+XlNFUPUYMrIKi9joBhu18ssf5i5Q= In-Reply-To: <20231127131651.476795-4-rui.zhang@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Thu, 30 Nov 2023 19:06:30 -0800 (PST) On 11/27/23 05:16, Zhang Rui wrote: > Currently, coretemp driver only supports 128 cores per package. > This loses some core temperation information on systems that have more > than 128 cores per package. > [ 58.685033] coretemp coretemp.0: Adding Core 128 failed > [ 58.692009] coretemp coretemp.0: Adding Core 129 failed > > Fix the problem by using a per package list to maintain the per core > temp_data instead of the fixed length pdata->core_data[] array. > > Signed-off-by: Zhang Rui > --- > drivers/hwmon/coretemp.c | 110 ++++++++++++++++++--------------------- > 1 file changed, 52 insertions(+), 58 deletions(-) > > diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c > index cef43fedbd58..1bb1a6e4b07b 100644 > --- a/drivers/hwmon/coretemp.c > +++ b/drivers/hwmon/coretemp.c > @@ -39,11 +39,7 @@ static int force_tjmax; > module_param_named(tjmax, force_tjmax, int, 0444); > MODULE_PARM_DESC(tjmax, "TjMax value in degrees Celsius"); > > -#define PKG_SYSFS_ATTR_NO 1 /* Sysfs attribute for package temp */ > -#define BASE_SYSFS_ATTR_NO 2 /* Sysfs Base attr no for coretemp */ > -#define NUM_REAL_CORES 128 /* Number of Real cores per cpu */ > #define CORETEMP_NAME_LENGTH 28 /* String Length of attrs */ > -#define MAX_CORE_DATA (NUM_REAL_CORES + BASE_SYSFS_ATTR_NO) > > enum coretemp_attr_index { > ATTR_LABEL, > @@ -90,17 +86,17 @@ struct temp_data { > struct attribute *attrs[TOTAL_ATTRS + 1]; > struct attribute_group attr_group; > struct mutex update_lock; > + struct list_head node; > }; > > /* Platform Data per Physical CPU */ > struct platform_data { > struct device *hwmon_dev; > u16 pkg_id; > - u16 cpu_map[NUM_REAL_CORES]; > - struct ida ida; > struct cpumask cpumask; > - struct temp_data *core_data[MAX_CORE_DATA]; > struct device_attribute name_attr; > + struct mutex core_data_lock; > + struct list_head core_data_list; > }; > > struct tjmax_pci { > @@ -491,6 +487,23 @@ static struct temp_data *init_temp_data(unsigned int cpu, int pkg_flag) > return tdata; > } > > +static struct temp_data *get_tdata(struct platform_data *pdata, int cpu) > +{ > + struct temp_data *tdata; > + > + mutex_lock(&pdata->core_data_lock); > + list_for_each_entry(tdata, &pdata->core_data_list, node) { > + if (cpu >= 0 && !tdata->is_pkg_data && tdata->cpu_core_id == topology_core_id(cpu)) > + goto found; > + if (cpu < 0 && tdata->is_pkg_data) > + goto found; > + } I really don't like this. With 128+ cores, it gets terribly expensive. How about calculating the number of cores in the probe function and allocating cpu_map[] and core_data[] instead ? Thanks, Guenter