1. 09 1月, 2006 3 次提交
  2. 23 11月, 2005 1 次提交
  3. 07 11月, 2005 2 次提交
  4. 31 10月, 2005 2 次提交
  5. 30 10月, 2005 1 次提交
    • H
      [PATCH] mm: pte_offset_map_lock loops · 705e87c0
      Hugh Dickins 提交于
      Convert those common loops using page_table_lock on the outside and
      pte_offset_map within to use just pte_offset_map_lock within instead.
      
      These all hold mmap_sem (some exclusively, some not), so at no level can a
      page table be whipped away from beneath them.  But whereas pte_alloc loops
      tested with the "atomic" pmd_present, these loops are testing with pmd_none,
      which on i386 PAE tests both lower and upper halves.
      
      That's now unsafe, so add a cast into pmd_none to test only the vital lower
      half: we lose a little sensitivity to a corrupt middle directory, but not
      enough to worry about.  It appears that i386 and UML were the only
      architectures vulnerable in this way, and pgd and pud no problem.
      Signed-off-by: NHugh Dickins <hugh@veritas.com>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      705e87c0
  6. 28 10月, 2005 2 次提交
  7. 05 10月, 2005 1 次提交
  8. 30 9月, 2005 1 次提交
  9. 23 9月, 2005 1 次提交
  10. 22 9月, 2005 1 次提交
  11. 18 9月, 2005 2 次提交
    • J
      [PATCH] uml: UML/i386 cmpxchg fix · 30134492
      Jeff Dike 提交于
      Using native cmpxchg offers a slight performance improvement in uml/i386.
      Signed-off-by: NJeff Dike <jdike@addtoit.com>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      30134492
    • J
      [PATCH] uml: breakpoint an arbitrary thread · 3eddddcf
      Jeff Dike 提交于
      This patch implements a stack trace for a thread, not unlike sysrq-t does.
      The advantage to this is that a break point can be placed on showreqs, so that
      upon showing the stack, you jump immediately into the debugger.  While sysrq-t
      does the same thing, sysrq-t shows *all* threads stacks.  It also doesn't work
      right now.  In the future, I thought it might be acceptable to make this show
      all pids stacks, but perhaps leaving well enough alone and just using sysrq-t
      would be okay.  For now, upon receiving the stack command, UML switches
      context to that thread, dumps its registers, and then switches context back to
      the original thread.  Since UML compacts all threads into one of 4 host
      threads, this sort of mechanism could be expanded in the future to include
      other debugging helpers that sysrq does not cover.
      
      Note by jdike - The main benefit to this is that it brings an arbitrary thread
      back into context, where it can be examined by gdb.  The fact that it dumps it
      stack is secondary.  This provides the capability to examine a sleeping
      thread, which has existed in tt mode, but not in skas mode until now.
      
      Also, the other threads, that sysrq doesn't cover, can be gdb-ed directly
      anyway.
      
      Signed-off-by: Allan Graves<allan.graves@gmail.com>
      Signed-off-by: NJeff Dike <jdike@addtoit.com>
      Cc: Paolo Giarrusso <blaisorblade@yahoo.it>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      3eddddcf
  12. 11 9月, 2005 2 次提交
  13. 08 9月, 2005 3 次提交
    • C
      [PATCH] remove asm-*/hdreg.h · c8d12741
      Christoph Hellwig 提交于
      unused and useless..
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      c8d12741
    • H
      [PATCH] auxiliary vector cleanups · 36d57ac4
      H. J. Lu 提交于
      The size of auxiliary vector is fixed at 42 in linux/sched.h.  But it isn't
      very obvious when looking at linux/elf.h.  This patch adds AT_VECTOR_SIZE
      so that we can change it if necessary when a new vector is added.
      
      Because of include file ordering problems, doing this necessitated the
      extraction of the AT_* symbols into a standalone header file.
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      36d57ac4
    • J
      [PATCH] FUTEX_WAKE_OP: pthread_cond_signal() speedup · 4732efbe
      Jakub Jelinek 提交于
      ATM pthread_cond_signal is unnecessarily slow, because it wakes one waiter
      (which at least on UP usually means an immediate context switch to one of
      the waiter threads).  This waiter wakes up and after a few instructions it
      attempts to acquire the cv internal lock, but that lock is still held by
      the thread calling pthread_cond_signal.  So it goes to sleep and eventually
      the signalling thread is scheduled in, unlocks the internal lock and wakes
      the waiter again.
      
      Now, before 2003-09-21 NPTL was using FUTEX_REQUEUE in pthread_cond_signal
      to avoid this performance issue, but it was removed when locks were
      redesigned to the 3 state scheme (unlocked, locked uncontended, locked
      contended).
      
      Following scenario shows why simply using FUTEX_REQUEUE in
      pthread_cond_signal together with using lll_mutex_unlock_force in place of
      lll_mutex_unlock is not enough and probably why it has been disabled at
      that time:
      
      The number is value in cv->__data.__lock.
              thr1            thr2            thr3
      0       pthread_cond_wait
      1       lll_mutex_lock (cv->__data.__lock)
      0       lll_mutex_unlock (cv->__data.__lock)
      0       lll_futex_wait (&cv->__data.__futex, futexval)
      0                       pthread_cond_signal
      1                       lll_mutex_lock (cv->__data.__lock)
      1                                       pthread_cond_signal
      2                                       lll_mutex_lock (cv->__data.__lock)
      2                                         lll_futex_wait (&cv->__data.__lock, 2)
      2                       lll_futex_requeue (&cv->__data.__futex, 0, 1, &cv->__data.__lock)
                                # FUTEX_REQUEUE, not FUTEX_CMP_REQUEUE
      2                       lll_mutex_unlock_force (cv->__data.__lock)
      0                         cv->__data.__lock = 0
      0                         lll_futex_wake (&cv->__data.__lock, 1)
      1       lll_mutex_lock (cv->__data.__lock)
      0       lll_mutex_unlock (cv->__data.__lock)
                # Here, lll_mutex_unlock doesn't know there are threads waiting
                # on the internal cv's lock
      
      Now, I believe it is possible to use FUTEX_REQUEUE in pthread_cond_signal,
      but it will cost us not one, but 2 extra syscalls and, what's worse, one of
      these extra syscalls will be done for every single waiting loop in
      pthread_cond_*wait.
      
      We would need to use lll_mutex_unlock_force in pthread_cond_signal after
      requeue and lll_mutex_cond_lock in pthread_cond_*wait after lll_futex_wait.
      
      Another alternative is to do the unlocking pthread_cond_signal needs to do
      (the lock can't be unlocked before lll_futex_wake, as that is racy) in the
      kernel.
      
      I have implemented both variants, futex-requeue-glibc.patch is the first
      one and futex-wake_op{,-glibc}.patch is the unlocking inside of the kernel.
       The kernel interface allows userland to specify how exactly an unlocking
      operation should look like (some atomic arithmetic operation with optional
      constant argument and comparison of the previous futex value with another
      constant).
      
      It has been implemented just for ppc*, x86_64 and i?86, for other
      architectures I'm including just a stub header which can be used as a
      starting point by maintainers to write support for their arches and ATM
      will just return -ENOSYS for FUTEX_WAKE_OP.  The requeue patch has been
      (lightly) tested just on x86_64, the wake_op patch on ppc64 kernel running
      32-bit and 64-bit NPTL and x86_64 kernel running 32-bit and 64-bit NPTL.
      
      With the following benchmark on UP x86-64 I get:
      
      for i in nptl-orig nptl-requeue nptl-wake_op; do echo time elf/ld.so --library-path .:$i /tmp/bench; \
      for j in 1 2; do echo ( time elf/ld.so --library-path .:$i /tmp/bench ) 2>&1; done; done
      time elf/ld.so --library-path .:nptl-orig /tmp/bench
      real 0m0.655s user 0m0.253s sys 0m0.403s
      real 0m0.657s user 0m0.269s sys 0m0.388s
      time elf/ld.so --library-path .:nptl-requeue /tmp/bench
      real 0m0.496s user 0m0.225s sys 0m0.271s
      real 0m0.531s user 0m0.242s sys 0m0.288s
      time elf/ld.so --library-path .:nptl-wake_op /tmp/bench
      real 0m0.380s user 0m0.176s sys 0m0.204s
      real 0m0.382s user 0m0.175s sys 0m0.207s
      
      The benchmark is at:
      http://sourceware.org/ml/libc-alpha/2005-03/txt00001.txt
      Older futex-requeue-glibc.patch version is at:
      http://sourceware.org/ml/libc-alpha/2005-03/txt00002.txt
      Older futex-wake_op-glibc.patch version is at:
      http://sourceware.org/ml/libc-alpha/2005-03/txt00003.txt
      Will post a new version (just x86-64 fixes so that the patch
      applies against pthread_cond_signal.S) to libc-hacker ml soon.
      
      Attached is the kernel FUTEX_WAKE_OP patch as well as a simple-minded
      testcase that will not test the atomicity of the operation, but at least
      check if the threads that should have been woken up are woken up and
      whether the arithmetic operation in the kernel gave the expected results.
      Acked-by: NIngo Molnar <mingo@redhat.com>
      Cc: Ulrich Drepper <drepper@redhat.com>
      Cc: Jamie Lokier <jamie@shareable.org>
      Cc: Rusty Russell <rusty@rustcorp.com.au>
      Signed-off-by: NYoichi Yuasa <yuasa@hh.iij4u.or.jp>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      4732efbe
  14. 05 9月, 2005 5 次提交
  15. 16 8月, 2005 1 次提交
  16. 29 7月, 2005 1 次提交
  17. 27 7月, 2005 1 次提交
    • E
      [PATCH] Add emergency_restart() · 7c903473
      Eric W. Biederman 提交于
      When the kernel is working well and we want to restart cleanly
      kernel_restart is the function to use.   But in many instances
      the kernel wants to reboot when thing are expected to be working
      very badly such as from panic or a software watchdog handler.
      
      This patch adds the function emergency_restart() so that
      callers can be clear what semantics they expect when calling
      restart.  emergency_restart() is expected to be callable
      from interrupt context and possibly reliable in even more
      trying circumstances.
      
      This is an initial generic implementation for all architectures.
      Signed-off-by: NEric W. Biederman <ebiederm@xmission.com>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      7c903473
  18. 15 7月, 2005 1 次提交
  19. 13 7月, 2005 1 次提交
    • B
      [PATCH] uml: tlb flushing fix · c40504e8
      Benjamin LaHaise 提交于
      This patch fixes a fairly serious tlb flushing bug that makes aio use under
      uml very unreliable -- SEGVs, Oops and panic()s occur as a result of stale
      tlb entires being used by uml when aio switches mms due to the fact that
      uml does not implement the activate_mm() hook.  This patch introduces a
      simple but correct approach (read: hammer) for implementing activate_mm()
      in uml by doing a force_flush_all() if the new mm is different from old.
      With this patch in place, uml is able to succeed at the aio test case that
      was randomly faulting for me before.
      
      Cc: Jeff Dike <jdike@addtoit.com>
      Cc: <blaisorblade@yahoo.it>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      c40504e8
  20. 08 7月, 2005 1 次提交
    • J
      [PATCH] uml: skas0 - separate kernel address space on stock hosts · d67b569f
      Jeff Dike 提交于
      UML has had two modes of operation - an insecure, slow mode (tt mode) in
      which the kernel is mapped into every process address space which requires
      no host kernel modifications, and a secure, faster mode (skas mode) in
      which the UML kernel is in a separate host address space, which requires a
      patch to the host kernel.
      
      This patch implements something very close to skas mode for hosts which
      don't support skas - I'm calling this skas0.  It provides the security of
      the skas host patch, and some of the performance gains.
      
      The two main things that are provided by the skas patch, /proc/mm and
      PTRACE_FAULTINFO, are implemented in a way that require no host patch.
      
      For the remote address space changing stuff (mmap, munmap, and mprotect),
      we set aside two pages in the process above its stack, one of which
      contains a little bit of code which can call mmap et al.
      
      To update the address space, the system call information (system call
      number and arguments) are written to the stub page above the code.  The
      %esp is set to the beginning of the data, the %eip is set the the start of
      the stub, and it repeatedly pops the information into its registers and
      makes the system call until it sees a system call number of zero.  This is
      to amortize the cost of the context switch across multiple address space
      updates.
      
      When the updates are done, it SIGSTOPs itself, and the kernel process
      continues what it was doing.
      
      For a PTRACE_FAULTINFO replacement, we set up a SIGSEGV handler in the
      child, and let it handle segfaults rather than nullifying them.  The
      handler is in the same page as the mmap stub.  The second page is used as
      the stack.  The handler reads cr2 and err from the sigcontext, sticks them
      at the base of the stack in a faultinfo struct, and SIGSTOPs itself.  The
      kernel then reads the faultinfo and handles the fault.
      
      A complication on x86_64 is that this involves resetting the registers to
      the segfault values when the process is inside the kill system call.  This
      breaks on x86_64 because %rcx will contain %rip because you tell SYSRET
      where to return to by putting the value in %rcx.  So, this corrupts $rcx on
      return from the segfault.  To work around this, I added an
      arch_finish_segv, which on x86 does nothing, but which on x86_64 ptraces
      the child back through the sigreturn.  This causes %rcx to be restored by
      sigreturn and avoids the corruption.  Ultimately, I think I will replace
      this with the trick of having it send itself a blocked signal which will be
      unblocked by the sigreturn.  This will allow it to be stopped just after
      the sigreturn, and PTRACE_SYSCALLed without all the back-and-forth of
      PTRACE_SYSCALLing it through sigreturn.
      
      This runs on a stock host, so theoretically (and hopefully), tt mode isn't
      needed any more.  We need to make sure that this is better in every way
      than tt mode, though.  I'm concerned about the speed of address space
      updates and page fault handling, since they involve extra round-trips to
      the child.  We can amortize the round-trip cost for large address space
      updates by writing all of the operations to the data page and having the
      child execute them all at the same time.  This will help fork and exec, but
      not page faults, since they involve only one page.
      
      I can't think of any way to help page faults, except to add something like
      PTRACE_FAULTINFO to the host.  There is PTRACE_SIGINFO, but UML doesn't use
      siginfo for SIGSEGV (or anything else) because there isn't enough
      information in the siginfo struct to handle page faults (the faulting
      operation type is missing).  Adding that would make PTRACE_SIGINFO a usable
      equivalent to PTRACE_FAULTINFO.
      
      As for the code itself:
      
      - The system call stub is in arch/um/kernel/sys-$(SUBARCH)/stub.S.  It is
        put in its own section of the binary along with stub_segv_handler in
        arch/um/kernel/skas/process.c.  This is manipulated with run_syscall_stub
        in arch/um/kernel/skas/mem_user.c.  syscall_stub will execute any system
        call at all, but it's only used for mmap, munmap, and mprotect.
      
      - The x86_64 stub calls sigreturn by hand rather than allowing the normal
        sigreturn to happen, because the normal sigreturn is a SA_RESTORER in
        UML's address space provided by libc.  Needless to say, this is not
        available in the child's address space.  Also, it does a couple of odd
        pops before that which restore the stack to the state it was in at the
        time the signal handler was called.
      
      - There is a new field in the arch mmu_context, which is now a union.
        This is the pid to be manipulated rather than the /proc/mm file
        descriptor.  Code which deals with this now checks proc_mm to see whether
        it should use the usual skas code or the new code.
      
      - userspace_tramp is now used to create a new host process for every UML
        process, rather than one per UML processor.  It checks proc_mm and
        ptrace_faultinfo to decide whether to map in the pages above its stack.
      
      - start_userspace now makes CLONE_VM conditional on proc_mm since we need
        separate address spaces now.
      
      - switch_mm_skas now just sets userspace_pid[0] to the new pid rather
        than PTRACE_SWITCH_MM.  There is an addition to userspace which updates
        its idea of the pid being manipulated each time around the loop.  This is
        important on exec, when the pid will change underneath userspace().
      
      - The stub page has a pte, but it can't be mapped in using tlb_flush
        because it is part of tlb_flush.  This is why it's required for it to be
        mapped in by userspace_tramp.
      
      Other random things:
      
      - The stub section in uml.lds.S is page aligned.  This page is written
        out to the backing vm file in setup_physmem because it is mapped from
        there into user processes.
      
      - There's some confusion with TASK_SIZE now that there are a couple of
        extra pages that the process can't use.  TASK_SIZE is considered by the
        elf code to be the usable process memory, which is reasonable, so it is
        decreased by two pages.  This confuses the definition of
        USER_PGDS_IN_LAST_PML4, making it too small because of the rounding down
        of the uneven division.  So we round it to the nearest PGDIR_SIZE rather
        than the lower one.
      
      - I added a missing PT_SYSCALL_ARG6_OFFSET macro.
      
      - um_mmu.h was made into a userspace-usable file.
      
      - proc_mm and ptrace_faultinfo are globals which say whether the host
        supports these features.
      
      - There is a bad interaction between the mm.nr_ptes check at the end of
        exit_mmap, stack randomization, and skas0.  exit_mmap will stop freeing
        pages at the PGDIR_SIZE boundary after the last vma.  If the stack isn't
        on the last page table page, the last pte page won't be freed, as it
        should be since the stub ptes are there, and exit_mmap will BUG because
        there is an unfreed page.  To get around this, TASK_SIZE is set to the
        next lowest PGDIR_SIZE boundary and mm->nr_ptes is decremented after the
        calls to init_stub_pte.  This ensures that we know the process stack (and
        all other process mappings) will be below the top page table page, and
        thus we know that mm->nr_ptes will be one too many, and can be
        decremented.
      
      Things that need fixing:
      
      - We may need better assurrences that the stub code is PIC.
      
      - The stub pte is set up in init_new_context_skas.
      
      - alloc_pgdir is probably the right place.
      Signed-off-by: NJeff Dike <jdike@addtoit.com>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      d67b569f
  21. 26 6月, 2005 1 次提交
  22. 24 6月, 2005 1 次提交
    • J
      [PATCH] streamline preempt_count type across archs · dcd497f9
      Jesper Juhl 提交于
      The preempt_count member of struct thread_info is currently either defined
      as int, unsigned int or __s32 depending on arch.  This patch makes the type
      of preempt_count an int on all archs.
      
      Having preempt_count be an unsigned type prevents the catching of
      preempt_count < 0 bugs, and using int on some archs and __s32 on others is
      not exactely "neat" - much nicer when it's just int all over.
      
      A previous version of this patch was already ACK'ed by Robert Love, and the
      only change in this version of the patch compared to the one he ACK'ed is
      that this one also makes sure the preempt_count member is consistently
      commented.
      Signed-off-by: NJesper Juhl <juhl-lkml@dif.dk>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      dcd497f9
  23. 22 6月, 2005 1 次提交
    • I
      [PATCH] smp_processor_id() cleanup · 39c715b7
      Ingo Molnar 提交于
      This patch implements a number of smp_processor_id() cleanup ideas that
      Arjan van de Ven and I came up with.
      
      The previous __smp_processor_id/_smp_processor_id/smp_processor_id API
      spaghetti was hard to follow both on the implementational and on the
      usage side.
      
      Some of the complexity arose from picking wrong names, some of the
      complexity comes from the fact that not all architectures defined
      __smp_processor_id.
      
      In the new code, there are two externally visible symbols:
      
       - smp_processor_id(): debug variant.
      
       - raw_smp_processor_id(): nondebug variant. Replaces all existing
         uses of _smp_processor_id() and __smp_processor_id(). Defined
         by every SMP architecture in include/asm-*/smp.h.
      
      There is one new internal symbol, dependent on DEBUG_PREEMPT:
      
       - debug_smp_processor_id(): internal debug variant, mapped to
                                   smp_processor_id().
      
      Also, i moved debug_smp_processor_id() from lib/kernel_lock.c into a new
      lib/smp_processor_id.c file.  All related comments got updated and/or
      clarified.
      
      I have build/boot tested the following 8 .config combinations on x86:
      
       {SMP,UP} x {PREEMPT,!PREEMPT} x {DEBUG_PREEMPT,!DEBUG_PREEMPT}
      
      I have also build/boot tested x64 on UP/PREEMPT/DEBUG_PREEMPT.  (Other
      architectures are untested, but should work just fine.)
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      Signed-off-by: NArjan van de Ven <arjan@infradead.org>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      39c715b7
  24. 29 5月, 2005 4 次提交