linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] block: use kmalloc alignment for bio slab
@ 2014-04-02 18:04 Mike Snitzer
  2014-04-07 18:15 ` Mike Snitzer
  0 siblings, 1 reply; 3+ messages in thread
From: Mike Snitzer @ 2014-04-02 18:04 UTC (permalink / raw)
  To: axboe; +Cc: linux-kernel, mpatocka, dm-devel

From: Mikulas Patocka <mpatocka@redhat.com>

Various subsystems can ask the bio subsystem to create a bio slab cache
with some free space before the bio.  This free space can be used for any
purpose.  Device mapper uses this per-bio-data feature to place some
target-specific and device-mapper specific data before the bio, so that
the target-specific data doesn't have to be allocated separately.

This per-bio-data mechanism is used in place of kmalloc, so we need the
allocated slab to have the same memory alignment as memory allocated
with kmalloc.

Change bio_find_or_create_slab() so that it uses ARCH_KMALLOC_MINALIGN
alignment when creating the slab cache.  This is needed so that dm-crypt
can use per-bio-data for encryption - the crypto subsystem assumes this
data will have the same alignment as kmalloc'ed memory.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
---
 fs/bio.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/bio.c b/fs/bio.c
index b2dd42e..6c94ba6 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -112,7 +112,8 @@ static struct kmem_cache *bio_find_or_create_slab(unsigned int extra_size)
 	bslab = &bio_slabs[entry];
 
 	snprintf(bslab->name, sizeof(bslab->name), "bio-%d", entry);
-	slab = kmem_cache_create(bslab->name, sz, 0, SLAB_HWCACHE_ALIGN, NULL);
+	slab = kmem_cache_create(bslab->name, sz, ARCH_KMALLOC_MINALIGN,
+				 SLAB_HWCACHE_ALIGN, NULL);
 	if (!slab)
 		goto out_unlock;
 
-- 
1.8.1.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: block: use kmalloc alignment for bio slab
  2014-04-02 18:04 [PATCH] block: use kmalloc alignment for bio slab Mike Snitzer
@ 2014-04-07 18:15 ` Mike Snitzer
  2014-04-07 18:16   ` Jens Axboe
  0 siblings, 1 reply; 3+ messages in thread
From: Mike Snitzer @ 2014-04-07 18:15 UTC (permalink / raw)
  To: axboe; +Cc: dm-devel, mpatocka, linux-kernel

On Wed, Apr 02 2014 at  2:04pm -0400,
Mike Snitzer <snitzer@redhat.com> wrote:

> From: Mikulas Patocka <mpatocka@redhat.com>
> 
> Various subsystems can ask the bio subsystem to create a bio slab cache
> with some free space before the bio.  This free space can be used for any
> purpose.  Device mapper uses this per-bio-data feature to place some
> target-specific and device-mapper specific data before the bio, so that
> the target-specific data doesn't have to be allocated separately.
> 
> This per-bio-data mechanism is used in place of kmalloc, so we need the
> allocated slab to have the same memory alignment as memory allocated
> with kmalloc.
> 
> Change bio_find_or_create_slab() so that it uses ARCH_KMALLOC_MINALIGN
> alignment when creating the slab cache.  This is needed so that dm-crypt
> can use per-bio-data for encryption - the crypto subsystem assumes this
> data will have the same alignment as kmalloc'ed memory.
> 
> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
> Signed-off-by: Mike Snitzer <snitzer@redhat.com>

Hey Jens,

Just wanted to give you a heads up that I staged this patch in
linux-dm.git's 'for-next', here:
https://git.kernel.org/cgit/linux/kernel/git/device-mapper/linux-dm.git/commit/?h=for-next&id=cd433c25f43eb054f62b7b48f1d0349f65b1740c

I rebased it to add this yesterday:
Acked-by: Jens Axboe <axboe@fb.com> # via private exchange on facebook

I put this in place because there is a chance I'll still be sending the
improved dm-crypt parallelization patches to Linus for 3.15 this week.
So having this go through linux-dm.git saves the awkward coordination
where otherwise DM would be depending on the block tree.

You OK with this?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: block: use kmalloc alignment for bio slab
  2014-04-07 18:15 ` Mike Snitzer
@ 2014-04-07 18:16   ` Jens Axboe
  0 siblings, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2014-04-07 18:16 UTC (permalink / raw)
  To: Mike Snitzer; +Cc: dm-devel, mpatocka, linux-kernel

On 04/07/2014 12:15 PM, Mike Snitzer wrote:
> On Wed, Apr 02 2014 at  2:04pm -0400,
> Mike Snitzer <snitzer@redhat.com> wrote:
>
>> From: Mikulas Patocka <mpatocka@redhat.com>
>>
>> Various subsystems can ask the bio subsystem to create a bio slab cache
>> with some free space before the bio.  This free space can be used for any
>> purpose.  Device mapper uses this per-bio-data feature to place some
>> target-specific and device-mapper specific data before the bio, so that
>> the target-specific data doesn't have to be allocated separately.
>>
>> This per-bio-data mechanism is used in place of kmalloc, so we need the
>> allocated slab to have the same memory alignment as memory allocated
>> with kmalloc.
>>
>> Change bio_find_or_create_slab() so that it uses ARCH_KMALLOC_MINALIGN
>> alignment when creating the slab cache.  This is needed so that dm-crypt
>> can use per-bio-data for encryption - the crypto subsystem assumes this
>> data will have the same alignment as kmalloc'ed memory.
>>
>> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
>> Signed-off-by: Mike Snitzer <snitzer@redhat.com>
>
> Hey Jens,
>
> Just wanted to give you a heads up that I staged this patch in
> linux-dm.git's 'for-next', here:
> https://urldefense.proofpoint.com/v1/url?u=https://git.kernel.org/cgit/linux/kernel/git/device-mapper/linux-dm.git/commit/?h%3Dfor-next%26id%3Dcd433c25f43eb054f62b7b48f1d0349f65b1740c&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=3JMVyziIyZtZ5cv9eWNLwQ%3D%3D%0A&m=yu%2BvHiMLQp0QZVW7KCcxC6XDci1OzHP9ymRaDDIROdk%3D%0A&s=7ac8f47451490f80d8bacbef2487bfa43c0d7c9a1c968558010f06f92e20caca
>
> I rebased it to add this yesterday:
> Acked-by: Jens Axboe <axboe@fb.com> # via private exchange on facebook
>
> I put this in place because there is a chance I'll still be sending the
> improved dm-crypt parallelization patches to Linus for 3.15 this week.
> So having this go through linux-dm.git saves the awkward coordination
> where otherwise DM would be depending on the block tree.
>
> You OK with this?

Yeah, that's fine.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-04-07 18:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-02 18:04 [PATCH] block: use kmalloc alignment for bio slab Mike Snitzer
2014-04-07 18:15 ` Mike Snitzer
2014-04-07 18:16   ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).