Re: Bulk kmalloc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, May 10, 2019 at 05:23:23PM +0100, David Howells wrote:
> Jesper Dangaard Brouer <brouer@xxxxxxxxxx> wrote:
> > What is you use case?
> 
> afs_do_lookup() allocates an array of file status records and an array of
> callback records:
> 
> 	/* Need space for examining all the selected files */
> 	inode = ERR_PTR(-ENOMEM);
> 	cookie->statuses = kcalloc(cookie->nr_fids, sizeof(struct afs_file_status),
> 				   GFP_KERNEL);
> 	if (!cookie->statuses)
> 		goto out;
> 
> 	cookie->callbacks = kcalloc(cookie->nr_fids, sizeof(struct afs_callback),
> 				    GFP_KERNEL);
> 	if (!cookie->callbacks)
> 		goto out_s;
> 
> These, however, may go to order-1 allocations or higher if nr_fids > 39, say,
> and it may be as many as 50 for AFS3 or 1024 for YFS.

kvmalloc() is the normal solution here.  Usual reasons for not being
able to do that would be that you do DMA to the memory or that you need
to be able to free each of these objects individually.

> Also, I'd like to combine the afs_file_status record with the afs_callback
> record inside another struct so that I can pass these around in more places
> and fix the locking over applying them to the relevant inodes.
> 
> So what I want to do is to allocate an array of pointers to {status,callback}
> records and then bulk allocate those records.  As it happens, the tuple is
> just shy of 128 bytes, so they should fit into that slab very nicely.
> 
> Note also that the records are transient - they're freed at the end of the
> operation.

sounds like you free them all together?




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux