From owner-freebsd-hackers@freebsd.org Tue Apr 11 13:42:46 2017 Return-Path: Delivered-To: freebsd-hackers@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 207B6D39747 for ; Tue, 11 Apr 2017 13:42:46 +0000 (UTC) (envelope-from freebsd-listen@fabiankeil.de) Received: from smtprelay01.ispgateway.de (smtprelay01.ispgateway.de [80.67.31.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DE130C65 for ; Tue, 11 Apr 2017 13:42:45 +0000 (UTC) (envelope-from freebsd-listen@fabiankeil.de) Received: from [78.35.167.42] (helo=fabiankeil.de) by smtprelay01.ispgateway.de with esmtpsa (TLSv1.2:AES256-GCM-SHA384:256) (Exim 4.84) (envelope-from ) id 1cxvfK-0001wT-NY; Tue, 11 Apr 2017 15:17:02 +0200 Date: Tue, 11 Apr 2017 15:14:26 +0200 From: Fabian Keil To: Christopher Bowman Cc: freebsd-hackers@freebsd.org Subject: Re: Dtrace oddity Message-ID: <20170411151426.3b760182@fabiankeil.de> In-Reply-To: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; boundary="Sig_/Wjcw_RzPb68pzBvBRYkVM4L"; protocol="application/pgp-signature" X-Df-Sender: Nzc1MDY3 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Apr 2017 13:42:46 -0000 --Sig_/Wjcw_RzPb68pzBvBRYkVM4L Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Christopher Bowman wrote: > The man page lists a bunch of reasons for EINVAL so I want to > investigate this and I don=E2=80=99t quite know good strategies to debug = the > kernel (yet) so I thought I=E2=80=99d experiment with Dtrace a bit. Here= is the > oddity: when I run Dtrace and then run my test program I get the > following output from Dtrace: >=20 > crb@retread:60> dtrace -n 'syscall:freebsd:mmap:entry /execname =3D=3D "t= est"/ {}' > dtrace: description 'syscall:freebsd:mmap:entry ' matched 1 > probe CPU ID FUNCTION:NAME > 0 63401 mmap:entry=20 > 0 63401 mmap:entry=20 > 0 63401 mmap:entry=20 > 0 63401 mmap:entry=20 > 0 63401 mmap:entry=20 > 0 63401 mmap:entry=20 > 0 63401 mmap:entry=20 > 0 63401 mmap:entry=20 > 0 63401 mmap:entry=20 > 0 63401 mmap:entry=20 > 0 63401 mmap:entry=20 > 0 63401 mmap:entry=20 >=20 > I think Dtrace is indicating that the mmap syscall was called 12 times > by my test program yet I can see how the program below would have done > that. A bunch of mmap syscalls occur before main is even entered. Try running your program with truss to see what's going on. > Here is my program: [...] > printf("opening device %s\n", argv[1]); > int device =3D open (argv[1], O_RDWR); > if (device =3D=3D 0) { You should check for -1 here. > void *pa =3D mmap (0, 4095, PROT_READ | PROT_WRITE, 0, device, 0); No flags? From the mmap man page: | [EINVAL] None of MAP_ANON, MAP_PRIVATE, MAP_SHARED, or | MAP_STACK was specified. At least one of these fl= ags | must be included. Fabian --Sig_/Wjcw_RzPb68pzBvBRYkVM4L Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iF0EARECAB0WIQTKUNd6H/m3+ByGULIFiohV/3dUnQUCWOzWswAKCRAFiohV/3dU naR9AKC88uaGiPliml1AEINPpCMkoYMAWQCfSPsCr/Gj/fo9J+0zFGmy+EYYvXU= =JFvI -----END PGP SIGNATURE----- --Sig_/Wjcw_RzPb68pzBvBRYkVM4L--