Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
* how to simulate an unaligned ldl_l
@ 2000-02-13 23:20 Ross A. Knepper
  2000-02-14  5:07 ` Jay.Estabrook
  2000-02-15  3:08 ` Richard Henderson
  0 siblings, 2 replies; 6+ messages in thread
From: Ross A. Knepper @ 2000-02-13 23:20 UTC (permalink / raw)
  To: axp-list


i've been looking at porting reiserfs to alpha.  unfortunately, it has a
bunch of unaligned data accesses.  naturally, intel doesnt care.  on
alpha, most unaligned LDx/STx instructions are emulated by a software
trap (outside the kernel that is -- i don't know about inside).  however,
this is not the case with the load_locked and store_conditional
instructions.

i'm looking at a number of routines that use these instructions for
atomicity, via clear_bit(), set_bit(), etc. in asm/bitops.h.  is there any
clever way to circumvent this problem?  the only hack i can think of at
the moment is to use ldl_u to extract it, put it into an aligned longword
buffer and do the ldl_l on that address instead.  i feel like i'd have to
be insane to try this, however :)

anybody had this problem before?  found a solution?

thanks much!

 -ross


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: how to simulate an unaligned ldl_l
  2000-02-13 23:20 how to simulate an unaligned ldl_l Ross A. Knepper
@ 2000-02-14  5:07 ` Jay.Estabrook
  2000-02-14 13:15   ` Peter Rival
  2000-02-15  3:08 ` Richard Henderson
  1 sibling, 1 reply; 6+ messages in thread
From: Jay.Estabrook @ 2000-02-14  5:07 UTC (permalink / raw)
  To: axp-list


>>> "Ross A. Knepper" said:
> 
> i've been looking at porting reiserfs to alpha.  unfortunately, it has a
> bunch of unaligned data accesses.  naturally, intel doesnt care.  on
> alpha, most unaligned LDx/STx instructions are emulated by a software
> trap (outside the kernel that is -- i don't know about inside).  however,
> this is not the case with the load_locked and store_conditional
> instructions.

Uh, oh... :-\

> i'm looking at a number of routines that use these instructions for
> atomicity, via clear_bit(), set_bit(), etc. in asm/bitops.h.  is there any
> clever way to circumvent this problem?  the only hack i can think of at
> the moment is to use ldl_u to extract it, put it into an aligned longword
> buffer and do the ldl_l on that address instead.  i feel like i'd have to
> be insane to try this, however :)
> 
> anybody had this problem before?  found a solution?

The only solution is to align those accesses.

The load_locked and store_conditional *MUST* be used with aligned operands,
otherwise what they are attempting to do (protect change of state from SMP
meddling) cannot be relied on.

And I believe strongly that this will be a problem on other architectures
beside Alpha. You must convince the authors to rework the data structures to
size and align the important fields correctly for operation on other
platorms than INTEL.

--Jay++

---------------------------------------------------------------
Jay A Estabrook                       Alpha Engineering - LINUX
Compaq Computer Corp. - MRO1-2/K20    (508) 467-2080
200 Forest Street, Marlboro MA 01752  Jay.Estabrook@compaq.com
---------------------------------------------------------------


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: how to simulate an unaligned ldl_l
  2000-02-14  5:07 ` Jay.Estabrook
@ 2000-02-14 13:15   ` Peter Rival
  2000-02-14 15:26     ` set_program_attributes message J. Pedro Sousa do Amaral
  2000-02-14 15:51     ` how to simulate an unaligned ldl_l Joseph A. Martin
  0 siblings, 2 replies; 6+ messages in thread
From: Peter Rival @ 2000-02-14 13:15 UTC (permalink / raw)
  To: axp-list

Jay.Estabrook@compaq.com wrote:

> >>> "Ross A. Knepper" said:
> >
> > i've been looking at porting reiserfs to alpha.  unfortunately, it has a
> > bunch of unaligned data accesses.  naturally, intel doesnt care.  on
> > alpha, most unaligned LDx/STx instructions are emulated by a software
> > trap (outside the kernel that is -- i don't know about inside).  however,
> > this is not the case with the load_locked and store_conditional
> > instructions.
>
> Uh, oh... :-\
>
> > i'm looking at a number of routines that use these instructions for
> > atomicity, via clear_bit(), set_bit(), etc. in asm/bitops.h.  is there any
> > clever way to circumvent this problem?  the only hack i can think of at
> > the moment is to use ldl_u to extract it, put it into an aligned longword
> > buffer and do the ldl_l on that address instead.  i feel like i'd have to
> > be insane to try this, however :)
> >
> > anybody had this problem before?  found a solution?
>
> The only solution is to align those accesses.
>
> The load_locked and store_conditional *MUST* be used with aligned operands,
> otherwise what they are attempting to do (protect change of state from SMP
> meddling) cannot be relied on.
>
> And I believe strongly that this will be a problem on other architectures
> beside Alpha. You must convince the authors to rework the data structures to
> size and align the important fields correctly for operation on other
> platorms than INTEL.
>

Jay - would it be enough to just simply wrap these data structures in an
__aligned(32) -type declaration?  Worst case I'd think would be that we'd have
to re-order struct members,which should only be a problem if they are written
to disk as is.  But that's what conversion programs are for ;)

 - Pete


^ permalink raw reply	[flat|nested] 6+ messages in thread

* set_program_attributes message
  2000-02-14 13:15   ` Peter Rival
