All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Dake <sdake@redhat.com>
To: sparclinux@vger.kernel.org
Subject: Re: mmap operation not working as expected on sparc linux
Date: Wed, 01 Jun 2011 09:37:04 +0000	[thread overview]
Message-ID: <4DE60840.900@redhat.com> (raw)
In-Reply-To: <4DE5F5B9.4020601@redhat.com>

On 06/01/2011 01:38 AM, David Miller wrote:
> From: Steven Dake <sdake@redhat.com>
> Date: Wed, 01 Jun 2011 01:18:01 -0700
> 
>> I maintain a project called corosync which uses a memory backed file to
>> generate a duplicate mapping in memory to implement a ring buffer.  It
>> essentially uses the concepts here:
>>
>> http://en.wikipedia.org/wiki/Ring_buffer#Exemplary_POSIX_Implementation
>>
>> This doesn't appear to work on sparclinux, returning an error EINVAL  on
>> the second memory map operation:
>>
>> address = mmap (buffer->address + buffer->count_bytes,
>>                   buffer->count_bytes, PROT_READ | PROT_WRITE,
>>                   MAP_FIXED | MAP_SHARED, file_descriptor, 0);
>>
>> Any ideas?
> 
> The start addresses of fixed and shared mappings need to have a
> certain property relative to other such mappings.
> 
> And that property is that the addresses must all be modulo the
> D-cache alias factor, which on sparc64 is 16384 bytes.
> 
> If we didn't enfore this, then writes from one mapping could get
> aliased in the L1 D-cache, and not show up in other mappings.
> 
> However if we force all the start address to the same 16K boundary,
> then this guarentees that writes to one mapping will show up in
> others.
> 
> You'll hit similar issues on MIPS, ARM, PARISC, and SH.  Just look for
> which platforms define __ARCH_FORCE_SHMLBA in their shmparam.h header
> file.

Thanks for the response.  For those searching for this problem in the
future, We tried 16384, and then decided to have a look at the kernel
source tree and came up with some speculation that the hugetlb settings
would result in EINVAL via prepare_hugetlb.  The minimum page we could
execute this operation on was 4MB.  I notice on some other arches this
is not required.

Best regards
-steve

  parent reply	other threads:[~2011-06-01  9:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-01  8:18 mmap operation not working as expected on sparc linux Steven Dake
2011-06-01  8:38 ` David Miller
2011-06-01  9:37 ` Steven Dake [this message]
2011-06-01 16:39 ` william felipe_welter
2011-06-02 15:47 ` william felipe_welter
2011-06-02 21:27 ` David Miller
2011-06-02 21:53 ` Steven Dake
2011-06-06 23:06 ` Matthias Rosenfelder

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=4DE60840.900@redhat.com \
    --to=sdake@redhat.com \
    --cc=sparclinux@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 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.