Received: by 10.223.148.5 with SMTP id 5csp7806052wrq; Thu, 18 Jan 2018 09:44:47 -0800 (PST) X-Google-Smtp-Source: ACJfBovQgleSFjw96YqYjUTEw6ZqyTg8LATdxB6NRsi6tWsVzE/b0WNIn/HcIkkjmjCTrFwd11eq X-Received: by 10.99.45.195 with SMTP id t186mr12552398pgt.127.1516297487294; Thu, 18 Jan 2018 09:44:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516297487; cv=none; d=google.com; s=arc-20160816; b=LtAZyXBSJo0ekB0oS4/FxxpRJAJV8ATyqqqDLYeKKVjbZTeCcIyc7nW+3cLxozIvAJ zdZFVS4XM85YrEHKiz835g98iASDN34lzNzv3hHx/cY2opL7jEqQpbuMJvXzWsFoyX4w Us5Ygiuar59PLjwea7cyuYW4+Ku9/oesxpPkTecReFNePqMA+ADCt9HVQqGdKj2kHk03 hL9FQL+cxbOT+s1N8zzAvLxX0eWJqoP/dCfJJ6A1rklLwoAaI8PlnpEP4zasPwNkKd0A G3Tar4s0rOaTcRe/Lj1uRrRALRqXEd6WwwYoGvvVa4WQhIOaLmutrQuQvnDsyoMuJtD+ jtcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :dlp-reaction:dlp-version:dlp-product:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:arc-authentication-results; bh=I6bnu1XIBHGqO8F4dGjD9x36y8Q7321fif/vUYTsArU=; b=phDo+yCBmmOfDXYVVdru0Dw2cRPesSSJqP/kAPCW9M/L2yT0epYT1vWl3gyfPVy7RL sSglf9x7XIaDOaKXaXWVf41vBky1eLPfNS5nydsxSg0wLDTTk14a3wS/z+/HJDuVMsOq szJMnsn8ei1N9XQ39e8sHt4Dc59oRDwZAfIG7c6R9yxoUrLETfP+0a7oHml78I01UsnD qqxX95F1Pmz1DqbkRSbC8SQrwgES1v1/gLI1fxIp+46Y9qHup8AmOFB07loSMqI+6j7/ iklwBMMmggupC2Vz4eqQAb5vWJFbSzwQ9swq2Da3+jaQzrik4OdDZ8bCH4Eb6nU69n1s siow== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r19si6563770pgn.85.2018.01.18.09.44.33; Thu, 18 Jan 2018 09:44:47 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932269AbeARRnR convert rfc822-to-8bit (ORCPT + 99 others); Thu, 18 Jan 2018 12:43:17 -0500 Received: from mga11.intel.com ([192.55.52.93]:44926 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932103AbeARRnP (ORCPT ); Thu, 18 Jan 2018 12:43:15 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Jan 2018 09:43:14 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,378,1511856000"; d="scan'208";a="10796084" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga007.jf.intel.com with ESMTP; 18 Jan 2018 09:43:14 -0800 Received: from fmsmsx111.amr.corp.intel.com (10.18.116.5) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 18 Jan 2018 09:43:13 -0800 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by fmsmsx111.amr.corp.intel.com (10.18.116.5) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 18 Jan 2018 09:43:13 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.213]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.152]) with mapi id 14.03.0319.002; Fri, 19 Jan 2018 01:43:11 +0800 From: "Liang, Kan" To: Peter Zijlstra CC: "tglx@linutronix.de" , "mingo@redhat.com" , "linux-kernel@vger.kernel.org" , "acme@kernel.org" , "eranian@google.com" , "ak@linux.intel.com" Subject: RE: [PATCH V5 4/8] perf/x86/intel/uncore: add new data structures for free running counters Thread-Topic: [PATCH V5 4/8] perf/x86/intel/uncore: add new data structures for free running counters Thread-Index: AQHTjjLMO5E6Fi0JBEaHVwBOA31k86N5HycAgACap6A= Date: Thu, 18 Jan 2018 17:43:10 +0000 Message-ID: <37D7C6CF3E00A74B8858931C1DB2F07753801FEF@SHSMSX103.ccr.corp.intel.com> References: <1516042629-387021-1-git-send-email-kan.liang@intel.com> <1516042629-387021-4-git-send-email-kan.liang@intel.com> <20180118133248.GC2249@hirez.programming.kicks-ass.net> In-Reply-To: <20180118133248.GC2249@hirez.programming.kicks-ass.net> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZDE0M2FmOWMtMTRlZS00ODQxLTliYjUtMTBkN2IwYjc5OWI0IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6IkYxZjdlQVg2XC9vZHZVaUhWUGp2UkJITWFLUjEyditIWFwvc3ZpenJyNUZocz0ifQ== x-ctpclassification: CTP_IC dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Mon, Jan 15, 2018 at 10:57:05AM -0800, kan.liang@intel.com wrote: > > From: Kan Liang > > > > There are a number of free running counters introduced for uncore, which > > provide highly valuable information to a wide array of customers. > > For example, Skylake Server has IIO free running counters to collect > > Input/Output x BW/Utilization. > > The precious generic counters could be saved to collect other customer > > interested data. > > > > The free running counter is read-only and always active. Current generic > > uncore code does not support this kind of counters. > > > > Introduce a new index to indicate the free running counters. Only one > > index is enough for all free running counters. Because the free running > > countes are always active, and the event and free running counter are > > always 1:1 mapped. It does not need extra index to indicate the assigned > > counter. > > > > Introduce some rules to encode the event for free running counters. > > - The event for free running counter has the same event code 0xff as the > > event for fixed counter. > > - The umask of the event starts from 0x10. The umask which is less than > > 0x10 is reserved for the event of fixed counter. > > - The free running counters can be divided into different types > > according to the MSR location, bit width or definition. The start > > point of the umask for different type has 0x10 offset. > > For example, there are three types of IIO free running counters on > > Skylake server, IO CLOCKS counters, BANDWIDTH counters and > UTILIZATION > > counters. > > The event code for all free running counters is 0xff. > > 'ioclk' is the first counter of IO CLOCKS. IO CLOCKS is the first type > > of free running counters, which umask starts from 0x10. > > So 'ioclk' is encoded as event=0xff,umask=0x10 > > 'bw_in_port2' is the third counter of BANDWIDTH counters. BANDWIDTH is > > the second type which umask starts from 0x20. > > So 'bw_in_port2' is encoded as event=0xff,umask=0x22. > > > > Introduce a new data structure to store free running counters related > > information for each type. It includes the number of counters, bit > > width, base address, offset between counters and offset between boxes. > > > > Introduce several inline helpers to check index for fixed counter and > > free running counter, validate free running counter event, and retrieve > > the free running counter information according to box and event. > > Sorry, none of this makes any sense, what? > > WTH would all free running counters, which presumably count different > things, have the same event code ? > > And whats the hackery with the umask do? > > Please rewrite this in comprehensible form and also give rationale for > the various choices. I rewrote the encoding part as blow. Does it look better? ------ In the uncore document, there is no event-code assigned to free running counters. Some events need to be defined to indicate the free running counters. The events are encoded as event-code + umask-code. The event-code for all free running counters is 0xff, which is the same as the fixed counters. - It has not been decided what code will be used for common events on future platforms. 0xff is the only one which will definitely not be used as any common event-code. - Free running counters and fixed counters are both dedicated counters. It makes sense to share the event-code between these two types of counters. - Even in the existing codes, the fixed counters for core, that have the same event-code, may count different things. Hence, it should not surprise the users if the free running counters that share the same event-code also count different things. Umask will be used to distinguish the counters. The umask-code is used to distinguish a fixed counter and a free running counter, and different types of free running counters. For fixed counters, the umask-code is 0x0X. X indicates the index of the fixed counter, which starts from 0. - Compatible with the old event encoding. - Currently, there is only one fixed counter. There are still 15 reserved spaces for Extension. For free running counters, the umask-code uses the rest of the space. It would bare the format of 0xXY. X stands for the type of free running counters, which starts from 1. Y stands for the index of free running counters of same type, which starts from 0. - The free-running counters do different thing. It can be categorized to several types, according to the MSR location, bit width and definition. E.g. there are three types of IIO free running counters on Skylake server to monitor IO CLOCKS, BANDWIDTH and UTILIZATION on different ports. It makes it easy to locate the free-running counter of a specific type. - So far, there are at most 8 counters of each type. There are still 8 reserved spaces for extension. ------ Thanks, Kan