All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ralf Baechle <ralf@linux-mips.org>
To: Jean-Christophe PINCE <jcpince@gmail.com>
Cc: linux-kernel@vger.kernel.org, linux-mips@linux-mips.org
Subject: Re: MIPS ASID type conflicts
Date: Fri, 2 Nov 2012 10:44:23 +0100	[thread overview]
Message-ID: <20121102094423.GB17860@linux-mips.org> (raw)
In-Reply-To: <CAEiBgeAukAdZv1WNcJQ6DByP7Yy63gvRS0cY6q6yU27p+XRi4A@mail.gmail.com>

On Mon, Apr 23, 2012 at 01:49:26PM +0200, Jean-Christophe PINCE wrote:

> I am analyzing Linux MIPS tasks memory spaces and found out what I
> think is a bug in the ASID management.
> 
> The structure "struct cpuinfo_mips" defined in
> arch/mips/include/asm/cpu-info.h uses a "unsigned int" field for
> asid_cache while the context field defined in
> arch/mips/include/asm/mmu.h is a "unsigned long".
> 
> This is ok with 32bits kernel but leads to 4bytes vs 8bytes fields
> with a 64bits kernel. And when the scheduler checks if the ASID is of
> an older ASID_VERSION, the test will always return that the version
> differs when the context bits above bit31 will be set.
> 
> I imagine this should be a quite rare issue but could likely happen on
> devices running for very long and starting processes very often (or
> running more than 256 processes per cpu). When this condition (bit 32
> or above of asid_cache is set), the effect should be that the TLB will
> be flushed on each context_switch required by the scheduler but there
> shouldn't be any crash.

A full flush of the TLB can be implemented by picking a fresh ASID as
long as there are still fresh ASIDs available.  This happens fairly
frequently; a typical system has burned through the first 256 ASIDs
somewhen during bootup.

There is not much advantage to be gained from having the ASID and generation
counter in a 64-bit variable so I think I'm just going to change
mmu_context_t to:

typedef struct {
        unsigned int asid[NR_CPUS];
        void *vdso;
} mm_context_t;

  Ralf

      reply	other threads:[~2012-11-02  9:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-23 11:49 MIPS ASID type conflicts Jean-Christophe PINCE
2012-11-02  9:44 ` Ralf Baechle [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=20121102094423.GB17860@linux-mips.org \
    --to=ralf@linux-mips.org \
    --cc=jcpince@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@linux-mips.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.