From owner-svn-src-head@freebsd.org Thu Nov 23 14:38:06 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 85D4ADEE5E0; Thu, 23 Nov 2017 14:38:06 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail108.syd.optusnet.com.au (mail108.syd.optusnet.com.au [211.29.132.59]) by mx1.freebsd.org (Postfix) with ESMTP id 4EF436DC3E; Thu, 23 Nov 2017 14:38:05 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from [192.168.0.102] (c110-21-101-228.carlnfd1.nsw.optusnet.com.au [110.21.101.228]) by mail108.syd.optusnet.com.au (Postfix) with ESMTPS id A99671A26B0; Fri, 24 Nov 2017 01:38:04 +1100 (AEDT) Date: Fri, 24 Nov 2017 01:38:03 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Edward Tomasz Napierala cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r326125 - head/usr.sbin/kgmon In-Reply-To: <201711231241.vANCf58n091345@repo.freebsd.org> Message-ID: <20171124002239.T1335@besplex.bde.org> References: <201711231241.vANCf58n091345@repo.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.2 cv=KeqiiUQD c=1 sm=1 tr=0 a=PalzARQSbocsUSjMRkwAPg==:117 a=PalzARQSbocsUSjMRkwAPg==:17 a=kj9zAlcOel0A:10 a=K3iUa49lGXHlmSPsME0A:9 a=CjuIK1q_8ugA:10 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Nov 2017 14:38:06 -0000 On Thu, 23 Nov 2017, Edward Tomasz Napierala wrote: > Log: > Mark kgmon(8) obsolete, redirecting users to pmcstat(8). It isn't obsolete. pmcstat can't do at least full (non-statistical) call graphs and high-resolution profiling. gmon in the kernel is slow to use in the SMP case and dangerous to use in all cases, but usually works for call graphs. In the SMP case, it uses a giant spinlock which is slow and gives deadlock when a non-maskable trap like an NMI or debugger trap occurs while the lock is held by the same CPU. In the !SMP case, it uses interrupt disabling to lock. This races instead of deadlocking for non-maskable traps while it is held. Ordinary mutexes have the same problems, and only work if NMI and debugger trap handlers don't use any mutexes that might be held by the interrupted context. Broken cases mostly involve broken locking in printf() and console drivers. High-resolution profiling was broken by gcc-4.2.1 and is more broken for clang. Only the parts written in asm sort of work, and no parts ever worked right for SMP. All these bugs are except the slowness from giant locking are fixed for gcc-4.2.1 in some of my versions, using better giant locking with a timeout on it to avoid deadlocking. When deadlock is detected, profiling is skipped. My fixes for printf() and console drivers are similar except fot trying harder to not skip (switch to alternative methods). pmc also can't do better than nothing for cases involving NMIs even when they aren't near deadlock. Ordinary profiling can do better, and high resolution profiling can do better still. E.g., for profiling an NMI handler, pmc can't generate NMIs to even sample it statistically, but ordinary profiling can see it whenever the NMI doesn't occur while the profiling lock is held. Ordinary profiling then gives an exact call graph, but broken statistical sampling for times since generating hardclock interrupts in an NMI (and other contexts) is even more impossible than generating an NMI for pmc. High-resolution profiling gives almost exact times (or perfmon counts) even in NMI handlers except in the near-deadlock case. Bruce