From: Adrian Hunter <adrian.hunter@intel.com>
To: David Jander <david@protonic.nl>,
Ulf Hansson <ulf.hansson@linaro.org>,
Sascha Hauer <s.hauer@pengutronix.de>
Cc: Johan Rudholm <johan.rudholm@axis.com>,
Javier Martinez Canillas <javier.martinez@collabora.co.uk>,
linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mmc: core: Fix off-by-one error in mmc_do_calc_max_discard()
Date: Mon, 01 Jun 2015 13:36:45 +0300 [thread overview]
Message-ID: <556C35BD.4050809@intel.com> (raw)
In-Reply-To: <1433150435-19997-1-git-send-email-david@protonic.nl>
On 01/06/15 12:20, David Jander wrote:
> qty is the maximum number of discard that _do_ fit in the timeout, not
> the first amount that does _not_ fit anymore.
> This seemingly harmless error has a very severe performance impact when
> the timeout value is enough for only 1 erase group.
>
> Signed-off-by: David Jander <david@protonic.nl>
> ---
> drivers/mmc/core/core.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
> index 92e7671..1f9573b 100644
> --- a/drivers/mmc/core/core.c
> +++ b/drivers/mmc/core/core.c
> @@ -2234,16 +2234,13 @@ static unsigned int mmc_do_calc_max_discard(struct mmc_card *card,
> if (!qty)
> return 0;
>
> - if (qty == 1)
> - return 1;
> -
> /* Convert qty to sectors */
> if (card->erase_shift)
> - max_discard = --qty << card->erase_shift;
> + max_discard = qty << card->erase_shift;
> else if (mmc_card_sd(card))
> max_discard = qty;
> else
> - max_discard = --qty * card->erase_size;
> + max_discard = qty * card->erase_size;
>
> return max_discard;
> }
>
This keeps coming up but there is more to it than that. See here:
http://marc.info/?l=linux-mmc&m=142504164427546
next prev parent reply other threads:[~2015-06-01 10:39 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-01 9:20 [PATCH] mmc: core: Fix off-by-one error in mmc_do_calc_max_discard() David Jander
2015-06-01 10:36 ` Adrian Hunter [this message]
2015-06-01 11:32 ` David Jander
2015-06-01 11:50 ` Adrian Hunter
2015-06-01 12:30 ` David Jander
2015-06-01 12:38 ` Adrian Hunter
2015-06-01 13:32 ` David Jander
2015-06-04 8:15 ` Ulf Hansson
2015-06-04 8:24 ` David Jander
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=556C35BD.4050809@intel.com \
--to=adrian.hunter@intel.com \
--cc=david@protonic.nl \
--cc=javier.martinez@collabora.co.uk \
--cc=johan.rudholm@axis.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=ulf.hansson@linaro.org \
/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.