linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Al Boldi <a1426z@gawab.com>
To: Paulo Marques <pmarques@grupopie.com>
Cc: Arjan van de Ven <arjan@infradead.org>,
	Frank van Maarseveen <frankvm@frankvm.com>,
	linux-kernel@vger.kernel.org, Andi Kleen <ak@suse.de>
Subject: Re: [PATCH] x86: Don't randomize stack unless current->personality permits it
Date: Tue, 18 Jul 2006 08:21:45 +0300	[thread overview]
Message-ID: <200607180821.45346.a1426z@gawab.com> (raw)
In-Reply-To: <44BBB1AA.3050703@grupopie.com>

Paulo Marques wrote:
> Al Boldi wrote:
> >[...] > void fn() {
> >
> > 	long i = 9999999;
> > 	double x,y;
> >
> > 	elapsed(1);
> > 	while (i--) fn2(&x,&y);
> > 	printf("%4lu ",elapsed(0));
> > }
>
> You are not initializing x and y and with -Os at least my gcc really
> uses floating point load/store operations to handle that code.

Thanks for pointing that out.

I was really waiting for someone to critique this, but keep in mind this code 
tries to surface a performance problem, and any modification changes the 
semantics of the compiled code, which then may yield different results.

> Maybe the coprocessor has a hard time normalizing certain garbage on the
> stack, but without/with randomization the data comes from other
> addresses and you're just lucky with the contents.

Good point, but this random garbage makes the test even more realistic, as 
this code would thus cover more variations without actually coding for it.

> Does this also happens if you add a "x=0, y=0;" line to that function?

with arch_stack_align using 0xf
gcc -Os tstExec.c
randomization on
causes 2x blips/hits
randomization off
causes no blips/hits
mv a.out tstExec
causes continuous 2x slowdown
sh -c ./tstExec
causes slowdown to disappear (can somebody explain this weirdness?)

with arch_stack_align using 0x7f
all weirdness is gone
gcc -O3 tstExec.c
randomization on
causes some minor blips/hits
randomization off
causes even less blips/hits

Going one step further,
with #define arch_stack_align(x) (x)
all blips/hits/weirdness are gone

Which means that either arch_stack_align isn't necessary at all, or 
randomization isn't working as intended.

Can somebody prove me wrong here?

Thanks!

--
Al



  reply	other threads:[~2006-07-18  5:21 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-11 19:57 [PATCH] x86: Don't randomize stack unless current->personality permits it Al Boldi
2006-07-12 16:03 ` Andi Kleen
2006-07-12 20:12   ` Al Boldi
2006-07-12 20:27     ` Arjan van de Ven
2006-07-12 21:13       ` Al Boldi
2006-07-13  9:44   ` Frank van Maarseveen
2006-07-13 20:51     ` Al Boldi
2006-07-13 20:54       ` Arjan van de Ven
2006-07-15 11:29         ` Al Boldi
2006-07-15 12:22           ` Arjan van de Ven
2006-07-15 14:09             ` Al Boldi
2006-07-15 16:15               ` Arjan van de Ven
2006-07-15 17:39               ` Al Boldi
2006-07-17 15:50               ` Paulo Marques
2006-07-18  5:21                 ` Al Boldi [this message]
  -- strict thread matches above, loose matches on Subject: below --
2006-07-25  0:21 Chuck Ebbert
2006-07-25  4:57 ` Al Boldi
2006-07-19 17:02 Chuck Ebbert
2006-07-20 17:23 ` Al Boldi
2006-07-24 15:57   ` Al Boldi
2006-07-16  3:58 Chuck Ebbert
2006-07-16 19:49 ` Al Boldi
2006-07-11 15:22 Frank van Maarseveen
2006-07-11 20:11 ` Arjan van de Ven

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=200607180821.45346.a1426z@gawab.com \
    --to=a1426z@gawab.com \
    --cc=ak@suse.de \
    --cc=arjan@infradead.org \
    --cc=frankvm@frankvm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmarques@grupopie.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 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).