Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp4393482rwi; Sat, 22 Oct 2022 09:21:46 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4iXupQ8Y8lqcHmxrKDeMO35LJ6UuaghLep1SKb2NXi5bwj0QZFY1CEeMrgTwTKjoLqilne X-Received: by 2002:a17:90a:ca87:b0:212:d2bd:82f5 with SMTP id y7-20020a17090aca8700b00212d2bd82f5mr9511142pjt.203.1666455706731; Sat, 22 Oct 2022 09:21:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666455706; cv=none; d=google.com; s=arc-20160816; b=fpkTof7jfWbqIefvM+p27Oys2e+xUZYFKytw2wXVCF51aGMQUpf14P1A8QnQvUx8rj 1mli6UbGGjvZLZuQTAKZXToEuUCIDwDHQBFP2o5etDzQeVXAVjkWfkdqwef+wEyCtXrm 6f9x6MsSCTd/9BRW3nkVAMbGJADhnleJ6N4ZEiAFdsyZ47gmp1NPBDznK64Q03p1DZKf n97aL/OMkkROIAKPZpEddan+l9l6JJsyW2/GqkAEMVeQdlldGCEavxjLGhVeTsH7irmJ TIis+g7MlHYK4V6MifWOqIe63z/XIW2YAi75WFzflID+xRH+sDcZttowdRt6Lto6MbQW nFMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=L1UkyWKGUQS7IqGEGknwzYINmCXfFGWCv/0pcBIBcHc=; b=T8639ivqAHnpbj5HrDeILLBD6rVEhsJXWtqUsknwhOeOJIJ19MEvxrhXPpBzWQl0jw 1Zd7Z33DKhyqjhPMXahEsAI7LyZ/hQIXKz1XOOqXR7wNibrTeuyyklNLEY+U43IVHKp1 MDz5QKoHqocBHj6s9TFOZjXEmJtW+3YXNExTng8l1y7rAkorfGtXinJiOvtSYYCsho0z QDyF6RT4W7PokTGUiopRx2E2qxhQDnyXX/Ldndwmv2CP6jmvwVkji0prv5+6wFHtoEiz 1Y1cYTuKHgBqewhEFSF5n2q+0osQAhUOsV2rnRb2MhWY5je8Spv3bTFjDHTgRUGWvgfg i05A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="IGsiP/sO"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t7-20020a170902e84700b0017f77922b11si11234497plg.84.2022.10.22.09.21.34; Sat, 22 Oct 2022 09:21:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="IGsiP/sO"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229497AbiJVQMr (ORCPT + 99 others); Sat, 22 Oct 2022 12:12:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229484AbiJVQMp (ORCPT ); Sat, 22 Oct 2022 12:12:45 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E61F126579 for ; Sat, 22 Oct 2022 09:12:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666455164; x=1697991164; h=message-id:subject:from:to:cc:date:in-reply-to: references:mime-version:content-transfer-encoding; bh=M3p+8NBkTUbFy4R5UzHnHF1Yyl5BTgdksK3WORtWcYY=; b=IGsiP/sOX+6JVr+egsCCju6cAO1S9rz8vaZRqEoBLkBrQmkjgvb70RIe H48OAxurnZTySGlMcdw6lWSFnJXIkX1cpE722C1XMyVaVP+nIEtaINg0Z e+q9/widPFaE8wt0zU6Ry1D9Y8O7NTFgjAB70j7WdDTKL294Tb1lwMN4o aSOmCjZTHpYyepZlKE04UXhI63KJRzxT4GFmVPze1MFvwAk49HOv9HFZI Z/Q0Z6Cz9GLPBh7OAEXO61AmyEHeNZeWiNDje+3AAz7Ne5eQyHQ5N1fzJ ZEdlFVgleBWuEMR1t6rXqr1PR1qhwIFT0WKRR15tzZM14F0ibwDdi+YH4 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10508"; a="308878825" X-IronPort-AV: E=Sophos;i="5.95,205,1661842800"; d="scan'208";a="308878825" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2022 09:12:44 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10508"; a="633271520" X-IronPort-AV: E=Sophos;i="5.95,205,1661842800"; d="scan'208";a="633271520" Received: from xlv2-mobl2.ccr.corp.intel.com ([10.254.213.114]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2022 09:12:41 -0700 Message-ID: <6636557f617ea5a1a1ab6f30f7aea0ececdd2a36.camel@intel.com> Subject: Re: [PATCH v1 1/2] x86/tsc: use logical_package as a better estimation of socket numbers From: Zhang Rui To: Dave Hansen , Feng Tang , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" , Peter Zijlstra , x86@kernel.org, linux-kernel@vger.kernel.org Cc: tim.c.chen@intel.com, Xiongfeng Wang , liaoyu15@huawei.com Date: Sun, 23 Oct 2022 00:12:38 +0800 In-Reply-To: <63dca468-c94d-844a-5b19-09c03cf84911@intel.com> References: <20221021062131.1826810-1-feng.tang@intel.com> <63dca468-c94d-844a-5b19-09c03cf84911@intel.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5-0ubuntu1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2022-10-21 at 09:21 -0700, Dave Hansen wrote: > On 10/21/22 08:00, Zhang Rui wrote: > > I checked the history of '__max_logical_packages', and realized > > that > > > > 1. for topology_max_packages()/'__max_logical_packages', the > > divisor > > 'ncpus' uses cpu_data(0).booted_cores, which is based on the > > *online* CPUs. So when using kernel cmdlines like > > maxcpus=/nr_cpus=, > > '__max_logical_packages' can get over-estimated. > > > > > > 2. for 'logical_packages', it equals the number of different > > physical > > Package IDs for all *online* CPUs. So with kernel cmdlines like > > nr_cpus=/maxcpus=, it can gets under-estimated. > > > > BTW, I also checked CPUID.B/1F, which can tell a fixed number of > > CPUs > > within a package. But we don't have a fixed number of total CPUs > > from > > hardware. > > On my Dell laptop, BIOS allows me to disable/enable one or several > > cores. When this happens, the 'total_cpus' changes, but CPUID.B/1F > > does > > not change. So I don't think CPUID.B/1F can be used to optimize the > > '__ > > max_logical_packages' calculation. > > > > I'm not sure if we have a perfect solution here. > > Are the implementations fixable? currently, I don't have any idea. > Or, at least tolerable? > > For instance, I can live with the implementation being a bit goofy > when > kernel commandlines are in play. We can pr_info() about those cases. My understanding is that the cpus in the last package may still have small cpu id value. This means that the 'logical_packages' is hard to break unless we boot with very small CPU count and happened to disable all cpus in one/more packages. Feng is experiencing with this and may have some update later. If this is the case, is this a valid case that we need to take care of? thanks, rui