mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jamie Lokier <jamie@shareable.org>
To: "David S. Miller" <davem@redhat.com>
Cc: mfedyk@matchmail.com, lm@bitmover.com, linux-kernel@vger.kernel.org
Subject: Re: x86, ARM, PARISC, PPC, MIPS and Sparc folks please run this
Date: Mon, 1 Sep 2003 09:29:11 +0100	[thread overview]
Message-ID: <20030901082911.GA1638@mail.jlokier.co.uk> (raw)
In-Reply-To: <20030901000615.28d93760.davem@redhat.com>

David S. Miller wrote:
> I disagree, MAP_FIXED means "I know what I am doing don't override
> this unless the mapping area is not available in my address space."
> You should never specify MAP_FIXED unless you _REALLY_ know what you
> are doing.

So explain this from the Sparc architecture code:

	if (flags & MAP_FIXED) {
		/* We do not accept a shared mapping if it would violate
		 * cache aliasing constraints.
		 */
		if ((flags & MAP_SHARED) && (addr & (SHMLBA - 1)))
			return -EINVAL;
		return addr;
	}

Ok, I'll explain it :)  At one time, the code did what the comment says,
but nowadays linux/mm/mmap.c doesn't call arch_get_unmapped_area() for
MAP_FIXED, so the above code is redundant and misleading.  It already
mislead me, so please remove it.  sparc and sparc64 both have it.

> > Thus I have three Sparc-specific questions:
> > 
> > 	1. How does userspace find out the value of SHMLBA?
> > 	   On Sparc, it is not a compile-time constant.
> 
> Don't specify MAP_FIXED for MAP_SHARED mapping if you want
> proper coherency, that's my answer for this one.

I can't safely set up this kind of mapping without MAP_FIXED, unless I
know SHMLBA.

This is my strategy:

	mmap MAP_ANON without MAP_FIXED to find a free area
	mmap MAP_FIXED over the anon area at same address
	mmap MAP_FIXED over the anon area at larger address

I don't see any strategy that lets me establish this kind of circular
mapping on Sparc without either (a) knowing the value of SHMLBA, or
(b) risking clobbering another thread's mmap.

> > 	3. Is there a kernel bug on Sparc, because the test program
> > 	   is either getting mappings that aren't aligned to run time
> > 	   SHMLBA, or the kernel's run time SHMLBA value is not correct.
> 
> No, the user is allowed to hang himself with MAP_FIXED.
> The bug is in your code :)

Well, my code has no bug because I do run-time tests to see what
rubbish the architecture gave me.  As we see, they work :)

I don't see any real alternative to doing that.  But that's ok, it
seems robust and portable.  It's a shame about the slow cache flush,
because I can sometimes use fast cache flushing to improve my DSP
buffering algorithms.

