Introduce the request handling for dm-crypt
Subsystems (3)
cover Introduce the request handling for dm-crypt
Now the dm-crypt code only implemented the 'based-bio' method to encrypt/ decrypt block data, which can only hanle one bio at one time. As we know, one bio must use the sequential physical address and it also has a limitation of length. Thus it may limit the big block encyrtion/decryption when some hardware support the big block data encryption.
This patch series introduc the 'based-request' method to handle the data encryption/decryption. One request can contain multiple bios, so it can handle big block data to improve the efficiency.
Also this patch refers to the Dinesh K Garg <[email protected]> and franciscofranco <[email protected]> submission of 'Request based dm-crypt', and the original link is:
https://github.com/major91/Zeta-Chromium-N5/commit/621d4821da04cfde383329ebdf4ce8711ec3329c
Now it can encrypt/decrypt successfully with read/write testing, and it shows some efficiency improvements with hardware acceleration. But I really hope to need more comments about the structure and conception. Thanks for your review.
Baolin Wang (2):
block: Introduce BIO_ENDIO_FREE for bio flags
md: dm-crypt: Introduce the request handling for dm-crypt
block/blk-core.c | 6 +- drivers/md/Kconfig | 6 + drivers/md/dm-crypt.c | 831 ++++++++++++++++++++++++++++++++++++++++- drivers/md/dm.c | 13 +- include/linux/blk_types.h | 6 + include/linux/device-mapper.h | 5 + 6 files changed, 861 insertions(+), 6 deletions(-)
Signature · 1 line
1.7.9.5
PATCH 1/2 block: Introduce BIO_ENDIO_FREE for bio flags
When we use dm-crypt to decrypt block data, it will decrypt the block data in endio() when one IO is completed. In this situation we don't want the cloned bios is freed before calling the endio().
Thus introduce 'BIO_ENDIO_FREE' flag to support the request handling for dm-crypt, this flag will ensure that blk layer does not complete the cloned bios before completing the request. When the crypt endio is called, post-processsing is done and then the dm layer will complete the bios (clones) and free them.
--- block/blk-core.c | 6 +++++- drivers/md/dm.c | 13 ++++++++++--- include/linux/blk_types.h | 6 ++++++ include/linux/device-mapper.h | 5 +++++ 4 files changed, 26 insertions(+), 4 deletions(-)
block/blk-core.c +5 -1
@@ -1411,7 +1411,7 @@ void __blk_put_request(struct request_queue *q, struct request *req)elv_completed_request (q, req);/* this is a bio leak */ -WARN_ON (req->bio !=NULL ); +WARN_ON (req->bio !=NULL && !bio_flagged (req->bio,BIO_ENDIO_FREE ));/* * Request may not have originated from ll_rw_blk. if not,
@@ -2521,6 +2521,10 @@ bool blk_update_request(struct request *req, int error, unsigned int nr_bytes)blk_account_io_completion (req, nr_bytes); total_bytes =0 ; + +if (bio_flagged (req->bio,BIO_ENDIO_FREE )) +return false; +while (req->bio) {struct bio *bio = req->bio;unsigned bio_bytes =min (bio->bi_iter.bi_size, nr_bytes);
drivers/md/dm.c +10 -3
@@ -1047,6 +1047,13 @@ static struct dm_rq_target_io *tio_from_request(struct request *rq)return (rq->q->mq_ops ?blk_mq_rq_to_pdu (rq) : rq->special); } +struct request *dm_get_orig_rq (struct request *clone) +{ +struct dm_rq_target_io *tio = clone->end_io_data; + +return tio->orig; +} +static void rq_end_stats (struct mapped_device *md,struct request *orig) {if (unlikely (dm_stats_used (&md->stats))) {
@@ -1118,7 +1125,7 @@ static void free_rq_clone(struct request *clone)* Must be called without clone's queue lock held, * see end_clone_request() for more details. */ -static void dm_end_request (struct request *clone,int error) +void dm_end_request (struct request *clone,int error) {int rw =rq_data_dir (clone);struct dm_rq_target_io *tio = clone->end_io_data;
@@ -1311,7 +1318,7 @@ static void dm_complete_request(struct request *rq, int error)* Target's rq_end_io() function isn't called. * This may be used when the target's map_rq() or clone_and_map_rq() functions fail. */ -static void dm_kill_unmapped_request (struct request *rq,int error) +void dm_kill_unmapped_request (struct request *rq,int error) { rq->cmd_flags |=REQ_FAILED ;dm_complete_request (rq, error);
@@ -1758,7 +1765,7 @@ int dm_request_based(struct mapped_device *md)return blk_queue_stackable (md->queue); } -static void dm_dispatch_clone_request (struct request *clone,struct request *rq) +void dm_dispatch_clone_request (struct request *clone,struct request *rq) {int r;
include/linux/blk_types.h +6 -0
@@ -122,6 +122,12 @@ struct bio {#define BIO_REFFED 8/* bio has elevated ->bi_cnt */ /* +* Added for Req based dm which need to perform post processing. This flag +* ensures blk_update_request does not free the bios or request, this is done +* at the dm level. +*/ +#define BIO_ENDIO_FREE 12 +/* * Flags starting here get preserved by bio_reset() - this includes * BIO_POOL_IDX() */
include/linux/device-mapper.h +5 -0
@@ -407,6 +407,11 @@ union map_info *dm_get_rq_mapinfo(struct request *rq);struct queue_limits *dm_get_queue_limits (struct mapped_device *md); +void dm_end_request (struct request *clone,int error); +void dm_kill_unmapped_request (struct request *rq,int error); +void dm_dispatch_clone_request (struct request *clone,struct request *rq); +struct request *dm_get_orig_rq (struct request *clone); +/* * Geometry functions. */
Signature · 1 line
1.7.9.5
Re: [PATCH 1/2] block: Introduce BIO_ENDIO_FREE for bio flags
Quoted 8 lines · Baolin Wang
When we use dm-crypt to decrypt block data, it will decrypt the block data in
endio()when one IO is completed. In this situation we don't want the cloned bios is freed before calling theendio().Thus introduce '
BIO_ENDIO_FREE' flag to support the request handling for dm-crypt, this flag will ensure that blk layer does not complete the cloned bios before completing the request. When the crypt endio is called, post-processsing is done and then the dm layer will complete the bios (clones) and free them.
Not following why request-based DM's partial completion handling (drivers/md/dm.c:end_clone_bio) isn't a sufficient hook -- no need to add block complexity.
But that aside, I'm not liking the idea of a request-based dm-crypt.
Quoted 6 lines
include/linux/device-mapper.h +0
-0@@ -407,6 +407,11 @@ union map_info *dm_get_rq_mapinfo(struct request *rq);
include/linux/device-mapper.h union map_info *dm_get_rq_mapinfo(struct request *rq); · line 417
Quoted 10 lines
include/linux/device-mapper.h +5
-0struct queue_limits *dm_get_queue_limits (struct mapped_device *md); +void dm_end_request (struct request *clone,int error); +void dm_kill_unmapped_request (struct request *rq,int error); +void dm_dispatch_clone_request (struct request *clone,struct request *rq); +struct request *dm_get_orig_rq (struct request *clone); +/* * Geometry functions. */
I have no interest in seeing any request-based DM interfaces exported.
Re: [PATCH 1/2] block: Introduce BIO_ENDIO_FREE for bio flags
Quoted 7 lines · Mike Snitzer
Quoted 4 lines · Baolin Wang
When we use dm-crypt to decrypt block data, it will decrypt the block data in
endio()when one IO is completed. In this situation we don't want the cloned bios is freed before calling theendio().
Quoted 9 lines
Quoted 4 lines
Thus introduce '
BIO_ENDIO_FREE' flag to support the request handling for dm-crypt, this flag will ensure that blk layer does not complete the cloned bios before completing the request. When the crypt endio is called, post-processsing is done and then the dm layer will complete the bios (clones) and free them.Not following why request-based DM's partial completion handling (drivers/md/dm.c:end_clone_bio) isn't a sufficient hook -- no need to add block complexity.
Sorry for lacking of more explanation for that. The dm-crypt will decrypt block data in the end_io() callback function when one request is completed, so we don't want the bios of this request is freed when calling the end_io() callback. Thus we introduce a flag to indicate these type bios of this request will be freed at dm layer not in block layer.
Quoted 10 lines
But that aside, I'm not liking the idea of a request-based dm-crypt.
Quoted 8 lines
include/linux/device-mapper.h +0
-0@@ -407,6 +407,11 @@ union map_info *dm_get_rq_mapinfo(struct request *rq);struct queue_limits *dm_get_queue_limits (struct mapped_device *md);
Quoted 10 lines
include/linux/device-mapper.h union map_info *dm_get_rq_mapinfo(struct request *rq); · line 417
Quoted 8 lines
include/linux/device-mapper.h +5
-0+void dm_end_request (struct request *clone,int error); +void dm_kill_unmapped_request (struct request *rq,int error); +void dm_dispatch_clone_request (struct request *clone,struct request *rq); +struct request *dm_get_orig_rq (struct request *clone); +/* * Geometry functions. */ I have no interest in seeing any request-based DM interfaces exported.
OK.
Signature · 2 lines
Baolin.wang Best Regards
PATCH 2/2 md: dm-crypt: Introduce the request handling for dm-crypt
In reply to Baolin WangSome hardware can support big block data encrytion, the original dm-crypt only implemented the 'based-bio' things that will limit the efficiency (only handle one bio at one time) for the big block data encryption.
This patch introduces the 'based-request' method to handle the big block, which it can contain more than one bio at one time for dm-drypt. Now we use a config macro to enable the 'based-request' method and to ensure the original code can be run successfully.
--- drivers/md/Kconfig | 6 + drivers/md/dm-crypt.c | 831 ++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 835 insertions(+), 2 deletions(-)
drivers/md/Kconfig +6 -0
@@ -266,6 +266,12 @@ config DM_CRYPT If unsure, say N. +config DM_REQ_CRYPT + bool "Crypt target support with request" + depends on BLK_DEV_DM + select CRYPTO + select CRYPTO_CBC + config DM_SNAPSHOT tristate "Snapshot target" depends on BLK_DEV_DM
drivers/md/dm-crypt.c +829 -2
901 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Quoted 9 lines · Baolin Wang
Now the dm-crypt code only implemented the 'based-bio' method to encrypt/ decrypt block data, which can only hanle one bio at one time. As we know, one bio must use the sequential physical address and it also has a limitation of length. Thus it may limit the big block encyrtion/decryption when some hardware support the big block data encryption.
This patch series introduc the 'based-request' method to handle the data encryption/decryption. One request can contain multiple bios, so it can handle big block data to improve the efficiency.
NAK for more request based stacking or DM drivers. They are a major pain to deal with, and adding more with different requirements then dm-multipath is not helping in actually making that one work properly.
Quoted 7 lines · Christoph Hellwig
Quoted 6 lines · Baolin Wang
Now the dm-crypt code only implemented the 'based-bio' method to encrypt/ decrypt block data, which can only hanle one bio at one time. As we know, one bio must use the sequential physical address and it also has a limitation of length. Thus it may limit the big block encyrtion/decryption when some hardware support the big block data encryption.
Quoted 7 lines
Quoted 3 lines
This patch series introduc the 'based-request' method to handle the data encryption/decryption. One request can contain multiple bios, so it can handle big block data to improve the efficiency.
NAK for more request based stacking or DM drivers. They are a major pain to deal with, and adding more with different requirements then dm-multipath is not helping in actually making that one work properly.
But now many vendors supply the hardware engine to handle the encyrtion/decryption. The hardware really need a big block to indicate its performance with request based things. Another thing is now the request based things is used by many vendors (Qualcomm, Spreadtrum and so on) to improve their performance and there's a real performance requirement here (I can show the performance result later).
I don't think you will worry if any one can work properly, we will remove the bio based things in future if the request things are accepted and proved effectively. Thanks for your comment.
Signature · 2 lines
Baolin.wang Best Regards
Quoted 16 lines · Baolin Wang
Quoted 7 lines · Christoph Hellwig
Quoted 6 lines · Baolin Wang
Now the dm-crypt code only implemented the 'based-bio' method to encrypt/ decrypt block data, which can only hanle one bio at one time. As we know, one bio must use the sequential physical address and it also has a limitation of length. Thus it may limit the big block encyrtion/decryption when some hardware support the big block data encryption.
Quoted 7 lines
Quoted 3 lines
This patch series introduc the 'based-request' method to handle the data encryption/decryption. One request can contain multiple bios, so it can handle big block data to improve the efficiency.
NAK for more request based stacking or DM drivers. They are a major pain to deal with, and adding more with different requirements then dm-multipath is not helping in actually making that one work properly.
Quoted 6 lines
But now many vendors supply the hardware engine to handle the encyrtion/decryption. The hardware really need a big block to indicate its performance with request based things. Another thing is now the request based things is used by many vendors (Qualcomm, Spreadtrum and so on) to improve their performance and there's a real performance requirement here (I can show the performance result later).
So you've mentioned several times that hardware needs big blocks. How big those blocks need to be? Ideally, can you give some numbers on how the throughput of the encryption hw grows with the block size?
Because as Mike had said there are downsides to having request based dm-crypt as well. E.g. if you want to have encrypted raid5 volume then you'd rather want to put encryption on top of raid5 (easier management, larger sequential blocks to encrypt, ...) but you cannot do that when dm-crypt would be request based. So modifying bio-based dm-crypt to form larger chunks for encryption HW would be superior in this regard.
You mentioned that you use requests because of size limitations on bios - I had a look and current struct bio can easily describe 1MB requests (that's assuming 64-bit architecture, 4KB pages) when we have 1 page worth of struct bio_vec. Is that not enough?
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Quoted 24 lines · Jan Kara
Quoted 16 lines · Baolin Wang
Quoted 7 lines · Christoph Hellwig
Quoted 6 lines · Baolin Wang
Now the dm-crypt code only implemented the 'based-bio' method to encrypt/ decrypt block data, which can only hanle one bio at one time. As we know, one bio must use the sequential physical address and it also has a limitation of length. Thus it may limit the big block encyrtion/decryption when some hardware support the big block data encryption.
Quoted 7 lines
Quoted 3 lines
This patch series introduc the 'based-request' method to handle the data encryption/decryption. One request can contain multiple bios, so it can handle big block data to improve the efficiency.
NAK for more request based stacking or DM drivers. They are a major pain to deal with, and adding more with different requirements then dm-multipath is not helping in actually making that one work properly.
Quoted 6 lines
But now many vendors supply the hardware engine to handle the encyrtion/decryption. The hardware really need a big block to indicate its performance with request based things. Another thing is now the request based things is used by many vendors (Qualcomm, Spreadtrum and so on) to improve their performance and there's a real performance requirement here (I can show the performance result later).
Quoted 3 lines
So you've mentioned several times that hardware needs big blocks. How big those blocks need to be? Ideally, can you give some numbers on how the throughput of the encryption hw grows with the block size?
It depends on the hardware design. My beaglebone black board's AES engine can handle 1M at one time which is not big. As I know some other AES engine can handle 16M data at one time or more.
Quoted 8 lines
Because as Mike had said there are downsides to having request based dm-crypt as well. E.g. if you want to have encrypted raid5 volume then you'd rather want to put encryption on top of raid5 (easier management, larger sequential blocks to encrypt, ...) but you cannot do that when dm-crypt would be request based. So modifying bio-based dm-crypt to form larger chunks for encryption HW would be superior in this regard.
Make sense.
Quoted 4 lines
You mentioned that you use requests because of size limitations on bios - I had a look and current struct bio can easily describe 1MB requests (that's assuming 64-bit architecture, 4KB pages) when we have 1 page worth of struct
bio_vec. Is that not enough?
Usually one bio does not always use the full 1M, maybe some 1k/2k/8k or some other small chunks. But request can combine some sequential small bios to be a big block and it is better than bio at least.
Quoted 5 lines
Honza
--
Jan Kara <[email protected]>
SUSE Labs, CR
Signature · 2 lines
Baolin.wang Best Regards
Quoted 25 lines · Baolin Wang
Quoted 24 lines · Jan Kara
Quoted 22 lines · Baolin Wang
Quoted 7 lines · Christoph Hellwig
Quoted 6 lines · Baolin Wang
Now the dm-crypt code only implemented the 'based-bio' method to encrypt/ decrypt block data, which can only hanle one bio at one time. As we know, one bio must use the sequential physical address and it also has a limitation of length. Thus it may limit the big block encyrtion/decryption when some hardware support the big block data encryption.
Quoted 7 lines
Quoted 3 lines
This patch series introduc the 'based-request' method to handle the data encryption/decryption. One request can contain multiple bios, so it can handle big block data to improve the efficiency.
NAK for more request based stacking or DM drivers. They are a major pain to deal with, and adding more with different requirements then dm-multipath is not helping in actually making that one work properly.
But now many vendors supply the hardware engine to handle the encyrtion/decryption. The hardware really need a big block to indicate its performance with request based things. Another thing is now the request based things is used by many vendors (Qualcomm, Spreadtrum and so on) to improve their performance and there's a real performance requirement here (I can show the performance result later).
Quoted 7 lines
Quoted 3 lines
So you've mentioned several times that hardware needs big blocks. How big those blocks need to be? Ideally, can you give some numbers on how the throughput of the encryption hw grows with the block size?
It depends on the hardware design. My beaglebone black board's AES engine can handle 1M at one time which is not big. As I know some other AES engine can handle 16M data at one time or more.
Well, one question is "can handle" and other question is how big gain in throughput it will bring compared to say 1M chunks. I suppose there's some constant overhead to issue a request to the crypto hw and by the time it is encrypting 1M it may be that this overhead is well amortized by the cost of the encryption itself which is in principle linear in the size of the block. That's why I'd like to get idea of the real numbers...
Quoted 8 lines
Quoted 4 lines
You mentioned that you use requests because of size limitations on bios - I had a look and current struct bio can easily describe 1MB requests (that's assuming 64-bit architecture, 4KB pages) when we have 1 page worth of struct
bio_vec. Is that not enough?Usually one bio does not always use the full 1M, maybe some 1k/2k/8k or some other small chunks. But request can combine some sequential small bios to be a big block and it is better than bio at least.
As Christoph mentions 4.3 should be better in submitting larger bios. Did you check it?
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Quoted 34 lines · Jan Kara
Quoted 25 lines · Baolin Wang
Quoted 24 lines · Jan Kara
Quoted 22 lines · Baolin Wang
Quoted 7 lines · Christoph Hellwig
Quoted 6 lines · Baolin Wang
Now the dm-crypt code only implemented the 'based-bio' method to encrypt/ decrypt block data, which can only hanle one bio at one time. As we know, one bio must use the sequential physical address and it also has a limitation of length. Thus it may limit the big block encyrtion/decryption when some hardware support the big block data encryption.
Quoted 7 lines
Quoted 3 lines
This patch series introduc the 'based-request' method to handle the data encryption/decryption. One request can contain multiple bios, so it can handle big block data to improve the efficiency.
NAK for more request based stacking or DM drivers. They are a major pain to deal with, and adding more with different requirements then dm-multipath is not helping in actually making that one work properly.
But now many vendors supply the hardware engine to handle the encyrtion/decryption. The hardware really need a big block to indicate its performance with request based things. Another thing is now the request based things is used by many vendors (Qualcomm, Spreadtrum and so on) to improve their performance and there's a real performance requirement here (I can show the performance result later).
Quoted 7 lines
Quoted 3 lines
So you've mentioned several times that hardware needs big blocks. How big those blocks need to be? Ideally, can you give some numbers on how the throughput of the encryption hw grows with the block size?
It depends on the hardware design. My beaglebone black board's AES engine can handle 1M at one time which is not big. As I know some other AES engine can handle 16M data at one time or more.
Quoted 6 lines
Well, one question is "can handle" and other question is how big gain in throughput it will bring compared to say 1M chunks. I suppose there's some constant overhead to issue a request to the crypto hw and by the time it is encrypting 1M it may be that this overhead is well amortized by the cost of the encryption itself which is in principle linear in the size of the block. That's why I'd like to get idea of the real numbers...
Please correct me if I misunderstood your point. Let's suppose the AES engine can handle 16M at one time. If we give the size of data is less than 16M, the engine can handle it at one time. But if the data size is 20M (more than 16M), the engine driver will split the data with 16M and 4M to deal with. I can not say how many numbers, but I think the engine is like to big chunks than small chunks which is the hardware engine's advantage.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
You mentioned that you use requests because of size limitations on bios - I had a look and current struct bio can easily describe 1MB requests (that's assuming 64-bit architecture, 4KB pages) when we have 1 page worth of struct
bio_vec. Is that not enough?
Quoted 6 lines
Quoted 3 lines
Usually one bio does not always use the full 1M, maybe some 1k/2k/8k or some other small chunks. But request can combine some sequential small bios to be a big block and it is better than bio at least.
As Christoph mentions 4.3 should be better in submitting larger bios. Did you check it?
I'm sorry I didn't check it. What's the limitation of one bio on 4.3? But I think it is better to choose a bigger one ( one request ) for crypto which is suitable for hardware engine.
Quoted 5 lines
Honza
--
Jan Kara <[email protected]>
SUSE Labs, CR
Signature · 2 lines
Baolin.wang Best Regards
Quoted 42 lines · Baolin Wang
Quoted 34 lines · Jan Kara
Quoted 25 lines · Baolin Wang
Quoted 24 lines · Jan Kara
Quoted 22 lines · Baolin Wang
Quoted 7 lines · Christoph Hellwig
Quoted 6 lines · Baolin Wang
Now the dm-crypt code only implemented the 'based-bio' method to encrypt/ decrypt block data, which can only hanle one bio at one time. As we know, one bio must use the sequential physical address and it also has a limitation of length. Thus it may limit the big block encyrtion/decryption when some hardware support the big block data encryption.
Quoted 7 lines
Quoted 3 lines
This patch series introduc the 'based-request' method to handle the data encryption/decryption. One request can contain multiple bios, so it can handle big block data to improve the efficiency.
NAK for more request based stacking or DM drivers. They are a major pain to deal with, and adding more with different requirements then dm-multipath is not helping in actually making that one work properly.
But now many vendors supply the hardware engine to handle the encyrtion/decryption. The hardware really need a big block to indicate its performance with request based things. Another thing is now the request based things is used by many vendors (Qualcomm, Spreadtrum and so on) to improve their performance and there's a real performance requirement here (I can show the performance result later).
Quoted 7 lines
Quoted 3 lines
So you've mentioned several times that hardware needs big blocks. How big those blocks need to be? Ideally, can you give some numbers on how the throughput of the encryption hw grows with the block size?
It depends on the hardware design. My beaglebone black board's AES engine can handle 1M at one time which is not big. As I know some other AES engine can handle 16M data at one time or more.
Quoted 6 lines
Well, one question is "can handle" and other question is how big gain in throughput it will bring compared to say 1M chunks. I suppose there's some constant overhead to issue a request to the crypto hw and by the time it is encrypting 1M it may be that this overhead is well amortized by the cost of the encryption itself which is in principle linear in the size of the block. That's why I'd like to get idea of the real numbers...
Quoted 7 lines
Please correct me if I misunderstood your point. Let's suppose the AES engine can handle 16M at one time. If we give the size of data is less than 16M, the engine can handle it at one time. But if the data size is 20M (more than 16M), the engine driver will split the data with 16M and 4M to deal with. I can not say how many numbers, but I think the engine is like to big chunks than small chunks which is the hardware engine's advantage.
No, I meant something different. I meant that if HW can encrypt 1M in say 1.05 ms and it can encrypt 16M in 16.05 ms, then although using 16 M blocks gives you some advantage it becomes diminishingly small.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
You mentioned that you use requests because of size limitations on bios - I had a look and current struct bio can easily describe 1MB requests (that's assuming 64-bit architecture, 4KB pages) when we have 1 page worth of struct
bio_vec. Is that not enough?
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Usually one bio does not always use the full 1M, maybe some 1k/2k/8k or some other small chunks. But request can combine some sequential small bios to be a big block and it is better than bio at least.
As Christoph mentions 4.3 should be better in submitting larger bios. Did you check it?
I'm sorry I didn't check it. What's the limitation of one bio on 4.3?
On 4.3 it is 1 MB (which should be enough because requests are limited to 512 KB by default anyway). Previously the maximum bio size depended on the queue parameters such as max number of segments etc.
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Quoted 51 lines · Jan Kara
Quoted 42 lines · Baolin Wang
Quoted 34 lines · Jan Kara
Quoted 25 lines · Baolin Wang
Quoted 24 lines · Jan Kara
Quoted 22 lines · Baolin Wang
Quoted 7 lines · Christoph Hellwig
Quoted 6 lines · Baolin Wang
Now the dm-crypt code only implemented the 'based-bio' method to encrypt/ decrypt block data, which can only hanle one bio at one time. As we know, one bio must use the sequential physical address and it also has a limitation of length. Thus it may limit the big block encyrtion/decryption when some hardware support the big block data encryption.
Quoted 7 lines
Quoted 3 lines
This patch series introduc the 'based-request' method to handle the data encryption/decryption. One request can contain multiple bios, so it can handle big block data to improve the efficiency.
NAK for more request based stacking or DM drivers. They are a major pain to deal with, and adding more with different requirements then dm-multipath is not helping in actually making that one work properly.
But now many vendors supply the hardware engine to handle the encyrtion/decryption. The hardware really need a big block to indicate its performance with request based things. Another thing is now the request based things is used by many vendors (Qualcomm, Spreadtrum and so on) to improve their performance and there's a real performance requirement here (I can show the performance result later).
Quoted 7 lines
Quoted 3 lines
So you've mentioned several times that hardware needs big blocks. How big those blocks need to be? Ideally, can you give some numbers on how the throughput of the encryption hw grows with the block size?
It depends on the hardware design. My beaglebone black board's AES engine can handle 1M at one time which is not big. As I know some other AES engine can handle 16M data at one time or more.
Quoted 6 lines
Well, one question is "can handle" and other question is how big gain in throughput it will bring compared to say 1M chunks. I suppose there's some constant overhead to issue a request to the crypto hw and by the time it is encrypting 1M it may be that this overhead is well amortized by the cost of the encryption itself which is in principle linear in the size of the block. That's why I'd like to get idea of the real numbers...
Quoted 7 lines
Please correct me if I misunderstood your point. Let's suppose the AES engine can handle 16M at one time. If we give the size of data is less than 16M, the engine can handle it at one time. But if the data size is 20M (more than 16M), the engine driver will split the data with 16M and 4M to deal with. I can not say how many numbers, but I think the engine is like to big chunks than small chunks which is the hardware engine's advantage.
Quoted 4 lines
No, I meant something different. I meant that if HW can encrypt 1M in say 1.05 ms and it can encrypt 16M in 16.05 ms, then although using 16 M blocks gives you some advantage it becomes diminishingly small.
But if it encrypts 16M with 1M one by one, it will be much more than 16.05ms (should be consider the SW submits bio one by one).
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 4 lines
You mentioned that you use requests because of size limitations on bios - I had a look and current struct bio can easily describe 1MB requests (that's assuming 64-bit architecture, 4KB pages) when we have 1 page worth of struct
bio_vec. Is that not enough?Usually one bio does not always use the full 1M, maybe some 1k/2k/8k or some other small chunks. But request can combine some sequential small bios to be a big block and it is better than bio at least.
Quoted 9 lines
Quoted 4 lines
Quoted 2 lines
As Christoph mentions 4.3 should be better in submitting larger bios. Did you check it?
I'm sorry I didn't check it. What's the limitation of one bio on 4.3?
On 4.3 it is 1 MB (which should be enough because requests are limited to 512 KB by default anyway). Previously the maximum bio size depended on the queue parameters such as max number of segments etc.
But it maybe not enough for HW engine which can handle maybe 10M/20M at one time.
Quoted 4 lines
Honza
--
Jan Kara <[email protected]>
SUSE Labs, CR
Signature · 2 lines
Baolin.wang Best Regards
Quoted 18 lines · On Thursday 12 November 2015 20:51:10 Baolin Wang wrote:
Quoted 17 lines · Jan Kara
Quoted 15 lines · Baolin Wang
Quoted 6 lines · Jan Kara
Well, one question is "can handle" and other question is how big gain in throughput it will bring compared to say 1M chunks. I suppose there's some constant overhead to issue a request to the crypto hw and by the time it is encrypting 1M it may be that this overhead is well amortized by the cost of the encryption itself which is in principle linear in the size of the block. That's why I'd like to get idea of the real numbers...
Please correct me if I misunderstood your point. Let's suppose the AES engine can handle 16M at one time. If we give the size of data is less than 16M, the engine can handle it at one time. But if the data size is 20M (more than 16M), the engine driver will split the data with 16M and 4M to deal with. I can not say how many numbers, but I think the engine is like to big chunks than small chunks which is the hardware engine's advantage.
Quoted 7 lines
Quoted 4 lines
No, I meant something different. I meant that if HW can encrypt 1M in say 1.05 ms and it can encrypt 16M in 16.05 ms, then although using 16 M blocks gives you some advantage it becomes diminishingly small.
But if it encrypts 16M with 1M one by one, it will be much more than 16.05ms (should be consider the SW submits bio one by one).
The example that Jan gave was meant to illustrate the case where it's not much more than 16.05ms, just slightly more.
The point is that we need real numbers to show at what size we stop getting significant returns from increased block sizes.
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
Quoted 8 lines
Quoted 4 lines
You mentioned that you use requests because of size limitations on bios - I had a look and current struct bio can easily describe 1MB requests (that's assuming 64-bit architecture, 4KB pages) when we have 1 page worth of struct
bio_vec. Is that not enough?Usually one bio does not always use the full 1M, maybe some 1k/2k/8k or some other small chunks. But request can combine some sequential small bios to be a big block and it is better than bio at least.
As Christoph mentions 4.3 should be better in submitting larger bios. Did you check it?
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
I'm sorry I didn't check it. What's the limitation of one bio on 4.3?
On 4.3 it is 1 MB (which should be enough because requests are limited to 512 KB by default anyway). Previously the maximum bio size depended on the queue parameters such as max number of segments etc.
But it maybe not enough for HW engine which can handle maybe 10M/20M at one time.
Given that you have already done measurements, can you find out how much you lose in overall performance with your existing patch if you artificially limit the maximum size to sizes like 256kb, 1MB, 4MB, ...?
Arnd
Quoted 8 lines · Arnd Bergmann
Quoted 2 lines · On Thursday 12 November 2015 20:51:10 Baolin Wang wrote:
But it maybe not enough for HW engine which can handle maybe 10M/20M at one time.
Given that you have already done measurements, can you find out how much you lose in overall performance with your existing patch if you artificially limit the maximum size to sizes like 256kb, 1MB, 4MB, ...?
It's probably also worth looking at the impact on CPU utilisation as well as throughput in your benchmarking since the system will often not be idle when it's doing a lot of I/O - I know you've done some measurements in that area before, including them when looking at block sizes might be interesting.
Quoted 10 lines · Mark Brown
Quoted 8 lines · Arnd Bergmann
Quoted 2 lines · On Thursday 12 November 2015 20:51:10 Baolin Wang wrote:
But it maybe not enough for HW engine which can handle maybe 10M/20M at one time.
Given that you have already done measurements, can you find out how much you lose in overall performance with your existing patch if you artificially limit the maximum size to sizes like 256kb, 1MB, 4MB, ...?
Quoted 5 lines
It's probably also worth looking at the impact on CPU utilisation as well as throughput in your benchmarking since the system will often not be idle when it's doing a lot of I/O - I know you've done some measurements in that area before, including them when looking at block sizes might be interesting.
Make sense.
Signature · 2 lines
Baolin.wang Best Regards
Quoted 24 lines · Arnd Bergmann
Quoted 23 lines · On Thursday 12 November 2015 20:51:10 Baolin Wang wrote:
Quoted 21 lines · Jan Kara
Quoted 8 lines · Baolin Wang
Quoted 6 lines · Jan Kara
Well, one question is "can handle" and other question is how big gain in throughput it will bring compared to say 1M chunks. I suppose there's some constant overhead to issue a request to the crypto hw and by the time it is encrypting 1M it may be that this overhead is well amortized by the cost of the encryption itself which is in principle linear in the size of the block. That's why I'd like to get idea of the real numbers...
Quoted 7 lines
Please correct me if I misunderstood your point. Let's suppose the AES engine can handle 16M at one time. If we give the size of data is less than 16M, the engine can handle it at one time. But if the data size is 20M (more than 16M), the engine driver will split the data with 16M and 4M to deal with. I can not say how many numbers, but I think the engine is like to big chunks than small chunks which is the hardware engine's advantage.
No, I meant something different. I meant that if HW can encrypt 1M in say 1.05 ms and it can encrypt 16M in 16.05 ms, then although using 16 M blocks gives you some advantage it becomes diminishingly small.
Quoted 9 lines
Quoted 2 lines
But if it encrypts 16M with 1M one by one, it will be much more than 16.05ms (should be consider the SW submits bio one by one).
The example that Jan gave was meant to illustrate the case where it's not much more than 16.05ms, just slightly more.
The point is that we need real numbers to show at what size we stop getting significant returns from increased block sizes.
Got it. Thanks.
Quoted 18 lines
Quoted 18 lines
Quoted 17 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
You mentioned that you use requests because of size limitations on bios - I had a look and current struct bio can easily describe 1MB requests (that's assuming 64-bit architecture, 4KB pages) when we have 1 page worth of struct
bio_vec. Is that not enough?Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Usually one bio does not always use the full 1M, maybe some 1k/2k/8k or some other small chunks. But request can combine some sequential small bios to be a big block and it is better than bio at least.
As Christoph mentions 4.3 should be better in submitting larger bios. Did you check it?
I'm sorry I didn't check it. What's the limitation of one bio on 4.3?
On 4.3 it is 1 MB (which should be enough because requests are limited to 512 KB by default anyway). Previously the maximum bio size depended on the queue parameters such as max number of segments etc.
Quoted 7 lines
Quoted 2 lines
But it maybe not enough for HW engine which can handle maybe 10M/20M at one time.
Given that you have already done measurements, can you find out how much you lose in overall performance with your existing patch if you artificially limit the maximum size to sizes like 256kb, 1MB, 4MB, ...?
Cause my board AES engine throughput is 1M, I just did a simple dd test with small chunks. Results are in last email.
Quoted 1 line
Arnd
Signature · 2 lines
Baolin.wang Best Regards
Quoted 52 lines · Baolin Wang
Quoted 51 lines · Jan Kara
Quoted 49 lines · Baolin Wang
Quoted 34 lines · Jan Kara
Quoted 25 lines · Baolin Wang
Quoted 24 lines · Jan Kara
Quoted 22 lines · Baolin Wang
Quoted 7 lines · Christoph Hellwig
Quoted 6 lines · Baolin Wang
Now the dm-crypt code only implemented the 'based-bio' method to encrypt/ decrypt block data, which can only hanle one bio at one time. As we know, one bio must use the sequential physical address and it also has a limitation of length. Thus it may limit the big block encyrtion/decryption when some hardware support the big block data encryption.
Quoted 7 lines
Quoted 3 lines
This patch series introduc the 'based-request' method to handle the data encryption/decryption. One request can contain multiple bios, so it can handle big block data to improve the efficiency.
NAK for more request based stacking or DM drivers. They are a major pain to deal with, and adding more with different requirements then dm-multipath is not helping in actually making that one work properly.
But now many vendors supply the hardware engine to handle the encyrtion/decryption. The hardware really need a big block to indicate its performance with request based things. Another thing is now the request based things is used by many vendors (Qualcomm, Spreadtrum and so on) to improve their performance and there's a real performance requirement here (I can show the performance result later).
Quoted 7 lines
Quoted 3 lines
So you've mentioned several times that hardware needs big blocks. How big those blocks need to be? Ideally, can you give some numbers on how the throughput of the encryption hw grows with the block size?
It depends on the hardware design. My beaglebone black board's AES engine can handle 1M at one time which is not big. As I know some other AES engine can handle 16M data at one time or more.
Quoted 6 lines
Well, one question is "can handle" and other question is how big gain in throughput it will bring compared to say 1M chunks. I suppose there's some constant overhead to issue a request to the crypto hw and by the time it is encrypting 1M it may be that this overhead is well amortized by the cost of the encryption itself which is in principle linear in the size of the block. That's why I'd like to get idea of the real numbers...
Please correct me if I misunderstood your point. Let's suppose the AES engine can handle 16M at one time. If we give the size of data is less than 16M, the engine can handle it at one time. But if the data size is 20M (more than 16M), the engine driver will split the data with 16M and 4M to deal with. I can not say how many numbers, but I think the engine is like to big chunks than small chunks which is the hardware engine's advantage.
Quoted 7 lines
Quoted 4 lines
No, I meant something different. I meant that if HW can encrypt 1M in say 1.05 ms and it can encrypt 16M in 16.05 ms, then although using 16 M blocks gives you some advantage it becomes diminishingly small.
But if it encrypts 16M with 1M one by one, it will be much more than 16.05ms (should be consider the SW submits bio one by one).
Really? In my example, it would take 16.8 ms if we encrypted 16M in 1M chunks and 16.05 ms if done in one chunk. That is a difference for which I would not be willing to bend over backwards. Now these numbers are completely made up and that's why I wanted to see the real numbers...
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
Quoted 8 lines
Quoted 4 lines
You mentioned that you use requests because of size limitations on bios - I had a look and current struct bio can easily describe 1MB requests (that's assuming 64-bit architecture, 4KB pages) when we have 1 page worth of struct
bio_vec. Is that not enough?Usually one bio does not always use the full 1M, maybe some 1k/2k/8k or some other small chunks. But request can combine some sequential small bios to be a big block and it is better than bio at least.
As Christoph mentions 4.3 should be better in submitting larger bios. Did you check it?
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
I'm sorry I didn't check it. What's the limitation of one bio on 4.3?
On 4.3 it is 1 MB (which should be enough because requests are limited to 512 KB by default anyway). Previously the maximum bio size depended on the queue parameters such as max number of segments etc.
But it maybe not enough for HW engine which can handle maybe 10M/20M at one time.
Currently, you would not be able to create larger than 512K / 1M chunks even with request based dm-crypt since requests have limits on number of data they can carry as well... So this is kind of abstract discussion.
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Quoted 58 lines · Jan Kara
Quoted 57 lines · Baolin Wang
Quoted 55 lines · Jan Kara
Quoted 42 lines · Baolin Wang
Quoted 34 lines · Jan Kara
Quoted 25 lines · Baolin Wang
Quoted 24 lines · Jan Kara
Quoted 22 lines · Baolin Wang
Quoted 7 lines · Christoph Hellwig
Quoted 6 lines · Baolin Wang
Now the dm-crypt code only implemented the 'based-bio' method to encrypt/ decrypt block data, which can only hanle one bio at one time. As we know, one bio must use the sequential physical address and it also has a limitation of length. Thus it may limit the big block encyrtion/decryption when some hardware support the big block data encryption.
Quoted 7 lines
Quoted 3 lines
This patch series introduc the 'based-request' method to handle the data encryption/decryption. One request can contain multiple bios, so it can handle big block data to improve the efficiency.
NAK for more request based stacking or DM drivers. They are a major pain to deal with, and adding more with different requirements then dm-multipath is not helping in actually making that one work properly.
But now many vendors supply the hardware engine to handle the encyrtion/decryption. The hardware really need a big block to indicate its performance with request based things. Another thing is now the request based things is used by many vendors (Qualcomm, Spreadtrum and so on) to improve their performance and there's a real performance requirement here (I can show the performance result later).
Quoted 7 lines
Quoted 3 lines
So you've mentioned several times that hardware needs big blocks. How big those blocks need to be? Ideally, can you give some numbers on how the throughput of the encryption hw grows with the block size?
It depends on the hardware design. My beaglebone black board's AES engine can handle 1M at one time which is not big. As I know some other AES engine can handle 16M data at one time or more.
Quoted 6 lines
Well, one question is "can handle" and other question is how big gain in throughput it will bring compared to say 1M chunks. I suppose there's some constant overhead to issue a request to the crypto hw and by the time it is encrypting 1M it may be that this overhead is well amortized by the cost of the encryption itself which is in principle linear in the size of the block. That's why I'd like to get idea of the real numbers...
Quoted 7 lines
Please correct me if I misunderstood your point. Let's suppose the AES engine can handle 16M at one time. If we give the size of data is less than 16M, the engine can handle it at one time. But if the data size is 20M (more than 16M), the engine driver will split the data with 16M and 4M to deal with. I can not say how many numbers, but I think the engine is like to big chunks than small chunks which is the hardware engine's advantage.
No, I meant something different. I meant that if HW can encrypt 1M in say 1.05 ms and it can encrypt 16M in 16.05 ms, then although using 16 M blocks gives you some advantage it becomes diminishingly small.
Quoted 8 lines
Quoted 2 lines
But if it encrypts 16M with 1M one by one, it will be much more than 16.05ms (should be consider the SW submits bio one by one).
Really? In my example, it would take 16.8 ms if we encrypted 16M in 1M chunks and 16.05 ms if done in one chunk. That is a difference for which I would not be willing to bend over backwards. Now these numbers are completely made up and that's why I wanted to see the real numbers...
Well, I did a simple test with dd reading, cause my engine limitation is 1M,
(1) so the time like below when handle 1M at one time.
1048576 bytes (1.0 MB) copied, 0.0841235 s, 12.5 MB/s
1048576 bytes (1.0 MB) copied, 0.0836294 s, 12.5 MB/s
1048576 bytes (1.0 MB) copied, 0.0836526 s, 12.5 MB/s
(2) These handle 64K at one time * 16 times 1048576 bytes (1.0 MB) copied, 0.0937223 s, 11.2 MB/s 1048576 bytes (1.0 MB) copied, 0.097205 s, 10.8 MB/s 1048576 bytes (1.0 MB) copied, 0.0935884 s, 11.2 MB/s
Here is a 10ms level difference, try to image if the hardware engine's throughput is bigger than that. But like Jens said, we can measure it by the performance data. Thanks.
Quoted 18 lines
Quoted 18 lines
Quoted 17 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
You mentioned that you use requests because of size limitations on bios - I had a look and current struct bio can easily describe 1MB requests (that's assuming 64-bit architecture, 4KB pages) when we have 1 page worth of struct
bio_vec. Is that not enough?Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Usually one bio does not always use the full 1M, maybe some 1k/2k/8k or some other small chunks. But request can combine some sequential small bios to be a big block and it is better than bio at least.
As Christoph mentions 4.3 should be better in submitting larger bios. Did you check it?
I'm sorry I didn't check it. What's the limitation of one bio on 4.3?
On 4.3 it is 1 MB (which should be enough because requests are limited to 512 KB by default anyway). Previously the maximum bio size depended on the queue parameters such as max number of segments etc.
Quoted 7 lines
Quoted 2 lines
But it maybe not enough for HW engine which can handle maybe 10M/20M at one time.
Currently, you would not be able to create larger than 512K / 1M chunks even with request based dm-crypt since requests have limits on number of data they can carry as well... So this is kind of abstract discussion.
OK. But I think if it is that it should change the default limitation for the DM device.
Quoted 4 lines
Honza
--
Jan Kara <[email protected]>
SUSE Labs, CR
Signature · 2 lines
Baolin.wang Best Regards
Quoted 7 lines · On Friday 13 November 2015 10:05:28 Baolin Wang wrote:
Well, I did a simple test with dd reading, cause my engine limitation is 1M,
(1) so the time like below when handle 1M at one time.
1048576 bytes (1.0 MB) copied, 0.0841235 s, 12.5 MB/s
1048576 bytes (1.0 MB) copied, 0.0836294 s, 12.5 MB/s
1048576 bytes (1.0 MB) copied, 0.0836526 s, 12.5 MB/s
Quoted 8 lines
(2) These handle 64K at one time * 16 times 1048576 bytes (1.0 MB) copied, 0.0937223 s, 11.2 MB/s 1048576 bytes (1.0 MB) copied, 0.097205 s, 10.8 MB/s 1048576 bytes (1.0 MB) copied, 0.0935884 s, 11.2 MB/s
Here is a 10ms level difference, try to image if the hardware engine's throughput is bigger than that. But like Jens said, we can measure it by the performance data.
The absolute numbers look really low. Does this include writing to a hard drive? That would certainly make the difference appear less significant.
Could you try backing this with a ram disk backing for comparison, and also use 'time dd' to show the CPU utilization for all cases? For completeness, including cpu-only performance might also help put this into perspective.
Arnd
Quoted 13 lines · Arnd Bergmann
Quoted 12 lines · On Friday 13 November 2015 10:05:28 Baolin Wang wrote:
Well, I did a simple test with dd reading, cause my engine limitation is 1M,
(1) so the time like below when handle 1M at one time.
1048576 bytes (1.0 MB) copied, 0.0841235 s, 12.5 MB/s
1048576 bytes (1.0 MB) copied, 0.0836294 s, 12.5 MB/s
1048576 bytes (1.0 MB) copied, 0.0836526 s, 12.5 MB/s(2) These handle 64K at one time * 16 times 1048576 bytes (1.0 MB) copied, 0.0937223 s, 11.2 MB/s 1048576 bytes (1.0 MB) copied, 0.097205 s, 10.8 MB/s 1048576 bytes (1.0 MB) copied, 0.0935884 s, 11.2 MB/s
Quoted 8 lines
Quoted 3 lines
Here is a 10ms level difference, try to image if the hardware engine's throughput is bigger than that. But like Jens said, we can measure it by the performance data.
The absolute numbers look really low. Does this include writing to a hard drive? That would certainly make the difference appear less significant.
OK, I'll supply the complete performance data to measure it.
Quoted 5 lines
Could you try backing this with a ram disk backing for comparison, and also use 'time dd' to show the CPU utilization for all cases? For completeness, including cpu-only performance might also help put this into perspective.
OK, I'll try. Thanks.
Quoted 1 line
Arnd
Signature · 2 lines
Baolin.wang Best Regards
Quoted 9 lines · Baolin Wang
Now the dm-crypt code only implemented the 'based-bio' method to encrypt/ decrypt block data, which can only hanle one bio at one time. As we know, one bio must use the sequential physical address and it also has a limitation of length. Thus it may limit the big block encyrtion/decryption when some hardware support the big block data encryption.
This patch series introduc the 'based-request' method to handle the data encryption/decryption. One request can contain multiple bios, so it can handle big block data to improve the efficiency.
The duality of bio-based vs request-based code paths in DM core frankly sucks. So the prospect of polluting dm-crypt with a similar duality is really _not_ interesting.
Request-based DM requires more memory reserves per device than bio-based DM. Also, you cannot stack request-based DM ontop of bio-based devices (be them DM, MD, etc) so request-based DM's underlying storage stack gets a lot less interesting with this change.
That said, it could be that the benefits of supporting both bio-based and request-based DM in dm-crypt outweigh any overhead/limitations. But you haven't given any performance data to justify this patchset.
There needs to be a _really_ compelling benefit to do this.
Also, FYI, having a big CONFIG knob to switch all of dm-crypt from bio-based to request-based is _not_ acceptable. Both modes would need to be supported in parallel. Could easily be that not all devices in a system will benefit from being request-based.
Regardless, the risk of this change causing request-based DM to become more brittle than it already is concerns me.
But I'm trying to keep an open mind... show me data that real hardware _really_ benefits and we'll go from there. Again, it needs to be "OMG, this is amazing!" level performance to warrant any further serious consideration.
Quoted 9 lines · Mike Snitzer
Quoted 6 lines · Baolin Wang
Now the dm-crypt code only implemented the 'based-bio' method to encrypt/ decrypt block data, which can only hanle one bio at one time. As we know, one bio must use the sequential physical address and it also has a limitation of length. Thus it may limit the big block encyrtion/decryption when some hardware support the big block data encryption.
Quoted 8 lines
Quoted 3 lines
This patch series introduc the 'based-request' method to handle the data encryption/decryption. One request can contain multiple bios, so it can handle big block data to improve the efficiency.
The duality of bio-based vs request-based code paths in DM core frankly sucks. So the prospect of polluting dm-crypt with a similar duality is really _not_ interesting.
That's right. But we'll not introduce the duality things, cause we will remove the bio based things in dm-crypt if the request based things are accepted.
Quoted 5 lines
Request-based DM requires more memory reserves per device than bio-based DM. Also, you cannot stack request-based DM ontop of bio-based devices (be them DM, MD, etc) so request-based DM's underlying storage stack gets a lot less interesting with this change.
Yes, the request based requires more memory than bio based, but it is not too much. And the request based has a big performance improvement.
Quoted 4 lines
That said, it could be that the benefits of supporting both bio-based and request-based DM in dm-crypt outweigh any overhead/limitations. But you haven't given any performance data to justify this patchset.
Like I said above, we plan to remove the bio based things which are not good support for hardware engine encryption. And I'll show you the performance data to prove the request things have a good performance.
Quoted 7 lines
There needs to be a _really_ compelling benefit to do this.
Also, FYI, having a big CONFIG knob to switch all of dm-crypt from bio-based to request-based is _not_ acceptable. Both modes would need to be supported in parallel. Could easily be that not all devices in a system will benefit from being request-based.
OK. The CONFIG is not suitable here. I'll remove the CONFIG with just enable the request based things.
Quoted 7 lines
Regardless, the risk of this change causing request-based DM to become more brittle than it already is concerns me.
But I'm trying to keep an open mind... show me data that real hardware _really_ benefits and we'll go from there. Again, it needs to be "OMG, this is amazing!" level performance to warrant any further serious consideration.
OK. I'll show you the performance data. Thanks for your comments.
Signature · 2 lines
Baolin.wang Best Regards
Quoted 3 lines · Baolin Wang
That's right. But we'll not introduce the duality things, cause we will remove the bio based things in dm-crypt if the request based things are accepted.
No, you will NOT remote the bio based path. That would break all kinds of perfectly valid setups.
Quoted 33 lines · Mike Snitzer
Quoted 9 lines · Baolin Wang
Now the dm-crypt code only implemented the 'based-bio' method to encrypt/ decrypt block data, which can only hanle one bio at one time. As we know, one bio must use the sequential physical address and it also has a limitation of length. Thus it may limit the big block encyrtion/decryption when some hardware support the big block data encryption.
This patch series introduc the 'based-request' method to handle the data encryption/decryption. One request can contain multiple bios, so it can handle big block data to improve the efficiency.
The duality of bio-based vs request-based code paths in DM core frankly sucks. So the prospect of polluting dm-crypt with a similar duality is really _not_ interesting.
Request-based DM requires more memory reserves per device than bio-based DM. Also, you cannot stack request-based DM ontop of bio-based devices (be them DM, MD, etc) so request-based DM's underlying storage stack gets a lot less interesting with this change.
That said, it could be that the benefits of supporting both bio-based and request-based DM in dm-crypt outweigh any overhead/limitations. But you haven't given any performance data to justify this patchset.
There needs to be a _really_ compelling benefit to do this.
Also, FYI, having a big CONFIG knob to switch all of dm-crypt from bio-based to request-based is _not_ acceptable. Both modes would need to be supported in parallel. Could easily be that not all devices in a system will benefit from being request-based.
Quoted 7 lines
Regardless, the risk of this change causing request-based DM to become more brittle than it already is concerns me.
But I'm trying to keep an open mind... show me data that real hardware _really_ benefits and we'll go from there. Again, it needs to be "OMG, this is amazing!" level performance to warrant any further serious consideration.
Thanks for your suggestion. But let me explain it again. Now for many vendors, they supply the encryption hardware (such as AES engine) to accelerate the encyrtion/decryption speed with handling a big block at one time. So if we want the hardware engine can play the best performance, the size of block handled at one time need to be expanded.
But it can only handle one bio at one time for bio based dm-crypt, one bio has a size limitation and one bio's size can't make the hardware engine reach its best performance. So we want to introduce the request based dm-crypt. For request based things, some sequential bios can merged into one request to expand the IO size to be a big block handled by hardware engine at one time. With the hardware acceleration, it can improve the encryption/decryption speed.
I think 3 questions need to be clarified.
1. Are there ways of enhancing the dm-crypt bio-based target to overcome this? The focus is the size limitation of one bio, its size can not meet the hardware requirement. But one request can have a big block size with merging multiple bios. So I think the request is the best choice.
2. Would any sort of bio aggregation mechanism help?
The request can combined sequential bios by block layer automatically. But for bio aggregation, I think it will be similar to that, why do we need recomplement it again?
3. perforamence data
It is just a simple dd test result, and will provide the formal report in future. But from the simple test, we can see the improvement. Hardware environment:
Board: beaglebone black
processor: AM335x 1GHz ARM Cortex-A8
RAM: 512M
Cipher: cbc(aes) with AES hardware engine
(1) bio based dm-crypt with hardware accelarate:
read 64M command: dd if=/dev/dm-0 of=/dev/null bs=512k count=128 iflag=direct 67108864 bytes (67 MB) copied, 11.6592 s, 5.8 MB/s
67108864 bytes (67 MB) copied, 11.6391 s, 5.8 MB/s
67108864 bytes (67 MB) copied, 11.6296 s, 5.8 MB/s
(2) request based dm-crypt with hardware accelarate
read 64M command: dd if=/dev/dm-0 of=/dev/null bs=512k count=128 iflag=direct 67108864 bytes (67 MB) copied, 5.16586 s, 13.0 MB/s
67108864 bytes (67 MB) copied, 5.19338 s, 12.9 MB/s
67108864 bytes (67 MB) copied, 5.19169 s, 12.9 MB/s
(3) bio based dm-crypt with hardware accelarate
write 64M command: dd if=/dev/zero of=/dev/dm-0 bs=512k count=128 iflag=direct 67108864 bytes (67 MB) copied, 13.6852 s, 4.9 MB/s
67108864 bytes (67 MB) copied, 14.0873 s, 4.8 MB/s
67108864 bytes (67 MB) copied, 13.6649 s, 4.9 MB/s
(4) request based dm-crypt with hardware accelarate
write 64M command: dd if=/dev/zero of=/dev/dm-0 bs=512k count=128 iflag=direct 67108864 bytes (67 MB) copied, 7.27832 s, 9.2 MB/s
67108864 bytes (67 MB) copied, 7.29051 s, 9.2 MB/s
67108864 bytes (67 MB) copied, 7.28318 s, 9.2 MB/s
From the simple result, we can see it at least has a double improvement of the encryption performance.
Signature · 2 lines
Baolin.wang Best Regards
Quoted 3 lines · Baolin Wang
3. perforamence data
It is just a simple dd test result, and will provide the formal report in future. But from the simple test, we can see the improvement.
It's probably also worth pointing out that Qualcomm have been shipping an out of tree implementation of this as a separate module in their BSP (originally written by Danesh Garg who's on this thread):
Android now wants to encrypt phones and tablets by default and have been seeing substantial performance hits as a result, we can try to get people to share performance data from productionish systems but it might be difficult.
Jens Axboe
maintainerQuoted 10 lines · Mark Brown
Quoted 3 lines · Baolin Wang
3. perforamence data
It is just a simple dd test result, and will provide the formal report in future. But from the simple test, we can see the improvement.It's probably also worth pointing out that Qualcomm have been shipping an out of tree implementation of this as a separate module in their BSP (originally written by Danesh Garg who's on this thread):
Quoted 6 lines
Android now wants to encrypt phones and tablets by default and have been seeing substantial performance hits as a result, we can try to get people to share performance data from productionish systems but it might be difficult.
Well, shame on them for developing out-of-tree, looks like they are reaping all the benefits of that.
Guys, we need some numbers, enough with the hand waving. There's no point discussing this further until we know how much of a difference it makes to handle X MB chunks instead of Y MB chunks. As was previously stated, unless there's a _substantial_ performance benefit, this patchset isn't going anywhere.
If there is a huge benefit, we can look into ways of making it actually work. That may not even be a request interface, it could just be proper utilization of plugging for in-dm bio merging.
Signature · 1 line
Jens Axboe
Quoted 22 lines · Jens Axboe
Quoted 13 lines · Mark Brown
Quoted 3 lines · Baolin Wang
3. perforamence data
It is just a simple dd test result, and will provide the formal report in future. But from the simple test, we can see the improvement.It's probably also worth pointing out that Qualcomm have been shipping an out of tree implementation of this as a separate module in their BSP (originally written by Danesh Garg who's on this thread):
Quoted 6 lines
Android now wants to encrypt phones and tablets by default and have been seeing substantial performance hits as a result, we can try to get people to share performance data from productionish systems but it might be difficult.
Quoted 8 lines
Well, shame on them for developing out-of-tree, looks like they are reaping all the benefits of that.
Guys, we need some numbers, enough with the hand waving. There's no point discussing this further until we know how much of a difference it makes to handle X MB chunks instead of Y MB chunks. As was previously stated, unless there's a _substantial_ performance benefit, this patchset isn't going anywhere.
That's fair enough and we will provide the performance data to measure the patchset.
Quoted 4 lines
If there is a huge benefit, we can look into ways of making it actually work. That may not even be a request interface, it could just be proper utilization of plugging for in-dm bio merging.
Make sense. Thanks.
Quoted 4 lines
--
Jens Axboe
Signature · 2 lines
Baolin.wang Best Regards
Quoted 7 lines · Jens Axboe
Quoted 4 lines · Mark Brown
Android now wants to encrypt phones and tablets by default and have been seeing substantial performance hits as a result, we can try to get people to share performance data from productionish systems but it might be difficult.
Quoted 8 lines
Well, shame on them for developing out-of-tree, looks like they are reaping all the benefits of that.
Guys, we need some numbers, enough with the hand waving. There's no point discussing this further until we know how much of a difference it makes to handle X MB chunks instead of Y MB chunks. As was previously stated, unless there's a _substantial_ performance benefit, this patchset isn't going anywhere.
Yeah, what I'm saying here is that there will issues getting the numbers from relevant production systems - we are most likely to be looking at proxies which are hopefully reasonably representative but there's likely to be more divergence than you'd see just running benchmark workloads on similar systems to those used in production.
Hi All,
These are the benchmarks for request based dm-crypt. Please check it.
一、Environment
1. Hardware configuration
Board: Beaglebone black
Processor: Am335x 1GHz ARM Cortex-A8
RAM:512M
SD card:8G
Kernel version:4.4-rc1
2. Encryption method
(1) Use cbc(aes) cipher to encrypt the block device with dmsetup tool dmsetup create dm-0 --table “0 blockdev --getsize /dev/mmcblk0p1 crypt aes-cbc-plain:sha256 babebabebabebabebabebabebabebabe 0 /dev/mmcblk0p1 0”
(2) Enable the AES engine by configCONFIG_CRYPTO_HW=yCONFIG_CRYPTO_DEV_OMAP_AES=y
(3) Limitation
We want to test it on ramdisk devices rather than slow media devices (SD card) firstly, but here we can't use ramdisk to be mapped with dmsetup tool. Cause ramdisk device is non-request-stackable device, it can not be used for request-based dm.
二. Result summary
1. Results table
-----------------------------------------------------------------------------------------------
| Test | size | bio | request | % change |
-----------------------------------------------------------------------------------------------
| dd sequential read | 1G | 5.6Mb/s | 11.3Mb/s | +101.8% |
-----------------------------------------------------------------------------------------------
| dd sequential write | 1G | 4.2Mb/s | 6.8Mb/s | +61.9% |
-----------------------------------------------------------------------------------------------
| fio sequential read | 1G | 5336KB/s | 10928KB/s | +104.8% |
-----------------------------------------------------------------------------------------------
| fio sequential write | 1G | 4049KB/s | 6574KB/s | +62.4% |
-----------------------------------------------------------------------------------------------
2. Summary
From all the test data with the dd/fio tools, the test results basically are coincident though the different tools, so it can basically reflect the IO performance effection by request based opimization.
It has a larger IO performance effection for reading speed, and it'll have a larger improvement (at least a double improvement) when enabling the request based opimization.
Also it will have a big improvement for writing speed, and it is increased about 50% when enabling the request based opimization. But for random writing, it has a litle difference limited by slow hardware random accessing.
三. DD test procedure
dd can be used for simplified copying of data at the low level with operating the raw devices.
dd can provide good basic coverage but isn't very realistic, and only provide sequential IO accessing.
But we can use dd to read/write the raw devices without the filesystem's caches effection, test result as below:
1. Sequential read:
(1) Sequential read 1G with bio based:
time dd if=/dev/dm-0 of=/dev/null bs=64K count=16384 iflag=direct 1073741824 bytes (1.1 GB) copied, 192.091 s, 5.6 MB/s
real 3m12.112s user 0m0.070s sys 0m3.820s
(2) Sequential read 1G with requset based:
time dd if=/dev/dm-0 of=/dev/null bs=64K count=16384 iflag=direct 1073741824 bytes (1.1 GB) copied, 94.8922 s, 11.3 MB/s
real 1m34.908s user 0m0.030s sys 0m4.000s
(3) Sequential read 1G without encryption:
time dd if=/dev/mmcblk0p1 of=/dev/null bs=64K count=16384 iflag=direct 1073741824 bytes (1.1 GB) copied, 58.49 s, 18.4 MB/s
real 0m58.505s user 0m0.040s sys 0m3.050s
2. Sequential write:
(1) Sequential write 1G with bio based:
time dd if=/dev/zero of=/dev/dm-0 bs=64K count=16384 oflag=direct 1073741824 bytes (1.1 GB) copied, 253.477 s, 4.2 MB/s
real 4m13.497s user 0m0.130s sys 0m3.990s
(2) Sequential write 1G with requset based:
time dd if=/dev/zero of=/dev/dm-0 bs=64K count=16384 oflag=direct 1073741824 bytes (1.1 GB) copied, 157.396 s, 6.8 MB/s
real 2m37.414s user 0m0.130s sys 0m4.190s
(3) Sequential write 1G without encryption:
time dd if=/dev/zero of=/dev/mmcblk0p1 bs=64K count=16384 oflag=direct 1073741824 bytes (1.1 GB) copied, 120.452 s, 8.9 MB/s
real 2m0.471s user 0m0.050s sys 0m3.820s
3. Summary:
we can see the sequential read/write speed with bio based is: 5.6MB/s and 4.2MB/s, but when encrypting the block device with request based things, the sequential read/write speed can be increased to: 11.3MB/s and 6.8MBs. So sequential reading and writing speed have a big different with request based, speed are increased by 101.8% and 61.9%. Meanwhile we also can see the difference in 'sys' time with request based optimizations.
三、Fio test procedure
We specify the block size is 64K, and command like:
fio --filename=/dev/dm-0 --direct=1 --iodepth=1 --rw=read --bs=64K --size=1G --group_reporting --numjobs=1 --name=test_read
1. Sequential read 1G with bio based:
READ: io=1024.0MB, aggrb=5336KB/s, minb=5336KB/s, maxb=5336KB/s, mint=196494msec, maxt=196494msec
2. Sequential write 1G with bio based:
WRITE: io=1024.0MB, aggrb=4049KB/s, minb=4049KB/s, maxb=4049KB/s, mint=258954msec, maxt=258954msec
3. Sequential read 1G with request based:
READ: io=1024.0MB, aggrb=10928KB/s, minb=10928KB/s, maxb=10928KB/s, mint=95947msec, maxt=95947msec
4. Sequential write 1G with request based:
WRITE: io=1024.0MB, aggrb=6574KB/s, minb=6574KB/s, maxb=6574KB/s, mint=159493msec, maxt=159493msec
5. Summary:
(1) read:
The sequential read speed has a big improvment with reuest based things, which is increased by 104.8% when the reuest based things are enabled for dm-crypt. It can not be a really random read if we specify the block size, so the data doesn't list the random read speed improvements, though it show big improvements.
(2) write:
The sequential write speed has some improvements with request based, which is increased about by 62.4%. But for random write, this part is very hard to measure on an SD card though, because any random write smaller than the underlying block size will cause long I/O latencies at some point, which is can not show the improvements.
四、IO block size test
We also change the block size from 4K to 1M (most IO block size in practice are much smaller than 1M) to see the block size influences with reuest based for dm-crypt.
1. Sequential read 1G
(1) block size = 4k
time dd if=/dev/dm-0 of=/dev/null bs=4k count=262144 iflag=direct 1073741824 bytes (1.1 GB) copied, 310.598 s, 3.5 MB/s
real 5m10.614s user 0m0.610s sys 0m36.040s
(2) block size = 64k
1073741824 bytes (1.1 GB) copied, 95.0489 s, 11.3 MB/s
real 1m35.071s user 0m0.040s sys 0m4.030s
(3) block size = 256k
1073741824 bytes (1.1 GB) copied, 84.3311 s, 12.7 MB/s
real 1m24.347s user 0m0.050s sys 0m1.950s
(4) block size = 1M
1073741824 bytes (1.1 GB) copied, 80.8778 s, 13.3 MB/s
real 1m20.893s user 0m0.010s sys 0m1.390s
2. Sequential write 1G
(1) block size = 4k
time dd if=/dev/zero of=/dev/dm-0 bs=4K count=262144 oflag=direct 1073741824 bytes (1.1 GB) copied, 629.656 s, 1.7 MB/s
real 10m29.671s user 0m0.790s sys 0m33.550s
(2) block size = 64k
1073741824 bytes (1.1 GB) copied, 155.697 s, 6.9 MB/s
real 2m35.713s user 0m0.040s sys 0m4.110s
(3) block size = 256k
1073741824 bytes (1.1 GB) copied, 143.682 s, 7.5 MB/s
real 2m23.698s user 0m0.040s sys 0m2.500s
(4) block size = 1M
1073741824 bytes (1.1 GB) copied, 140.654 s, 7.6 MB/s
real 2m20.670s user 0m0.040s sys 0m2.090s
3. Summary
For request based things, some sequential bios/requests can merged into one request to expand the IO size to be a big block handled by hardware engine at one time. With the hardware acceleration, it can improve the encryption/decryption speed, so the hardware engine can play the best performance with big block size.
From the data, we also can see the reading/writing speed can be increased by expanding the block size, which means that it doesn't help much for small sizes in. But when the block size is above 64K, the speed dose not get the corresponding performance benefits, I think the speed limitation is also in cryto that lets the bigger bios can't get the similar performance benefits, which is need more investigations.
Quoted 22 lines · Mark Brown
Quoted 7 lines · Jens Axboe
Quoted 4 lines · Mark Brown
Android now wants to encrypt phones and tablets by default and have been seeing substantial performance hits as a result, we can try to get people to share performance data from productionish systems but it might be difficult.
Quoted 8 lines
Well, shame on them for developing out-of-tree, looks like they are reaping all the benefits of that.
Guys, we need some numbers, enough with the hand waving. There's no point discussing this further until we know how much of a difference it makes to handle X MB chunks instead of Y MB chunks. As was previously stated, unless there's a _substantial_ performance benefit, this patchset isn't going anywhere.
Yeah, what I'm saying here is that there will issues getting the numbers from relevant production systems - we are most likely to be looking at proxies which are hopefully reasonably representative but there's likely to be more divergence than you'd see just running benchmark workloads on similar systems to those used in production.
Signature · 2 lines
Baolin.wang Best Regards
Alasdair G Kergon
maintainerQuoted 1 line · Baolin Wang
These are the benchmarks for request based dm-crypt. Please check it.
Now please put request-based dm-crypt completely to one side and focus just on the existing bio-based code. Why is it slower and what can be adjusted to improve this?
People aren't going to take a request-based solution seriously until you can explain in full detail *why* bio-based is slower AND why it's impossible to improve its performance.
Quoted 3 lines
For request based things, some sequential bios/requests can merged into one request to expand the IO size to be a big block handled by hardware engine at one time.
Bio-based also merges I/O so that does not provide justification. Investigate in much more detail the actual merging and scheduling involved in the cases you need to optimise. See if blktrace gives you any clues, or add your own instrumentation. You could even look at some of the patches we've had in the list archives for optimising bio-based crypt in different situations.
Alasdair
Quoted 7 lines · Alasdair G Kergon
Quoted 1 line · Baolin Wang
These are the benchmarks for request based dm-crypt. Please check it.
Now please put request-based dm-crypt completely to one side and focus just on the existing bio-based code. Why is it slower and what can be adjusted to improve this?
OK. I think I find something need to be point out.
1. From the IO block size test in the performance report, for the request based, we can find it can not get the corresponding performance if we just expand the IO size. Because In dm crypt, it will map the data buffer of one request with scatterlists, and send all scatterlists of one request to the encryption engine to encrypt or decrypt. I found if the scatterlist list number is small and each scatterlist length is bigger, it will improve the encryption speed, that helps the engine palys best performance. But a big IO size does not mean bigger scatterlists (maybe many scatterlists with small length), that's why we can not get the corresponding performance if we just expand the IO size I think.
2. Why bio based is slower?
If you understand 1, you can obviously understand the crypto engine likes bigger scatterlists to improve the performance. But for bio based, it only send one scatterlist (the scatterlist's length is always '1 << SECTOR_SHIFT' = 512) to the crypto engine at one time. It means if the bio size is 1M, the bio based will send 2048 times (evey time the only one scatterlist length is 512 bytes) to crypto engine to handle, which is more time-consuming and ineffective for the crypto engine. But for request based, it can map the whole request with many scatterlists (not just one scatterlist), and send all the scatterlists to the crypto engine which can improve the performance, is it right?
Another optimization solution I think is we can expand the scatterlist entry number for bio based.
Quoted 17 lines
People aren't going to take a request-based solution seriously until you can explain in full detail *why* bio-based is slower AND why it's impossible to improve its performance.
Quoted 3 lines
For request based things, some sequential bios/requests can merged into one request to expand the IO size to be a big block handled by hardware engine at one time.
Bio-based also merges I/O so that does not provide justification. Investigate in much more detail the actual merging and scheduling involved in the cases you need to optimise. See if blktrace gives you any clues, or add your own instrumentation. You could even look at some of the patches we've had in the list archives for optimising bio-based crypt in different situations.
Alasdair
Signature · 2 lines
Baolin.wang Best Regards
Quoted 34 lines · Baolin Wang
Quoted 7 lines · Alasdair G Kergon
Quoted 1 line · Baolin Wang
These are the benchmarks for request based dm-crypt. Please check it.
Now please put request-based dm-crypt completely to one side and focus just on the existing bio-based code. Why is it slower and what can be adjusted to improve this?
OK. I think I find something need to be point out.
1. From the IO block size test in the performance report, for the request based, we can find it can not get the corresponding performance if we just expand the IO size. Because In dm crypt, it will map the data buffer of one request with scatterlists, and send all scatterlists of one request to the encryption engine to encrypt or decrypt. I found if the scatterlist list number is small and each scatterlist length is bigger, it will improve the encryption speed, that helps the engine palys best performance. But a big IO size does not mean bigger scatterlists (maybe many scatterlists with small length), that's why we can not get the corresponding performance if we just expand the IO size I think.2. Why bio based is slower?
If you understand 1, you can obviously understand the crypto engine likes bigger scatterlists to improve the performance. But for bio based, it only send one scatterlist (the scatterlist's length is always '1 <<SECTOR_SHIFT' = 512) to the crypto engine at one time. It means if the bio size is 1M, the bio based will send 2048 times (evey time the only one scatterlist length is 512 bytes) to crypto engine to handle, which is more time-consuming and ineffective for the crypto engine. But for request based, it can map the whole request with many scatterlists (not just one scatterlist), and send all the scatterlists to the crypto engine which can improve the performance, is it right?
Quoted 3 lines
Another optimization solution I think is we can expand the scatterlist entry number for bio based.
I did some testing about my assumption of expanding the scatterlist entry number for bio based. I did some modification for the bio based to support multiple scatterlists, then it will get the same performance as the request based things.
1. bio based with expanding the scatterlist entry
time dd if=/dev/dm-0 of=/dev/null bs=64K count=16384 iflag=direct 1073741824 bytes (1.1 GB) copied, 94.5458 s, 11.4 MB/s
real 1m34.562s user 0m0.030s sys 0m3.850s
2. Sequential read 1G with requset based:
time dd if=/dev/dm-0 of=/dev/null bs=64K count=16384 iflag=direct 1073741824 bytes (1.1 GB) copied, 94.8922 s, 11.3 MB/s
real 1m34.908s user 0m0.030s sys 0m4.000s
From the data, we can find the bio based also can get the same performance as the request based. So if someone still don't like the request based things, I think we can optimize the bio based by expanding the scatterlists number. Thanks.
Quoted 9 lines
Quoted 3 lines
Alasdair
--
Baolin.wang
Best Regards
Signature · 2 lines
Baolin.wang Best Regards
Dne 3.12.2015 v 11:36 Baolin Wang napsal(a):
Quoted 54 lines · Baolin Wang
Quoted 34 lines · Alasdair G Kergon
Quoted 7 lines · Baolin Wang
Quoted 1 line
These are the benchmarks for request based dm-crypt. Please check it.
Now please put request-based dm-crypt completely to one side and focus just on the existing bio-based code. Why is it slower and what can be adjusted to improve this?
OK. I think I find something need to be point out.
1. From the IO block size test in the performance report, for the request based, we can find it can not get the corresponding performance if we just expand the IO size. Because In dm crypt, it will map the data buffer of one request with scatterlists, and send all scatterlists of one request to the encryption engine to encrypt or decrypt. I found if the scatterlist list number is small and each scatterlist length is bigger, it will improve the encryption speed, that helps the engine palys best performance. But a big IO size does not mean bigger scatterlists (maybe many scatterlists with small length), that's why we can not get the corresponding performance if we just expand the IO size I think.2. Why bio based is slower?
If you understand 1, you can obviously understand the crypto engine likes bigger scatterlists to improve the performance. But for bio based, it only send one scatterlist (the scatterlist's length is always '1 <<SECTOR_SHIFT' = 512) to the crypto engine at one time. It means if the bio size is 1M, the bio based will send 2048 times (evey time the only one scatterlist length is 512 bytes) to crypto engine to handle, which is more time-consuming and ineffective for the crypto engine. But for request based, it can map the whole request with many scatterlists (not just one scatterlist), and send all the scatterlists to the crypto engine which can improve the performance, is it right?Quoted 3 lines
Another optimization solution I think is we can expand the scatterlist entry number for bio based.
I did some testing about my assumption of expanding the scatterlist entry number for bio based. I did some modification for the bio based to support multiple scatterlists, then it will get the same performance as the request based things.
1. bio based with expanding the scatterlist entry
time dd if=/dev/dm-0 of=/dev/null bs=64K count=16384 iflag=direct 1073741824 bytes (1.1 GB) copied, 94.5458 s, 11.4 MB/sreal 1m34.562s user 0m0.030s sys 0m3.850s2. Sequential read 1G with requset based:
time dd if=/dev/dm-0 of=/dev/null bs=64K count=16384 iflag=direct 1073741824 bytes (1.1 GB) copied, 94.8922 s, 11.3 MB/s
Quoted 9 lines
real 1m34.908s user 0m0.030s sys 0m4.000sFrom the data, we can find the bio based also can get the same
performance as the request based. So if someone still don't like the request based things, I think we can optimize the bio based by expanding the scatterlists number. Thanks.
Hi
Do you see any performance impact if you use with cryptsetup options:
--perf-same_cpu_crypt
--perf-submit_from_crypt_cpus
with your regular unpatched kernel.
Zdenek
Quoted 71 lines · Zdenek Kabelac
Dne 3.12.2015 v 11:36 Baolin Wang napsal(a):
Quoted 58 lines · Baolin Wang
Quoted 38 lines · Alasdair G Kergon
Quoted 10 lines · Baolin Wang
Quoted 2 lines
These are the benchmarks for request based dm-crypt. Please check it.
Now please put request-based dm-crypt completely to one side and focus just on the existing bio-based code. Why is it slower and what can be adjusted to improve this?
OK. I think I find something need to be point out.
1. From the IO block size test in the performance report, for the request based, we can find it can not get the corresponding performance if we just expand the IO size. Because In dm crypt, it will map the data buffer of one request with scatterlists, and send all scatterlists of one request to the encryption engine to encrypt or decrypt. I found if the scatterlist list number is small and each scatterlist length is bigger, it will improve the encryption speed, that helps the engine palys best performance. But a big IO size does not mean bigger scatterlists (maybe many scatterlists with small length), that's why we can not get the corresponding performance if we just expand the IO size I think.2. Why bio based is slower?
If you understand 1, you can obviously understand the crypto engine likes bigger scatterlists to improve the performance. But for bio based, it only send one scatterlist (the scatterlist's length is always '1 <<SECTOR_SHIFT' = 512) to the crypto engine at one time. It means if the bio size is 1M, the bio based will send 2048 times (evey time the only one scatterlist length is 512 bytes) to crypto engine to handle, which is more time-consuming and ineffective for the crypto engine. But for request based, it can map the whole request with many scatterlists (not just one scatterlist), and send all the scatterlists to the crypto engine which can improve the performance, is it right?Quoted 3 lines
Another optimization solution I think is we can expand the scatterlist entry number for bio based.
I did some testing about my assumption of expanding the scatterlist entry number for bio based. I did some modification for the bio based to support multiple scatterlists, then it will get the same performance as the request based things.
1. bio based with expanding the scatterlist entry
time dd if=/dev/dm-0 of=/dev/null bs=64K count=16384 iflag=direct 1073741824 bytes (1.1 GB) copied, 94.5458 s, 11.4 MB/sreal 1m34.562s user 0m0.030s sys 0m3.850s2. Sequential read 1G with requset based:
time dd if=/dev/dm-0 of=/dev/null bs=64K count=16384 iflag=direct 1073741824 bytes (1.1 GB) copied, 94.8922 s, 11.3 MB/sQuoted 9 lines
real 1m34.908s user 0m0.030s sys 0m4.000sFrom the data, we can find the bio based also can get the same
performance as the request based. So if someone still don't like the request based things, I think we can optimize the bio based by expanding the scatterlists number. Thanks.
Quoted 8 lines
Hi
Do you see any performance impact if you use with cryptsetup options:
--perf-same_cpu_crypt
--perf-submit_from_crypt_cpuswith your regular unpatched kernel.
I did not see the performance impact with these options you said, cause my board only has one cpu.
Quoted 3 lines
Zdenek
Signature · 2 lines
Baolin.wang Best Regards
Mikulas Patocka
maintainerQuoted 51 lines · Baolin Wang
Quoted 34 lines · Baolin Wang
Quoted 7 lines · Alasdair G Kergon
Quoted 1 line · Baolin Wang
These are the benchmarks for request based dm-crypt. Please check it.
Now please put request-based dm-crypt completely to one side and focus just on the existing bio-based code. Why is it slower and what can be adjusted to improve this?
OK. I think I find something need to be point out.
1. From the IO block size test in the performance report, for the request based, we can find it can not get the corresponding performance if we just expand the IO size. Because In dm crypt, it will map the data buffer of one request with scatterlists, and send all scatterlists of one request to the encryption engine to encrypt or decrypt. I found if the scatterlist list number is small and each scatterlist length is bigger, it will improve the encryption speed, that helps the engine palys best performance. But a big IO size does not mean bigger scatterlists (maybe many scatterlists with small length), that's why we can not get the corresponding performance if we just expand the IO size I think.2. Why bio based is slower?
If you understand 1, you can obviously understand the crypto engine likes bigger scatterlists to improve the performance. But for bio based, it only send one scatterlist (the scatterlist's length is always '1 <<SECTOR_SHIFT' = 512) to the crypto engine at one time. It means if the bio size is 1M, the bio based will send 2048 times (evey time the only one scatterlist length is 512 bytes) to crypto engine to handle, which is more time-consuming and ineffective for the crypto engine. But for request based, it can map the whole request with many scatterlists (not just one scatterlist), and send all the scatterlists to the crypto engine which can improve the performance, is it right?Quoted 3 lines
Another optimization solution I think is we can expand the scatterlist entry number for bio based.
I did some testing about my assumption of expanding the scatterlist entry number for bio based. I did some modification for the bio based to support multiple scatterlists, then it will get the same performance as the request based things.
1. bio based with expanding the scatterlist entry
time dd if=/dev/dm-0 of=/dev/null bs=64K count=16384 iflag=direct 1073741824 bytes (1.1 GB) copied, 94.5458 s, 11.4 MB/sreal 1m34.562s user 0m0.030s sys 0m3.850s
Quoted 6 lines
2. Sequential read 1G with requset based:
time dd if=/dev/dm-0 of=/dev/null bs=64K count=16384 iflag=direct 1073741824 bytes (1.1 GB) copied, 94.8922 s, 11.3 MB/sreal 1m34.908s user 0m0.030s sys 0m4.000s
Measuring the system time this way is completely wrong because it doesn't account for the time spent in kernel threads.
Mikulas
Quoted 62 lines · Mikulas Patocka
Quoted 51 lines · Baolin Wang
Quoted 34 lines · Baolin Wang
Quoted 7 lines · Alasdair G Kergon
Quoted 1 line · Baolin Wang
These are the benchmarks for request based dm-crypt. Please check it.
Now please put request-based dm-crypt completely to one side and focus just on the existing bio-based code. Why is it slower and what can be adjusted to improve this?
OK. I think I find something need to be point out.
1. From the IO block size test in the performance report, for the request based, we can find it can not get the corresponding performance if we just expand the IO size. Because In dm crypt, it will map the data buffer of one request with scatterlists, and send all scatterlists of one request to the encryption engine to encrypt or decrypt. I found if the scatterlist list number is small and each scatterlist length is bigger, it will improve the encryption speed, that helps the engine palys best performance. But a big IO size does not mean bigger scatterlists (maybe many scatterlists with small length), that's why we can not get the corresponding performance if we just expand the IO size I think.2. Why bio based is slower?
If you understand 1, you can obviously understand the crypto engine likes bigger scatterlists to improve the performance. But for bio based, it only send one scatterlist (the scatterlist's length is always '1 <<SECTOR_SHIFT' = 512) to the crypto engine at one time. It means if the bio size is 1M, the bio based will send 2048 times (evey time the only one scatterlist length is 512 bytes) to crypto engine to handle, which is more time-consuming and ineffective for the crypto engine. But for request based, it can map the whole request with many scatterlists (not just one scatterlist), and send all the scatterlists to the crypto engine which can improve the performance, is it right?Quoted 3 lines
Another optimization solution I think is we can expand the scatterlist entry number for bio based.
I did some testing about my assumption of expanding the scatterlist entry number for bio based. I did some modification for the bio based to support multiple scatterlists, then it will get the same performance as the request based things.
1. bio based with expanding the scatterlist entry
time dd if=/dev/dm-0 of=/dev/null bs=64K count=16384 iflag=direct 1073741824 bytes (1.1 GB) copied, 94.5458 s, 11.4 MB/sreal 1m34.562s user 0m0.030s sys 0m3.850sQuoted 6 lines
2. Sequential read 1G with requset based:
time dd if=/dev/dm-0 of=/dev/null bs=64K count=16384 iflag=direct 1073741824 bytes (1.1 GB) copied, 94.8922 s, 11.3 MB/sreal 1m34.908s user 0m0.030s sys 0m4.000s
Quoted 3 lines
Measuring the system time this way is completely wrong because it doesn't account for the time spent in kernel threads.
OK. Thanks for your suggestions.
Quoted 1 line
Mikulas
Signature · 2 lines
Baolin.wang Best Regards
Mikulas Patocka
maintainerQuoted 9 lines · Baolin Wang
Quoted 7 lines · Alasdair G Kergon
Quoted 1 line · Baolin Wang
These are the benchmarks for request based dm-crypt. Please check it.
Now please put request-based dm-crypt completely to one side and focus just on the existing bio-based code. Why is it slower and what can be adjusted to improve this?
Quoted 8 lines
OK. I think I find something need to be point out.
1. From the IO block size test in the performance report, for the request based, we can find it can not get the corresponding performance if we just expand the IO size. Because In dm crypt, it will map the data buffer of one request with scatterlists, and send all scatterlists of one request to the encryption engine to encrypt or decrypt. I found if the scatterlist list number is small and each scatterlist length is bigger, it will improve the encryption speed,
This optimization is only applicable to XTS mode. XTS has its weaknesses and it is not recommended for encryption of more than 1TB of data ( http://grouper.ieee.org/groups/1619/email/msg02357.html )
You can optimize bio-based dm-crypt as well (use larger encryption chunk than 512 bytes when the mode is XTS).
The most commonly used mode aes-cbc-essiv:sha256 can't be optimized that way. You have to do encryption and decryption sector by sector because every sector has different IV.
Mikulas
Quoted 19 lines
that helps the engine palys best performance. But a big IO size does not mean bigger scatterlists (maybe many scatterlists with small length), that's why we can not get the corresponding performance if we just expand the IO size I think.
2. Why bio based is slower?
If you understand 1, you can obviously understand the crypto engine likes bigger scatterlists to improve the performance. But for bio based, it only send one scatterlist (the scatterlist's length is always '1 <<SECTOR_SHIFT' = 512) to the crypto engine at one time. It means if the bio size is 1M, the bio based will send 2048 times (evey time the only one scatterlist length is 512 bytes) to crypto engine to handle, which is more time-consuming and ineffective for the crypto engine. But for request based, it can map the whole request with many scatterlists (not just one scatterlist), and send all the scatterlists to the crypto engine which can improve the performance, is it right?Another optimization solution I think is we can expand the scatterlist entry number for bio based.
Quoted 26 lines · Mikulas Patocka
Quoted 9 lines · Baolin Wang
Quoted 7 lines · Alasdair G Kergon
Quoted 1 line · Baolin Wang
These are the benchmarks for request based dm-crypt. Please check it.
Now please put request-based dm-crypt completely to one side and focus just on the existing bio-based code. Why is it slower and what can be adjusted to improve this?
Quoted 8 lines
OK. I think I find something need to be point out.
1. From the IO block size test in the performance report, for the request based, we can find it can not get the corresponding performance if we just expand the IO size. Because In dm crypt, it will map the data buffer of one request with scatterlists, and send all scatterlists of one request to the encryption engine to encrypt or decrypt. I found if the scatterlist list number is small and each scatterlist length is bigger, it will improve the encryption speed,This optimization is only applicable to XTS mode. XTS has its weaknesses and it is not recommended for encryption of more than 1TB of data ( http://grouper.ieee.org/groups/1619/email/msg02357.html )
Quoted 6 lines
You can optimize bio-based dm-crypt as well (use larger encryption chunk than 512 bytes when the mode is XTS).
The most commonly used mode aes-cbc-essiv:sha256 can't be optimized that way. You have to do encryption and decryption sector by sector because every sector has different IV.
Make sense. We'll optimize bio-based dm-crypt for XTS mode, and do some investigations for none XTS mode.
Quoted 3 lines
Mikulas
Signature · 2 lines
Baolin.wang Best Regards
Quoted 4 lines · Mike Snitzer
But I'm trying to keep an open mind... show me data that real hardware _really_ benefits and we'll go from there. Again, it needs to be "OMG, this is amazing!" level performance to warrant any further serious consideration.
Also the numbers should be on 4.3+ with our arbitrarily sizeds bios, and a file system that isn't stupid and actually submits bios (xfs, btrfs for example).