1. 11 8月, 2010 2 次提交
  2. 10 8月, 2010 8 次提交
    • A
      gcc-4.6: printk: use stable variable to dump kmsg buffer · 8c4af38e
      Andi Kleen 提交于
      kmsg_dump takes care to sample the global variables
      inside a spinlock, but then goes on to use the same
      variables outside the spinlock region too.
      
      Use the correct variable. This will make the race
      window smaller.
      
      Found by gcc 4.6's new warnings.
      Signed-off-by: NAndi Kleen <ak@linux.intel.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      8c4af38e
    • R
      stop_machine: struct cpu_stopper, remove alignment padding on 64 bits · 878ae127
      Richard Kennedy 提交于
      Reorder elements in structure cpu_stopper to remove alignment padding on
      64 bit builds, this shrinks its size from 40 to 32 bytes saving 8 bytes
      per cpu.
      Signed-off-by: NRichard Kennedy <richard@rsk.demon.co.uk>
      Acked-by: NTejun Heo <tj@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Rusty Russell <rusty@rustcorp.com.au>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      878ae127
    • G
      kernel/range: remove unused definition of ARRAY_SIZE() · 459b37d4
      Geert Uytterhoeven 提交于
      Remove duplicate definition of ARRAY_SIZE(), which was never used anyway.
      Signed-off-by: NGeert Uytterhoeven <geert@linux-m68k.org>
      Cc: Yinghai Lu <yinghai@kernel.org>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      459b37d4
    • O
      sys_personality: remove the bogus checks in sys_personality()->__set_personality() path · 2ee7c922
      Oleg Nesterov 提交于
      Cleanup, no functional changes.
      
      - __set_personality() always changes ->exec_domain/personality, the
        special case when ->exec_domain remains the same buys nothing but
        complicates the code. Unify both cases to simplify the code.
      
      - The -EINVAL check in sys_personality() was never right. If we assume
        that set_personality() can fail we should check the value it returns
        instead of verifying that task->personality was actually changed.
      
        Remove it. Before the previous patch it was possible to hit this case
        due to overflow problems, but this -EINVAL just indicated the kernel
        bug.
      
      OTOH, probably it makes sense to change lookup_exec_domain() to return
      ERR_PTR() instead of default_exec_domain if the search in exec_domains
      list fails, and report this error to the user-space.  But this means
      another user-space change, and we have in-kernel users which need fixes.
      For example, PER_OSF4 falls into PER_MASK for unkown reason and nobody
      cares to register this domain.
      Signed-off-by: NOleg Nesterov <oleg@redhat.com>
      Cc: Wenming Zhang <wezhang@redhat.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      2ee7c922
    • K
      hibernation: freeze swap at hibernation · d2997b10
      KAMEZAWA Hiroyuki 提交于
      When taking a memory snapshot in hibernate_snapshot(), all (directly
      called) memory allocations use GFP_ATOMIC.  Hence swap misusage during
      hibernation never occurs.
      
      But from a pessimistic point of view, there is no guarantee that no page
      allcation has __GFP_WAIT.  It is better to have a global indication "we
      enter hibernation, don't use swap!".
      
      This patch tries to freeze new-swap-allocation during hibernation.  (All
      user processes are frozenm so swapin is not a concern).
      
      This way, no updates will happen to swap_map[] between
      hibernate_snapshot() and save_image().  Swap is thawed when swsusp_free()
      is called.  We can be assured that swap corruption will not occur.
      Signed-off-by: NKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
      Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
      Cc: Hugh Dickins <hughd@google.com>
      Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
      Cc: Ondrej Zary <linux@rainbow-software.org>
      Cc: Balbir Singh <balbir@in.ibm.com>
      Cc: Andrea Arcangeli <aarcange@redhat.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      d2997b10
    • D
      oom: badness heuristic rewrite · a63d83f4
      David Rientjes 提交于
      This a complete rewrite of the oom killer's badness() heuristic which is
      used to determine which task to kill in oom conditions.  The goal is to
      make it as simple and predictable as possible so the results are better
      understood and we end up killing the task which will lead to the most
      memory freeing while still respecting the fine-tuning from userspace.
      
      Instead of basing the heuristic on mm->total_vm for each task, the task's
      rss and swap space is used instead.  This is a better indication of the
      amount of memory that will be freeable if the oom killed task is chosen
      and subsequently exits.  This helps specifically in cases where KDE or
      GNOME is chosen for oom kill on desktop systems instead of a memory
      hogging task.
      
      The baseline for the heuristic is a proportion of memory that each task is
      currently using in memory plus swap compared to the amount of "allowable"
      memory.  "Allowable," in this sense, means the system-wide resources for
      unconstrained oom conditions, the set of mempolicy nodes, the mems
      attached to current's cpuset, or a memory controller's limit.  The
      proportion is given on a scale of 0 (never kill) to 1000 (always kill),
      roughly meaning that if a task has a badness() score of 500 that the task
      consumes approximately 50% of allowable memory resident in RAM or in swap
      space.
      
      The proportion is always relative to the amount of "allowable" memory and
      not the total amount of RAM systemwide so that mempolicies and cpusets may
      operate in isolation; they shall not need to know the true size of the
      machine on which they are running if they are bound to a specific set of
      nodes or mems, respectively.
      
      Root tasks are given 3% extra memory just like __vm_enough_memory()
      provides in LSMs.  In the event of two tasks consuming similar amounts of
      memory, it is generally better to save root's task.
      
      Because of the change in the badness() heuristic's baseline, it is also
      necessary to introduce a new user interface to tune it.  It's not possible
      to redefine the meaning of /proc/pid/oom_adj with a new scale since the
      ABI cannot be changed for backward compatability.  Instead, a new tunable,
      /proc/pid/oom_score_adj, is added that ranges from -1000 to +1000.  It may
      be used to polarize the heuristic such that certain tasks are never
      considered for oom kill while others may always be considered.  The value
      is added directly into the badness() score so a value of -500, for
      example, means to discount 50% of its memory consumption in comparison to
      other tasks either on the system, bound to the mempolicy, in the cpuset,
      or sharing the same memory controller.
      
      /proc/pid/oom_adj is changed so that its meaning is rescaled into the
      units used by /proc/pid/oom_score_adj, and vice versa.  Changing one of
      these per-task tunables will rescale the value of the other to an
      equivalent meaning.  Although /proc/pid/oom_adj was originally defined as
      a bitshift on the badness score, it now shares the same linear growth as
      /proc/pid/oom_score_adj but with different granularity.  This is required
      so the ABI is not broken with userspace applications and allows oom_adj to
      be deprecated for future removal.
      Signed-off-by: NDavid Rientjes <rientjes@google.com>
      Cc: Nick Piggin <npiggin@suse.de>
      Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
      Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Balbir Singh <balbir@in.ibm.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      a63d83f4
    • D
      oom: move sysctl declarations to oom.h · 8e4228e1
      David Rientjes 提交于
      The three oom killer sysctl variables (sysctl_oom_dump_tasks,
      sysctl_oom_kill_allocating_task, and sysctl_panic_on_oom) are better
      declared in include/linux/oom.h rather than kernel/sysctl.c.
      Signed-off-by: NDavid Rientjes <rientjes@google.com>
      Acked-by: NKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
      Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      8e4228e1
    • C
      pass a struct path to vfs_statfs · ebabe9a9
      Christoph Hellwig 提交于
      We'll need the path to implement the flags field for statvfs support.
      We do have it available in all callers except:
      
       - ecryptfs_statfs.  This one doesn't actually need vfs_statfs but just
         needs to do a caller to the lower filesystem statfs method.
       - sys_ustat.  Add a non-exported statfs_by_dentry helper for it which
         doesn't won't be able to fill out the flags field later on.
      
      In addition rename the helpers for statfs vs fstatfs to do_*statfs instead
      of the misleading vfs prefix.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      ebabe9a9
  3. 09 8月, 2010 1 次提交
  4. 08 8月, 2010 4 次提交
  5. 06 8月, 2010 2 次提交
  6. 05 8月, 2010 23 次提交
    • J
      vt,console,kdb: automatically set kdb LINES variable · 81d44507
      Jason Wessel 提交于
      The kernel console interface stores the number of lines it is
      configured to use. The kdb debugger can greatly benefit by knowing how
      many lines there are on the console for the pager functionality
      without having the end user compile in the setting or have to
      repeatedly change it at run time.
      Signed-off-by: NJason Wessel <jason.wessel@windriver.com>
      Signed-off-by: NJesse Barnes <jbarnes@virtuousgeek.org>
      CC: David Airlie <airlied@linux.ie>
      CC: Andrew Morton <akpm@linux-foundation.org>
      81d44507
    • J
      debug_core,kdb: fix crash when arch does not have single step · 3fa43aba
      Jason Wessel 提交于
      When an arch such as mips and microblaze does not implement either HW
      or software single stepping the debug core should re-enter kdb.  The
      kdb code will properly ignore the single step operation.  Attempting
      to single step the kernel without software or hardware support causes
      unpredictable kernel crashes.
      Signed-off-by: NJason Wessel <jason.wessel@windriver.com>
      3fa43aba
    • J
      ftrace,kdb: Allow dumping a specific cpu's buffer with ftdump · 19063c77
      Jason Wessel 提交于
      In systems with more than one processor it is desirable to look at the
      per cpu trace buffers.
      Signed-off-by: NJason Wessel <jason.wessel@windriver.com>
      Acked-by: NSteven Rostedt <rostedt@goodmis.org>
      CC: Frederic Weisbecker <fweisbec@gmail.com>
      19063c77
    • J
      ftrace,kdb: Extend kdb to be able to dump the ftrace buffer · 955b61e5
      Jason Wessel 提交于
      Add in a helper function to allow the kdb shell to dump the ftrace
      buffer.
      
      Modify trace.c to expose the capability to iterate over the ftrace
      buffer in a read only capacity.
      Signed-off-by: NJason Wessel <jason.wessel@windriver.com>
      Acked-by: NSteven Rostedt <rostedt@goodmis.org>
      CC: Frederic Weisbecker <fweisbec@gmail.com>
      955b61e5
    • J
      gdbstub: do not directly use dbg_reg_def[] in gdb_cmd_reg_set() · 6d855b1d
      Jason Wessel 提交于
      Presently the usable registers definitions on x86 are not contiguous
      for kgdb.  The x86 kgdb uses a case statement for the sparse register
      accesses.  The array which defines the registers (dbg_reg_def) should
      not be used directly in order to safely work with sparse register
      definitions.
      
      Specifically there was a problem when gdb accesses ORIG_AX, which is
      accessed only through the case statement.
      
      This patch encodes register memory using the size information provided
      from the debugger which avoids the need to look up the size of the
      register.  The dbg_set_reg() function always further validates the
      inputs from the debugger.
      Signed-off-by: NJason Wessel <jason.wessel@windriver.com>
      Signed-off-by: NDongdong Deng <dongdong.deng@windriver.com>
      6d855b1d
    • J
      gdbstub: Implement gdbserial 'p' and 'P' packets · 55751145
      Jason Wessel 提交于
      The gdbserial 'p' and 'P' packets allow gdb to individually get and
      set registers instead of querying for all the available registers.
      Signed-off-by: NJason Wessel <jason.wessel@windriver.com>
      55751145
    • J
      kgdb,kdb: individual register set and and get API · 534af108
      Jason Wessel 提交于
      The kdb shell specification includes the ability to get and set
      architecture specific registers by name.
      
      For the time being individual register get and set will be implemented
      on a per architecture basis.  If an architecture defines
      DBG_MAX_REG_NUM > 0 then kdb and the gdbstub will use the capability
      for individually getting and setting architecture specific registers.
      Signed-off-by: NJason Wessel <jason.wessel@windriver.com>
      534af108
    • J
      gdbstub: Optimize kgdb's "thread:" response for the gdb serial protocol · 84a0bd5b
      Jason Wessel 提交于
      The gdb debugger understands how to parse short versions of the thread
      reference string as long as the bytes are paired in sets of two
      characters.  The kgdb implementation was always sending 8 leading
      zeros which could be omitted, and further optimized in the case of
      non-negative thread numbers.  The negative numbers are used to
      reference a specific cpu in the case of kgdb.
      
      An example of the previous i386 stop packet looks like:
          T05thread:00000000000003bb;
      
      New stop packet response:
          T05thread:03bb;
      
      The previous ThreadInfo response looks like:
          m00000000fffffffe,0000000000000001,0000000000000002,0000000000000003,0000000000000004,0000000000000005,0000000000000006,0000000000000007,000000000000000c,0000000000000088,000000000000008a,000000000000008b,000000000000008c,000000000000008d,000000000000008e,00000000000000d4,00000000000000d5,00000000000000dd
      
      New ThreadInfo response:
          mfffffffe,01,02,03,04,05,06,07,0c,88,8a,8b,8c,8d,8e,d4,d5,dd
      
      A few bytes saved means better response time when using kgdb over a
      serial line.
      Signed-off-by: NJason Wessel <jason.wessel@windriver.com>
      84a0bd5b
    • A
    • K
      printk: fix delayed messages from CPU hotplug events · 034260d6
      Kevin Cernekee 提交于
      When a secondary CPU is being brought up, it is not uncommon for
      printk() to be invoked when cpu_online(smp_processor_id()) == 0.  The
      case that I witnessed personally was on MIPS:
      
      http://lkml.org/lkml/2010/5/30/4
      
      If (can_use_console() == 0), printk() will spool its output to log_buf
      and it will be visible in "dmesg", but that output will NOT be echoed to
      the console until somebody calls release_console_sem() from a CPU that
      is online.  Therefore, the boot time messages from the new CPU can get
      stuck in "limbo" for a long time, and might suddenly appear on the
      screen when a completely unrelated event (e.g. "eth0: link is down")
      occurs.
      
      This patch modifies the console code so that any pending messages are
      automatically flushed out to the console whenever a CPU hotplug
      operation completes successfully or aborts.
      
      The issue was seen on 2.6.34.
      
      Original patch by Kevin Cernekee with cleanups by akpm and additional fixes
      by Santosh Shilimkar.  This patch superseeds
      https://patchwork.linux-mips.org/patch/1357/.
      Signed-off-by: NKevin Cernekee <cernekee@gmail.com>
      To: <mingo@elte.hu>
      To: <akpm@linux-foundation.org>
      To: <simon.kagstrom@netinsight.net>
      To: <David.Woodhouse@intel.com>
      To: <lethal@linux-sh.org>
      Cc: <linux-kernel@vger.kernel.org>
      Cc: <linux-mips@linux-mips.org>
      Reviewed-by: NPaul Mundt <lethal@linux-sh.org>
      Signed-off-by: NKevin Cernekee <cernekee@gmail.com>
      Patchwork: https://patchwork.linux-mips.org/patch/1534/
      LKML-Reference: <ede63b5a20af951c755736f035d1e787772d7c28@localhost>
      LKML-Reference: <EAF47CD23C76F840A9E7FCE10091EFAB02C5DB6D1F@dbde02.ent.ti.com>
      Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      034260d6
    • R
      module: cleanup comments, remove noinline · 51f3d0f4
      Rusty Russell 提交于
      On my (32-bit x86) machine, sys_init_module() uses 124 bytes of stack
      once load_module() is inlined.
      
      This effectively reverts ffb4ba76 which inlined it due to stack
      pressure.
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      51f3d0f4
    • R
      module: group post-relocation functions into post_relocation() · 811d66a0
      Rusty Russell 提交于
      This simply hoists more code out of load_module; we also put the
      identification of the extable and dynamic debug table in with the
      others in find_module_sections().
      
      We move the taint check to the actual add/remove of the dynamic debug
      info: this is certain (find_module_sections is too early).
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      Cc: Yehuda Sadeh <yehuda@hq.newdream.net>
      811d66a0
    • R
      module: move module args strndup_user to just before use · 6526c534
      Rusty Russell 提交于
      Instead of copying and allocating the args and storing it in
      load_info, we can just allocate them right before we need them.
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      6526c534
    • R
      module: pass load_info into other functions · 49668688
      Rusty Russell 提交于
      Pass the struct load_info into all the other functions in module
      loading.  This neatens things and makes them more consistent.
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      49668688
    • R
      module: fix sysfs cleanup for !CONFIG_SYSFS · 36b0360d
      Rusty Russell 提交于
      Restore the stub module_remove_modinfo_attrs, remove the now-unused
      !CONFIG_SYSFS module_sysfs_init.
      
      Also, rename mod_kobject_remove() to mod_sysfs_teardown() as
      it is the logical counterpart to mod_sysfs_setup now.
      Reported-by: NRandy Dunlap <randy.dunlap@oracle.com>
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      36b0360d
    • R
      module: sysfs cleanup · 8f6d0378
      Rusty Russell 提交于
      We change the sysfs functions to take struct load_info, and call
      them all in mod_sysfs_setup().
      
      We also clean up the #ifdefs a little.
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      8f6d0378
    • R
      module: layout_and_allocate · d913188c
      Rusty Russell 提交于
      layout_and_allocate() does everything up to and including the final
      struct module placement inside the allocated module memory.  We have
      to store the symbol layout information in our struct load_info though.
      
      This avoids the nasty code we had before where 'mod' pointed first
      to the version inside the temporary allocation containing the entire
      file, then later was moved to point to the real struct module: now
      the main code only ever sees the final module address.
      
      (Includes fix for the Tony Luck-found Linus-diagnosed failure path
       error).
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      d913188c
    • R
      module: fix crash in get_ksymbol() when oopsing in module init · 511ca6ae
      Rusty Russell 提交于
      Andrew had the sole pleasure of tickling this bug in linux-next; when we set
      up "info->strtab" it's pointing into the temporary copy of the module.  For
      most uses that is fine, but kallsyms keeps a pointer around during module
      load (inside mod->strtab).
      
      If we oops for some reason inside a module's init function, kallsyms will use
      the mod->strtab pointer into the now-freed temporary module copy.
      
      (Later oopses work fine: after init we overwrite mod->strtab to point to a
       compacted core-only strtab).
      Reported-by: NAndrew "Grumpy" Morton <akpm@linux-foundation.org>
      Signed-off-by: NRusty "Buggy" Russell <rusty@rustcorp.com.au>
      Tested-by: NAndrew "Happy" Morton <akpm@linux-foundation.org>
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      511ca6ae
    • R
      module: kallsyms functions take struct load_info · eded41c1
      Rusty Russell 提交于
      Simple refactor causes us to lift struct definition to top of file.
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      eded41c1
    • R
      module: refactor out section header rewriting: FIX modversions · d6df72a0
      Rusty Russell 提交于
      We can't do the find_sec after removing the SHF_ALLOC flags; it won't
      find the sections.
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      d6df72a0
    • R
      module: refactor out section header rewriting · 8b5f61a7
      Rusty Russell 提交于
      Put all the "rewrite and check section headers" in one place.  This
      adds another iteration over the sections, but it's far clearer.  We
      iterate once for every find_section() so we already iterate over many
      times.
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      8b5f61a7
    • L
      module: add load_info · 3264d3f9
      Linus Torvalds 提交于
      Btw, here's a patch that _looks_ large, but it really pretty trivial, and
      sets things up so that it would be way easier to split off pieces of the
      module loading.
      
      The reason it looks large is that it creates a "module_info" structure
      that contains all the module state that we're building up while loading,
      instead of having individual variables for all the indices etc.
      
      So the patch ends up being large, because every "symindex" access instead
      becomes "info.index.sym" etc. That may be a few characters longer, but it
      then means that we can just pass a pointer to that "info" structure
      around. and let all the pieces fill it in very naturally.
      
      As an example of that, the patch also moves the initialization of all
      those convenience variables into a "setup_module_info()" function. And at
      this point it really does become very natural to start to peel off some of
      the error labels and move them into the helper functions - now the
      "truncated" case is gone, and is handled inside that setup function
      instead.
      
      So maybe you don't like this approach, and it does make the variable
      accesses a bit longer, but I don't think unreadably so. And the patch
      really does look big and scary, but there really should be absolutely no
      semantic changes - most of it was a trivial and mindless rename.
      
      In fact, it was so mindless that I on purpose kept the existing helper
      functions looking like this:
      
      -       err = check_modinfo(mod, sechdrs, infoindex, versindex);
      +       err = check_modinfo(mod, info.sechdrs, info.index.info, info.index.vers);
      
      rather than changing them to just take the "info" pointer. IOW, a second
      phase (if you think the approach is ok) would change that calling
      convention to just do
      
      	err = check_modinfo(mod, &info);
      
      (and same for "layout_sections()", "layout_symtabs()" etc.) Similarly,
      while right now it makes things _look_ bigger, with things like this:
      
      	versindex = find_sec(hdr, sechdrs, secstrings, "__versions");
      
      becoming
      
      	info->index.vers = find_sec(info->hdr, info->sechdrs, info->secstrings, "__versions");
      
      in the new "setup_module_info()" function, that's again just a result of
      it being a search-and-replace patch. By using the 'info' pointer, we could
      just change the 'find_sec()' interface so that it ends up being
      
      	info->index.vers = find_sec(info, "__versions");
      
      instead, and then we'd actually have a shorter and more readable line. So
      for a lot of those mindless variable name expansions there's would be room
      for separate cleanups.
      
      I didn't move quite everything in there - if we do this to layout_symtabs,
      for example, we'd want to move the percpu, symoffs, stroffs, *strmap
      variables to be fields in that module_info structure too. But that's a
      much smaller patch, I moved just the really core stuff that is currently
      being set up and used in various parts.
      
      But even in this rough form, it removes close to 70 lines from that
      function (but adds 22 lines overall, of course - the structure definition,
      the helper function declarations and call-sites etc etc).
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      3264d3f9
    • L
      module: reduce stack usage for each_symbol() · 44032e63
      Linus Torvalds 提交于
      And now that I'm looking at that call-chain (to see if it would make sense
      to use some other more specific lock - doesn't look like it: all the
      readers are using RCU and this is the only writer), I also give you this
      trivial one-liner. It changes each_symbol() to not put that constant array
      on the stack, resulting in changing
      
              movq    $C.388.31095, %rsi      #, tmp85
              subq    $376, %rsp      #,
              movq    %rdi, %rbx      # fn, fn
              leaq    -208(%rbp), %rdi        #, tmp84
              movq    %rbx, %rdx      # fn,
              rep movsl
              xorl    %esi, %esi      #
              leaq    -208(%rbp), %rdi        #, tmp87
              movq    %r12, %rcx      # data,
              call    each_symbol_in_section.clone.0  #
      
      into
      
              xorl    %esi, %esi      #
              subq    $216, %rsp      #,
              movq    %rdi, %rbx      # fn, fn
              movq    $arr.31078, %rdi        #,
              call    each_symbol_in_section.clone.0  #
      
      which is not so much about being obviously shorter and simpler because we
      don't unnecessarily copy that constant array around onto the stack, but
      also about having a much smaller stack footprint (376 vs 216 bytes - see
      the update of 'rsp').
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      44032e63