From owner-freebsd-arch@FreeBSD.ORG Fri Nov 14 01:22:17 2014 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 1753B138; Fri, 14 Nov 2014 01:22:17 +0000 (UTC) Received: from mail105.syd.optusnet.com.au (mail105.syd.optusnet.com.au [211.29.132.249]) by mx1.freebsd.org (Postfix) with ESMTP id 9FFFC612; Fri, 14 Nov 2014 01:22:16 +0000 (UTC) Received: from c122-106-147-133.carlnfd1.nsw.optusnet.com.au (c122-106-147-133.carlnfd1.nsw.optusnet.com.au [122.106.147.133]) by mail105.syd.optusnet.com.au (Postfix) with ESMTPS id CE1041040A39; Fri, 14 Nov 2014 12:22:10 +1100 (AEDT) Date: Fri, 14 Nov 2014 12:22:09 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Navdeep Parhar Subject: Re: missing DTrace FBT return probes In-Reply-To: <5464FBFF.6020200@FreeBSD.org> Message-ID: <20141114115632.J1286@besplex.bde.org> References: <5464FBFF.6020200@FreeBSD.org> MIME-Version: 1.0 X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=BdjhjNd2 c=1 sm=1 tr=0 a=7NqvjVvQucbO2RlWB8PEog==:117 a=PO7r1zJSAAAA:8 a=JzwRw_2MAAAA:8 a=nlC_4_pT8q9DhB4Ho9EA:9 a=cz2ZRIgtxKwA:10 a=wJWlkF7cXJYA:10 a=6I5d2MoRAAAA:8 a=IbOoWMm4W4JsMnJ5gfIA:9 a=45ClL6m2LaAA:10 a=fgf5PR_cwQYA:10 Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE X-Content-Filtered-By: Mailman/MimeDel 2.1.18-1 Cc: "Grier, James" , "freebsd-arch@freebsd.org" X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Nov 2014 01:22:17 -0000 On Thu, 13 Nov 2014, Navdeep Parhar wrote: > On 11/13/14 08:33, Grier, James wrote: >> On Wed, Jun 5, 2013 at 5:50 PM, Navdeep Parhar wrote= : >=20 >> A large number of kernel functions have an FBT entry probe but no return >>> probe. I believe this is due to tail call optimization by the compiler. >>> Should we disable this optimization for kernel configs that have DTrace >>> support? The missing return probes make it very difficult to write >>> DTrace scripts that want to set flags etc. at function entry and then >>> clean them up on return. >>>=20 >>> A quick sample from a recent HEAD shows ~4000 out of ~27000 functions >>> are missing return probes. See the list of functions in these files >>> (the ones listed in entry-only.txt do not have return probes). >>>=20 >>> http://people.freebsd.org/~np/entry-only.txt >>> http://people.freebsd.org/~np/entry.txt >>> http://people.freebsd.org/~np/return.txt >>=20 >> By trial and error, I discovered that it=E2=80=99s =E2=80=98-funit-at-a-= time=E2=80=99 that=20 >> does the dirty work, so >> using =E2=80=98-fno-unit-at-a-time=E2=80=99 with -O2 we get all the retu= rn fbt probes.=20 >> I haven=E2=80=99t determined >> the performance impact of this. > > Hmm, I thought it was -fno-optimize-sibling-calls that controlled this=20 > particular optimization. Perhaps it is all of these, plus -fno-inline-functions-called-once. Inlining functions when not requested to do so gives undebuggable code. -funit-at-a-time exposes even static functions that are defined after they are used to inlining. > These days I compile my debug kernels with -O0. There is a very signific= ant=20 > performance impact but it makes kgdb and DTrace very happy. But -O0 means that you are not testing what will be used on production systems. gcc used to promise that -g not disturb anything and that -O not make debugging impossible. Lots of flags that were under -O2 in gcc-3 crept into -O in gcc-4. clang is worse -- its -O is more agressive than gcc-4's -O2, and its -O2 is little different from its -O. Apart from kgdb and DTrace, this breaks: - profiling - kernel stack traces from ddb - ddb generally. With no debugging symbol support, it is even harder to find where args and local variables are if they are optimized away. (In userland, they often cannot be found even with debugging symbol support.) ddb's heuristic for finding args never worked for amd64 and is now under #if !1 with a comment that dwarf2 is needed. Thus, stack traces never showed any args correctly on amd64. I recently noticed a case where gcc without many optimizations on i386 messed up the arg printing because the function was static and gcc "optimized" it by passing an arg in %eax instead of on the stack. Bruce From owner-freebsd-arch@FreeBSD.ORG Fri Nov 14 01:55:30 2014 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id CB146812; Fri, 14 Nov 2014 01:55:30 +0000 (UTC) Received: from mail-ie0-x229.google.com (mail-ie0-x229.google.com [IPv6:2607:f8b0:4001:c03::229]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8DE6094B; Fri, 14 Nov 2014 01:55:30 +0000 (UTC) Received: by mail-ie0-f169.google.com with SMTP id y20so179475ier.0 for ; Thu, 13 Nov 2014 17:55:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=OAuWdS4dmVFXMZ0gdjxpYWjaqa36yqtAKFjmj8tcR8M=; b=MWa8Whoz4AT4F/0UEoNbcS7rLL+yj5U/JzeLZYv6cEkvmemGxxlNEIIg2+UNu6U6qf 16QMvWPXznvNyDqYEArmdDiRn8l50fwYffpRkuIl1N2k+rL7ubiwsskbhuzYsgeKyC0O 7GnXe1/O6XP+4+aCzjvIbj9GGP68/CC+qrrAh68JVfL3d/tphwSySXhh7ZqrRLv0PILL znwcc6QV4PBg8BruIvcy/Q1SOtD4ynlJ39i+gJ6ES588xnHNVciTEQDgUMMUMj9loGay Yi/UdxEuGVfabGengUBUbzCiQCaWB9jGFPA9VXUfRX9HB/dOflk0dmwVOzFID5VJH4xu CPCw== MIME-Version: 1.0 X-Received: by 10.107.13.6 with SMTP id 6mr6562099ion.68.1415930129975; Thu, 13 Nov 2014 17:55:29 -0800 (PST) Received: by 10.50.235.49 with HTTP; Thu, 13 Nov 2014 17:55:29 -0800 (PST) In-Reply-To: References: <54647D1E.9010904@freebsd.org> <201411130948.23785.jhb@freebsd.org> Date: Thu, 13 Nov 2014 17:55:29 -0800 Message-ID: Subject: Re: Questions about locking; turnstiles and sleeping threads From: NGie Cooper To: Adrian Chadd Content-Type: text/plain; charset=UTF-8 Cc: Hans Petter Selasky , Alfred Perlstein , Steve Kargl , "freebsd-arch@freebsd.org" X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Nov 2014 01:55:30 -0000 On Thu, Nov 13, 2014 at 3:01 PM, Adrian Chadd wrote: > I'd like to try and add WITNESS_WARN() where appropriate. > > How's this look? > > Index: kern_timeout.c > =================================================================== > --- kern_timeout.c (revision 274304) > +++ kern_timeout.c (working copy) > @@ -1096,7 +1096,22 @@ > struct lock_class *class; > int direct, sq_locked, use_lock; > > + /* XXX GIANTOK? c_lock can be NULL? */ > + > /* > + * If safe is clear then we're not going to drop into the > + * sleepq wait routines. So, we don't have to check > + * for the witness warning here. > + * > + * If safe is set then we may drop into the sleep routines > + * so do the check. > + */ > + if (safe) { > + WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, c->c_lock, > + "calling %s", __func__); > + } > + > + /* > * Some old subsystems don't hold Giant while running a callout_stop(), > * so just discard this check for the moment. > */ - This should have WITNESS #ifdef guards (for clarity... it would probably be optimized out by the compiler if -O0 wasn't specified, but some folks seem to use -O0 lately, like np@). - Should this have __predict_{false,true} applied to the if (safe) check? Thanks!