From: Andrew Morton <akpm@linux-foundation.org>
To: David Miller <davem@davemloft.net>
Cc: airlied@linux.ie, benh@kernel.crashing.org,
dri-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm: Preserve SHMLBA bits in hash key for _DRM_SHM mappings.
Date: Thu, 19 Feb 2009 15:27:26 -0800 [thread overview]
Message-ID: <20090219152726.9551fb7a.akpm@linux-foundation.org> (raw)
In-Reply-To: <20090218.154102.122148224.davem@davemloft.net>
On Wed, 18 Feb 2009 15:41:02 -0800 (PST)
David Miller <davem@davemloft.net> wrote:
>
> Platforms such as sparc64 have D-cache aliasing issues. We
> cannot allow virtual mappings in different contexts to be such
> that two cache lines can be loaded for the same backing data.
> Updates to one cache line won't be seen by accesses to the other
> cache line.
>
> Code in sparc64 and other architectures solve this problem by
> making sure that all userland mappings of MAP_SHARED objects have
> the same virtual address base. They implement this by keying
> off of the page offset, and using that to choose a suitably
> consistent virtual address for mmap() requests.
>
> Making things even worse, getting this wrong on sparc64 can result
> in hangs during DRM lock acquisition. This is because, at least on
> UltraSPARC-III, normal loads consult the D-cache but atomics such
> as 'cas' (which is what cmpxchg() is implement using) only consult
> the L2 cache. So if a D-cache alias is inserted, the load can
> see different data than the atomic, and we'll loop forever because
> the atomic compare-and-exchange will never complete successfully.
>
> So to make this all work properly, we need to make sure that the
> hash address computed by drm_map_handle() preserves the SHMLBA
> relevant bits, and that's what this patch does for _DRM_SHM mappings.
>
> As a historical note, many years ago this bug didn't exist because we
> used to just use the low 32-bits of the address as the hash and just
> hope for the best. This preserved the SHMLBA bits properly. But when
> the hashtab code was added to DRM, this was no longer the case.
>
> ...
>
> #include <linux/vmalloc.h>
> +#include <linux/log2.h>
> +#include <asm/shmparam.h>
> #include "drmP.h"
>
The inclusion of asm/shmparam.h direct from a driver is a bit risky.
It assumes that asm/shmparam.h is compileable in isolation from the
additional things which include/linux/shm.h includes. In particular,
asm/page.h.
eg:
arch/xtensa/include/asm/shmparam.h
#define SHMLBA ((PAGE_SIZE > DCACHE_WAY_SIZE)? PAGE_SIZE : DCACHE_WAY_SIZE)
But including linux/shm.h here seems a bit silly. We'll see..
next prev parent reply other threads:[~2009-02-19 23:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-18 23:41 David Miller
2009-02-19 23:27 ` Andrew Morton [this message]
2009-02-20 8:54 ` David Miller
2009-02-20 9:43 ` Andrew Morton
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=20090219152726.9551fb7a.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=airlied@linux.ie \
--cc=benh@kernel.crashing.org \
--cc=davem@davemloft.net \
--cc=dri-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome