~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/Documentation/mm/page_frags.rst

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 ==============
  2 Page fragments
  3 ==============
  4 
  5 A page fragment is an arbitrary-length arbitrary-offset area of memory
  6 which resides within a 0 or higher order compound page.  Multiple
  7 fragments within that page are individually refcounted, in the page's
  8 reference counter.
  9 
 10 The page_frag functions, page_frag_alloc and page_frag_free, provide a
 11 simple allocation framework for page fragments.  This is used by the
 12 network stack and network device drivers to provide a backing region of
 13 memory for use as either an sk_buff->head, or to be used in the "frags"
 14 portion of skb_shared_info.
 15 
 16 In order to make use of the page fragment APIs a backing page fragment
 17 cache is needed.  This provides a central point for the fragment allocation
 18 and tracks allows multiple calls to make use of a cached page.  The
 19 advantage to doing this is that multiple calls to get_page can be avoided
 20 which can be expensive at allocation time.  However due to the nature of
 21 this caching it is required that any calls to the cache be protected by
 22 either a per-cpu limitation, or a per-cpu limitation and forcing interrupts
 23 to be disabled when executing the fragment allocation.
 24 
 25 The network stack uses two separate caches per CPU to handle fragment
 26 allocation.  The netdev_alloc_cache is used by callers making use of the
 27 netdev_alloc_frag and __netdev_alloc_skb calls.  The napi_alloc_cache is
 28 used by callers of the __napi_alloc_frag and napi_alloc_skb calls.  The
 29 main difference between these two calls is the context in which they may be
 30 called.  The "netdev" prefixed functions are usable in any context as these
 31 functions will disable interrupts, while the "napi" prefixed functions are
 32 only usable within the softirq context.
 33 
 34 Many network device drivers use a similar methodology for allocating page
 35 fragments, but the page fragments are cached at the ring or descriptor
 36 level.  In order to enable these cases it is necessary to provide a generic
 37 way of tearing down a page cache.  For this reason __page_frag_cache_drain
 38 was implemented.  It allows for freeing multiple references from a single
 39 page via a single call.  The advantage to doing this is that it allows for
 40 cleaning up the multiple references that were added to a page in order to
 41 avoid calling get_page per allocation.
 42 
 43 Alexander Duyck, Nov 29, 2016.

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php