All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Mikulas Patocka <mpatocka@redhat.com>
Cc: linux-kernel@vger.kernel.org, sparclinux@vger.kernel.org,
	davem@davemloft.net, Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [10 PATCHES] inline functions to avoid stack overflow
Date: Tue, 24 Jun 2008 07:01:06 +0000	[thread overview]
Message-ID: <20080624070106.GA32607@elte.hu> (raw)
In-Reply-To: <Pine.LNX.4.64.0806240136200.27784@engineering.redhat.com>


* Mikulas Patocka <mpatocka@redhat.com> wrote:

> Hi
>
> Here I'm sending 10 patches to inline various functions.

( sidenote: the patches are seriously whitespace damaged. Please see
  Documentation/email-clients.txt about how to send patches. )

NAK on this whole current line of approach. One problem is that it 
affects a lot more than just sparc64:

> This patch has the worst size-increase impact, increasing total kernel 
> size by 0.2%.

[...]

> To give you some understanding of sparc64, every function there uses 
> big stack frame (at least 192 bytes). 128 bytes are required by 
> architecture (16 64-bit registers), 48 bytes are there due to mistake 
> of Sparc64 ABI designers (calling function has to allocate 48 bytes 
> for called function) and 16 bytes are some dubious padding.
>
> So, on sparc64, if you have a simple function that passes arguments to 
> other function it still takes 192 byte --- regardless of how simple 
> the function is. Tail-call may be used, but it is disabled in kernel 
> if debugging is enabled (Makefile: ifdef CONFIG_FRAME_POINTER 
> KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls).
>
> The stack trace has 75 nested functions, that totals to at least 14400 
> bytes --- and it kills the 16k stack space on sparc. In the stack 
> trace, there are many function which do nothing but pass parameters to 
> other function. In this series of patches, I found 10 such functions 
> and turned them to inlines, saving 1920 bytes. Especially waking wait 
> queue is bad, it calls 8 nested functions, 7 of which do nothing. I 
> turned 5 of them to inline.

please solve this sparc64 problem without hurting other architectures.

also, the trace looks suspect:

> This was the trace:
>
> linux_sparc_syscall32
> sys_read
> vfs_read
> do_sync_read
> generic_file_aio_read
> generic_file_direct_io
> filemap_write_and_wait
> filemap_fdatawrite
> __filemap_fdatawrite_range
> do_writepages
> generic_writepages
> write_cache_pages
> __writepage
> blkdev_writepage
> block_write_full_page
> __block_write_fiull_page
> submit_bh
> submit_bio
> generic_make_request
> dm_request
> __split_bio
> __map_bio
> origin_map
> start_copy
> dm_kcopyd_copy
> dispatch_job
> wake
> queue_work
> __queue_work
> __spin_unlock_irqrestore
> sys_call_table
> timer_interrupt
> irq_exit
> do_softirq
> __do_softirq
> run_timer_softirq
> __spin_unlock_irq
> sys_call_table
> handler_irq
> handler_fasteoi_irq
> handle_irq_event
> ide_intr
> ide_dma_intr
> task_end_request
> ide_end_request
> __ide_end_request
> __blk_end_request
> __end_that_request_first
> req_bio_endio
> bio_endio
> clone_endio
> dec_pending
> bio_endio
> clone_endio
> dec_pending
> bio_endio
> clone_endio
> dec_pending
> bio_endio
> end_bio_bh_io_sync
> end_buffer_read_sync
> __end_buffer_read_notouch
> unlock_buffer
> wake_up_bit
> __wake_up_bit
> __wake_up
> __wake_up_common
> wake_bio_function
> autoremove_wake_function
> default_wake_function
> try_to_wake_up
> task_rq_lock
> __spin_lock
> lock_acquire
> __lock_acquire

if function frames are so large, why are there no separate IRQ stacks on 
Sparc64? IRQ stacks can drastically lower the worst-case stack footprint 
and only affect sparc64.

Also, the stack trace above seems to be imprecise (for example sys_read 
cannot nest inside an irq context - so it does not show 75 function 
frames) and there are no stack frame size annotations that could tell us 
exactly where the stack overhead comes from.

( Please Cc: me to future iterations of this patchset - as long as it
  still has generic impact. Thanks! )

	Ingo

WARNING: multiple messages have this Message-ID (diff)
From: Ingo Molnar <mingo@elte.hu>
To: Mikulas Patocka <mpatocka@redhat.com>
Cc: linux-kernel@vger.kernel.org, sparclinux@vger.kernel.org,
	davem@davemloft.net, Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [10 PATCHES] inline functions to avoid stack overflow
Date: Tue, 24 Jun 2008 09:01:06 +0200	[thread overview]
Message-ID: <20080624070106.GA32607@elte.hu> (raw)
In-Reply-To: <Pine.LNX.4.64.0806240136200.27784@engineering.redhat.com>


* Mikulas Patocka <mpatocka@redhat.com> wrote:

> Hi
>
> Here I'm sending 10 patches to inline various functions.

( sidenote: the patches are seriously whitespace damaged. Please see
  Documentation/email-clients.txt about how to send patches. )

NAK on this whole current line of approach. One problem is that it 
affects a lot more than just sparc64:

> This patch has the worst size-increase impact, increasing total kernel 
> size by 0.2%.

[...]

> To give you some understanding of sparc64, every function there uses 
> big stack frame (at least 192 bytes). 128 bytes are required by 
> architecture (16 64-bit registers), 48 bytes are there due to mistake 
> of Sparc64 ABI designers (calling function has to allocate 48 bytes 
> for called function) and 16 bytes are some dubious padding.
>
> So, on sparc64, if you have a simple function that passes arguments to 
> other function it still takes 192 byte --- regardless of how simple 
> the function is. Tail-call may be used, but it is disabled in kernel 
> if debugging is enabled (Makefile: ifdef CONFIG_FRAME_POINTER 
> KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls).
>
> The stack trace has 75 nested functions, that totals to at least 14400 
> bytes --- and it kills the 16k stack space on sparc. In the stack 
> trace, there are many function which do nothing but pass parameters to 
> other function. In this series of patches, I found 10 such functions 
> and turned them to inlines, saving 1920 bytes. Especially waking wait 
> queue is bad, it calls 8 nested functions, 7 of which do nothing. I 
> turned 5 of them to inline.

please solve this sparc64 problem without hurting other architectures.

also, the trace looks suspect:

> This was the trace:
>
> linux_sparc_syscall32
> sys_read
> vfs_read
> do_sync_read
> generic_file_aio_read
> generic_file_direct_io
> filemap_write_and_wait
> filemap_fdatawrite
> __filemap_fdatawrite_range
> do_writepages
> generic_writepages
> write_cache_pages
> __writepage
> blkdev_writepage
> block_write_full_page
> __block_write_fiull_page
> submit_bh
> submit_bio
> generic_make_request
> dm_request
> __split_bio
> __map_bio
> origin_map
> start_copy
> dm_kcopyd_copy
> dispatch_job
> wake
> queue_work
> __queue_work
> __spin_unlock_irqrestore
> sys_call_table
> timer_interrupt
> irq_exit
> do_softirq
> __do_softirq
> run_timer_softirq
> __spin_unlock_irq
> sys_call_table
> handler_irq
> handler_fasteoi_irq
> handle_irq_event
> ide_intr
> ide_dma_intr
> task_end_request
> ide_end_request
> __ide_end_request
> __blk_end_request
> __end_that_request_first
> req_bio_endio
> bio_endio
> clone_endio
> dec_pending
> bio_endio
> clone_endio
> dec_pending
> bio_endio
> clone_endio
> dec_pending
> bio_endio
> end_bio_bh_io_sync
> end_buffer_read_sync
> __end_buffer_read_notouch
> unlock_buffer
> wake_up_bit
> __wake_up_bit
> __wake_up
> __wake_up_common
> wake_bio_function
> autoremove_wake_function
> default_wake_function
> try_to_wake_up
> task_rq_lock
> __spin_lock
> lock_acquire
> __lock_acquire

if function frames are so large, why are there no separate IRQ stacks on 
Sparc64? IRQ stacks can drastically lower the worst-case stack footprint 
and only affect sparc64.

Also, the stack trace above seems to be imprecise (for example sys_read 
cannot nest inside an irq context - so it does not show 75 function 
frames) and there are no stack frame size annotations that could tell us 
exactly where the stack overhead comes from.

( Please Cc: me to future iterations of this patchset - as long as it
  still has generic impact. Thanks! )

	Ingo

  parent reply	other threads:[~2008-06-24  7:01 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-24  5:54 [10 PATCHES] inline functions to avoid stack overflow Mikulas Patocka
2008-06-24  5:54 ` Mikulas Patocka
2008-06-24  5:55 ` [1/10 PATCH] inline __queue_work Mikulas Patocka
2008-06-24  5:55   ` Mikulas Patocka
2008-06-24  5:56   ` [2/10 PATCH] inline inline-generic_writepages.patch Mikulas Patocka
2008-06-24  5:56     ` Mikulas Patocka
2008-06-24  5:57   ` [3/10 PATCH] inline wake_up_bit Mikulas Patocka
2008-06-24  5:57     ` Mikulas Patocka
2008-06-25 14:17     ` Denys Vlasenko
2008-06-25 14:17       ` Denys Vlasenko
2008-06-25 14:36       ` Mikulas Patocka
2008-06-25 14:36         ` Mikulas Patocka
2008-06-25 15:24         ` Denys Vlasenko
2008-06-25 15:24           ` Denys Vlasenko
2008-06-25 16:01           ` Mikulas Patocka
2008-06-25 16:01             ` Mikulas Patocka
2008-06-25 20:37             ` Denys Vlasenko
2008-06-25 20:37               ` Denys Vlasenko
2008-06-26  0:28               ` David Miller
2008-06-26  0:28                 ` David Miller
2008-06-26  3:35                 ` Denys Vlasenko
2008-06-26  3:35                   ` Denys Vlasenko
2008-06-26  4:18                   ` David Miller
2008-06-26  4:18                     ` David Miller
2008-06-26 18:22                 ` Pavel Machek
2008-06-26 18:22                   ` Pavel Machek
2008-06-25 22:23           ` David Miller
2008-06-25 22:23             ` David Miller
2008-06-25 22:30       ` David Miller
2008-06-25 22:30         ` David Miller
2008-06-24  5:57   ` [4/10 PATCH] inline __wake_up_bit Mikulas Patocka
2008-06-24  5:57     ` Mikulas Patocka
2008-06-24  5:58   ` [5/10 PATCH] inline __wake_up Mikulas Patocka
2008-06-24  5:58     ` Mikulas Patocka
2008-06-24  5:59   ` [6/10 PATCH] inline default_wake_function Mikulas Patocka
2008-06-24  5:59     ` Mikulas Patocka
2008-06-24  5:59   ` [6/10 PATCH] inline autoremove_wake_function Mikulas Patocka
2008-06-24  5:59     ` Mikulas Patocka
2008-06-24  6:01   ` [8/10 PATCH] inline filemap_fdatawrite Mikulas Patocka
2008-06-24  6:01     ` Mikulas Patocka
2008-06-24  6:01   ` [9/10 PATCH] inline dm-kcopyd-inline-wake.patch Mikulas Patocka
2008-06-24  6:01     ` Mikulas Patocka
2008-06-24  6:03   ` [10/10 PATCH] inline dispatch_job Mikulas Patocka
2008-06-24  6:03     ` Mikulas Patocka
2008-06-24  6:06 ` [PATCH] limit irq nesting Mikulas Patocka
2008-06-24  6:06   ` Mikulas Patocka
2008-06-24  7:01 ` Ingo Molnar [this message]
2008-06-24  7:01   ` [10 PATCHES] inline functions to avoid stack overflow Ingo Molnar
     [not found] ` <486216E7.8000002@aitel.hist.no>
2008-06-25 12:53   ` Mikulas Patocka
2008-06-25 12:53     ` Mikulas Patocka
2008-06-25 22:09     ` David Miller
2008-06-25 22:09       ` David Miller
2008-06-26  6:32       ` Bart Van Assche
2008-06-26  6:32         ` Bart Van Assche
2008-06-26  9:06         ` David Miller
2008-06-26  9:06           ` David Miller
2008-07-02  4:39       ` Mikulas Patocka
2008-07-02  4:39         ` Mikulas Patocka
2008-07-02  4:45         ` David Miller
2008-07-02  4:45           ` David Miller
2008-07-03 21:12           ` Mikulas Patocka
2008-07-03 21:12             ` Mikulas Patocka

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=20080624070106.GA32607@elte.hu \
    --to=mingo@elte.hu \
    --cc=akpm@linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpatocka@redhat.com \
    --cc=sparclinux@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.