From: Robert Jarzmik <robert.jarzmik@free.fr>
To: Baolin Wang <baolin.wang@linaro.org>
Cc: herbert@gondor.apana.org.au, davem@davemloft.net, agk@redhat.com,
snitzer@redhat.com, axboe@fb.com, dm-devel@redhat.com,
akpm@linux-foundation.org, david.s.gordon@intel.com,
thomas.lendacky@amd.com, yamada.masahiro@socionext.com,
smueller@chronox.de, tadeusz.struk@intel.com,
standby24x7@gmail.com, shli@kernel.org, broonie@kernel.org,
linus.walleij@linaro.org, arnd@arndb.de,
linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org,
linux-raid@vger.kernel.org
Subject: Re: [PATCH v2 1/4] scatterlist: Introduce some helper functions
Date: Sat, 02 Apr 2016 17:00:58 +0200 [thread overview]
Message-ID: <87r3eoukb9.fsf@belgarion.home> (raw)
In-Reply-To: <9442060edaca12f520bcbb76545ad33a52346e58.1458023698.git.baolin.wang@linaro.org> (Baolin Wang's message of "Tue, 15 Mar 2016 15:47:59 +0800")
Baolin Wang <baolin.wang@linaro.org> writes:
> +/**
> + * sg_is_contiguous - Check if the scatterlists are contiguous
> + * @sga: SG entry
> + * @sgb: SG entry
> + *
> + * Description:
> + * If the sga scatterlist is contiguous with the sgb scatterlist,
> + * that means they can be merged together.
> + *
> + **/
> +static inline bool sg_is_contiguous(struct scatterlist *sga,
> + struct scatterlist *sgb)
> +{
> + return *(unsigned long *)sg_virt(sga) + sga->length ==
> + *(unsigned long *)sg_virt(sgb);
As I already said, I don't like casts.
But let's take some height : you're needing this function to decide to merge
scatterlists. That means that you think the probability of having 2 scatterlist
mergeable is not meaningless, ie. 50% or more.
I suppose your scatterlists are allocated through kmalloc(). I'd like to know,
through your testing, what is the success rate of sg_is_contiguous(), ie. I'd
like to know how many times sg_is_contiguous() was called, and amongst these
calls how many times it returned true.
That will tell me how "worth" is this optimization.
> + * sg_add_sg_to_table - Add one scatterlist into sg table
> + * @sgt: The sg table header to use
> + * @src: The sg need to be added into sg table
> + *
> + * Description:
> + * The 'nents' member indicates how many mapped scatterlists has been added
> + * in the dynamic sg table. The 'orig_nents' member indicates the size of the
> + * dynamic sg table.
> + *
> + * Copy one mapped @src@ scatterlist into the dynamic sg table and increase
> + * 'nents' member.
> + *
> + **/
Okay, I still believe this one is wrong, because we don't understand each other.
So let's take an example :
sg_table = {
.sgl = {
{
.page_link = PAGE_48,
.offset = 0,
.length = 2048,
.dma_address = 0x30000,
.dma_length = 4096,
},
{
.page_link = PAGE_48 | 0x02,
.offset = 2048,
.length = 2048,
.dma_address = 0,
.dma_length = 0,
},
},
.nents = 1,
.orig_nents = 2,
};
In this example, by sheer luck the 2 scatterlist entries were physically
contiguous, and the mapping function coallesced the 2 entries into only one
(dma_address, dma_length) entry. That could also happen with an IOMMU by the
way. Therefore, sg_table.nents = 1.
If I understand your function correctly, it will erase sg_table.sgl[1], and that
looks incorrect to me. This is why I can't understand how your code can be
correct, and why I say you add a new "meaning" to sg_table->nents, which is not
consistent with the meaning I understand.
Cheers.
--
Robert
next prev parent reply other threads:[~2016-04-02 15:01 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-15 7:47 [PATCH v2 0/4] Introduce bulk mode for crypto engine framework Baolin Wang
2016-03-15 7:47 ` [PATCH v2 1/4] scatterlist: Introduce some helper functions Baolin Wang
2016-04-02 15:00 ` Robert Jarzmik [this message]
2016-04-05 7:10 ` Baolin Wang
2016-04-20 7:34 ` Baolin Wang
2016-04-20 8:38 ` Herbert Xu
2016-03-15 7:48 ` [PATCH v2 2/4] crypto: Introduce some helper functions to help to merge requests Baolin Wang
2016-03-15 7:48 ` [PATCH v2 3/4] crypto: Introduce the bulk mode for crypto engine framework Baolin Wang
2016-03-15 7:48 ` [PATCH v2 4/4] md: dm-crypt: Initialize the sector number for one request Baolin Wang
2016-04-15 13:48 ` [PATCH v2 0/4] Introduce bulk mode for crypto engine framework Herbert Xu
2016-04-18 5:31 ` Baolin Wang
2016-04-18 5:45 ` Herbert Xu
2016-04-18 6:02 ` Baolin Wang
2016-04-18 7:04 ` Herbert Xu
2016-04-18 7:21 ` Baolin Wang
2016-04-18 7:24 ` Herbert Xu
2016-04-18 7:58 ` Baolin Wang
2016-04-18 8:04 ` Herbert Xu
2016-04-18 8:14 ` Baolin Wang
2016-04-18 8:17 ` Herbert Xu
2016-04-18 8:28 ` Baolin Wang
2016-04-18 8:31 ` Herbert Xu
2016-04-18 8:40 ` Baolin Wang
2016-04-18 8:41 ` Herbert Xu
2016-04-18 8:51 ` Baolin Wang
2016-04-18 13:36 ` Mike Snitzer
2016-04-18 21:22 ` Milan Broz
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=87r3eoukb9.fsf@belgarion.home \
--to=robert.jarzmik@free.fr \
--cc=agk@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=axboe@fb.com \
--cc=baolin.wang@linaro.org \
--cc=broonie@kernel.org \
--cc=davem@davemloft.net \
--cc=david.s.gordon@intel.com \
--cc=dm-devel@redhat.com \
--cc=herbert@gondor.apana.org.au \
--cc=linus.walleij@linaro.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=shli@kernel.org \
--cc=smueller@chronox.de \
--cc=snitzer@redhat.com \
--cc=standby24x7@gmail.com \
--cc=tadeusz.struk@intel.com \
--cc=thomas.lendacky@amd.com \
--cc=yamada.masahiro@socionext.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
all inboxes | Powered by JetHome®