From: Tyler Hicks <tyhicks@canonical.com>
To: Thieu Le <thieule@google.com>
Cc: dragonylffly <dragonylffly@163.com>,
ecryptfs@vger.kernel.org, Colin King <colin.king@canonical.com>
Subject: Re: [PATCH 1/1] ecryptfs: Migrate to ablkcipher API
Date: Mon, 18 Jun 2012 20:52:30 -0700 [thread overview]
Message-ID: <20120619035229.GB8811@boyd> (raw)
In-Reply-To: <CAEcckGp22vMzEocMT54ksHRtunKrQmoVgP7LeZCvWV9wuzKu0A@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 7638 bytes --]
On 2012-06-18 10:17:29, Thieu Le wrote:
> Inline.
>
> On Sat, Jun 16, 2012 at 4:12 AM, dragonylffly <dragonylffly@163.com> wrote:
> > HI,
> > I did not think it thoroughly, I have two questions,
> > 1 For asynchronous encryption, although it may enjoy a throughput
> > improvement for a bunch of pages, however, it seems that each dirty
> > page will now more likely have a longer time to be written back after
> > marked PG_WRITEBACK,
> > in other words, it is being locked for a longer time, what if a write
> > happens on that locked page? so it seems it may slow down the
> > performance on some REWRITE cases.
>
> If I understand you correctly, I think there could be some slowdown in
> your scenario if we assume the sync and async crypto code paths are
> similar or the async path is longer. However, if there are are
> multiple extents per page, the async approach will allow us to run the
> crypto requests in parallel thereby lowering the amount of time under
> page lock.
>
>
> >
> > 2 It is not very clear that why it could speed up read performance,
> > from the Linux source code, it seems the kernel will wait for the
> > non uptodate page being uptodate (do_generic_file_read) before trying next page.
>
> There are two ways that this patch can speed up performance in the read path:
>
> 1. If the page contains multiple extents, this patch will submit the
> extent decryption requests to the crypto API in parallel.
>
> 2. The readahead does not wait for the page to be read thereby
> allowing us to submit multiple extents decryption requests in
> parallel.
I'm repeating myself from earlier in the thread, but I think that
implementing ->readpages would be easy and could really benefit from an
async patch.
Tyler
>
>
> >
> > Cheers,
> > Li Wang
> >
> > At 2012-06-14 06:25:28,"Thieu Le" <thieule@google.com> wrote:
> >>Kewl :)
> >>
> >>Let me know if you have more questions.
> >>
> >>
> >>On Wed, Jun 13, 2012 at 3:20 PM, Tyler Hicks <tyhicks@canonical.com> wrote:
> >>> On 2012-06-13 15:03:42, Thieu Le wrote:
> >>>> On Wed, Jun 13, 2012 at 2:17 PM, Tyler Hicks <tyhicks@canonical.com> wrote:
> >>>> > On Wed, Jun 13, 2012 at 11:53 AM, Thieu Le <thieule@google.com> wrote:
> >>>> >>
> >>>> >> Hi Tyler, I believe the performance improvement from the async
> >>>> >> interface comes from the ability to fully utilize the crypto
> >>>> >> hardware.
> >>>> >>
> >>>> >> Firstly, being able to submit multiple outstanding requests fills
> >>>> >> the crypto engine pipeline which allows it to run more efficiently
> >>>> >> (ie. minimal cycles are wasted waiting for the next crypto request).
> >>>> >> This perf improvement is similar to network transfer efficiency.
> >>>> >> Sending a 1GB file via 4K packets synchronously is not going to
> >>>> >> fully saturate a gigabit link but queuing a bunch of 4K packets to
> >>>> >> send will.
> >>>> >
> >>>> > Ok, it is clicking for me now. Additionally, I imagine that the async
> >>>> > interface helps in the multicore/multiprocessor case.
> >>>> >
> >>>> >> Secondly, if you have crypto hardware that has multiple crypto
> >>>> >> engines, then the multiple outstanding requests allow the crypto
> >>>> >> hardware to put all of those engines to work.
> >>>> >>
> >>>> >> To answer your question about page_crypt_req, it is used to track
> >>>> >> all of the extent_crypt_reqs for a particular page. When we write a
> >>>> >> page, we break the page up into extents and encrypt each extent.
> >>>> >> For each extent, we submit the encrypt request using
> >>>> >> extent_crypt_req. To determine when the entire page has been
> >>>> >> encrypted, we create one page_crypt_req and associates the
> >>>> >> extent_crypt_req to the page by incrementing
> >>>> >> page_crypt_req::num_refs. As the extent encrypt request completes,
> >>>> >> we decrement num_refs. The entire page is encrypted when num_refs
> >>>> >> goes to zero, at which point, we end the page writeback.
> >>>> >
> >>>> > Alright, that is what I had understood from reviewing the code. No
> >>>> > surprises there.
> >>>> >
> >>>> > What I'm suggesting is to do away with the page_crypt_req and simply have
> >>>> > ecryptfs_encrypt_page_async() keep track of the extent_crypt_reqs for
> >>>> > the page it is encrypting. Its prototype would look like this:
> >>>> >
> >>>> > int ecryptfs_encrypt_page_async(struct page *page);
> >>>> >
> >>>> > An example of how it would be called would be something like this:
> >>>> >
> >>>> > static int ecryptfs_writepage(struct page *page, struct writeback_control *wbc)
> >>>> > {
> >>>> > int rc = 0;
> >>>> >
> >>>> > /*
> >>>> > * Refuse to write the page out if we are called from reclaim context
> >>>> > * since our writepage() path may potentially allocate memory when
> >>>> > * calling into the lower fs vfs_write() which may in turn invoke
> >>>> > * us again.
> >>>> > */
> >>>> > if (current->flags & PF_MEMALLOC) {
> >>>> > redirty_page_for_writepage(wbc, page);
> >>>> > goto out;
> >>>> > }
> >>>> >
> >>>> > set_page_writeback(page);
> >>>> > rc = ecryptfs_encrypt_page_async(page);
> >>>> > if (unlikely(rc)) {
> >>>> > ecryptfs_printk(KERN_WARNING, "Error encrypting "
> >>>> > "page (upper index [0x%.16lx])\n", page->index);
> >>>> > ClearPageUptodate(page);
> >>>> > SetPageError(page);
> >>>> > } else {
> >>>> > SetPageUptodate(page);
> >>>> > }
> >>>> > end_page_writeback(page);
> >>>> > out:
> >>>> > unlock_page(page);
> >>>> > return rc;
> >>>> > }
> >>>>
> >>>> Will this make ecryptfs_encrypt_page_async() block until all of the
> >>>> extents are encrypted and written to the lower file before returning?
> >>>>
> >>>> In the current patch, ecryptfs_encrypt_page_async() returns
> >>>> immediately after the extents are submitted to the crypto layer.
> >>>> ecryptfs_writepage() will also return before the encryption and write
> >>>> to the lower file completes. This allows the OS to start writing
> >>>> other pending pages without being blocked.
> >>>
> >>> Ok, now I see the source of my confusion. The wait_for_completion()
> >>> added in ecryptfs_encrypt_page() was throwing me off. I initially
> >>> noticed that and didn't realize that wait_for_completion() was *not*
> >>> being called in ecryptfs_writepage().
> >>>
> >>> I hope to give the rest of the patch a thorough review by the end of the
> >>> week. Thanks for your help!
> >>>
> >>> Tyler
> >>>
> >>>>
> >>>>
> >>>> >
> >>>> >
> >>>> >> We can get rid of page_crypt_req if we can guarantee that the extent
> >>>> >> size and page size are the same.
> >>>> >
> >>>> > We can't guarantee that but that doesn't matter because
> >>>> > ecryptfs_encrypt_page_async() already handles that problem. Its caller doesn't
> >>>> > care if the extent size is less than the page size.
> >>>> >
> >>>> > Tyler
> >>>> --
> >>>> To unsubscribe from this list: send the line "unsubscribe ecryptfs" in
> >>>> the body of a message to majordomo@vger.kernel.org
> >>>> More majordomo info at http://vger.kernel.org/majordomo-info.html
> >>--
> >>To unsubscribe from this list: send the line "unsubscribe ecryptfs" in
> >>the body of a message to majordomo@vger.kernel.org
> >>More majordomo info at http://vger.kernel.org/majordomo-info.html
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
next prev parent reply other threads:[~2012-06-19 3:52 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-13 12:14 [PATCH 0/1] ecryptfs: Migrate to ablkcipher API Colin King
2012-06-13 12:14 ` [PATCH 1/1] " Colin King
2012-06-13 16:11 ` Tyler Hicks
[not found] ` <CAEcckGpMt1O+2syGbCQYC5ERCmXwCCvYjTYrHEeqZtQsA-qLLg@mail.gmail.com>
2012-06-13 19:04 ` Thieu Le
2012-06-13 21:17 ` Tyler Hicks
2012-06-13 22:03 ` Thieu Le
2012-06-13 22:20 ` Tyler Hicks
2012-06-13 22:25 ` Thieu Le
[not found] ` <539626322.30300@eyou.net>
2012-06-16 11:12 ` dragonylffly
2012-06-18 17:17 ` Thieu Le
2012-06-19 3:52 ` Tyler Hicks [this message]
[not found] ` <540077879.03766@eyou.net>
2012-06-19 7:06 ` Li Wang
[not found] ` <540039783.18266@eyou.net>
2012-06-19 3:19 ` Li Wang
2012-06-19 3:47 ` 'Tyler Hicks'
2012-07-21 1:58 ` Tyler Hicks
2012-12-19 11:44 ` Zeev Zilberman
2012-06-13 15:54 ` [PATCH 0/1] " Tyler Hicks
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120619035229.GB8811@boyd \
--to=tyhicks@canonical.com \
--cc=colin.king@canonical.com \
--cc=dragonylffly@163.com \
--cc=ecryptfs@vger.kernel.org \
--cc=thieule@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox