mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: "Kanigeri, Hari" <h-kanigeri2@ti.com>
Cc: Kyungmin Park <kmpark@infradead.org>,
	linux-arm-kernel@lists.infradead.org,
	Santosh Shilimkar <santosh.shilimkar@ti.com>,
	Tony Lindgren <tony@atomide.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	linux-kernel@vger.kernel.org,
	Linus Walleij <linus.walleij@stericsson.com>
Subject: Re: [PATCH] ARM: l2x0: Check the correct address range
Date: Fri, 19 Nov 2010 19:56:35 +0000	[thread overview]
Message-ID: <20101119195635.GB10722@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <AANLkTikpAPLSTAzm2iPSV1_LL=B+zPbWzTPdhne3XFVc@mail.gmail.com>

On Fri, Nov 19, 2010 at 05:30:14AM -0600, Kanigeri, Hari wrote:
> > diff --git a/arch/arm/mm/cache-l2x0.c b/arch/arm/mm/cache-l2x0.c
> > index 170c9bb..50599d9 100644
> > --- a/arch/arm/mm/cache-l2x0.c
> > +++ b/arch/arm/mm/cache-l2x0.c
> > @@ -195,7 +195,7 @@ static void l2x0_clean_range(unsigned long start, unsigned long end)
> >        void __iomem *base = l2x0_base;
> >        unsigned long flags;
> >
> > -       if ((end - start) >= l2x0_size) {
> > +       if ((end - start + 1) >= l2x0_size) {
> 
> nitpick: probably will look more obvious if it is coded as  if ((end +
> 1) - start) >= l2x0_size)

Start defines the first byte of the object to perform the cache
maintainence on.  End defines the first subsequent byte not in the
object.  So, (end - start) is the number of bytes in the object,
and therefore the original code _is_ correct.

If you have an object which is 1MB in size, then (end - start) will
be 1048576 bytes.  If your cache is 1MB, then we'll use the xxx_all()
version of the function.

However, things get more murky when you consider that we have the
granularity of cache lines to deal with.

If start is mid-way in a cache line, then that cache line has to be
operated on.  If end is mid-way or at the end of a cache line, that
cache line also has to be operated on.  However, if end is at the
very first byte of the cache line, it must not be operated on.

So, it is possible for start = mid-cache line, end = start + 1048575,
that you will end up not doing the xxx_all() optimization, despite
operating on over 1MB of cached data - but this is only true for the
corner case up to 1MB + cache line size - 1.

      reply	other threads:[~2010-11-19 19:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-19  1:40 Kyungmin Park
2010-11-19 11:08 ` Catalin Marinas
2010-11-19 21:49   ` Linus WALLEIJ
2010-11-19 11:30 ` Kanigeri, Hari
2010-11-19 19:56   ` Russell King - ARM Linux [this message]

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=20101119195635.GB10722@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --cc=catalin.marinas@arm.com \
    --cc=h-kanigeri2@ti.com \
    --cc=kmpark@infradead.org \
    --cc=linus.walleij@stericsson.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=santosh.shilimkar@ti.com \
    --cc=tony@atomide.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®