All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ralf Baechle <ralf@linux-mips.org>
To: "Kevin D. Kissell" <kevink@paralogos.com>
Cc: wuzhangjin@gmail.com, linux-mips@linux-mips.org
Subject: Re: Error: symbol `__pastwait' is already defined
Date: Sun, 14 Jun 2009 10:12:45 +0100	[thread overview]
Message-ID: <20090614091245.GA27667@linux-mips.org> (raw)
In-Reply-To: <4A33D2EA.801@paralogos.com>

On Sat, Jun 13, 2009 at 06:25:14PM +0200, Kevin D. Kissell wrote:

> Calling a function does not cause replication of its symbols.  That  
> would happen if it were a macro, or an inline function, but not a simple  
> global function, which r4k_wait_irqoff is supposed to be, since (at  
> least the last time I worked with it), it is only called indirectly by  
> having its address stored in the cpu_wait function pointer.  Either your  
> compiler is doing something insane and replicating the function each  
> time its address is taken (!), or someone has added another __pastwait  
> symbol somewhere.
>
> And you are correct that moving the symbol to another function risks  
> breaking the functionality. Even if the compiler didn't reorder things -  
> which you are correct to note that it might do - you would create a  
> window during which the kernel would mistakenly believe that the CPU was  
> in the interrupt-disabled wait state when in fact it had just fallen out  
> of the loop and serviced an interrupt.  I don't think that would  
> necessarily be fatal, but it would at least be inefficient.

It depends on how gcc optimized the if statement.  Gcc might compile the
function as if it was written like this:

void r4k_wait_irqoff(void)
{
	local_irq_disable();
	if (need_resched())
		goto nowait;

	__asm__(
	"	.set	push		\n"
	"	.set	mips3		\n"
	"	wait			\n"
	"	.set	pop		\n");
	local_irq_enable();
	__asm__(
	"	.globl	__pastwait	\n"
	"__pastwait:			\n");
	return;

nowait
	local_irq_enable();
	__asm__(
	"	.globl	__pastwait	\n"
	"__pastwait:			\n");
}

Which isn't quite the brightest thing to do but perfectly legal.  As for
gcc follow the old motto trust is futile, suspicion breeds confidence.

  Ralf

      reply	other threads:[~2009-06-15 13:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-13  7:58 Error: symbol `__pastwait' is already defined Wu Zhangjin
2009-06-13 16:25 ` Kevin D. Kissell
2009-06-14  9:12   ` Ralf Baechle [this message]

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=20090614091245.GA27667@linux-mips.org \
    --to=ralf@linux-mips.org \
    --cc=kevink@paralogos.com \
    --cc=linux-mips@linux-mips.org \
    --cc=wuzhangjin@gmail.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 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.