1. 30 7月, 2009 2 次提交
    • D
      lib: flexible array implementation · 534acc05
      Dave Hansen 提交于
      Once a structure goes over PAGE_SIZE*2, we see occasional allocation
      failures.  Some people have chosen to switch over to things like vmalloc()
      that will let them keep array-like access to such a large structures.
      But, vmalloc() has plenty of downsides.
      
      Here's an alternative.  I think it's what Andrew was suggesting here:
      
      	http://lkml.org/lkml/2009/7/2/518
      
      I call it a flexible array.  It does all of its work in PAGE_SIZE bits, so
      never does an order>0 allocation.  The base level has
      PAGE_SIZE-2*sizeof(int) bytes of storage for pointers to the second level.
       So, with a 32-bit arch, you get about 4MB (4183112 bytes) of total
      storage when the objects pack nicely into a page.  It is half that on
      64-bit because the pointers are twice the size.  There's a table detailing
      this in the code.
      
      There are kerneldocs for the functions, but here's an
      overview:
      
      flex_array_alloc() - dynamically allocate a base structure
      flex_array_free() - free the array and all of the
      		    second-level pages
      flex_array_free_parts() - free the second-level pages, but
      			  not the base (for static bases)
      flex_array_put() - copy into the array at the given index
      flex_array_get() - copy out of the array at the given index
      flex_array_prealloc() - preallocate the second-level pages
      			between the given indexes to
      			guarantee no allocs will occur at
      			put() time.
      
      We could also potentially just pass the "element_size" into each of the
      API functions instead of storing it internally.  That would get us one
      more base pointer on 32-bit.
      
      I've been testing this by running it in userspace.  The header and patch
      that I've been using are here, as well as the little script I'm using to
      generate the size table which goes in the kerneldocs.
      
      	http://sr71.net/~dave/linux/flexarray/
      
      [akpm@linux-foundation.org: coding-style fixes]
      Signed-off-by: NDave Hansen <dave@linux.vnet.ibm.com>
      Reviewed-by: NKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      534acc05
    • R
      lib: export generic atomic64_t functions · 3fc7b4b2
      Roland Dreier 提交于
      The generic atomic64_t implementation in lib/ did not export the functions
      it defined, which means that modules that use atomic64_t would not link on
      platforms (such as 32-bit powerpc).  For example, trying to build a kernel
      with CONFIG_NET_RDS on such a platform would fail with:
      
          ERROR: "atomic64_read" [net/rds/rds.ko] undefined!
          ERROR: "atomic64_set" [net/rds/rds.ko] undefined!
      
      Fix this by exporting the atomic64_t functions to modules.  (I export the
      entire API even if it's not all currently used by in-tree modules to avoid
      having to continue fixing this in dribs and drabs)
      Signed-off-by: NRoland Dreier <rolandd@cisco.com>
      Acked-by: NPaul Mackerras <paulus@samba.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      3fc7b4b2
  2. 29 7月, 2009 1 次提交
  3. 11 7月, 2009 1 次提交
    • I
      dma-debug: Fix the overlap() function to be correct and readable · f39d1b97
      Ingo Molnar 提交于
      Linus noticed how unclean and buggy the overlap() function is:
      
       - It uses convoluted (and bug-causing) positive checks for
         range overlap - instead of using a more natural negative
         check.
      
       - Even the positive checks are buggy: a positive intersection
         check has four natural cases while we checked only for three,
         missing the (addr < start && addr2 == end) case for example.
      
       - The variables are mis-named, making it non-obvious how the
         check was done.
      
       - It needlessly uses u64 instead of unsigned long. Since these
         are kernel memory pointers and we explicitly exclude highmem
         ranges anyway we cannot ever overflow 32 bits, even if we
         could. (and on 64-bit it doesnt matter anyway)
      
      All in one, this function needs a total revamp. I used Linus's
      suggestions minus the paranoid checks (we cannot overflow really
      because if we get totally bad DMA ranges passed far more things
      break in the systems than just DMA debugging). I also fixed a
      few other small details i noticed.
      Reported-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Cc: Joerg Roedel <joerg.roedel@amd.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      f39d1b97
  4. 25 6月, 2009 1 次提交
  5. 23 6月, 2009 1 次提交
  6. 21 6月, 2009 1 次提交
  7. 19 6月, 2009 2 次提交
    • A
      lib/checksum.c: fix endianess bug · 32a9ff9c
      Arnd Bergmann 提交于
      The new generic checksum code has a small dependency on endianess and
      worked only on big-endian systems. I could not find a nice efficient
      way to express this, so I added an #ifdef. Using
      'result += le16_to_cpu(*buff);' would have worked as well, but
      would be slightly less efficient on big-endian systems and IMHO
      would not be clearer.
      
      Also fix a bug that prevents this from working on 64-bit machines.
      If you have a 64-bit CPU and want to use the generic checksum
      code, you should probably do some more optimizations anyway, but
      at least the code should not break.
      Reported-by: NMike Frysinger <vapier@gentoo.org>
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      32a9ff9c
    • F
      lib: add lib/gcd.c · d2829224
      Florian Fainelli 提交于
      This patch adds lib/gcd.c which contains a greatest common divider
      implementation taken from sound/core/pcm_timer.c
      
      Several usages of this new library function will be sent to subsystem
      maintainers.
      
      [akpm@linux-foundation.org: use swap() (pointed out by Joe)]
      [akpm@linux-foundation.org: just add gcd.o to obj-y, remove Kconfig changes]
      Signed-off-by: NFlorian Fainelli <florian@openwrt.org>
      Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
      Cc: Takashi Iwai <tiwai@suse.de>
      Cc: Simon Horman <horms@verge.net.au>
      Cc: Julius Volz <juliusv@google.com>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Patrick McHardy <kaber@trash.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      d2829224
  8. 17 6月, 2009 9 次提交
  9. 16 6月, 2009 2 次提交
  10. 15 6月, 2009 5 次提交
  11. 12 6月, 2009 5 次提交
  12. 11 6月, 2009 1 次提交
  13. 09 6月, 2009 1 次提交
  14. 08 6月, 2009 5 次提交
  15. 07 6月, 2009 1 次提交
  16. 02 6月, 2009 2 次提交