diff options
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/skbuff.h | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index b814bb8fd5ab..7632c87da2c9 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h | |||
| @@ -1774,6 +1774,61 @@ static inline struct sk_buff *netdev_alloc_skb_ip_align(struct net_device *dev, | |||
| 1774 | return __netdev_alloc_skb_ip_align(dev, length, GFP_ATOMIC); | 1774 | return __netdev_alloc_skb_ip_align(dev, length, GFP_ATOMIC); |
| 1775 | } | 1775 | } |
| 1776 | 1776 | ||
| 1777 | /* | ||
| 1778 | * __skb_alloc_page - allocate pages for ps-rx on a skb and preserve pfmemalloc data | ||
| 1779 | * @gfp_mask: alloc_pages_node mask. Set __GFP_NOMEMALLOC if not for network packet RX | ||
| 1780 | * @skb: skb to set pfmemalloc on if __GFP_MEMALLOC is used | ||
| 1781 | * @order: size of the allocation | ||
| 1782 | * | ||
| 1783 | * Allocate a new page. | ||
| 1784 | * | ||
| 1785 | * %NULL is returned if there is no free memory. | ||
| 1786 | */ | ||
| 1787 | static inline struct page *__skb_alloc_pages(gfp_t gfp_mask, | ||
| 1788 | struct sk_buff *skb, | ||
| 1789 | unsigned int order) | ||
| 1790 | { | ||
| 1791 | struct page *page; | ||
| 1792 | |||
| 1793 | gfp_mask |= __GFP_COLD; | ||
| 1794 | |||
| 1795 | if (!(gfp_mask & __GFP_NOMEMALLOC)) | ||
| 1796 | gfp_mask |= __GFP_MEMALLOC; | ||
| 1797 | |||
| 1798 | page = alloc_pages_node(NUMA_NO_NODE, gfp_mask, order); | ||
| 1799 | if (skb && page && page->pfmemalloc) | ||
| 1800 | skb->pfmemalloc = true; | ||
| 1801 | |||
| 1802 | return page; | ||
| 1803 | } | ||
| 1804 | |||
| 1805 | /** | ||
| 1806 | * __skb_alloc_page - allocate a page for ps-rx for a given skb and preserve pfmemalloc data | ||
| 1807 | * @gfp_mask: alloc_pages_node mask. Set __GFP_NOMEMALLOC if not for network packet RX | ||
| 1808 | * @skb: skb to set pfmemalloc on if __GFP_MEMALLOC is used | ||
| 1809 | * | ||
| 1810 | * Allocate a new page. | ||
| 1811 | * | ||
| 1812 | * %NULL is returned if there is no free memory. | ||
| 1813 | */ | ||
| 1814 | static inline struct page *__skb_alloc_page(gfp_t gfp_mask, | ||
| 1815 | struct sk_buff *skb) | ||
| 1816 | { | ||
| 1817 | return __skb_alloc_pages(gfp_mask, skb, 0); | ||
| 1818 | } | ||
| 1819 | |||
| 1820 | /** | ||
| 1821 | * skb_propagate_pfmemalloc - Propagate pfmemalloc if skb is allocated after RX page | ||
| 1822 | * @page: The page that was allocated from skb_alloc_page | ||
| 1823 | * @skb: The skb that may need pfmemalloc set | ||
| 1824 | */ | ||
| 1825 | static inline void skb_propagate_pfmemalloc(struct page *page, | ||
| 1826 | struct sk_buff *skb) | ||
| 1827 | { | ||
| 1828 | if (page && page->pfmemalloc) | ||
| 1829 | skb->pfmemalloc = true; | ||
| 1830 | } | ||
| 1831 | |||
| 1777 | /** | 1832 | /** |
| 1778 | * skb_frag_page - retrieve the page refered to by a paged fragment | 1833 | * skb_frag_page - retrieve the page refered to by a paged fragment |
| 1779 | * @frag: the paged fragment | 1834 | * @frag: the paged fragment |
