public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Bryan Wu <cooloney@kernel.org>
Cc: torvalds@linux-foundation.org, mingo@elte.hu,
	linux-kernel@vger.kernel.org, Graf Yang <graf.yang@analog.com>
Subject: Re: [PATCH 2/5] Blackfin arch: SMP supporting patchset: Blackfin header files and machine common code
Date: Tue, 18 Nov 2008 22:56:29 -0800	[thread overview]
Message-ID: <20081118225629.eddd23ae.akpm@linux-foundation.org> (raw)
In-Reply-To: <1226999108-13839-3-git-send-email-cooloney@kernel.org>

On Tue, 18 Nov 2008 17:05:05 +0800 Bryan Wu <cooloney@kernel.org> wrote:

> From: Graf Yang <graf.yang@analog.com>
> 
> Blackfin dual core BF561 processor can support SMP like features.
> https://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:smp-like
> 
> In this patch, we provide SMP extend to Blackfin header files
> and machine common code
> 
>
> ...
>
> +#define atomic_add_unless(v, a, u)				\
> +({								\
> +	int c, old;						\
> +	c = atomic_read(v);					\
> +	while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \
> +		c = old;					\
> +	c != (u);						\
> +})

The macro references its args multiple times and will do weird or
inefficient things when called with expressions which have
side-effects, or which do slow things.

>
> ...
>
> +#include <asm/system.h>		/* save_flags */
> +
> +static inline void set_bit(int nr, volatile unsigned long *addr)
>  {
>  	int *a = (int *)addr;
>  	int mask;
> @@ -57,21 +91,23 @@ static __inline__ void clear_bit(int nr, volatile unsigned long *addr)
>  	a += nr >> 5;
>  	mask = 1 << (nr & 0x1f);
>  	local_irq_save(flags);
> -	*a &= ~mask;
> +	*a |= mask;

I think you just broke clear_bit().  Maybe I'm misreading the diff.

>  	local_irq_restore(flags);
>  }
>
>
> ...
>
> +#define smp_mb__before_clear_bit()	barrier()
> +#define smp_mb__after_clear_bit()	barrier()
> +
> +static inline void __set_bit(int nr, volatile unsigned long *addr)
> +{
> +	int *a = (int *)addr;
> +	int mask;
> +
> +	a += nr >> 5;
> +	mask = 1 << (nr & 0x1f);
> +	*a |= mask;
> +}
> +
> +static inline void __clear_bit(int nr, volatile unsigned long *addr)
> +{
> +	int *a = (int *)addr;
> +	int mask;
> +
> +	a += nr >> 5;
> +	mask = 1 << (nr & 0x1f);
> +	*a &= ~mask;
> +}
> +
> +static inline void __change_bit(int nr, volatile unsigned long *addr)
> +{
> +	int mask;
> +	unsigned long *ADDR = (unsigned long *)addr;
> +
> +	ADDR += nr >> 5;
> +	mask = 1 << (nr & 31);
> +	*ADDR ^= mask;
> +}

I'm surprised there isn't any generic code which can be used for the above.

>
> ...
>

Gad what a lot of code.  I don't think I have time to read it all, sorry.

  reply	other threads:[~2008-11-19  6:57 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-18  9:05 [PATCH 0/5] Blackfin SMP like patchset Bryan Wu
2008-11-18  9:05 ` [PATCH 1/5] Blackfin arch: SMP supporting patchset: BF561 related code Bryan Wu
2008-11-19  6:56   ` Andrew Morton
2008-11-19  7:39     ` Bryan Wu
2008-11-19  8:10       ` gyang
2008-11-18  9:05 ` [PATCH 2/5] Blackfin arch: SMP supporting patchset: Blackfin header files and machine common code Bryan Wu
2008-11-19  6:56   ` Andrew Morton [this message]
2008-11-19  7:05     ` Nick Piggin
2008-11-19  7:44       ` Bryan Wu
2008-11-19  7:42     ` Bryan Wu
2008-11-20 13:50       ` Mike Frysinger
2008-11-19  7:52     ` gyang
2008-11-19  8:20       ` Bryan Wu
2008-11-19  7:44   ` Bryan Wu
2008-11-18  9:05 ` [PATCH 3/5] Blackfin arch: SMP supporting patchset: Blackfin CPLB related code Bryan Wu
2008-11-19  7:45   ` Bryan Wu
2008-11-18  9:05 ` [PATCH 4/5] Blackfin arch: SMP supporting patchset: Blackfin kernel and memory management code Bryan Wu
2008-11-19  7:46   ` Bryan Wu
2008-11-18  9:05 ` [PATCH 5/5] Blackfin arch: SMP supporting patchset: some other misc code Bryan Wu
2008-11-19  7:47   ` Bryan Wu
2008-11-19  6:56 ` [PATCH 0/5] Blackfin SMP like patchset Andrew Morton
2008-11-19  7:27   ` Bryan Wu
2008-11-19  7:28     ` Bryan Wu
2008-11-19 13:51   ` Mike Frysinger

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=20081118225629.eddd23ae.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=cooloney@kernel.org \
    --cc=graf.yang@analog.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=torvalds@linux-foundation.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