net/core/: possible cleanups
Subsystems (3)
RFC PATCH 1/1 net/core/: possible cleanups
This patch contains the following possible cleanups:
- make the following needlessly global functions static:
- skbuff.c: kfree_skbmem()
- skbuff.c: skb_prepare_seq_read()
- skbuff.c: skb_seq_read()
- skbuff.c: skb_abort_seq_read()
- #if 0 the following unused global functions:
- skbuff.c: alloc_skb_from_cache()
- skbuff.c: skb_insert()
- make the following trivial wrapper function a static inline:
- neighbour.c: neigh_parms_destroy()
- remove the following unused EXPORT_SYMBOL's:
- dev.c: netdev_features_change
- dev.c: register_gifconf
- flow.c: flow_cache_genid
- flow.c: flow_cache_lookup
- gen_stats.c: gnet_stats_start_copy
- iovec.c: csum_partial_copy_fromiovecend
- neighbour.c: neigh_add
- neighbour.c: neigh_compat_output
- neighbour.c: neigh_delete
- neighbour.c: neigh_dump_info
- neighbour.c: neigh_event_ns
- neighbour.c: neigh_update_hhs (static inline function!)
- neighbour.c: neightbl_dump_info
- neighbour.c: neightbl_set
- request_sock.c: reqsk_queue_alloc
- request_sock.c: reqsk_queue_destroy
- skbuff.c: skb_clone_fraglist (static function!)
- skbuff.c: skb_split
- stream.c: sk_stream_wait_memory
- stream.c: sk_stream_rfree
- stream.c: __sk_stream_mem_reclaim
- stream.c: sk_stream_mem_schedule
- stream.c: sk_stream_kill_queues
- remove the following unused EXPORT_SYMBOL_GPL:
- sock.c: sk_clone
---
include/linux/skbuff.h | 12 ------------ include/net/neighbour.h | 6 +++++- net/core/dev.c | 2 -- net/core/flow.c | 2 -- net/core/gen_stats.c | 1 - net/core/iovec.c | 1 - net/core/neighbour.c | 14 -------------- net/core/request_sock.c | 3 --- net/core/skbuff.c | 26 ++++++++++++-------------- net/core/sock.c | 2 -- net/core/stream.c | 9 --------- 11 files changed, 17 insertions(+), 61 deletions(-)
net/core/dev.c renamed from net/core/dev.c.old +0 -2
@@ -752,7 +752,6 @@ {blocking_notifier_call_chain (&netdev_chain,NETDEV_FEAT_CHANGE , dev); } -EXPORT_SYMBOL (netdev_features_change);/** * netdev_state_change - device changes state
@@ -3398,7 +3397,6 @@EXPORT_SYMBOL (netdev_state_change);EXPORT_SYMBOL (netif_receive_skb);EXPORT_SYMBOL (netif_rx); -EXPORT_SYMBOL (register_gifconf);EXPORT_SYMBOL (register_netdevice);EXPORT_SYMBOL (register_netdevice_notifier);EXPORT_SYMBOL (skb_checksum_help);
net/core/flow.c renamed from net/core/flow.c.old +0 -2
@@ -370,5 +370,3 @@module_init (flow_cache_init); -EXPORT_SYMBOL (flow_cache_genid); -EXPORT_SYMBOL (flow_cache_lookup);
net/core/gen_stats.c renamed from net/core/gen_stats.c.old +0 -1
@@ -230,7 +230,6 @@ } -EXPORT_SYMBOL (gnet_stats_start_copy);EXPORT_SYMBOL (gnet_stats_start_copy_compat);EXPORT_SYMBOL (gnet_stats_copy_basic);EXPORT_SYMBOL (gnet_stats_copy_rate_est);
net/core/iovec.c renamed from net/core/iovec.c.old +0 -1
@@ -233,7 +233,6 @@ goto out; } -EXPORT_SYMBOL (csum_partial_copy_fromiovecend);EXPORT_SYMBOL (memcpy_fromiovec);EXPORT_SYMBOL (memcpy_fromiovecend);EXPORT_SYMBOL (memcpy_toiovec);
include/net/neighbour.h renamed from include/net/neighbour.h.old +5 -1
@@ -235,7 +235,6 @@extern struct neigh_parms *neigh_parms_alloc (struct net_device *dev,struct neigh_table *tbl);extern void neigh_parms_release (struct neigh_table *tbl,struct neigh_parms *parms); -extern void neigh_parms_destroy (struct neigh_parms *parms);extern unsigned long neigh_rand_reach_time (unsigned long base); extern void pneigh_enqueue(struct neigh_table *tbl, struct neigh_parms *p,
@@ -279,6 +278,11 @@ ctl_handler *strategy);extern void neigh_sysctl_unregister (struct neigh_parms *p); +static inline void neigh_parms_destroy (struct neigh_parms *parms) +{ +kfree (parms); +} +static inline void __neigh_parms_put (struct neigh_parms *parms) {atomic_dec (&parms->refcnt);
net/core/neighbour.c renamed from net/core/neighbour.c.old +0 -14
@@ -1321,12 +1321,6 @@NEIGH_PRINTK1 ("neigh_parms_release: not found\n" ); } -void neigh_parms_destroy (struct neigh_parms *parms) -{ -kfree (parms); -} - -void neigh_table_init (struct neigh_table *tbl) {unsigned long now = jiffies;
@@ -2639,15 +2633,10 @@#endif /* CONFIG_SYSCTL */ EXPORT_SYMBOL (__neigh_event_send); -EXPORT_SYMBOL (neigh_add);EXPORT_SYMBOL (neigh_changeaddr); -EXPORT_SYMBOL (neigh_compat_output);EXPORT_SYMBOL (neigh_connected_output);EXPORT_SYMBOL (neigh_create); -EXPORT_SYMBOL (neigh_delete);EXPORT_SYMBOL (neigh_destroy); -EXPORT_SYMBOL (neigh_dump_info); -EXPORT_SYMBOL (neigh_event_ns);EXPORT_SYMBOL (neigh_ifdown);EXPORT_SYMBOL (neigh_lookup);EXPORT_SYMBOL (neigh_lookup_nodev);
@@ -2658,11 +2647,8 @@EXPORT_SYMBOL (neigh_table_clear);EXPORT_SYMBOL (neigh_table_init);EXPORT_SYMBOL (neigh_update); -EXPORT_SYMBOL (neigh_update_hhs);EXPORT_SYMBOL (pneigh_enqueue);EXPORT_SYMBOL (pneigh_lookup); -EXPORT_SYMBOL (neightbl_dump_info); -EXPORT_SYMBOL (neightbl_set);#ifdef CONFIG_ARPD EXPORT_SYMBOL (neigh_app_ns);
net/core/request_sock.c renamed from net/core/request_sock.c.old +0 -3
@@ -59,8 +59,6 @@return 0 ; } -EXPORT_SYMBOL (reqsk_queue_alloc); -void reqsk_queue_destroy (struct request_sock_queue *queue) {/* make all the listen_opt local to us */
@@ -84,4 +82,3 @@kfree (lopt); } -EXPORT_SYMBOL (reqsk_queue_destroy);
include/linux/skbuff.h renamed from include/linux/skbuff.h.old +0 -12
@@ -320,10 +320,6 @@return __alloc_skb (size, priority,1 ); } -extern struct sk_buff *alloc_skb_from_cache (kmem_cache_t *cp, -unsigned int size, -gfp_t priority); -extern void kfree_skbmem (struct sk_buff *skb);extern struct sk_buff *skb_clone (struct sk_buff *skb,gfp_t priority); extern struct sk_buff *skb_copy(const struct sk_buff *skb,
@@ -361,13 +357,6 @@__u8 *frag_data; }; -extern void skb_prepare_seq_read (struct sk_buff *skb, -unsigned int from,unsigned int to, -struct skb_seq_state *st); -extern unsigned int skb_seq_read (unsigned int consumed,const u8 **data, -struct skb_seq_state *st); -extern void skb_abort_seq_read (struct skb_seq_state *st); -extern unsigned int skb_find_text (struct sk_buff *skb,unsigned int from,unsigned int to,struct ts_config *config,struct ts_state *state);
@@ -685,7 +674,6 @@/* * Insert a packet on a list. */ -extern void skb_insert (struct sk_buff *old,struct sk_buff *newsk,struct sk_buff_head *list);static inline void __skb_insert (struct sk_buff *newsk,struct sk_buff *prev,struct sk_buff *next,struct sk_buff_head *list)
net/core/skbuff.c renamed from net/core/skbuff.c.old +12 -14
@@ -187,6 +187,7 @@ goto out; } +#if 0 /** * alloc_skb_from_cache - allocate a network buffer * @cp: kmem_cache from which to allocate the data area
@@ -240,6 +241,7 @@ skb =NULL ; goto out; } +#endif /* 0 */ static void skb_drop_fraglist (struct sk_buff *skb)
@@ -284,7 +286,7 @@/* * Free an skbuff by memory without cleaning the state. */ -void kfree_skbmem (struct sk_buff *skb) +static void kfree_skbmem (struct sk_buff *skb) {struct sk_buff *other;atomic_t *fclone_ref;
@@ -1458,6 +1460,8 @@ } +#if 0 +/** * skb_insert - insert a buffer * @old: buffer to insert before
@@ -1479,7 +1483,6 @@spin_unlock_irqrestore (&list->lock, flags); } -#if 0 /* * Tune the memory allocator for a new MTU size. */
@@ -1490,7 +1493,8 @@kmem_add_cache_size (mtu); } -#endif + +#endif /* 0 */ static inline void skb_split_inside_header(struct sk_buff *skb, struct sk_buff* skb1,
@@ -1580,8 +1584,8 @@* Initializes the specified state variable. Must be called before * invoking skb_seq_read() for the first time. */ -void skb_prepare_seq_read (struct sk_buff *skb,unsigned int from, -unsigned int to,struct skb_seq_state *st) +static void skb_prepare_seq_read (struct sk_buff *skb,unsigned int from, +unsigned int to,struct skb_seq_state *st) { st->lower_offset = from; st->upper_offset = to;
@@ -1615,8 +1619,8 @@* at the moment, state->root_skb could be replaced with * a stack for this purpose. */ -unsigned int skb_seq_read (unsigned int consumed,const u8 **data, -struct skb_seq_state *st) +static unsigned int skb_seq_read (unsigned int consumed,const u8 **data, +struct skb_seq_state *st) {unsigned int block_limit, abs_offset = consumed + st->lower_offset;skb_frag_t *frag;
@@ -1678,7 +1682,7 @@* Must be called if skb_seq_read() was not called until it * returned 0. */ -void skb_abort_seq_read (struct skb_seq_state *st) +static void skb_abort_seq_read (struct skb_seq_state *st) {if (st->frag_data)kunmap_skb_frag (st->frag_data);
@@ -1847,7 +1851,6 @@EXPORT_SYMBOL (pskb_expand_head);EXPORT_SYMBOL (skb_checksum);EXPORT_SYMBOL (skb_clone); -EXPORT_SYMBOL (skb_clone_fraglist);EXPORT_SYMBOL (skb_copy);EXPORT_SYMBOL (skb_copy_and_csum_bits);EXPORT_SYMBOL (skb_copy_and_csum_dev);
@@ -1859,15 +1862,10 @@EXPORT_SYMBOL (skb_under_panic);EXPORT_SYMBOL (skb_dequeue);EXPORT_SYMBOL (skb_dequeue_tail); -EXPORT_SYMBOL (skb_insert);EXPORT_SYMBOL (skb_queue_purge);EXPORT_SYMBOL (skb_queue_head);EXPORT_SYMBOL (skb_queue_tail);EXPORT_SYMBOL (skb_unlink);EXPORT_SYMBOL (skb_append); -EXPORT_SYMBOL (skb_split); -EXPORT_SYMBOL (skb_prepare_seq_read); -EXPORT_SYMBOL (skb_seq_read); -EXPORT_SYMBOL (skb_abort_seq_read);EXPORT_SYMBOL (skb_find_text);EXPORT_SYMBOL (skb_append_datato_frags);
net/core/sock.c renamed from net/core/sock.c.old +0 -2
@@ -885,8 +885,6 @@return newsk; } -EXPORT_SYMBOL_GPL (sk_clone); -void __init sk_init (void ) {if (num_physpages <=4096 ) {
net/core/stream.c renamed from net/core/stream.c.old +0 -9
@@ -170,8 +170,6 @@ goto out; } -EXPORT_SYMBOL (sk_stream_wait_memory); -void sk_stream_rfree (struct sk_buff *skb) {struct sock *sk = skb->sk;
@@ -180,8 +178,6 @@ sk->sk_forward_alloc += skb->truesize; } -EXPORT_SYMBOL (sk_stream_rfree); -int sk_stream_error (struct sock *sk,int flags,int err) {if (err == -EPIPE )
@@ -206,8 +202,6 @@ } } -EXPORT_SYMBOL (__sk_stream_mem_reclaim); -int sk_stream_mem_schedule (struct sock *sk,int size,int kind) {int amt =sk_stream_pages (size);
@@ -266,8 +260,6 @@return 0 ; } -EXPORT_SYMBOL (sk_stream_mem_schedule); -void sk_stream_kill_queues (struct sock *sk) {/* First the read buffer. */
@@ -291,4 +283,3 @@*/ } -EXPORT_SYMBOL (sk_stream_kill_queues);
Quoted 3 lines · Adrian Bunk
- make the following trivial wrapper function a static inline:
-neighbour.c:neigh_parms_destroy()
Am I missing something or is there just a single caller? In that case, neigh_parms_put() could call kfree() directly and neigh_parms_destroy() is free for termination.
Jörn
Signature · 3 lines
"[One] doesn't need to know [...] how to cause a headache in order to take an aspirin." -- Scott Culp, Manager of the Microsoft Security Response Center, 2001