> > 	2. Is flushing part of the data cache something I can do from
> > 	   userspace?  (I'll figure out the exact machine instructions
> > 	   myself if I need to do this, but it'd be nice to know if
> > 	   it's possible before I have a go).
> 
> There is no efficient way to do this from userspace, only the
> kernel has access to the more efficient cache flushing instructions.
> You'd need to flush via loads to displace the aliasing cache lines.

Will msync() do it?

Thanks,
-- Jamie

  reply	other threads:[~2003-09-01  8:29 UTC|newest]

Thread overview: 106+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-29  5:35 Jamie Lokier
2003-08-29 10:03 ` J.A. Magallon
2003-08-29 10:36   ` Alan Cox
2003-09-01  4:49   ` Jamie Lokier
2003-08-29 10:04 ` Sergey S. Kostyliov
2003-08-29 10:15 ` J.A. Magallon
2003-08-29 10:21 ` J.A. Magallon
2003-08-29 10:34 ` CaT
2003-08-29 10:37 ` CaT
2003-08-29 10:49 ` Mikael Pettersson
2003-08-29 11:41 ` Gianni Tedesco
2003-08-29 11:51 ` James Morris
2003-08-29 15:41 ` Larry McVoy
2003-08-29 23:05   ` Mike Fedyk
2003-08-31  5:10     ` David S. Miller
2003-08-31 22:49       ` Jamie Lokier
2003-09-01  5:31         ` David S. Miller
2003-09-01  6:42           ` Jamie Lokier
2003-09-01  7:06             ` David S. Miller
2003-09-01  8:29               ` Jamie Lokier [this message]
2003-09-01  9:02                 ` David S. Miller
2003-09-01 10:04                   ` Jamie Lokier
2003-09-01 10:02                     ` David S. Miller
2003-09-03 17:36                   ` bill davidsen
2003-09-04 22:50                     ` Jamie Lokier
2003-09-01  5:44   ` Jamie Lokier
2003-09-01 14:43     ` Larry McVoy
2003-09-01 16:33       ` Jamie Lokier
2003-09-01 16:58         ` Larry McVoy
2003-09-02 20:29       ` Jamie Lokier
2003-08-29 15:47 ` Herbert Poetzl
2003-08-30  1:48   ` Stuart Longland
2003-08-29 16:27 ` Geert Uytterhoeven
2003-09-01  5:58   ` Jamie Lokier
2003-09-01  8:34     ` Geert Uytterhoeven
2003-09-01  9:09       ` Kars de Jong
2003-09-01 10:08         ` Jamie Lokier
2003-09-01 11:13           ` Roman Zippel
2003-09-02 20:42           ` Kars de Jong
2003-09-02 21:39             ` Jamie Lokier
2003-09-03  7:59             ` Geert Uytterhoeven
2003-09-03  9:13               ` Jamie Lokier
2003-09-03  9:26                 ` Geert Uytterhoeven
2003-09-03 12:17                   ` Roman Zippel
2003-09-03 12:36                     ` Geert Uytterhoeven
2003-09-03 13:29                       ` Jamie Lokier
2003-09-03 16:07                         ` Nagendra Singh Tomar
2003-09-04  5:03                           ` Davide Libenzi
2003-09-03 18:03                             ` Nagendra Singh Tomar
2003-09-04  6:38                               ` Davide Libenzi
2003-09-04 11:19                           ` Alan Cox
2003-09-05 21:24                             ` Pavel Machek
2003-09-06 23:09                               ` Jamie Lokier
2003-09-07 13:10                                 ` Pavel Machek
2003-09-07 13:35                                   ` Jamie Lokier
2003-09-07 13:40                                     ` Pavel Machek
2003-09-07 13:53                                       ` Jamie Lokier
2003-09-07 17:56                                         ` Alan Cox
2003-09-03 12:13               ` Jan-Benedict Glaw
2003-09-01 10:35       ` Sam Creasey
2003-09-01 10:48         ` Jamie Lokier
2003-09-01 12:23           ` Sam Creasey
2003-09-03  8:00       ` Kars de Jong
2003-09-03  8:05         ` Geert Uytterhoeven
2003-09-03  9:24           ` Kars de Jong
2003-08-29 16:31 ` Brian Jackson
2003-08-29 17:39 ` Matt Porter
2003-09-01  6:00   ` Jamie Lokier
2003-09-01 11:17     ` Alan Cox
2003-09-01 17:22     ` Roland Dreier
2003-09-02  2:16       ` Matt Porter
2003-09-02  5:40         ` Jamie Lokier
2003-08-29 19:37 ` Thorsten Kranzkowski
2003-08-29 20:03 ` Sean Neakums
2003-08-29 20:14 ` Iulian Musat
2003-08-29 20:26 ` Paul J.Y. Lahaie
2003-09-01  8:15   ` Russell King
2003-09-01 10:12     ` Jamie Lokier
2003-09-01 11:30       ` Geert Uytterhoeven
2003-09-01 14:17       ` Russell King
2003-09-01 14:51         ` Russell King
2003-09-01 19:09           ` Guennadi Liakhovetski
2003-09-01 16:52         ` Jamie Lokier
2003-09-01 17:11           ` Russell King
2003-09-02  5:34             ` Jamie Lokier
2003-09-02  8:15               ` Russell King
2003-09-02 11:57                 ` Jamie Lokier
2003-09-02 18:52                   ` Russell King
2003-09-02 23:59                     ` Larry McVoy
2003-09-03  7:31                       ` Russell King
2003-09-03  7:41                         ` Jamie Lokier
2003-09-03 18:05                           ` Russell King
2003-09-04 22:20                             ` Jamie Lokier
2003-09-04 17:37       ` Maciej W. Rozycki
2003-08-29 22:35 ` Kenneth Johansson
2003-08-29 23:47 ` Kurt Wall
2003-09-01  0:24 ` Paul Mundt
2003-09-01  0:37   ` Jamie Lokier
2003-09-01  1:00     ` Paul Mundt
2003-09-01  1:58       ` Jamie Lokier
2003-09-01  1:13 ` dean gaudet
2003-09-01  4:29   ` Jamie Lokier
2003-09-02 10:08 ` Jan Rychter
     [not found] <20030829053510.GA12663@mail.jlokier.co.uk.suse.lists.linux.kernel>
2003-08-29 11:08 ` Andi Kleen
2003-08-29 11:17   ` Russell King
2003-09-01  5:03   ` Jamie Lokier

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=20030901082911.GA1638@mail.jlokier.co.uk \
    --to=jamie@shareable.org \
    --cc=davem@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lm@bitmover.com \
    --cc=mfedyk@matchmail.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®