@ 2000-02-14 15:26     ` J. Pedro Sousa do Amaral
  2000-02-14 15:51     ` how to simulate an unaligned ldl_l Joseph A. Martin
  1 sibling, 0 replies; 6+ messages in thread
From: J. Pedro Sousa do Amaral @ 2000-02-14 15:26 UTC (permalink / raw)
  To: axp-list

Hi,
In the last couple of days, my AlphaStation (Avanti, running 2.2.14) has the
following message repeated echoed in front of the login prompt:

set_program_attributes(120000000 1c000 140000000 18c00

In the morning when I come to my desk, this message will be repeated four
times, and this has happened in the last two days but not before. Do any of
you know what this means? Should I worry about this?

I do not remember adding anything new to this machine.
TIA,
ZP
-- 
José Pedro Sousa do Amaral

What had that flower to do with being white,
The wayside blue and innocent heal-all?
What brought the kindred spider to that height,
Then steered the white moth thither in the night?
What but design of darkness to appall?--
If design govern in a thing so small.

   --R. Frost


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: how to simulate an unaligned ldl_l
  2000-02-14 13:15   ` Peter Rival
  2000-02-14 15:26     ` set_program_attributes message J. Pedro Sousa do Amaral
@ 2000-02-14 15:51     ` Joseph A. Martin
  1 sibling, 0 replies; 6+ messages in thread
From: Joseph A. Martin @ 2000-02-14 15:51 UTC (permalink / raw)
  To: axp-list

> i'm looking at a number of routines that use these instructions for
> atomicity, via clear_bit(), set_bit(), etc. in asm/bitops.h.  is there any
> clever way to circumvent this problem?  the only hack i can think of at
> the moment is to use ldl_u to extract it, put it into an aligned longword
> buffer and do the ldl_l on that address instead.  i feel like i'd have to
> be insane to try this, however :)

Doesn't sound like it would work either, since you're not effectively
locking the transfer between the aligned memory word and the unaligned
memory.  I like the __aligned(32) suggestion best, but if you want to
muck with the bitop functions instead of the data structures, consider
a modification like this:

extern __inline__ void set_bit(unsigned long nr, volatile void * addr)
{
	unsigned long oldbit;
	unsigned long temp;
#ifdef UNALIGNED_addr
	unsigned int * m;
	nr += ((unsigned long)addr & 3) << 3;
	addr = (void *)((unsigned long)addr & ~(3L));
	m = ((unsigned int *) addr) + (nr >> 5);
#else
	unsigned int * m = ((unsigned int *) addr) + (nr >> 5);
#endif

	__asm__ __volatile__(
	"1:	ldl_l %0,%1\n"
	"	and %0,%3,%2\n"
	"	bne %2,2f\n"
	"	xor %0,%3,%0\n"
	"	stl_c %0,%1\n"
	"	beq %0,3f\n"
	"2:\n"
	".section .text2,\"ax\"\n"
	"3:	br 1b\n"
	".previous"
	:"=&r" (temp), "=m" (*m), "=&r" (oldbit)
	:"Ir" (1UL << (nr & 31)), "m" (*m));
}




\Joe   [Joseph.Martin@Compaq.com	Joseph A. Martin
			 		Compaq Computer Corporation
					200 Forest Street MRO1-2/K20
 (508) 467-2100				Marlboro, MA  01752  U.S.A.
 ]


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: how to simulate an unaligned ldl_l
  2000-02-13 23:20 how to simulate an unaligned ldl_l Ross A. Knepper
  2000-02-14  5:07 ` Jay.Estabrook
@ 2000-02-15  3:08 ` Richard Henderson
  1 sibling, 0 replies; 6+ messages in thread
From: Richard Henderson @ 2000-02-15  3:08 UTC (permalink / raw)
  To: axp-list

On Sun, Feb 13, 2000 at 06:20:48PM -0500, Ross A. Knepper wrote:
> i'm looking at a number of routines that use these instructions for
> atomicity, via clear_bit(), set_bit(), etc. in asm/bitops.h.  is there any
> clever way to circumvent this problem?

No.  I wonder if reiserfs actually needs atomic operations,
or whether they're using set_bit etc for convenience.


r~


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2000-02-15  3:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-02-13 23:20 how to simulate an unaligned ldl_l Ross A. Knepper
2000-02-14  5:07 ` Jay.Estabrook
2000-02-14 13:15   ` Peter Rival
2000-02-14 15:26     ` set_program_attributes message J. Pedro Sousa do Amaral
2000-02-14 15:51     ` how to simulate an unaligned ldl_l Joseph A. Martin
2000-02-15  3:08 ` Richard Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox