linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Getting the instruction pointer on a per arch basis
@ 2018-07-31 22:32 Nick Desaulniers
  2018-07-31 23:09 ` Nick Desaulniers
  0 siblings, 1 reply; 6+ messages in thread
From: Nick Desaulniers @ 2018-07-31 22:32 UTC (permalink / raw)
  To: LKML; +Cc: Pirama Arumuga Nainar, Greg Hackmann, Mark Salyzyn

I'm currently looking into cleaning up the code duplication between
current_text_addr() and _THIS_IP_, virtually every implementation of
current_text_addr() and _THIS_IP_ itself are basically:

#define _THIS_IP_ ({ __label__ _l; _l: &&_l; })

For a few arch's, they have inline assembly instead (for
current_text_addr()).  Examples:
* s390
* sh
* ia64
* x86 (um and 32b)
* c6x
* sparc

I have a patch that cuts down on the duplication, but I don't
understand why the few arch specific implementations are necessary.  I
could reduce the duplication further if it's ok to just use the
statement expression.

Does anyone know why this is the case?
-- 
Thanks,
~Nick Desaulniers

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

* Re: Getting the instruction pointer on a per arch basis
  2018-07-31 22:32 Getting the instruction pointer on a per arch basis Nick Desaulniers
@ 2018-07-31 23:09 ` Nick Desaulniers
  2018-08-01  1:33   ` Randy Dunlap
  2018-08-01  5:40   ` Martin Schwidefsky
  0 siblings, 2 replies; 6+ messages in thread
From: Nick Desaulniers @ 2018-07-31 23:09 UTC (permalink / raw)
  To: schwidefsky, heiko.carstens, ysato, dalias, tony.luck,
	fenghua.yu, msalter, jacquiot.aurelien, David S. Miller,
	Thomas Gleixner, mingo
  Cc: Pirama Arumuga Nainar, Greg Hackmann, Mark Salyzyn, LKML,
	linux-s390, linux-sh, linux-ia64, linux-c6x-dev, sparclinux

+ More maintainers and lists for visibility

On Tue, Jul 31, 2018 at 3:32 PM Nick Desaulniers
<ndesaulniers@google.com> wrote:
>
> I'm currently looking into cleaning up the code duplication between
> current_text_addr() and _THIS_IP_, virtually every implementation of
> current_text_addr() and _THIS_IP_ itself are basically:
>
> #define _THIS_IP_ ({ __label__ _l; _l: &&_l; })
>
> For a few arch's, they have inline assembly instead (for
> current_text_addr()).  Examples:
> * s390
> * sh
> * ia64
> * x86 (um and 32b)
> * c6x
> * sparc
>
> I have a patch that cuts down on the duplication, but I don't
> understand why the few arch specific implementations are necessary.  I
> could reduce the duplication further if it's ok to just use the
> statement expression.
>
> Does anyone know why this is the case?
> --
> Thanks,
> ~Nick Desaulniers

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

* Re: Getting the instruction pointer on a per arch basis
  2018-07-31 23:09 ` Nick Desaulniers
@ 2018-08-01  1:33   ` Randy Dunlap
  2018-08-01  5:40   ` Martin Schwidefsky
  1 sibling, 0 replies; 6+ messages in thread
From: Randy Dunlap @ 2018-08-01  1:33 UTC (permalink / raw)
  To: Nick Desaulniers, schwidefsky, heiko.carstens, ysato, dalias,
	tony.luck, fenghua.yu, msalter, jacquiot.aurelien,
	David S. Miller, Thomas Gleixner, mingo
  Cc: Pirama Arumuga Nainar, Greg Hackmann, Mark Salyzyn, LKML,
	linux-s390, linux-sh, linux-ia64, linux-c6x-dev, sparclinux

On 07/31/2018 04:09 PM, Nick Desaulniers wrote:
> + More maintainers and lists for visibility
> 

Ideally the linux-arch@vger.kernel.org mailing list would be sufficient,
but I doubt that it is.  :(

-- 
~Randy

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

* Re: Getting the instruction pointer on a per arch basis
  2018-07-31 23:09 ` Nick Desaulniers
  2018-08-01  1:33   ` Randy Dunlap
@ 2018-08-01  5:40   ` Martin Schwidefsky
  2018-08-01 18:21     ` Nick Desaulniers
  1 sibling, 1 reply; 6+ messages in thread
From: Martin Schwidefsky @ 2018-08-01  5:40 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: heiko.carstens, ysato, dalias, tony.luck, fenghua.yu, msalter,
	jacquiot.aurelien, David S. Miller, Thomas Gleixner, mingo,
	Pirama Arumuga Nainar, Greg Hackmann, Mark Salyzyn, LKML,
	linux-s390, linux-sh, linux-ia64, linux-c6x-dev, sparclinux

On Tue, 31 Jul 2018 16:09:06 -0700
Nick Desaulniers <ndesaulniers@google.com> wrote:

> + More maintainers and lists for visibility
> 
> On Tue, Jul 31, 2018 at 3:32 PM Nick Desaulniers
> <ndesaulniers@google.com> wrote:
> >
> > I'm currently looking into cleaning up the code duplication between
> > current_text_addr() and _THIS_IP_, virtually every implementation of
> > current_text_addr() and _THIS_IP_ itself are basically:
> >
> > #define _THIS_IP_ ({ __label__ _l; _l: &&_l; })
> >
> > For a few arch's, they have inline assembly instead (for
> > current_text_addr()).  Examples:
> > * s390
> > * sh
> > * ia64
> > * x86 (um and 32b)
> > * c6x
> > * sparc
> >
> > I have a patch that cuts down on the duplication, but I don't
> > understand why the few arch specific implementations are necessary.  I
> > could reduce the duplication further if it's ok to just use the
> > statement expression.
> >
> > Does anyone know why this is the case?

For s390 it is just that we did not know about the label trick when we
introduced the define. The inline has an advantage though, the code
generated with the label trick is using a LARL instruction which is
4 bytes, the inline assembly uses a BASR which is 2 bytes.

If I use the label method in current_text_addr() the size of vmlinux
increases by a small amount:

add/remove: 33/13 grow/shrink: 101/48 up/down: 11941/-8887 (3054)

This is acceptable though, I would not mind if _THIS_IP_ and
current_text_addr use a common definition using labels.

-- 
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.


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

* Re: Getting the instruction pointer on a per arch basis
  2018-08-01  5:40   ` Martin Schwidefsky
@ 2018-08-01 18:21     ` Nick Desaulniers
  2018-08-06  5:24       ` Martin Schwidefsky
  0 siblings, 1 reply; 6+ messages in thread
From: Nick Desaulniers @ 2018-08-01 18:21 UTC (permalink / raw)
  To: schwidefsky
  Cc: heiko.carstens, Yoshinori Sato, dalias, tony.luck, fenghua.yu,
	msalter, jacquiot.aurelien, David S. Miller, Thomas Gleixner,
	mingo, Pirama Arumuga Nainar, Greg Hackmann, Mark Salyzyn, LKML,
	linux-s390, linux-sh, linux-ia64, linux-c6x-dev, sparclinux

On Tue, Jul 31, 2018 at 10:41 PM Martin Schwidefsky
<schwidefsky@de.ibm.com> wrote:
>
> On Tue, 31 Jul 2018 16:09:06 -0700
> Nick Desaulniers <ndesaulniers@google.com> wrote:
>
> > + More maintainers and lists for visibility
> >
> > On Tue, Jul 31, 2018 at 3:32 PM Nick Desaulniers
> > <ndesaulniers@google.com> wrote:
> > >
> > > I'm currently looking into cleaning up the code duplication between
> > > current_text_addr() and _THIS_IP_, virtually every implementation of
> > > current_text_addr() and _THIS_IP_ itself are basically:
> > >
> > > #define _THIS_IP_ ({ __label__ _l; _l: &&_l; })
> > >
> > > For a few arch's, they have inline assembly instead (for
> > > current_text_addr()).  Examples:
> > > * s390
> > > * sh
> > > * ia64
> > > * x86 (um and 32b)
> > > * c6x
> > > * sparc
> > >
> > > I have a patch that cuts down on the duplication, but I don't
> > > understand why the few arch specific implementations are necessary.  I
> > > could reduce the duplication further if it's ok to just use the
> > > statement expression.
> > >
> > > Does anyone know why this is the case?
>
> For s390 it is just that we did not know about the label trick when we
> introduced the define. The inline has an advantage though, the code
> generated with the label trick is using a LARL instruction which is
> 4 bytes, the inline assembly uses a BASR which is 2 bytes.
>
> If I use the label method in current_text_addr() the size of vmlinux
> increases by a small amount:
>
> add/remove: 33/13 grow/shrink: 101/48 up/down: 11941/-8887 (3054)

