All of lore.kernel.org
 help / color / mirror / Atom feed
From: Martin Hicks <mort@bork.org>
To: "Horia Geantă" <horia.geanta@freescale.com>
Cc: Kim Phillips <kim.phillips@freescale.com>,
	Scott Wood <scottwood@freescale.com>,
	Kumar Gala <galak@kernel.crashing.org>,
	linuxppc-dev@lists.ozlabs.org, linux-crypto@vger.kernel.org
Subject: Re: [PATCH 5/5] crypto: talitos: Add software backlog queue handling
Date: Thu, 26 Feb 2015 14:22:38 -0500	[thread overview]
Message-ID: <CAJUS3X=jFNi9yoKkrHtMxir5DfLaWoCqAoVfj2a7-wHo-29woA@mail.gmail.com> (raw)
In-Reply-To: <54ECC140.9090100@freescale.com>

Hi Horia,

On Tue, Feb 24, 2015 at 1:21 PM, Horia Geantă
<horia.geanta@freescale.com> wrote:
> On 2/20/2015 6:21 PM, Martin Hicks wrote:
>> +     int ret = -EINPROGRESS;
>>
>>       spin_lock_irqsave(&priv->chan[ch].head_lock, flags);
>>
>> +     if (edesc) {
>> +             orig_request = &edesc->req;
>> +             crypto_enqueue_request(&priv->chan[ch].queue, &orig_request->base);
>> +     }
>
> The request goes through the SW queue even if there are empty slots in
> the HW queue, doing unnecessary crypto_queue_encrypt() and
> crypto_queue_decrypt(). Trying to use the HW queue first would be better.
>

Definitely a valid point.  In trying to reorganize this it really
complicates things.
Splitting the submit from issuing requests from the backlog seems to
make it much more straightforward.

>> @@ -1170,6 +1211,8 @@ static struct talitos_edesc *talitos_edesc_alloc(struct device *dev,
>>                                                    edesc->dma_len,
>>                                                    DMA_BIDIRECTIONAL);
>>       edesc->req.desc = &edesc->desc;
>> +     /* A copy of the crypto_async_request to use the crypto_queue backlog */
>> +     memcpy(&edesc->req.base, areq, sizeof(struct crypto_async_request));
>
> Why not have a
> struct crypto_async_request *base;
> instead of
> struct crypto_async_request base;
> in talitos_request structure?
>
> This way:
> 1. memcopy above is avoided
> 2. talitos_request structure gets smaller - remember that
> talitos_request is now embedded in talitos_edesc structure, which gets
> kmalloc-ed for every request

The trouble I ran into was that after a request is backlogged and put
on the crypto queue, I couldn't see how else I could go from the
crypto_async_request that is pulled from the queue back to the
talitos_request that is needed in order put the pointer into the
hardware FIFO.

This is the one issue from you review that I didn't address in v2 of the patch.

Thanks for the review.  Not releasing / re-acquiring the spinlock
while trying to flush the backlog really improved performance.

mh

-- 
Martin Hicks P.Eng.      |         mort@bork.org
Bork Consulting Inc.     |   +1 (613) 266-2296

WARNING: multiple messages have this Message-ID (diff)
From: Martin Hicks <mort@bork.org>
To: "Horia Geantă" <horia.geanta@freescale.com>
Cc: Scott Wood <scottwood@freescale.com>,
	linuxppc-dev@lists.ozlabs.org, linux-crypto@vger.kernel.org
Subject: Re: [PATCH 5/5] crypto: talitos: Add software backlog queue handling
Date: Thu, 26 Feb 2015 14:22:38 -0500	[thread overview]
Message-ID: <CAJUS3X=jFNi9yoKkrHtMxir5DfLaWoCqAoVfj2a7-wHo-29woA@mail.gmail.com> (raw)
In-Reply-To: <54ECC140.9090100@freescale.com>

Hi Horia,

