Received: by 2002:ab2:6c55:0:b0:1fd:c486:4f03 with SMTP id v21csp269309lqp; Wed, 12 Jun 2024 00:28:25 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUzIkbu9NIt0/Zk/v3fSRCsNljM6PmGwqrT5EeRy3gof4A73e9zG6vdkq20FDOzfeXVaU1fZM6Bn2St+DSnLcF5WdV0fz38syC6Vp+pFg== X-Google-Smtp-Source: AGHT+IHT6RB62FNccZE4L40dcg5qNPJcOuEiromyHxp6yMhpr230oCCRnkChf6ZkQDMxz512PU8Z X-Received: by 2002:a2e:bc0a:0:b0:2eb:fcf2:f7c9 with SMTP id 38308e7fff4ca-2ebfcf2f958mr8007211fa.3.1718177305808; Wed, 12 Jun 2024 00:28:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718177305; cv=pass; d=google.com; s=arc-20160816; b=dkyL4MB2XZfMptokzX6Vfu4ckcYnd3kAp1zEqKVV18chXqBaZTppsduZuf+s6CcwTS UINqS6NP3ULiYjbI4BD2QO0Q766HLn3D3CpU6I0RzzMmuxXROz6KCjokoZYDQWbft42N STrT/VYuf7ONDCpHUijC12zVkHQ6+vIEWEf6GYXLZ0FuvnRqA4Ii9K3XdK5X/RZGRnR7 +Lm+HoYfpV/zWL8aW6OUnBZ2+mI6CI9tnQSVenz0QI4mbuFK+CC9g0eP9UQ/xYZTqxA1 ncyVjGO1kK+nBKpaO7xcrB/4O8VqXABq8TBRfiCwbIznMhraVb05kySB86aLE2/sbST+ /OdA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:in-reply-to:subject:cc:to:date:from :dkim-signature; bh=PAn0nBykLiCYLkLXvYjCH1v7bvTgkHbh/5yFRGSZ9LI=; fh=y/wMW4UR3LCHQmqtjj9gqB0p9kBu6pMVeBxG0ghPsJA=; b=ajDzutD9jZKhlZQtVjV5U8AVXPX1L18tPviTeaxhmOKb4aL5RzqPVtfjdbjyAzEofb D7XnitoEMIqVan3+HE0evnusglRp0RI049lu9JDUytloA9iT9dwEsL+TZlIU0bJupz2f e2Ai0VBeJJWv2uPitEGS71ekR9u0GnqkVxaEG9naQyywVwBv1zrInT5yyNUkMMEd0koH lwMuINg0OLfhqGRFrk2PEs1VhsK5O16zFqpgLu7a+8S9ml4rFsX0OHtk+YHUYGL3Kesn GErWRKikslkenSv/caG4qQzDVULDllrkWPr6wi3KPTawiBlkW/2r7m/5HdMCA66QXkS/ 7mAA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZAtkH9f4; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-211076-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-211076-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a6f3e5a8a5bsi113258966b.105.2024.06.12.00.28.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 00:28:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-211076-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZAtkH9f4; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-211076-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-211076-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 4FD0D1F2189A for ; Wed, 12 Jun 2024 07:28:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BA75216B729; Wed, 12 Jun 2024 07:28:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ZAtkH9f4" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 09892167270; Wed, 12 Jun 2024 07:28:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718177296; cv=none; b=iElQ3+4syZPYOngv423kyTgWXo/YVLI7IJR/KSg6AwvS0IhpkkqQEPMiYxzo6a/rSwZI2gqQgVbIe33B4pe9aR/QhUqSzPfFACOgUw4mfOuSdzSoSU4NavkhyyHPiaJ3fDc8QVhrufh98w8/oKV13r2+WXkUz1LdlXTNr/d0rWk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718177296; c=relaxed/simple; bh=OINFqR0m9qTBB2evRLkOh/KF43W/Ig7Ub6ACgHyZnCw=; h=From:Date:To:cc:Subject:In-Reply-To:Message-ID:References: MIME-Version:Content-Type; b=GuNXjjRjMReN8PUg5bUI9OtgK+ajSm7BBDQ7MF8iqXU6u/0ghZcbEjXUn3b+/HISWSPITS03Ziqc0sYWWmq+q2Uo0tS0Nv436pfIAVuez+/Q9O026YstILXRK802XX0KQA0e2uMa8lUF4X9/9mDiniW4nXh11hdcLtdceWf0pyc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ZAtkH9f4; arc=none smtp.client-ip=192.198.163.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718177295; x=1749713295; h=from:date:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=OINFqR0m9qTBB2evRLkOh/KF43W/Ig7Ub6ACgHyZnCw=; b=ZAtkH9f4XLCatNKGB6E1KtwqdqUSTDoDv1fQFauWUNYMBlASyvgnzdeu K23rusFCzLC6xXTpcKFH6y2a312jW3am7BnF19Nz3X+KNYU9amn1GA306 WO4p2H0Sgeh9x1UH7offnjnQDBNaYSNWWlAW1LypZaoZNhR1Nc6lydEWv G5pmoO1CvC6Yuj5iC8gVuoTRGP1Uqg1nfFVVL58JPbS6rGOOqOvzm05Vh GXLDPpaLxUnkhv+XPduteItRmAKZhpi0cEcVKuy5HlTOwdxu+QO4w8s60 ZGN4yXaLKIhNJBeLd8vQnwxUoqFjXO7+FveJ75IZgu7ygg3jbw6w03x4h Q==; X-CSE-ConnectionGUID: ekdBCSkPRk+9li5Nfmak0Q== X-CSE-MsgGUID: H49Uyl6iQuOZ0a1XyeKSOg== X-IronPort-AV: E=McAfee;i="6600,9927,11100"; a="14649308" X-IronPort-AV: E=Sophos;i="6.08,232,1712646000"; d="scan'208";a="14649308" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jun 2024 00:28:14 -0700 X-CSE-ConnectionGUID: fq3kvE2WR7uapVrS4pFk4g== X-CSE-MsgGUID: 8hrHmmwDRzO2V+ClaDy/aQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,232,1712646000"; d="scan'208";a="39806557" Received: from unknown (HELO localhost) ([10.245.247.204]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jun 2024 00:28:11 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Date: Wed, 12 Jun 2024 10:28:06 +0300 (EEST) To: Shravan Ramani cc: Hans de Goede , Vadim Pasternak , David Thompson , "platform-driver-x86@vger.kernel.org" , LKML Subject: Re: [PATCH v2 2/4] platform/mellanox: mlxbf-pmc: Add support for 64-bit counters and cycle count In-Reply-To: Message-ID: <370b5e44-cf92-21af-8c01-dbb208bf323f@linux.intel.com> References: <70d3c0af-8bf6-2e33-074d-5b1719a5674f@linux.intel.com> <33f25d4f-386c-6df6-344d-8b7aa011e69c@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII On Tue, 11 Jun 2024, Shravan Ramani wrote: > > > When 2 32-bit counters are coupled to form a 64-bit counter using this setting, > > > one counter will hold the lower 32 bits while the other will hold the upper 32. > > > So the other counter (or syses corresponding to it) also needs to be accessed. > > > > > > > For 64-bit counter, I suppose the userspace is expected to read the full > > > > counter from two sysfs files and combine the value (your documentation > > > > doesn't explain this)? That seems non-optimal, why cannot kernel just > > > > return the full combined 64-value directly in kernel? > > > > > > I will add more clear comments for this. > > > While it is true that the driver could combine the 2 fields and present a > > > 64-bit value via one of the sysfs, the reason for the current approach is that > > > there are other interfaces which expose the same counters for our platform > > > and there are tools that are expected to work on top of both interfaces for > > > the purpose of collecting performance stats. > > > > > The other interfaces follow this > > > approach of having lower and upper 32-bits separately in each counter, and > > > the tools expect the same. Hence the driver follows this approach to keep > > > things consistent across the BlueField platform. > > > > Hi, > > > > I went to look through the existing arrays in mlxbf-pmc.c but did not find > > any entries that would have clearly indicated the counters being hi/lo > > parts of the same counter. There were a few 0/1 ones which could be the > > same counter although I suspect even they are not parts of the same > > counter but two separate entities called 0 and 1 having the same counter. > > > > Could you please elaborate further what you meant with the note about > > other interfaces above so I can better assess the claim? > > When combining 2 counters using the "use_odd_counter" setting, the mechanism > of joining them or assigning upper or lower 32 bits to a counter is handled in HW > and not by the driver. For example, if bit0 of "use_odd_counter" is set, counter0 > and counter1 (which were originally separate counters) automatically become > the lower and upper bits of one 64-bit value. The user needs to read both these > sysfs separately to get the full 64-bit value. The driver does not do any special > handling for such cases, merely provides access to both counter0 and counter1. I know all this by now, but we're discussion here is whether kernel should do "special handling". Although, it's not really correct to depict representing 64-bit counter in its entirety as "special handling". I think the kernel should combine the 64-bit halved and you argumented it shouldn't. When I went to confirm the claim your argument was based on, I couldn't find on what basis the claim was made. > Since the events supported by the blocks are quite HW centric and low-level in > nature, the driver is generally used alongside various tools which work on top of > this driver to collect telemetry info and provide more readable statistics to the > end-user. Similar to this driver, there are other FW interfaces providing access to > these counters (same and other additional ones as well that belong to other HW > blocks). For the sake of consistency and to allow the tools to be compatible with > all interfaces, the counter data needs to be accessible in the same way, ie, as 32-bit > upper and lower values in counter0 and counter1 sysfs as in the above case. This does nothing to answer my question. Where in the kernel, there's an example where a 64-bit counter for BlueField platform is presented as 2 32-bit counters? If there isn't any examples in the kernel, your statement about consistency within the platform doesn't hold water, quoted (again) here for clarity what I'm refering to: "The other interfaces follow this approach of having lower and upper 32-bits separately in each counter, and the tools expect the same. Hence the driver follows this approach to keep things consistent across the BlueField platform." Where I can find those "other interfaces" that already follow this convention? -- i.