lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20100115233820.GF10591@ovro.caltech.edu>
Date:	Fri, 15 Jan 2010 15:38:20 -0800
From:	"Ira W. Snyder" <iws@...o.caltech.edu>
To:	Stefani Seibold <stefani@...bold.net>
Cc:	linux-kernel <linux-kernel@...r.kernel.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Andi Kleen <andi@...stfloor.org>,
	Greg Kroah-Hartman <gregkh@...e.de>,
	Alan Cox <alan@...rguk.ukuu.org.uk>,
	Theodore Tso <tytso@....edu>,
	Jens Axboe <jens.axboe@...cle.com>
Subject: Re: [PATCH] enhanced reimplemented of the kfifo API

On Fri, Jan 15, 2010 at 11:05:07PM +0100, Stefani Seibold wrote:
> Am Freitag, den 15.01.2010, 14:01 -0800 schrieb Ira W. Snyder:
> > On Fri, Jan 15, 2010 at 10:30:01PM +0100, Stefani Seibold wrote:
> > > 
> > > > I'm glad to see this example, it really illustrates how to use the new
> > > > DMA functionality of the kfifo API.
> > > > 
> > > > Is there any reason why a very large scatterlist could not be used? I
> > > > have a driver that uses a large scatterlist (~4000 entries, allocated as
> > > > a struct sg_table). I implemented my own copy_from_user() functionality
> > > > into this scatterlist, but I'd love to use the kfifo DMA API instead.
> > > > After filling the scatterlist, I use the usual DMA API's to transfer it
> > > > to my device.
> > > > 
> > > 
> > > No, but the API will only return max. two entries.
> > > 
> > 
> > Ah, I see. __kfifo_alloc() uses kmalloc() internally. The kfifo API will
> > not work for my purposes then, since I want to allocate a 16MB chunk of
> > memory, and I'm very uncomfortable doing that with kmalloc(). I'll stick
> > with my custom scatterlist code, which uses alloc_page() to fill in the
> > scatterlist with order-0 allocations.
> > 
> 
> I think you can use vmalloc() instead and assign this buffer with
> kfifo_init().
> 

Yes, that might be an option. I presume I could still use dma_map_sg()
on the resulting scatterlist.

> > Another nitpick in the code: I've noticed that you use sgl++ in the
> > setup_sgl() function. That should become "sgl = sg_next(sgl);" so that
> > this code can work with an struct sg_table as well.
> 
> No, its by definition an array. You cannot pass as struct sg_table to
> the kfifo_dma_* functions.
> 

A struct sg_table is a container for an underlying chain of struct
scatterlists, allowing for easier allocation. See the definition of
struct sg_table and the sgl member (include/linux/scatterlist.h line
11).

IIRC, struct sg_table allocates arrays of struct scatterlist in
PAGE_SIZE chunks, and chains them together.

If you change from "sg++" to "sg_next()", you should be able to work
with chained scatterlists. You can only have a single struct page * in
one struct scatterlist. This would mean that if I tried to use
kfifo_dma_out_prepare() to give me 16MB worth of data, I would need 4096
seperate struct scatterlist entries. One for each struct page * in that
16MB chunk.

Jens, you added a lot of the scatterlist chaining code. Can you comment
on this? I don't claim to be a scatterlist expert :)

Ira
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