Thanks for the measurements.  Was this output produced by a utility?

> This is acceptable though, I would not mind if _THIS_IP_ and
> current_text_addr use a common definition using labels.

Thank you for this feedback Martin, I appreciate it.  Patches soon.

-- 
Thanks,
~Nick Desaulniers

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

* Re: Getting the instruction pointer on a per arch basis
  2018-08-01 18:21     ` Nick Desaulniers
@ 2018-08-06  5:24       ` Martin Schwidefsky
  0 siblings, 0 replies; 6+ messages in thread
From: Martin Schwidefsky @ 2018-08-06  5:24 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: heiko.carstens, Yoshinori Sato, dalias, tony.luck, fenghua.yu,
	msalter, jacquiot.aurelien, David S. Miller, Thomas Gleixner,
	mingo, Pirama Arumuga Nainar, Greg Hackmann, Mark Salyzyn, LKML,
	linux-s390, linux-sh, linux-ia64, linux-c6x-dev, sparclinux

On Wed, 1 Aug 2018 11:21:13 -0700
Nick Desaulniers <ndesaulniers@google.com> wrote:

> On Tue, Jul 31, 2018 at 10:41 PM Martin Schwidefsky
> <schwidefsky@de.ibm.com> wrote:
> >
> > On Tue, 31 Jul 2018 16:09:06 -0700
> > Nick Desaulniers <ndesaulniers@google.com> wrote:
> >  
> > > + More maintainers and lists for visibility
> > >
> > > On Tue, Jul 31, 2018 at 3:32 PM Nick Desaulniers
> > > <ndesaulniers@google.com> wrote:  
> > > >
> > > > I'm currently looking into cleaning up the code duplication between
> > > > current_text_addr() and _THIS_IP_, virtually every implementation of
> > > > current_text_addr() and _THIS_IP_ itself are basically:
> > > >
> > > > #define _THIS_IP_ ({ __label__ _l; _l: &&_l; })
> > > >
> > > > For a few arch's, they have inline assembly instead (for
> > > > current_text_addr()).  Examples:
> > > > * s390
> > > > * sh
> > > > * ia64
> > > > * x86 (um and 32b)
> > > > * c6x
> > > > * sparc
> > > >
> > > > I have a patch that cuts down on the duplication, but I don't
> > > > understand why the few arch specific implementations are necessary.  I
> > > > could reduce the duplication further if it's ok to just use the
> > > > statement expression.
> > > >
> > > > Does anyone know why this is the case?  
> >
> > For s390 it is just that we did not know about the label trick when we
> > introduced the define. The inline has an advantage though, the code
> > generated with the label trick is using a LARL instruction which is
> > 4 bytes, the inline assembly uses a BASR which is 2 bytes.
> >
> > If I use the label method in current_text_addr() the size of vmlinux
> > increases by a small amount:
> >
> > add/remove: 33/13 grow/shrink: 101/48 up/down: 11941/-8887 (3054)  
> 
> Thanks for the measurements.  Was this output produced by a utility?

Yes, ./scripts/bloat-o-meter

> > This is acceptable though, I would not mind if _THIS_IP_ and
> > current_text_addr use a common definition using labels.  
> 
> Thank you for this feedback Martin, I appreciate it.  Patches soon.

-- 
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.


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

end of thread, other threads:[~2018-08-06  5:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-31 22:32 Getting the instruction pointer on a per arch basis Nick Desaulniers
2018-07-31 23:09 ` Nick Desaulniers
2018-08-01  1:33   ` Randy Dunlap
2018-08-01  5:40   ` Martin Schwidefsky
2018-08-01 18:21     ` Nick Desaulniers
2018-08-06  5:24       ` Martin Schwidefsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).