From owner-freebsd-dtrace@FreeBSD.ORG Sun Nov 17 03:31:33 2013 Return-Path: Delivered-To: freebsd-dtrace@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 396152DF; Sun, 17 Nov 2013 03:31:33 +0000 (UTC) Received: from mail-ie0-x22c.google.com (mail-ie0-x22c.google.com [IPv6:2607:f8b0:4001:c03::22c]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 0331C250F; Sun, 17 Nov 2013 03:31:32 +0000 (UTC) Received: by mail-ie0-f172.google.com with SMTP id to1so7177043ieb.17 for ; Sat, 16 Nov 2013 19:31:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=7mNtsOVF9hJoyjI9cfH11tco9rpTOfaH+T2auRq0Au0=; b=m8Dm6tmsc8apPbTsxsrluxhTJ/6mFFBa2RbHQPUy3a0pvV1Yi56GR58YL2XhR0ykH+ 5/UHF2g0NvaK+Ox704LmooKVz7hNy93kUH/aRPGKFLQ4jdAnNhQfYRxUaG5HGjysSBp4 r1WMqsWK6HryuFZfUpz9+JBDMiYDW/3u5w9ZCavS2iWreSzgsOkSxZZLZknRC5z9oERL sOUrsBX16CIveyJZ2u7yDJ3LPGH+K5wbNr41kVZdsfNWLMNOMYSIqCGI5xPLjadaO7kS XvsO/qTdsfxWJ/zAL/LS9NsjMy+4EYn5AGP8vqGCHDyrgBI4zoTegf2nSXWLjxtYD47U +9Yw== X-Received: by 10.50.39.45 with SMTP id m13mr9317908igk.14.1384659091979; Sat, 16 Nov 2013 19:31:31 -0800 (PST) Received: from charmander (192-0-203-16.cpe.teksavvy.com. [192.0.203.16]) by mx.google.com with ESMTPSA id m1sm6223233igj.10.2013.11.16.19.31.30 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 16 Nov 2013 19:31:31 -0800 (PST) Sender: Mark Johnston Date: Sat, 16 Nov 2013 23:31:27 -0500 From: Mark Johnston To: Alan Somers Subject: Re: Please review: fix panics on kldload/kldunload fasttrap Message-ID: <20131117043127.GA64214@charmander> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.22 (2013-10-16) Cc: freebsd-dtrace@freebsd.org X-BeenThere: freebsd-dtrace@freebsd.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "A discussion list for developers working on DTrace in FreeBSD." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Nov 2013 03:31:33 -0000 On Fri, Nov 15, 2013 at 01:31:26PM -0700, Alan Somers wrote: > I've found a few problems with fasttrap that can cause panics on > kldload and kldunload. Can someone please review this patch? I've > also attached an ATF test case for it. The test case loads and > unloads the fasttrap module 500 times while several sh processes are > forking, execing, and exiting at about 600 times/second/cpu. This looks good to me. Thanks! > > * kproc_create(fasttrap_pid_cleanup_cb, ...) gets called before > fasttrap_provs.fth_table gets allocated. This can lead to a panic on > module load, because fasttrap_pid_cleanup_cb references > fasttrap_provs.fth_table. My patch moves kproc_create down after the > point that fasttrap_provs.fth_table gets allocated, and modifies the > error handling accordingly. > > * dtrace_fasttrap_{fork,exec,exit} weren't getting NULLed until after > fasttrap_provs.fth_table got freed. That caused panics on module > unload because fasttrap_exec_exit calls fasttrap_provider_retire, > which references fasttrap_provs.fth_table. My patch NULLs those > function pointers earlier. > > * There isn't any code to destroy the > fasttrap_{tpoints,provs,procs}.fth_table mutexes on module unload, > leading to a resource leak when WITNESS is enabled. My patch destroys > those mutexes during fasttrap_unload(). > > -Alan > Index: sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c > =================================================================== > --- sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c (revision 257803) > +++ sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c (working copy) > @@ -2284,13 +2284,6 @@ > mutex_init(&fasttrap_count_mtx, "fasttrap count mtx", MUTEX_DEFAULT, > NULL); > > - ret = kproc_create(fasttrap_pid_cleanup_cb, NULL, > - &fasttrap_cleanup_proc, 0, 0, "ftcleanup"); > - if (ret != 0) { > - destroy_dev(fasttrap_cdev); > - return (ret); > - } > - > #if defined(sun) > fasttrap_max = ddi_getprop(DDI_DEV_T_ANY, devi, DDI_PROP_DONTPASS, > "fasttrap-max-probes", FASTTRAP_MAX_DEFAULT); > @@ -2344,6 +2337,24 @@ > "providers bucket mtx", MUTEX_DEFAULT, NULL); > #endif > > + ret = kproc_create(fasttrap_pid_cleanup_cb, NULL, > + &fasttrap_cleanup_proc, 0, 0, "ftcleanup"); > + if (ret != 0) { > + destroy_dev(fasttrap_cdev); > +#if !defined(sun) > + for (i = 0; i < fasttrap_provs.fth_nent; i++) > + mutex_destroy(&fasttrap_provs.fth_table[i].ftb_mtx); > + for (i = 0; i < fasttrap_tpoints.fth_nent; i++) > + mutex_destroy(&fasttrap_tpoints.fth_table[i].ftb_mtx); > +#endif > + kmem_free(fasttrap_provs.fth_table, fasttrap_provs.fth_nent * > + sizeof (fasttrap_bucket_t)); > + mtx_destroy(&fasttrap_cleanup_mtx); > + mutex_destroy(&fasttrap_count_mtx); > + return (ret); > + } > + > + > /* > * ... and the procs hash table. > */ > @@ -2436,6 +2447,20 @@ > return (-1); > } > > + /* > + * Stop new processes from entering these hooks now, before the > + * fasttrap_cleanup thread runs. That way all processes will hopefully > + * be out of these hooks before we free fasttrap_provs.fth_table > + */ > + ASSERT(dtrace_fasttrap_fork == &fasttrap_fork); > + dtrace_fasttrap_fork = NULL; > + > + ASSERT(dtrace_fasttrap_exec == &fasttrap_exec_exit); > + dtrace_fasttrap_exec = NULL; > + > + ASSERT(dtrace_fasttrap_exit == &fasttrap_exec_exit); > + dtrace_fasttrap_exit = NULL; > + > mtx_lock(&fasttrap_cleanup_mtx); > fasttrap_cleanup_drain = 1; > /* Wait for the cleanup thread to finish up and signal us. */ > @@ -2451,6 +2476,14 @@ > mutex_exit(&fasttrap_count_mtx); > #endif > > +#if !defined(sun) > + for (i = 0; i < fasttrap_tpoints.fth_nent; i++) > + mutex_destroy(&fasttrap_tpoints.fth_table[i].ftb_mtx); > + for (i = 0; i < fasttrap_provs.fth_nent; i++) > + mutex_destroy(&fasttrap_provs.fth_table[i].ftb_mtx); > + for (i = 0; i < fasttrap_procs.fth_nent; i++) > + mutex_destroy(&fasttrap_procs.fth_table[i].ftb_mtx); > +#endif > kmem_free(fasttrap_tpoints.fth_table, > fasttrap_tpoints.fth_nent * sizeof (fasttrap_bucket_t)); > fasttrap_tpoints.fth_nent = 0; > @@ -2463,22 +2496,6 @@ > fasttrap_procs.fth_nent * sizeof (fasttrap_bucket_t)); > fasttrap_procs.fth_nent = 0; > > - /* > - * We know there are no tracepoints in any process anywhere in > - * the system so there is no process which has its p_dtrace_count > - * greater than zero, therefore we know that no thread can actively > - * be executing code in fasttrap_fork(). Similarly for p_dtrace_probes > - * and fasttrap_exec() and fasttrap_exit(). > - */ > - ASSERT(dtrace_fasttrap_fork == &fasttrap_fork); > - dtrace_fasttrap_fork = NULL; > - > - ASSERT(dtrace_fasttrap_exec == &fasttrap_exec_exit); > - dtrace_fasttrap_exec = NULL; > - > - ASSERT(dtrace_fasttrap_exit == &fasttrap_exec_exit); > - dtrace_fasttrap_exit = NULL; > - > #if !defined(sun) > destroy_dev(fasttrap_cdev); > mutex_destroy(&fasttrap_count_mtx); > _______________________________________________ > freebsd-dtrace@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-dtrace > To unsubscribe, send any mail to "freebsd-dtrace-unsubscribe@freebsd.org" From owner-freebsd-dtrace@FreeBSD.ORG Sun Nov 17 03:48:03 2013 Return-Path: Delivered-To: freebsd-dtrace@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 6CF0B397 for ; Sun, 17 Nov 2013 03:48:03 +0000 (UTC) Received: from mail-ie0-x22c.google.com (mail-ie0-x22c.google.com [IPv6:2607:f8b0:4001:c03::22c]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 3E56E2580 for ; Sun, 17 Nov 2013 03:48:03 +0000 (UTC) Received: by mail-ie0-f172.google.com with SMTP id to1so7172042ieb.3 for ; Sat, 16 Nov 2013 19:48:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=xysXRywSs+H+VK9JAAL99ZdiQyt56Fp5CCb8Hj40WKs=; b=u49YEwPzUpcRzD6UqNH+EoMIhgE5ah0WSQhTwc99PzutWVArAUJiTMrRIGf76U4k6f 7WUe8vI+PHXdzrinQTT2Eto7BDX7l3YSznpGQsYOVrfATRw0m8wFt9W3/mUad6HXMoaZ 7uLuJYc2gS1hQTNzRHxpjfrUFkJbHQTyMUjRpcU5KxTNRA7zm+N3D6SN2RoUchjqTyC2 NXIe6SeBs+kqmncmoIKPdJOkst2U6Jy5IKQ0CgYKXjbJ5VCfTPvjKmsaOsQiBd1oj4vy ZL2r1ezBKWljfxRJ+Gpf0eVDUngPAI5DKtpfUQhMzt1OjG8noHDuRD8QarM7rQuKhzde cFGw== X-Received: by 10.50.29.43 with SMTP id g11mr4889447igh.25.1384660082825; Sat, 16 Nov 2013 19:48:02 -0800 (PST) Received: from charmander (192-0-203-16.cpe.teksavvy.com. [192.0.203.16]) by mx.google.com with ESMTPSA id ri5sm1458576igc.1.2013.11.16.19.48.01 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 16 Nov 2013 19:48:02 -0800 (PST) Sender: Mark Johnston Date: Sat, 16 Nov 2013 23:48:01 -0500 From: Mark Johnston To: Prashanth Kumar Subject: Re: Fw: your mail Message-ID: <20131117044801.GB64214@charmander> References: <1384228985.51085.YahooMailNeo@web192604.mail.sg3.yahoo.com> <20131112041805.GA76413@raichu> <1384258564.17896.YahooMailNeo@web192603.mail.sg3.yahoo.com> <1384260159.73063.YahooMailNeo@web192605.mail.sg3.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1384260159.73063.YahooMailNeo@web192605.mail.sg3.yahoo.com> User-Agent: Mutt/1.5.22 (2013-10-16) Cc: "freebsd-dtrace@freebsd.org" X-BeenThere: freebsd-dtrace@freebsd.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "A discussion list for developers working on DTrace in FreeBSD." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Nov 2013 03:48:03 -0000 On Tue, Nov 12, 2013 at 08:42:39PM +0800, Prashanth Kumar wrote: > Hi Mark > > --------------------------------------- > /* scan.c */ > > #include > > int main() > { >     int str[10]; > >     if (scanf("%s", str) > 0) >         printf("name %s\n", str); > >     return 0; > } > ----------------------------- > > "dtrace -n 'pid$target:::entry' -c scanf" > > if you run the above dtrace command on the program , dtrace will not exit and hung in input. I can't reproduce that problem. If I use 'pid$target:::entry', dtrace(1) matches ~3000 probes and usually exits immediately with "processing aborted: No error". If I instead use 'pid$target:ld-elf.so.*::entry', I get: markj@charmander: ~/src/dtrace/tls $ sudo dtrace -n 'pid$target:ld-elf.so.*::entry' -c ./test dtrace: description 'pid$target:ld-elf.so.*::entry' matched 21 probes CPU ID FUNCTION:NAME 2 39804 __tls_get_addr:entry mark name: mark dtrace: pid 75490 has exited 2 39804 __tls_get_addr:entry 2 39804 __tls_get_addr:entry 2 39804 __tls_get_addr:entry 2 39804 __tls_get_addr:entry 2 39804 __tls_get_addr:entry 2 39804 __tls_get_addr:entry 2 39786 _rtld_addr_phdr:entry What version of FreeBSD are you using? Are you i386 or amd64? (I'm on amd64.) -Mark From owner-freebsd-dtrace@FreeBSD.ORG Sun Nov 17 04:10:11 2013 Return-Path: Delivered-To: freebsd-dtrace@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D68096BA for ; Sun, 17 Nov 2013 04:10:11 +0000 (UTC) Received: from nm25-vm5.bullet.mail.sg3.yahoo.com (nm25-vm5.bullet.mail.sg3.yahoo.com [106.10.151.100]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 2D164266B for ; Sun, 17 Nov 2013 04:10:10 +0000 (UTC) Received: from [106.10.166.123] by nm25.bullet.mail.sg3.yahoo.com with NNFMP; 17 Nov 2013 04:06:48 -0000 Received: from [106.10.150.24] by tm12.bullet.mail.sg3.yahoo.com with NNFMP; 17 Nov 2013 04:06:47 -0000 Received: from [127.0.0.1] by omp1025.mail.sg3.yahoo.com with NNFMP; 17 Nov 2013 04:06:47 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 905850.31144.bm@omp1025.mail.sg3.yahoo.com Received: (qmail 68912 invoked by uid 60001); 17 Nov 2013 04:06:47 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.in; s=s1024; t=1384661207; bh=XY9oQKyKOERTi97bo9u2XcMPy/BjQ7yUnFLGdpG48gA=; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:Message-ID:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=HkjelX8X3C7ZjUdRcdZhw6zwJo5JIVM9QJJnL5b+m46jyyUIhKl9tZQQYIOur/iOf8H1IkL3ZxrfxO4wxMphfro2hXZSvKhDPqQzstIKJjEI/nZh2PNUrrlfRb7r8UAqWAED+thQzAc+qqBPrtT2q5KMz5kS6Eopqq+K1quqYK4= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.co.in; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:Message-ID:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=WdBwnbuOS3/GdK7S3Am7KCa9tIU+KhOf1rjRE/WgfedojhLwVly9PhGQ8ak72ZyFPZOisFOMqj+jqlSDP91kB87JO+R82x6UUBqbq3Iyk2wXpaMzSg5qnuSMzdDAXEpPfgtpPLlzytce9Eczo6fgda1anCVVHuNtWKOQ8VI/8cE=; X-YMail-OSG: 7vnYc8cVM1kQufFvfA6lolGRIhkZkjPGP9S4wUoRnj0KfWT aneJ_16TUduQrDM5dS1bChoQ2sxk7DuM.lA2HsrOdZtX2IY1rtgveXKpAhHa yDNWj5aeJNUWY.UG50dYz3jl3VeiHWVAomGISZFd1EPjoCgMcfBSuBBgsZ3s g_bGxcI4_l_1royIPLTeIumYe5RneV0Xc9UvdGqaQn9iRiWpsRn9GApUujZF gdyx_kUr4o5LgOLmHFXeqg8xT.0yqq97YIA7t0UFFxk6vgBjEYbEekaSdZKY t0OTFU38xQEnBZfguWpVsjKin7WDOBXU25O1CKHoHbyVChWA.NvKLZC4_UUD EeKpZL4RG8Oqf3.qTUvrDX6y0k3nH6j7TJ4p93DK4v3vajZGLERQLCPIlaXq .Awl80tEoK._9Wi4KyvdjhSRKG_I3NqtWasEsdQ6A27tFBUR52hYma_6W7dR 5OlEnTDalAEVsv5YDaqV5SMi95Kf.7c9oemLAdfOziwk.120UxUoDeopyZUp Ot_rztEaHu1fpEekfO9_ABu4abcnRJZbaDsAw0vxFldxIUdONVakrd0Zb0tI AfXihZbQDoEY- Received: from [217.165.101.109] by web192604.mail.sg3.yahoo.com via HTTP; Sun, 17 Nov 2013 12:06:47 SGT X-Rocket-MIMEInfo: 002.001, SGkgTWFyaywNCg0KIEl0IHdhcyB0ZXN0ZWQgb24gRnJlZUJTRCA5LjIgYW5kIEZyZWVCU0QgMTAgQmV0YSAtIGkzODYuSSBkaWQgbm90IA0KdGVzdCBpdCBvbiBBTUQgNjQuDQoNClJlZ2FyZHMNClByYXNoYW50aA0KLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0NCk9uIFN1biwgMTcvMTEvMTMsIE1hcmsgSm9obnN0b24gPG1hcmtqQGZyZWVic2Qub3JnPiB3cm90ZToNCg0KIFN1YmplY3Q6IFJlOiBGdzogeW91ciBtYWlsDQogVG86ICJQcmFzaGFudGggS3VtYXIiIDxwcmFfdWQBMAEBAQE- X-Mailer: YahooMailClassic/365 YahooMailWebService/0.8.163.597 Message-ID: <1384661207.68304.YahooMailBasic@web192604.mail.sg3.yahoo.com> Date: Sun, 17 Nov 2013 12:06:47 +0800 (SGT) From: Prashanth Kumar Subject: Re: Fw: your mail To: Mark Johnston In-Reply-To: <20131117044801.GB64214@charmander> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Cc: "freebsd-dtrace@freebsd.org" X-BeenThere: freebsd-dtrace@freebsd.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "A discussion list for developers working on DTrace in FreeBSD." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Nov 2013 04:10:11 -0000 Hi Mark, It was tested on FreeBSD 9.2 and FreeBSD 10 Beta - i386.I did not=20 test it on AMD 64. Regards Prashanth -------------------------------------------- On Sun, 17/11/13, Mark Johnston wrote: Subject: Re: Fw: your mail To: "Prashanth Kumar" Cc: "freebsd-dtrace@freebsd.org" Date: Sunday, 17 November, 2013, 10:18 AM =20 On Tue, Nov 12, 2013 at 08:42:39PM +0800, Prashanth Kumar wrote: > Hi Mark >=20 > --------------------------------------- > /* scan.c */ >=20 > #include >=20 > int main() > { > =A0=A0=A0 int str[10]; >=20 > =A0=A0=A0 if (scanf("%s", str) > 0) > =A0=A0=A0 =A0=A0=A0 printf("name %s\n", str); >=20 > =A0=A0=A0 return 0; > } > ----------------------------- > > "dtrace -n 'pid$target:::entry' -c scanf" >=20 > if you run the above dtrace command on the program , dtrace will not exit and hung in input. =20 I can't reproduce that problem. If I use 'pid$target:::entry', dtrace(1) matches ~3000 probes and usually exits immediately with "processing aborted: No error". =20 If I instead use 'pid$target:ld-elf.so.*::entry', I get: =20 markj@charmander: ~/src/dtrace/tls $ sudo dtrace -n 'pid$target:ld-elf.so.*::entry' -c ./test dtrace: description 'pid$target:ld-elf.so.*::entry' matched 21 probes CPU=A0 =A0=A0=A0ID=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 FUNCTION:NAME =A0 2=A0 39804=A0 =A0 =A0 =A0 =A0 =A0=A0=A0__tls_get_addr:entry=20 mark name: mark dtrace: pid 75490 has exited =A0 2=A0 39804=A0 =A0 =A0 =A0 =A0 =A0=A0=A0__tls_get_addr:entry=20 =A0 2=A0 39804=A0 =A0 =A0 =A0 =A0 =A0=A0=A0__tls_get_addr:entry=20 =A0 2=A0 39804=A0 =A0 =A0 =A0 =A0 =A0=A0=A0__tls_get_addr:entry=20 =A0 2=A0 39804=A0 =A0 =A0 =A0 =A0 =A0=A0=A0__tls_get_addr:entry=20 =A0 2=A0 39804=A0 =A0 =A0 =A0 =A0 =A0=A0=A0__tls_get_addr:entry=20 =A0 2=A0 39804=A0 =A0 =A0 =A0 =A0 =A0=A0=A0__tls_get_addr:entry=20 =A0 2=A0 39786=A0 =A0 =A0 =A0 =A0 =A0 _rtld_addr_phdr:entry=20 =20 What version of FreeBSD are you using? Are you i386 or amd64? (I'm on amd64.) =20 -Mark From owner-freebsd-dtrace@FreeBSD.ORG Wed Nov 20 10:18:40 2013 Return-Path: Delivered-To: freebsd-dtrace@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id C5CDBE29 for ; Wed, 20 Nov 2013 10:18:40 +0000 (UTC) Received: from nm22-vm2.bullet.mail.sg3.yahoo.com (nm22-vm2.bullet.mail.sg3.yahoo.com [106.10.151.49]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 195A82E33 for ; Wed, 20 Nov 2013 10:18:39 +0000 (UTC) Received: from [106.10.166.115] by nm22.bullet.mail.sg3.yahoo.com with NNFMP; 20 Nov 2013 10:18:32 -0000 Received: from [106.10.151.154] by tm4.bullet.mail.sg3.yahoo.com with NNFMP; 20 Nov 2013 10:18:32 -0000 Received: from [127.0.0.1] by omp1008.mail.sg3.yahoo.com with NNFMP; 20 Nov 2013 10:18:32 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 373933.29686.bm@omp1008.mail.sg3.yahoo.com Received: (qmail 92258 invoked by uid 60001); 20 Nov 2013 10:18:32 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.in; s=s1024; t=1384942712; bh=CzdsLdSLtFBg6lWXJusNqKV3H+SeDnQHgaqlEyAv4Qc=; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:Message-ID:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=Rdav86U8R772CkVw0Aiii4yPYLpk60SbaDeMOy5O4F3eAQr5mBnNofJhyGSZ/T7fuE8FZh+/0/+3ATXv+qyAwuiyCAX2YUiXyHkZpxxjNySDVf7AAdrLs6ZTonLwPczS0G3w12FbkACR33FAkDlrxBIG1ZZIzYLtqKMVt1M3Zi4= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.co.in; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:Message-ID:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=ceOZyjtf+O154KEg1kyTobpSFtIyBLnie3UwuWvDQM0bJyq2TDzLVI0ujAGxS8snz/JatH38GY4J//UmBMLOu8JZIaPlg4nFrmG9N/JdMD3nvy2+d1OLHeCpvDyje6GV3SIgfsENBfij1RSmQ1c0BRNPZlKD+d9PZbD4QrDId9o=; X-YMail-OSG: gHBB.c0VM1l2m8EmaIkg6.ZMH42ItPcCfrLAV5ONCL4hUwL v10..Dp_zD7U4XyCGd8Yt3BFVSESI_2lQNRF2nGoWvdz.YWuZwf2P8GOgeE_ YcyEPgJRFdNwlYIQjLOFgmNA1L873TwmBrcJGfZydR1vZaoON8ao1HC.HINy V4kBvU9fKdWIETeWKLRaVBRbcqPIUwFe9X1z5bP7pPy4iAXCNgy94OryQ62M xwO9IpIzd5oIGSePnzs0NuqRIXPduPVyTk68wjNwKz5BdIOrjRLaaNiudDkw JBXyDpyAyYjLUe1qCDY1VA9DTGip8XAxw38otlYrNf1Y1MJ.Wo_YDVqzCr5l vVafFCbSkxHHTE2ReUGTSq1dvk0Audq.6Zywmhxt4PzeLoTGpw.Dpn33Y5CA M8GXmtgwz9V7vZTzt.pB37rWc0p3A.xX6lk24H1ZJEbaPb0JIAK.q2B.1562 exDY3mkN4x0m67kX96e4MhMH9yl24x1g9fRARAydyhUzSV_rONzuAGbvRLV_ zrIdqP1irihGbjDoVuASPtLaz9cEG7SelPg6TEIuEOYPZNyQD1BFL Received: from [217.165.101.109] by web192602.mail.sg3.yahoo.com via HTTP; Wed, 20 Nov 2013 18:18:31 SGT X-Rocket-MIMEInfo: 002.001, SXMgaXQgcG9zc2libGUgdG8gZW5hYmxlIGR0cmFjZSBhbm9ueW1vdXMgdHJhY2luZyBpbiBmcmVlYnNkPwEwAQEBAQ-- X-Mailer: YahooMailClassic/370 YahooMailWebService/0.8.166.601 Message-ID: <1384942711.92225.YahooMailBasic@web192602.mail.sg3.yahoo.com> Date: Wed, 20 Nov 2013 18:18:31 +0800 (SGT) From: Prashanth Kumar Subject: dtrace anonymous tracing To: freebsd-dtrace@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: freebsd-dtrace@freebsd.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "A discussion list for developers working on DTrace in FreeBSD." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Nov 2013 10:18:40 -0000 Is it possible to enable dtrace anonymous tracing in freebsd? From owner-freebsd-dtrace@FreeBSD.ORG Wed Nov 20 11:16:09 2013 Return-Path: Delivered-To: freebsd-dtrace@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 46A3F63D for ; Wed, 20 Nov 2013 11:16:09 +0000 (UTC) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id 7E2062236 for ; Wed, 20 Nov 2013 11:16:05 +0000 (UTC) Received: from porto.starpoint.kiev.ua (porto-e.starpoint.kiev.ua [212.40.38.100]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id NAA25328; Wed, 20 Nov 2013 13:15:59 +0200 (EET) (envelope-from avg@FreeBSD.org) Received: from localhost ([127.0.0.1]) by porto.starpoint.kiev.ua with esmtp (Exim 4.34 (FreeBSD)) id 1Vj5lH-000Onf-A4; Wed, 20 Nov 2013 13:15:59 +0200 Message-ID: <528C99B7.2040304@FreeBSD.org> Date: Wed, 20 Nov 2013 13:15:03 +0200 From: Andriy Gapon User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 MIME-Version: 1.0 To: Prashanth Kumar , freebsd-dtrace@FreeBSD.org Subject: Re: dtrace anonymous tracing References: <1384942711.92225.YahooMailBasic@web192602.mail.sg3.yahoo.com> In-Reply-To: <1384942711.92225.YahooMailBasic@web192602.mail.sg3.yahoo.com> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-dtrace@freebsd.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "A discussion list for developers working on DTrace in FreeBSD." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Nov 2013 11:16:09 -0000 on 20/11/2013 12:18 Prashanth Kumar said the following: > Is it possible to enable dtrace anonymous tracing in freebsd? > Not without some kernel coding, I believe :-) -- Andriy Gapon From owner-freebsd-dtrace@FreeBSD.ORG Thu Nov 21 11:55:19 2013 Return-Path: Delivered-To: freebsd-dtrace@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 75C77AA7 for ; Thu, 21 Nov 2013 11:55:19 +0000 (UTC) Received: from nm9-vm5.bullet.mail.sg3.yahoo.com (nm9-vm5.bullet.mail.sg3.yahoo.com [106.10.148.212]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id D48F8216E for ; Thu, 21 Nov 2013 11:54:57 +0000 (UTC) Received: from [106.10.166.62] by nm9.bullet.mail.sg3.yahoo.com with NNFMP; 21 Nov 2013 11:54:48 -0000 Received: from [106.10.151.203] by tm19.bullet.mail.sg3.yahoo.com with NNFMP; 21 Nov 2013 11:54:48 -0000 Received: from [127.0.0.1] by omp1015.mail.sg3.yahoo.com with NNFMP; 21 Nov 2013 11:54:48 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 748942.22125.bm@omp1015.mail.sg3.yahoo.com Received: (qmail 36947 invoked by uid 60001); 21 Nov 2013 11:54:48 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.in; s=s1024; t=1385034888; bh=IWYe84julJ3+fNq1u9X4ZsABnyZngd7od48CA8P9ZdU=; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:Message-ID:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=ql/9Z2mIFolAWlWjS/zITPAX8d/I2jxOlB7WGg+fykTSbGGTD/WgjjlfXCVbPs/6NTuiEYvCzSksPE0ioH/tgq+PBjAgsnlMBOzWDcRVBadKQ43LvaqitNFI2p5FGoGcFoh927QWQSRsHqmUb25DCRq7RRKeRhxyHNUP/KTlSqQ= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.co.in; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:Message-ID:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=mhahyjY2r6NS8rOEVkLKn5t8Ri9pN7g+orAT/TQCEHegnG+04SreFrfkp2Jca3VtbcVH1P9mZ0AeZ3iSqc9tPbJdQDzTDI7zvkMnQ27Q6Fr34MwbIM2NErjkNefjhWNGjfNzTg3GFb+p08ibnvsQDOOwxyEX854/cCEOqWJbhDc=; X-YMail-OSG: XffZ6KoVM1kuI59UUzJ6nJBLwUh4VjnlExLME1_AaCMbSyp o466SgJhQXrUpToH7qRY.BvV_gTysydIEqiYu8IcXmdy7nmndi283Hmj2jPr JMG4uuEIJwcwcrmKFV32eGHs.t8M1PzTN5a7KqKIEw6w7myYt2fvyElX_EAv VV2n3tUDZ4G7GDKjA1P5.kic.Ph49wBHw7kc4jC__X6lcSHVUxgqq1FTyE9p 06uFPRlSbNp4tjB.vJNT3x99ut1DBJOsSqpSgkXzAE9fCEc9OaUgbHeEteIZ sv8Gqx7yfquLSQQmG54uVZx9wXLYvKljxvxOtNIpWUwEj18aElEsmBotyY71 OK1FyzQ1I9Ac7nvOqjfm6QECwc_dY0AN9KrTaW5ETZl8nR0SPnFWAkrbD2Zt 58A4kZWdqc0B2S3kBlE7DY.tHl0Gh5Rru8Vyuhp6QRilSQmGN4xsKW6uFMwC 5mEacU1sdGsqVRZZfzPg_KTq7JzmAbYlL4pGxUM6ftG6y6l45dHXoZNDv8n7 ej9YVyyGowYYjsXXCemYaEESBnmocQdZ94fMH_OrOzivaVvRXF.pCKbKye52 bkmvTj8.Y1zU- Received: from [217.165.101.109] by web192603.mail.sg3.yahoo.com via HTTP; Thu, 21 Nov 2013 19:54:47 SGT X-Rocket-MIMEInfo: 002.001, TG9va3MgbGlrZSBjb2RlIGZvciBhbm9ueW1vdXMgdHJhY2luZyBpcyBhbHJlYWR5IHByZXNlbnQuIElmIHlvdSByZWFkIHRoZSAvYm9vdC9kdHJhY2UuZG9mDQpmaWxlIGZyb20gdGhlIGxvYWRlciBhbmQgc2V0IGl0IGFzIGEgZW52aXJvbm1lbnQgdmFyaWFibGUgaXQgd2lsbCB3b3JrLg0KSSB0ZXN0ZWQgaXQgd2l0aCB0aGUgZm9sbG93aW5nIHBhdGNoIGp1c3QgdG8gc2VlIHdoZXRoZXIgaXQgd291bGQgd29yay4NCg0KLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0BMAEBAQE- X-Mailer: YahooMailClassic/370 YahooMailWebService/0.8.166.601 Message-ID: <1385034887.36908.YahooMailBasic@web192603.mail.sg3.yahoo.com> Date: Thu, 21 Nov 2013 19:54:47 +0800 (SGT) From: Prashanth Kumar Subject: Re: dtrace anonymous tracing To: freebsd-dtrace@FreeBSD.org, Andriy Gapon In-Reply-To: <528C99B7.2040304@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: freebsd-dtrace@freebsd.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "A discussion list for developers working on DTrace in FreeBSD." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Nov 2013 11:55:19 -0000 Looks like code for anonymous tracing is already present. If you read the /= boot/dtrace.dof file from the loader and set it as a environment variable it will work. I tested it with the following patch just to see whether it would work. ---------------------------------------------------------------------------= --------------------------------------------- --- main.c=092013-11-21 12:03:57.000000000 +0400 +++ /usr/src/sys/boot/i386/loader/main.c=092013-11-21 12:44:23.000000000 +0= 400 @@ -84,6 +84,11 @@ main(void) { int=09=09=09i; + =20 + char *dtracedof =3D "/boot/dtrace.dof"; + int fd, n=3D0, l=3D0; + char *buf, *s, *e, c[32]; + struct stat dstat; =20 /* Pick up arguments */ kargs =3D (void *)__args; @@ -190,6 +195,40 @@ extract_currdev();=09=09=09=09/* set $currdev and $loaddev */ setenv("LINES", "24", 1);=09=09=09/* optional */ =20 + if ((fd =3D open(dtracedof, O_RDONLY)) =3D=3D -1)=20 +=09=09printf("Error opening dtrace file %s\n", dtracedof); + else if (fstat(fd, &dstat) =3D=3D -1)=20 +=09=09printf("Can't access %s\n", dtracedof); + else if ((buf =3D malloc(dstat.st_size+1)) =3D=3D NULL) + =09=09printf("Error allocating mem size %d - %s\n", dstat.st_size, dtr= acedof); + else if (read(fd, buf, dstat.st_size) < dstat.st_size) +=09=09printf("Error reading file %s size %d\n", dtracedof, dstat.st_size); + else { + =09for (i =3D 0; ; i++) { +=09 (void) sprintf(c, "dof-data-%d", i); +=09 l =3D strlen(c); +=09 if (strncmp(c, buf, l) !=3D 0) { +=09=09printf("Malformed name %s\n", c); +=09=09close(fd); +=09=09free(buf); +=09=09break; +=09 } + =09 s =3D e =3D &buf[l+1]; +=09 n +=3D l+1; +=09 while(*e !=3D '\n') +=09=09e++; +=09 *e =3D 0; +=09 //printf("string %s %s\n",c, s); +=09 setenv(c, s, 1); +=09 n +=3D e - s; +=09 n++; +=09 if (n < dstat.st_size)=20 +=09=09buf =3D ++e; +=09 else +=09=09break; +=09} + }=09 + =20 bios_getsmap(); =20 interact();=09=09=09/* doesn't return */ ---------------------------------------------------------------------------= -------------------------------------------------- Kernel environment variable value has to be in increased. In sys/kenv.h,=20 -------------------------------------------------------------------------- --- kenv.h=092013-11-21 14:31:50.000000000 +0400 +++ /usr/src/sys/sys/kenv.h=092013-11-21 14:32:05.000000000 +0400 @@ -38,6 +38,6 @@ #define KENV_DUMP=093 =20 #define KENV_MNAMELEN=09128=09/* Maximum name length (for the syscall) */ -#define KENV_MVALLEN=09128=09/* Maximum value length (for the syscall) */ +#define KENV_MVALLEN=093000=09/* Maximum value length (for the syscall) */ =20 #endif /* !_SYS_KENV_H_ */ ---------------------------------------------------------------------------= ------------------------------------- example : $> dtrace -A vboxguest $> reboot $>dtrace -a Probably be better to read dtrace.dof from dtrace module itself. regards Prashanth -------------------------------------------- On Wed, 20/11/13, Andriy Gapon wrote: Subject: Re: dtrace anonymous tracing To: "Prashanth Kumar" , freebsd-dtrace@FreeBSD.org Date: Wednesday, 20 November, 2013, 4:45 PM =20 on 20/11/2013 12:18 Prashanth Kumar said the following: > Is it possible to enable dtrace anonymous tracing in freebsd? >=20 =20 Not without some kernel coding, I believe :-) =20 --=20 Andriy Gapon