@@ -517,18 +517,16 @@ static void *kmalloc_reserve(unsigned int *size, gfp_t flags, int node,
517
517
#ifdef HAVE_SKB_SMALL_HEAD_CACHE
518
518
if (obj_size <= SKB_SMALL_HEAD_CACHE_SIZE &&
519
519
!(flags & KMALLOC_NOT_NORMAL_BITS )) {
520
-
521
- /* skb_small_head_cache has non power of two size,
522
- * likely forcing SLUB to use order-3 pages.
523
- * We deliberately attempt a NOMEMALLOC allocation only.
524
- */
525
520
obj = kmem_cache_alloc_node (skb_small_head_cache ,
526
521
flags | __GFP_NOMEMALLOC | __GFP_NOWARN ,
527
522
node );
528
- if ( obj ) {
529
- * size = SKB_SMALL_HEAD_CACHE_SIZE ;
523
+ * size = SKB_SMALL_HEAD_CACHE_SIZE ;
524
+ if ( obj || !( gfp_pfmemalloc_allowed ( flags )))
530
525
goto out ;
531
- }
526
+ /* Try again but now we are using pfmemalloc reserves */
527
+ ret_pfmemalloc = true;
528
+ obj = kmem_cache_alloc_node (skb_small_head_cache , flags , node );
529
+ goto out ;
532
530
}
533
531
#endif
534
532
* size = obj_size = kmalloc_size_roundup (obj_size );
@@ -2082,6 +2080,7 @@ struct sk_buff *skb_realloc_headroom(struct sk_buff *skb, unsigned int headroom)
2082
2080
}
2083
2081
EXPORT_SYMBOL (skb_realloc_headroom );
2084
2082
2083
+ /* Note: We plan to rework this in linux-6.4 */
2085
2084
int __skb_unclone_keeptruesize (struct sk_buff * skb , gfp_t pri )
2086
2085
{
2087
2086
unsigned int saved_end_offset , saved_truesize ;
@@ -2100,6 +2099,22 @@ int __skb_unclone_keeptruesize(struct sk_buff *skb, gfp_t pri)
2100
2099
if (likely (skb_end_offset (skb ) == saved_end_offset ))
2101
2100
return 0 ;
2102
2101
2102
+ #ifdef HAVE_SKB_SMALL_HEAD_CACHE
2103
+ /* We can not change skb->end if the original or new value
2104
+ * is SKB_SMALL_HEAD_HEADROOM, as it might break skb_kfree_head().
2105
+ */
2106
+ if (saved_end_offset == SKB_SMALL_HEAD_HEADROOM ||
2107
+ skb_end_offset (skb ) == SKB_SMALL_HEAD_HEADROOM ) {
2108
+ /* We think this path should not be taken.
2109
+ * Add a temporary trace to warn us just in case.
2110
+ */
2111
+ pr_err_once ("__skb_unclone_keeptruesize() skb_end_offset() %u -> %u\n" ,
2112
+ saved_end_offset , skb_end_offset (skb ));
2113
+ WARN_ON_ONCE (1 );
2114
+ return 0 ;
2115
+ }
2116
+ #endif
2117
+
2103
2118
shinfo = skb_shinfo (skb );
2104
2119
2105
2120
/* We are about to change back skb->end,
0 commit comments