public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Cyrill Gorcunov <gorcunov@gmail.com>
To: Jiri Kosina <jkosina@suse.cz>
Cc: Adam Osuchowski <adwol@zonk.pl>,
	linux-kernel@vger.kernel.org, Ingo Molnar <mingo@elte.hu>,
	Nick Piggin <npiggin@suse.de>
Subject: Re: Is 386 processor still supported?
Date: Thu, 8 Jan 2009 16:24:42 +0300	[thread overview]
Message-ID: <20090108132442.GB8015@localhost> (raw)
In-Reply-To: <alpine.LRH.1.10.0901081359520.24105@twin.jikos.cz>

[Jiri Kosina - Thu, Jan 08, 2009 at 02:05:48PM +0100]
| 
| [ CCs added ]
| 
| On Thu, 8 Jan 2009, Adam Osuchowski wrote:
| 
| > Recently, I found such piece of code in kernel 2.6.28 compiled for 386
| > processor:
| > 
| > # grep M386 .config
| > CONFIG_M386=y
| > # objdump -d vmlinux | grep -A11 '<_spin_lock>:'
| > c0321827 <_spin_lock>:
| > c0321827:	89 e2                	mov    %esp,%edx
| > c0321829:	81 e2 00 f0 ff ff    	and    $0xfffff000,%edx
| > c032182f:	ff 42 14             	incl   0x14(%edx)
| > c0321832:	ba 00 01 00 00       	mov    $0x100,%edx
| > c0321837:	f0 66 0f c1 10       	lock xadd %dx,(%eax)
| > c032183c:	38 f2                	cmp    %dh,%dl
| > c032183e:	74 06                	je     c0321846 <_spin_lock+0x1f>
| > c0321840:	f3 90                	pause  
| > c0321842:	8a 10                	mov    (%eax),%dl
| > c0321844:	eb f6                	jmp    c032183c <_spin_lock+0x15>
| > c0321846:	c3                   	ret    
| > 
| > But there is no xadd instruction on 386 processors. It is available on
| > 486+ only. I have no chance to run this kernel on real 386 box, so I can't
| > check it in practice, but I think it will not run.
| > 
| > It is not compiler problem because it is explicitly written in assembly
| > in __raw_spin_lock() function (include/asm-x86/spinlock.h) and there is
| > no alternative code depending on CONFIG_M386.
| 
| Hmm, this really looks like a bug to me. How about something like this 
| (untested).
| 
| 
| From: Jiri Kosina <jkosina@suse.cz>
| Subject: x86: make spinlocks available on machines without xadd insn
| 
| Current kernel wouldn't compile on ancient x86 machines that don't support 
| xadd instruction, as ticket spinlocks implementation unconditionally uses 
| it.
| 
| On machines without CONFIG_X86_XADD, use old-style byte spinlock 
| implementation instead.
| 
| Reported-by: Adam Osuchowski <adwol@zonk.pl>
| Signed-off-by: Jiri Kosina <jkosina@suse.cz>
| 
| diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
| index d17c919..b3bc71b 100644
| --- a/arch/x86/include/asm/spinlock.h
| +++ b/arch/x86/include/asm/spinlock.h
| @@ -236,6 +236,40 @@ static inline void __byte_spin_unlock(raw_spinlock_t *lock)
|  	bl->lock = 0;
|  }
|  #else  /* !CONFIG_PARAVIRT */
| +
| +/* old x86 machines do not have xadd insns, use old-style locks for them */
| +#ifndef CONFIG_X86_XADD
| +static inline int __raw_spin_is_locked(raw_spinlock_t *lock)
| +{
| +	return __byte_spin_is_locked(lock);
| +}
| +
| +static inline int __raw_spin_is_contended(raw_spinlock_t *lock)
| +{
| +	return __byte_spin_is_contended(lock);
| +}
| +
| +static __always_inline void __raw_spin_lock(raw_spinlock_t *lock)
| +{
| +	__byte_spin_lock(lock);
| +}
| +
| +static __always_inline int __raw_spin_trylock(raw_spinlock_t *lock)
| +{
| +	return __byte_spin_trylock(lock);
| +}
| +
| +static __always_inline void __raw_spin_unlock(raw_spinlock_t *lock)
| +{
| +	__byte_spin_unlock(lock);
| +}
| +
| +static __always_inline void __raw_spin_lock_flags(raw_spinlock_t *lock,
| +						  unsigned long flags)
| +{
| +	__raw_spin_lock(lock);
| +}
| +#else /* CONFIG_X86_XADD */
|  static inline int __raw_spin_is_locked(raw_spinlock_t *lock)
|  {
|  	return __ticket_spin_is_locked(lock);
| @@ -267,6 +301,7 @@ static __always_inline void __raw_spin_lock_flags(raw_spinlock_t *lock,
|  	__raw_spin_lock(lock);
|  }
|  
| +#endif  /* CONFIG_X86_XADD */
|  #endif	/* CONFIG_PARAVIRT */
|  
|  static inline void __raw_spin_unlock_wait(raw_spinlock_t *lock)
| 

Jiri I could be wrong but it seems __byte_spin_lock is implemented
under CONFIG_PARAVIRT and now referred under #else  /* !CONFIG_PARAVIRT */
At least I didn'y found additional implementaion in tree.
Did I miss anything?

		- Cyrill -

  reply	other threads:[~2009-01-08 13:24 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-08 12:03 Is 386 processor still supported? Adam Osuchowski
2009-01-08 13:05 ` Jiri Kosina
2009-01-08 13:24   ` Cyrill Gorcunov [this message]
2009-01-08 13:48     ` Jiri Kosina
2009-01-08 14:13   ` Peter Zijlstra
2009-01-08 14:21     ` Jiri Kosina
2009-01-08 14:27       ` Peter Zijlstra
2009-01-08 15:04         ` Alan Cox
2009-01-08 15:10           ` Ingo Molnar
2009-01-13  1:06             ` Maciej W. Rozycki
2009-01-15 12:36               ` Jan-Benedict Glaw
2009-01-15 13:22                 ` Maciej W. Rozycki
2009-01-15 13:32                   ` Alan Cox
2009-01-15 14:15                     ` Maciej W. Rozycki
2009-01-15 14:17                       ` Ingo Molnar
2009-01-16  9:00                         ` Pavel Machek
2009-01-16 10:13                           ` Jan-Benedict Glaw
2009-01-16 11:18                           ` Andrey Panin
2009-01-16 13:46                           ` Ingo Molnar
2009-01-16 18:17                           ` H. Peter Anvin
2009-01-15 14:20                       ` Jan-Benedict Glaw
2009-01-15 14:37                         ` Bastien ROUCARIES
2009-01-15 14:25                       ` Alan Cox
2009-01-15 14:44                         ` Maciej W. Rozycki
2009-01-15 20:11                           ` H. Peter Anvin
2009-01-15 14:46                     ` Jan-Benedict Glaw
2009-01-08 16:45         ` Sam Ravnborg
2009-01-08 16:27   ` Andi Kleen

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=20090108132442.GB8015@localhost \
    --to=gorcunov@gmail.com \
    --cc=adwol@zonk.pl \
    --cc=jkosina@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=npiggin@suse.de \
    /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