linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: David Miller <davem@davemloft.net>
Cc: clameter@sgi.com, linux-mm@kvack.org, sparclinux@vger.kernel.org
Subject: Re: Vmstat: Small revisions to refresh_cpu_vm_stats()
Date: Tue, 13 Nov 2007 03:55:09 -0800	[thread overview]
Message-ID: <20071113035509.5d221318.akpm@linux-foundation.org> (raw)
In-Reply-To: <20071113.034737.199780122.davem@davemloft.net>

On Tue, 13 Nov 2007 03:47:37 -0800 (PST) David Miller <davem@davemloft.net> wrote:

> From: Andrew Morton <akpm@linux-foundation.org>
> Date: Tue, 13 Nov 2007 03:37:55 -0800
> 
> > : undefined reference to `__xchg_called_with_bad_pointer'
> > 
> > This is sparc64's way of telling you that you can'd do xchg on an s8.
> > 
> > Dave, is that fixable?
> > 
> > I assume not, in which case we either go for some open-coded implementation
> > for 8- and 16-bits or we should ban (at compile time) 8- and 16-bit xchg on
> > all architectures.
> 
> Right, let's write some generic code for this because other platforms
> are going to need this too.

ok.  I guess if x86 can do it in hardware then it's worthwhile.

> Basically, do a normal "ll/sc" or "load/cas" sequence on a u32 with
> some shifting and masking as needed.
> 
> 	int shift = (((unsigned long) addr) % 4) * 8;
> 	unsigned long mask = 0xff << shift;
> 	unsigned long val = newval << shift;
> 	u32 *ptr = (u32 *) ((unsigned long)addr & ~0x3UL);
> 
> 	while (1) {
> 		u32 orig, tmp = *ptr;
> 
> 		orig = tmp;
> 		tmp &= ~mask;
> 		tmp |= val;
> 		cmpxchg_u32(ptr, orig, tmp);
> 		if (orig == tmp)
> 			break;
> 	}
> 
> Repeat for u16, etc.
> 
> However, for platforms like sparc32 that can do a xchg() atomically
> but can't do cmpxchg, this idea won't work :-/

xchg() is nonatomic wrt other CPUs, so I think we can get by with
local_irq_save()/swap()/local_irq_restore().

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2007-11-13 11:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-10  2:39 Christoph Lameter
2007-11-13 11:37 ` Andrew Morton
2007-11-13 11:47   ` David Miller, Andrew Morton
2007-11-13 11:55     ` Andrew Morton [this message]
2007-11-13 22:05       ` Christoph Lameter

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=20071113035509.5d221318.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=clameter@sgi.com \
    --cc=davem@davemloft.net \
    --cc=linux-mm@kvack.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox