[lkml]   [1999]   [Oct]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: how much stack space can I use
    On Sat, 23 Oct 1999 17:36:12 +0200, 
    Manfred Spraul <> wrote:
    >How much stack space can I use without causing a stack overflow? None of
    >these functions are recursive, and they don't call any subfunctions
    >which need more than a few bytes stack space.

    Anybody looking at stack usage might find this script useful, it can
    also be found in It taks a
    while to run, mainly because objdump --disassemble of everything takes
    a while. Some interesting results from 2.2.23 :-

    7c4 ncr53c8xx_detect
    824 dvd_read_disckey
    824 dvd_read_manufact
    914 mmc_ioctl

    mmc_ioctl is worrying. That code contains a switch statement with
    allocations on individual case statements. gcc version egcs-2.91.66
    19990314/Linux (egcs-1.1.2 release) has consolidated all the
    allocations into a single large allocation at the start of the routine.

    # Run a compiled ix86 kernel and print large local stack usage.
    # Before running this script, cd /usr/src/linux or wherever you keep
    # your compiled kernel and modules.
    # />:/{s/[<>:]*//g; h; } On lines that contain '>:' (headings like
    # c0100000 <_stext>:), remove <, > and : and hold the line. Identifies
    # the procedure and its start address.
    # /subl.*$0x[^,][^,][^,].*,%esp/{ Select lines containing
    # subl...0x...,%esp but only if there are at least 3 digits between 0x and
    # ,%esp. These are local stacks of at least 0x100 bytes.
    # s/.*$0x\([^,]*\).*/\1/; Extract just the stack adjustment
    # /^[89a-f].......$/d; Ignore lines with 8 digit offsets that are
    # negative. Some compilers adjust the stack on exit, seems to be related
    # to goto statements
    # G; Append the held line (procedure and start address).
    # s/\(.*\)\n.* \(.*\)/\1 \2/; Remove the newline and procedure start
    # address. Leaves just stack size and procedure name.
    # p; }; Print stack size and procedure name.
    # /subl.*%.*,%esp/{ Selects adjustment of %esp by register, dynamic
    # arrays on stack.
    # G; Append the held line (procedure and start address).
    # s/\(.*\)\n\(.*\)/Dynamic \2 \1/; Reformat to "Dynamic", procedure
    # start address, procedure name and the instruction that adjusts the
    # stack, including its offset within the proc.
    # p; }; Print the dynamic line.
    # Leading spaces in the sed string are required.
    objdump --disassemble vmlinux modules/*.o | \
    sed -ne '/>:/{s/[<>:]*//g; h; };
    s/.*$0x\([^,]*\).*/\1/; /^[89a-f].......$/d; G; s/\(.*\)\n.* \(.*\)/\1 \2/; p; };
    /subl.*%.*,%esp/{ G; s/\(.*\)\n\(.*\)/Dynamic \2 \1/; p; }; ' | \

    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    Please read the FAQ at

     \ /
      Last update: 2005-03-22 13:54    [W:0.024 / U:54.308 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site