Commits
Andrey Ryabinin authored and Konstantin Khorenko committed fe0b01d2eea
net/skbuff: Don't waste memory reserves We were observing network performance issues due to packets being dropped by sk_filter_trim_cap() since the 'skb' was allocated from pfmemalloc reserves: /* * If the skb was allocated from pfmemalloc reserves, only * allow SOCK_MEMALLOC sockets to use it as this socket is * helping free memory */ if (skb_pfmemalloc(skb) && !sock_flag(sk, SOCK_MEMALLOC)) return -ENOMEM; Memalloc sockets are used for stuff like swap over NBD or NFS and only memalloc sockets can process memalloc skbs. Since we don't have any memalloc sockets in our setups we shouldn't have memalloc skbs either. It simply doesn't make any sense to waste memory reserves on skb only to drop packets later. It appears that __dev_alloc_pages() unconditionally uses __GFP_MEMALLOC, so unless caller added __GFP_NOMEMALLOC, the __dev_alloc_pages() may dive into memory reserves. Later build_skb() or __skb_fill_page_desc() sets skb->pfmemalloc = 1 so this skb always dropped by sk_filter_trim_cap(). Instead of wasting memory reserves we should simply avoid using them in case of absence memalloc sockets in the system. Do this by adding __GFP_MEMALLOC only when such socket is present in the system. https://pmc.acronis.com/browse/VSTOR-21390 Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>