Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752540AbdI2S4e convert rfc822-to-8bit (ORCPT ); Fri, 29 Sep 2017 14:56:34 -0400 Received: from esa4.microchip.iphmx.com ([68.232.154.123]:14797 "EHLO esa4.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752351AbdI2S4d (ORCPT ); Fri, 29 Sep 2017 14:56:33 -0400 X-IronPort-AV: E=Sophos;i="5.42,453,1500966000"; d="scan'208";a="7249863" From: To: CC: , , , , , , , Subject: RE: [PATCH RFC 3/5] Add KSZ8795 switch driver Thread-Topic: [PATCH RFC 3/5] Add KSZ8795 switch driver Thread-Index: AdMoGw7chwKpH5nHQDyZLhGSoYClOwAA0svAABGDyIACFLHiAAIDM9mAACPJiPA= Date: Fri, 29 Sep 2017 18:56:31 +0000 Message-ID: <93AF473E2DA327428DE3D46B72B1E9FD4112CBF0@CHN-SV-EXMX02.mchp-main.com> References: <93AF473E2DA327428DE3D46B72B1E9FD41121A87@CHN-SV-EXMX02.mchp-main.com> <20170907223625.GW11248@lunn.ch> <93AF473E2DA327428DE3D46B72B1E9FD41124D5A@CHN-SV-EXMX02.mchp-main.com> <20170928184059.GA2825@amd> In-Reply-To: <20170928184059.GA2825@amd> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.10.76.4] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1869 Lines: 45 > On Mon 2017-09-18 20:27:13, Tristram.Ha@microchip.com wrote: > > > > +/** > > > > + * Some counters do not need to be read too often because they are > less > > > likely > > > > + * to increase much. > > > > + */ > > > > > > What does comment mean? Are you caching statistics, and updating > > > different values at different rates? > > > > > > > There are 34 counters. In normal case using generic bus I/O or PCI to read > them > > is very quick, but the switch is mostly accessed using SPI, or even I2C. As > the SPI > > access is very slow and cannot run in interrupt context I keep worrying > reading > > the MIB counters in a loop for 5 or more ports will prevent other critical > hardware > > access from executing soon enough. These accesses can be getting 1588 > PTP > > timestamps and opening/closing ports. (RSTP Conformance Test sends test > traffic > > to port supposed to be closed/opened after receiving specific RSTP > > BPDU.) > > Hmm. Ok, interesting. > > I wonder how well this is going to work if userspace actively 'does > something' with the switch. > > It seems to me that even if your statistics code is careful not to do > 'a lot' of accesses at the same time, userspace can use other parts of > the driver to do the same, and thus cause same unwanted effects... If the user calls "ethtool -S" in a tight loop the system will waste a lot of CPU time, but this is more like a user error. Another solution is not to schedule to read the MIB counters in that function call. I think I was doing a favor to update the MIB counters sooner as the user probably wants to find out what is wrong with the switch by reading the MIB counters and checking them several times. For system tracking like SNMP I think it is likely a separate mechanism is used to gather those information. If I am wrong that function definitely needs to be modified.