Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net/sched: cake: avoid separate allocation of struct cake_sched_config

Paolo pointed out that we can avoid separately allocating struct
cake_sched_config even in the non-mq case, by embedding it into struct
cake_sched_data. This reduces the complexity of the logic that swaps the
pointers and frees the old value, at the cost of adding 56 bytes to the
latter. Since cake_sched_data is already almost 17k bytes, this seems
like a reasonable tradeoff.

Suggested-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Fixes: bc0ce2bad36c ("net/sched: sch_cake: Factor out config variables into separate struct")
Link: https://patch.msgid.link/20260113143157.2581680-1-toke@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Toke Høiland-Jørgensen and committed by
Jakub Kicinski
2a85541d 8fc80710

+6 -23
+6 -23
net/sched/sch_cake.c
··· 221 221 struct tcf_block *block; 222 222 struct cake_tin_data *tins; 223 223 struct cake_sched_config *config; 224 + struct cake_sched_config initial_config; 224 225 225 226 struct cake_heap_entry overflow_heap[CAKE_QUEUES * CAKE_MAX_TINS]; 226 227 ··· 2799 2798 qdisc_watchdog_cancel(&q->watchdog); 2800 2799 tcf_block_put(q->block); 2801 2800 kvfree(q->tins); 2802 - if (q->config && !q->config->is_shared) 2803 - kvfree(q->config); 2804 2801 } 2805 2802 2806 2803 static void cake_config_init(struct cake_sched_config *q, bool is_shared) ··· 2821 2822 struct netlink_ext_ack *extack) 2822 2823 { 2823 2824 struct cake_sched_data *qd = qdisc_priv(sch); 2824 - struct cake_sched_config *q; 2825 + struct cake_sched_config *q = &qd->initial_config; 2825 2826 int i, j, err; 2826 - 2827 - q = kzalloc(sizeof(*q), GFP_KERNEL); 2828 - if (!q) 2829 - return -ENOMEM; 2830 2827 2831 2828 cake_config_init(q, false); 2832 2829 ··· 2837 2842 2838 2843 if (opt) { 2839 2844 err = cake_change(sch, opt, extack); 2840 - 2841 2845 if (err) 2842 - goto err; 2846 + return err; 2843 2847 } 2844 2848 2845 2849 err = tcf_block_get(&qd->block, &qd->filter_list, sch, extack); 2846 2850 if (err) 2847 - goto err; 2851 + return err; 2848 2852 2849 2853 quantum_div[0] = ~0; 2850 2854 for (i = 1; i <= CAKE_QUEUES; i++) ··· 2851 2857 2852 2858 qd->tins = kvcalloc(CAKE_MAX_TINS, sizeof(struct cake_tin_data), 2853 2859 GFP_KERNEL); 2854 - if (!qd->tins) { 2855 - err = -ENOMEM; 2856 - goto err; 2857 - } 2860 + if (!qd->tins) 2861 + return -ENOMEM; 2858 2862 2859 2863 for (i = 0; i < CAKE_MAX_TINS; i++) { 2860 2864 struct cake_tin_data *b = qd->tins + i; ··· 2885 2893 qd->last_checked_active = 0; 2886 2894 2887 2895 return 0; 2888 - err: 2889 - kvfree(qd->config); 2890 - qd->config = NULL; 2891 - return err; 2892 2896 } 2893 2897 2894 2898 static void cake_config_replace(struct Qdisc *sch, struct cake_sched_config *cfg) 2895 2899 { 2896 2900 struct cake_sched_data *qd = qdisc_priv(sch); 2897 - struct cake_sched_config *q = qd->config; 2898 2901 2899 2902 qd->config = cfg; 2900 - 2901 - if (!q->is_shared) 2902 - kvfree(q); 2903 - 2904 2903 cake_reconfigure(sch); 2905 2904 } 2906 2905