@@ -1125,6 +1125,7 @@ static void pipapo_free_scratch(const struct nft_pipapo_match *m, unsigned int c
1125
1125
return ;
1126
1126
1127
1127
mem = s ;
1128
+ mem -= s -> align_off ;
1128
1129
kfree (mem );
1129
1130
}
1130
1131
@@ -1144,6 +1145,7 @@ static int pipapo_realloc_scratch(struct nft_pipapo_match *clone,
1144
1145
struct nft_pipapo_scratch * scratch ;
1145
1146
#ifdef NFT_PIPAPO_ALIGN
1146
1147
void * scratch_aligned ;
1148
+ u32 align_off ;
1147
1149
#endif
1148
1150
scratch = kzalloc_node (struct_size (scratch , map ,
1149
1151
bsize_max * 2 ) +
@@ -1162,8 +1164,6 @@ static int pipapo_realloc_scratch(struct nft_pipapo_match *clone,
1162
1164
1163
1165
pipapo_free_scratch (clone , i );
1164
1166
1165
- * per_cpu_ptr (clone -> scratch , i ) = scratch ;
1166
-
1167
1167
#ifdef NFT_PIPAPO_ALIGN
1168
1168
/* Align &scratch->map (not the struct itself): the extra
1169
1169
* %NFT_PIPAPO_ALIGN_HEADROOM bytes passed to kzalloc_node()
@@ -1175,8 +1175,12 @@ static int pipapo_realloc_scratch(struct nft_pipapo_match *clone,
1175
1175
1176
1176
scratch_aligned = NFT_PIPAPO_LT_ALIGN (& scratch -> map );
1177
1177
scratch_aligned -= offsetof(struct nft_pipapo_scratch , map );
1178
- * per_cpu_ptr (clone -> scratch_aligned , i ) = scratch_aligned ;
1178
+ align_off = scratch_aligned - (void * )scratch ;
1179
+
1180
+ scratch = scratch_aligned ;
1181
+ scratch -> align_off = align_off ;
1179
1182
#endif
1183
+ * per_cpu_ptr (clone -> scratch , i ) = scratch ;
1180
1184
}
1181
1185
1182
1186
return 0 ;
@@ -1331,11 +1335,6 @@ static struct nft_pipapo_match *pipapo_clone(struct nft_pipapo_match *old)
1331
1335
if (!new -> scratch )
1332
1336
goto out_scratch ;
1333
1337
1334
- #ifdef NFT_PIPAPO_ALIGN
1335
- new -> scratch_aligned = alloc_percpu (* new -> scratch_aligned );
1336
- if (!new -> scratch_aligned )
1337
- goto out_scratch ;
1338
- #endif
1339
1338
for_each_possible_cpu (i )
1340
1339
* per_cpu_ptr (new -> scratch , i ) = NULL ;
1341
1340
@@ -1388,9 +1387,6 @@ static struct nft_pipapo_match *pipapo_clone(struct nft_pipapo_match *old)
1388
1387
out_scratch_realloc :
1389
1388
for_each_possible_cpu (i )
1390
1389
pipapo_free_scratch (new , i );
1391
- #ifdef NFT_PIPAPO_ALIGN
1392
- free_percpu (new -> scratch_aligned );
1393
- #endif
1394
1390
out_scratch :
1395
1391
free_percpu (new -> scratch );
1396
1392
kfree (new );
@@ -1673,11 +1669,7 @@ static void pipapo_free_match(struct nft_pipapo_match *m)
1673
1669
for_each_possible_cpu (i )
1674
1670
pipapo_free_scratch (m , i );
1675
1671
1676
- #ifdef NFT_PIPAPO_ALIGN
1677
- free_percpu (m -> scratch_aligned );
1678
- #endif
1679
1672
free_percpu (m -> scratch );
1680
-
1681
1673
pipapo_free_fields (m );
1682
1674
1683
1675
kfree (m );
@@ -2171,16 +2163,6 @@ static int nft_pipapo_init(const struct nft_set *set,
2171
2163
for_each_possible_cpu (i )
2172
2164
* per_cpu_ptr (m -> scratch , i ) = NULL ;
2173
2165
2174
- #ifdef NFT_PIPAPO_ALIGN
2175
- m -> scratch_aligned = alloc_percpu (struct nft_pipapo_scratch * );
2176
- if (!m -> scratch_aligned ) {
2177
- err = - ENOMEM ;
2178
- goto out_free ;
2179
- }
2180
- for_each_possible_cpu (i )
2181
- * per_cpu_ptr (m -> scratch_aligned , i ) = NULL ;
2182
- #endif
2183
-
2184
2166
rcu_head_init (& m -> rcu );
2185
2167
2186
2168
nft_pipapo_for_each_field (f , i , m ) {
@@ -2211,9 +2193,6 @@ static int nft_pipapo_init(const struct nft_set *set,
2211
2193
return 0 ;
2212
2194
2213
2195
out_free :
2214
- #ifdef NFT_PIPAPO_ALIGN
2215
- free_percpu (m -> scratch_aligned );
2216
- #endif
2217
2196
free_percpu (m -> scratch );
2218
2197
out_scratch :
2219
2198
kfree (m );
@@ -2267,9 +2246,6 @@ static void nft_pipapo_destroy(const struct nft_ctx *ctx,
2267
2246
2268
2247
nft_set_pipapo_match_destroy (ctx , set , m );
2269
2248
2270
- #ifdef NFT_PIPAPO_ALIGN
2271
- free_percpu (m -> scratch_aligned );
2272
- #endif
2273
2249
for_each_possible_cpu (cpu )
2274
2250
pipapo_free_scratch (m , cpu );
2275
2251
free_percpu (m -> scratch );
@@ -2284,9 +2260,6 @@ static void nft_pipapo_destroy(const struct nft_ctx *ctx,
2284
2260
if (priv -> dirty )
2285
2261
nft_set_pipapo_match_destroy (ctx , set , m );
2286
2262
2287
- #ifdef NFT_PIPAPO_ALIGN
2288
- free_percpu (priv -> clone -> scratch_aligned );
2289
- #endif
2290
2263
for_each_possible_cpu (cpu )
2291
2264
pipapo_free_scratch (priv -> clone , cpu );
2292
2265
free_percpu (priv -> clone -> scratch );
0 commit comments