On Tue, Feb 24, 2015 at 1:21 PM, Horia Geant=C4=83
<horia.geanta@freescale.com> wrote:
> On 2/20/2015 6:21 PM, Martin Hicks wrote:
>> +     int ret =3D -EINPROGRESS;
>>
>>       spin_lock_irqsave(&priv->chan[ch].head_lock, flags);
>>
>> +     if (edesc) {
>> +             orig_request =3D &edesc->req;
>> +             crypto_enqueue_request(&priv->chan[ch].queue, &orig_reques=
t->base);
>> +     }
>
> The request goes through the SW queue even if there are empty slots in
> the HW queue, doing unnecessary crypto_queue_encrypt() and
> crypto_queue_decrypt(). Trying to use the HW queue first would be better.
>

Definitely a valid point.  In trying to reorganize this it really
complicates things.
Splitting the submit from issuing requests from the backlog seems to
make it much more straightforward.

>> @@ -1170,6 +1211,8 @@ static struct talitos_edesc *talitos_edesc_alloc(s=
truct device *dev,
>>                                                    edesc->dma_len,
>>                                                    DMA_BIDIRECTIONAL);
>>       edesc->req.desc =3D &edesc->desc;
>> +     /* A copy of the crypto_async_request to use the crypto_queue back=
log */
>> +     memcpy(&edesc->req.base, areq, sizeof(struct crypto_async_request)=
);
>
> Why not have a
> struct crypto_async_request *base;
> instead of
> struct crypto_async_request base;
> in talitos_request structure?
>
> This way:
> 1. memcopy above is avoided
> 2. talitos_request structure gets smaller - remember that
> talitos_request is now embedded in talitos_edesc structure, which gets
> kmalloc-ed for every request

The trouble I ran into was that after a request is backlogged and put
on the crypto queue, I couldn't see how else I could go from the
crypto_async_request that is pulled from the queue back to the
talitos_request that is needed in order put the pointer into the
hardware FIFO.

This is the one issue from you review that I didn't address in v2 of the pa=
tch.

Thanks for the review.  Not releasing / re-acquiring the spinlock
while trying to flush the backlog really improved performance.

mh

--=20
Martin Hicks P.Eng.      |         mort@bork.org
Bork Consulting Inc.     |   +1 (613) 266-2296

  reply	other threads:[~2015-02-26 19:22 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-20 16:21 [PATCH 0/5] crypto: talitos: Add crypto async queue handling Martin Hicks
2015-02-20 16:21 ` Martin Hicks
2015-02-20 16:21 ` [PATCH 1/5] crypto: talitos: Simplify per-channel initialization Martin Hicks
2015-02-20 16:21   ` Martin Hicks
2015-02-20 16:21 ` [PATCH 2/5] crypto: talitos: Remove MD5_BLOCK_SIZE Martin Hicks
2015-02-20 16:21   ` Martin Hicks
2015-02-27 11:03   ` Horia Geantă
2015-02-27 11:03     ` Horia Geantă
2015-03-01  9:32   ` Herbert Xu
2015-03-01  9:32     ` Herbert Xu
2015-02-20 16:21 ` [PATCH 3/5] crypto: talitos: Fix off-by-one and use all hardware slots Martin Hicks
2015-02-20 16:21   ` Martin Hicks
2015-02-20 16:21 ` [PATCH 4/5] crypto: talitos: Reorganize request submission data structures Martin Hicks
2015-02-20 16:21   ` Martin Hicks
2015-02-20 16:21 ` [PATCH 5/5] crypto: talitos: Add software backlog queue handling Martin Hicks
2015-02-20 16:21   ` Martin Hicks
2015-02-24 18:21   ` Horia Geantă
2015-02-24 18:21     ` Horia Geantă
2015-02-26 19:22     ` Martin Hicks [this message]
2015-02-26 19:22       ` Martin Hicks
2015-02-20 18:23 ` [PATCH 0/5] crypto: talitos: Add crypto async " Martin Hicks
2015-02-20 18:23   ` Martin Hicks
2015-02-20 18:26   ` Martin Hicks
2015-02-20 18:26     ` Martin 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='CAJUS3X=jFNi9yoKkrHtMxir5DfLaWoCqAoVfj2a7-wHo-29woA@mail.gmail.com' \
    --to=mort@bork.org \
    --cc=galak@kernel.crashing.org \
    --cc=horia.geanta@freescale.com \
    --cc=kim.phillips@freescale.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=scottwood@freescale.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.