From owner-freebsd-net@freebsd.org Thu Jul 30 00:54:56 2015 Return-Path: Delivered-To: freebsd-net@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 06C2A9A670C for ; Thu, 30 Jul 2015 00:54:56 +0000 (UTC) (envelope-from laurie_jennings_1977@yahoo.com) Received: from nm35-vm7.bullet.mail.bf1.yahoo.com (nm35-vm7.bullet.mail.bf1.yahoo.com [72.30.238.79]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9F9BC307 for ; Thu, 30 Jul 2015 00:54:55 +0000 (UTC) (envelope-from laurie_jennings_1977@yahoo.com) Received: from [66.196.81.170] by nm35.bullet.mail.bf1.yahoo.com with NNFMP; 30 Jul 2015 00:52:22 -0000 Received: from [98.139.212.245] by tm16.bullet.mail.bf1.yahoo.com with NNFMP; 30 Jul 2015 00:52:22 -0000 Received: from [127.0.0.1] by omp1054.mail.bf1.yahoo.com with NNFMP; 30 Jul 2015 00:52:22 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 367778.81800.bm@omp1054.mail.bf1.yahoo.com Received: (qmail 51804 invoked by uid 60001); 30 Jul 2015 00:52:22 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1438217542; bh=YBuVA3XLUYHWbAqvU0LA81bBXlnztyyt4qQzZd4CI4c=; h=Message-ID:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=12RU2SUn/8tntUkn89JSmN2N2kfyQLEaApN8lWBALtNHcWVTmL92zrj0Sr2IQG5Ndqeoicgrfdb5hi2AIgmWOYP8pdrxtSkibt6MIXksE1xrz4ojtE/RAUI4pzou+UAn5AdjXqGPG96+8rz4w2VdZRzpx1ZWBKpmcInOxVGvyq4= X-YMail-OSG: 6gBS41AVM1lhUNxsbxbXZFgRacqhYs2iS7Wgdas8X.n8irj OTGKtNYeXAophdeiYVoJ.SUsW.3KrtBijhOkucQ.GdQOQutLBMQYrjeyj5Zl OfAifkNpqROcugIRZ2WPv1FaWPlye3twvNilJxG.RG2xv7pYXQ5yqoC45xt7 mcwLjZsrCYjS7qx83_6UFu84cnwCbZ.pUdNXhctX3RwZA_LDpviY1lXsEdbw aGSaDOe48158.C6c7HoM382YLFKiwQfWjlNXMr4098pdF6QFLOOVvvXNVXfW fO0JmXQN6FnFBuSyRGX2E_KH8rvHUey3tnhB7hPtP7VT4UtbYVgDGD6hF4MT AWFGFEa1iu1J8PkqVOjMtJpAqH4jdyZIU3ULz7_CHjxtvTqJJ0wF.BeWUCb7 0jUrzItsx5Cs1cpEEyWOODYxmh82LNVyy38JDOWuBEPYvXD3n9ycq3XQ6Xov mY7rxBkwO4IYh.4xm1Lk9RpEhEzkzxaQ.vDAFpbHAvfZyhfMH4ctf90fJaJD UJV1mKd5tTqJOK5DlkLeEB1eHboYLPA_880TVsxMoBoCuzzNj.B1DGRE0qw- - Received: from [73.0.96.254] by web141502.mail.bf1.yahoo.com via HTTP; Wed, 29 Jul 2015 17:52:22 PDT X-Rocket-MIMEInfo: 002.001, DQotLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLQ0KT24gV2VkLCA3LzI5LzE1LCBKb2huLU1hcmsgR3VybmV5IDxqbWdAZnVua3RoYXQuY29tPiB3cm90ZToNCg0KIFN1YmplY3Q6IFJlOiBMb2NraW5nIE1lbW9yeSBRdWVzdGlvbg0KIFRvOiAiTGF1cmllIEplbm5pbmdzIiA8bGF1cmllX2plbm5pbmdzXzE5NzdAeWFob28uY29tPg0KIENjOiAiSm9obiBCYWxkd2luIiA8amhiQGZyZWVic2Qub3JnPiwgZnJlZWJzZC1uZXRAZnJlZWJzZC5vcmcNCiBEYXRlOiBXZWRuZXNkYXksIEoBMAEBAQE- X-Mailer: YahooMailBasic/600 YahooMailWebService/0.8.203.802 Message-ID: <1438217542.41867.YahooMailBasic@web141502.mail.bf1.yahoo.com> Date: Wed, 29 Jul 2015 17:52:22 -0700 From: Laurie Jennings Subject: Re: Locking Memory Question To: John-Mark Gurney Cc: John Baldwin , freebsd-net@freebsd.org In-Reply-To: <20150729232522.GN78154@funkthat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Jul 2015 00:54:56 -0000 -------------------------------------------- On Wed, 7/29/15, John-Mark Gurney wrote: Subject: Re: Locking Memory Question To: "Laurie Jennings" Cc: "John Baldwin" , freebsd-net@freebsd.org Date: Wednesday, July 29, 2015, 7:25 PM =20 Laurie Jennings via freebsd-net wrote this message on Wed, Jul 29, 2015 at 15:26 -0700: >=20 > I have a problem and I can't quite figure out where to look. This is what Im doing: >=20 > I have an IOCTL to read a block of data, but the data is too large to return via ioctl. So to get the data, > I allocate a block in a kernel module: > =20 > foo =3D malloc(1024000,M_DEVBUF,M_WAITOK); >=20 >=A0 I pass up a pointer and in user space map it using /dev/kmem: =20 An easier solution would be for your ioctl to pass in a userland pointer and then use copyout(9) to push the data to userland...=A0 This means the userland process doesn't have to have /dev/kmem access... =20 Is there a reason you need to use kmem?=A0 The only reason you list above is that it's too large via ioctl, but a copyout is fine, and would handle all page faults for you.. =20 __________________________________ I'm using kmem because the only options I could think of was to 1) use shared memory 2) use kmem 3) use a huge ioctl structure. Im not clear how I'd do that. the data being passed up from the kernel is a= variable size. To use copyout I'd have to pass a pointer with a static buffer, right? Is there a way to malloc user space me= mory from within an ioctl call? Or would I just have to pass down a pointer to a huge buffer large enough for = the largest possible answer? thanks Laurie