From owner-freebsd-arch@freebsd.org Wed Nov 25 13:15:44 2015 Return-Path: Delivered-To: freebsd-arch@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 6E991A36025 for ; Wed, 25 Nov 2015 13:15:44 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 66A451FEB; Wed, 25 Nov 2015 13:15:43 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id tAPDFYr5003863 (version=TLSv1 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Wed, 25 Nov 2015 15:15:34 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua tAPDFYr5003863 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id tAPDFX6R003860; Wed, 25 Nov 2015 15:15:33 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 25 Nov 2015 15:15:33 +0200 From: Konstantin Belousov To: Mark Johnston Cc: freebsd-arch@FreeBSD.org Subject: Re: zero-cost SDT probes Message-ID: <20151125131533.GB3448@kib.kiev.ua> References: <20151122024542.GA44664@wkstn-mjohnston.west.isilon.com> <20151123113511.GX58629@kib.kiev.ua> <20151125001136.GB70878@wkstn-mjohnston.west.isilon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20151125001136.GB70878@wkstn-mjohnston.west.isilon.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Nov 2015 13:15:44 -0000 On Tue, Nov 24, 2015 at 04:11:36PM -0800, Mark Johnston wrote: > If I understood correctly, each probe site would require a separate page > in KVA to be able to enable and disable individual probes in the manner > that I described in a previous reply. Today, a kernel with lock inlining > has thousands of probe sites; wouldn't the requirement of allocating KVA > for each of them be prohibitive on 32-bit architectures? Several variations of the approach allow to control each probe site individually, while still avoiding jumps and reducing the cache consumption. And, of course, the biggest advantage is avoiding the need to change the text at runtime. E.g., you could have a byte allocated somewhere for each probe, with usual boolean values true/false for enabled/disabled state. Also, somewhere, you have two KVA pages allocated, say, starting at address p, the first page is mapped, the second page is not. The pages are shared between all probes. Then, the following code sequence would trigger the page fault only for enabled probe: movzbl this_probe_enable_byte, %eax movl (p + PAGE_SIZE - 4)(%eax), %eax This approach is quite portable and can be expressed in C. If expected count of probes is thousands, as you mentioned, then you would pay only for several KB of memory for enable control bytes. Another variant is possible with the use of INTO instruction, which has relatively low latency when not trapping, according to the Agner Fog tables.