public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/18403] New: statically linked app uses
@ 2015-05-12 15:20 dave at sr71 dot net
  2015-05-12 15:22 ` [Bug libc/18403] statically linked app uses FPU before main() dave at sr71 dot net
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: dave at sr71 dot net @ 2015-05-12 15:20 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=18403

            Bug ID: 18403
           Summary: statically linked app uses
           Product: glibc
           Version: 2.21
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: dave at sr71 dot net
                CC: drepper.fsp at gmail dot com
  Target Milestone: ---

-- 
You are receiving this mail because:
You are on the CC list for the bug.


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

* [Bug libc/18403] statically linked app uses FPU before main()
  2015-05-12 15:20 [Bug libc/18403] New: statically linked app uses dave at sr71 dot net
@ 2015-05-12 15:22 ` dave at sr71 dot net
  2015-05-12 15:22 ` [Bug libc/18403] statically linked app uses dave at sr71 dot net
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: dave at sr71 dot net @ 2015-05-12 15:22 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=18403

Dave Hansen <dave at sr71 dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|statically linked app uses  |statically linked app uses
                   |                            |FPU before main()

-- 
You are receiving this mail because:
You are on the CC list for the bug.


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

* [Bug libc/18403] statically linked app uses
  2015-05-12 15:20 [Bug libc/18403] New: statically linked app uses dave at sr71 dot net
  2015-05-12 15:22 ` [Bug libc/18403] statically linked app uses FPU before main() dave at sr71 dot net
@ 2015-05-12 15:22 ` dave at sr71 dot net
  2015-05-15 12:44 ` [Bug libc/18403] statically linked app uses FPU before main() fweimer at redhat dot com
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: dave at sr71 dot net @ 2015-05-12 15:22 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=18403

--- Comment #1 from Dave Hansen <dave at sr71 dot net> ---
I have a small application:

int main() {
    int i;
    char msg[] = "hello dave\n";

    write(1, msg, sizeof(msg));
    sleep(9999);
    return 0;

}

Which I compile like this, and run under gdb:

gcc -static -g -o hellodave hellodave.c

I've indicated in comments where the FPU gets used and provided disassembly and
a backtrace.

(gdb) break strlen
Breakpoint 1 at 0x41b2c0
(gdb) start
Temporary breakpoint 2 at 0x400e06: file hellodave.c, line 19.
Starting program: /root/hellodave 

Breakpoint 1, 0x000000000041b2c0 in strlen ()
# at this point the FPU is not in use
(gdb) stepi
0x000000000041b2c5 in strlen ()
# The FPU has now been used
(gdb) disassemble strlen
Dump of assembler code for function strlen:
   0x000000000041b2c0 <+0>:     pxor   %xmm8,%xmm8
=> 0x000000000041b2c5 <+5>:     pxor   %xmm9,%xmm9
   0x000000000041b2ca <+10>:    pxor   %xmm10,%xmm10
...
(gdb) bt
#0  0x000000000041b2c5 in strlen ()
#1  0x00000000004074a6 in getenv ()
#2  0x0000000000439f9e in _dl_non_dynamic_init ()
#3  0x000000000043ad18 in __libc_init_first ()
#4  0x000000000040102c in __libc_start_main ()
#5  0x0000000000400d09 in _start ()
(gdb)

-- 
You are receiving this mail because:
You are on the CC list for the bug.


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

* [Bug libc/18403] statically linked app uses FPU before main()
  2015-05-12 15:20 [Bug libc/18403] New: statically linked app uses dave at sr71 dot net
  2015-05-12 15:22 ` [Bug libc/18403] statically linked app uses FPU before main() dave at sr71 dot net
  2015-05-12 15:22 ` [Bug libc/18403] statically linked app uses dave at sr71 dot net
@ 2015-05-15 12:44 ` fweimer at redhat dot com
  2015-05-15 14:51 ` dave at sr71 dot net
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: fweimer at redhat dot com @ 2015-05-15 12:44 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=18403

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |WAITING
                 CC|                            |fweimer at redhat dot com
              Flags|                            |security-

--- Comment #2 from Florian Weimer <fweimer at redhat dot com> ---
What is the problem you are trying to solve?  I see nothing wrong with using
vector instructions in statically linked programs.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


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

* [Bug libc/18403] statically linked app uses FPU before main()
  2015-05-12 15:20 [Bug libc/18403] New: statically linked app uses dave at sr71 dot net
                   ` (2 preceding siblings ...)
  2015-05-15 12:44 ` [Bug libc/18403] statically linked app uses FPU before main() fweimer at redhat dot com
@ 2015-05-15 14:51 ` dave at sr71 dot net
  2015-05-15 15:00 ` [Bug libc/18403] statically linked app uses vector instructions " hjl.tools at gmail dot com
  2015-05-15 15:02 ` hjl.tools at gmail dot com
  5 siblings, 0 replies; 7+ messages in thread
From: dave at sr71 dot net @ 2015-05-15 14:51 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=18403

Dave Hansen <dave at sr71 dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hjl.tools at gmail dot com

--- Comment #3 from Dave Hansen <dave at sr71 dot net> ---
Using the FPU forever costs a process memory (for kernel FPU state), power (to
keep that part of the CPU powered on), and CPU cycles (to save/restore the
state).  The first 5 uses (which occur after a context switch) are also
guaranteed to cause a device-not-available/#ND exception if the kernel is in
its lazy FPU mode.

The kernel tries to be lazy about allocating and saving/restoring FPU state. 
If the task is virtually guaranteed to have FPU state, then we should
reconsider the lazy mode being the default.  This lazy mode is utterly useless
and counterproductive if userspace is guaranteed to use the FPU in every task.

It would be nice if an application had the choice to use the FPU or not.  This
issue was touched on in bug#18402 and H.J. Lu suggested discussing it in
another issue.

Feel free to close this if it is not something you consider a bug.  I just
wanted to bring it to your attention.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


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

* [Bug libc/18403] statically linked app uses vector instructions before main()
  2015-05-12 15:20 [Bug libc/18403] New: statically linked app uses dave at sr71 dot net
                   ` (3 preceding siblings ...)
  2015-05-15 14:51 ` dave at sr71 dot net
@ 2015-05-15 15:00 ` hjl.tools at gmail dot com
  2015-05-15 15:02 ` hjl.tools at gmail dot com
  5 siblings, 0 replies; 7+ messages in thread
From: hjl.tools at gmail dot com @ 2015-05-15 15:00 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=18403

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|statically linked app uses  |statically linked app uses
                   |FPU before main()           |vector instructions before
                   |                            |main()

--- Comment #4 from H.J. Lu <hjl.tools at gmail dot com> ---
"vector instructions" is more accurate than FPU.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


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

* [Bug libc/18403] statically linked app uses vector instructions before main()
  2015-05-12 15:20 [Bug libc/18403] New: statically linked app uses dave at sr71 dot net
                   ` (4 preceding siblings ...)
  2015-05-15 15:00 ` [Bug libc/18403] statically linked app uses vector instructions " hjl.tools at gmail dot com
@ 2015-05-15 15:02 ` hjl.tools at gmail dot com
  5 siblings, 0 replies; 7+ messages in thread
From: hjl.tools at gmail dot com @ 2015-05-15 15:02 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=18403

--- Comment #5 from H.J. Lu <hjl.tools at gmail dot com> ---
Since compiler will generate vector instructions under optimization
and glibc has functions optimized with vector instructions, shouldn't
kernel assume that vector instructions will always be used?

-- 
You are receiving this mail because:
You are on the CC list for the bug.


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

end of thread, other threads:[~2015-05-15 15:02 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-12 15:20 [Bug libc/18403] New: statically linked app uses dave at sr71 dot net
2015-05-12 15:22 ` [Bug libc/18403] statically linked app uses FPU before main() dave at sr71 dot net
2015-05-12 15:22 ` [Bug libc/18403] statically linked app uses dave at sr71 dot net
2015-05-15 12:44 ` [Bug libc/18403] statically linked app uses FPU before main() fweimer at redhat dot com
2015-05-15 14:51 ` dave at sr71 dot net
2015-05-15 15:00 ` [Bug libc/18403] statically linked app uses vector instructions " hjl.tools at gmail dot com
2015-05-15 15:02 ` hjl.tools at gmail dot com

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 read-only IMAP folder(s) and NNTP newsgroup(s).