From 706cf38423d43cca6431405830542fa5f722f214 Mon Sep 17 00:00:00 2001 From: k-nakahara Date: Mon, 11 Apr 2016 12:06:40 +0900 Subject: [PATCH 3/5] more refactor to fix performance issue --- sys/altq/altq_blue.c | 5 +++-- sys/altq/altq_cbq.c | 8 ++++---- sys/altq/altq_fifoq.c | 6 ++---- sys/altq/altq_hfsc.c | 6 +++--- sys/altq/altq_jobs.c | 5 +++-- sys/altq/altq_priq.c | 5 +++-- sys/altq/altq_red.c | 5 +++-- sys/altq/altq_rio.c | 5 +++-- sys/altq/altq_subr.c | 2 +- sys/altq/altq_wfq.c | 6 +++--- sys/altq/if_altq.h | 10 ++++------ sys/net/if.h | 7 +++---- 12 files changed, 35 insertions(+), 35 deletions(-) diff --git a/sys/altq/altq_blue.c b/sys/altq/altq_blue.c index f5d9c64..11f57db 100644 --- a/sys/altq/altq_blue.c +++ b/sys/altq/altq_blue.c @@ -112,7 +112,7 @@ __KERNEL_RCSID(0, "$NetBSD: altq_blue.c,v 1.23 2011/11/19 22:51:18 tls Exp $"); static blue_queue_t *blue_list = NULL; /* internal function prototypes */ -static int blue_enqueue(struct ifaltq *, struct mbuf *, struct altq_pktattr *); +static int blue_enqueue(struct ifaltq *, struct mbuf *); static struct mbuf *blue_dequeue(struct ifaltq *, int); static int drop_early(blue_t *); static int mark_ecn(struct mbuf *, struct altq_pktattr *, int); @@ -391,9 +391,10 @@ blue_init(blue_t *rp, int flags, int pkttime, int blue_max_pmark, * ENOBUFS when drop occurs. */ static int -blue_enqueue(struct ifaltq *ifq, struct mbuf *m, struct altq_pktattr *pktattr) +blue_enqueue(struct ifaltq *ifq, struct mbuf *m) { blue_queue_t *rqp = (blue_queue_t *)ifq->altq_disc; + struct altq_pktattr *pktattr = &m->m_pkthdr.pattr; int error = 0; if (blue_addq(rqp->rq_blue, rqp->rq_q, m, pktattr) == 0) diff --git a/sys/altq/altq_cbq.c b/sys/altq/altq_cbq.c index 97e6d20..9d9f384 100644 --- a/sys/altq/altq_cbq.c +++ b/sys/altq/altq_cbq.c @@ -82,8 +82,7 @@ static int cbq_class_destroy(cbq_state_t *, struct rm_class *); static struct rm_class *clh_to_clp(cbq_state_t *, u_int32_t); static int cbq_clear_interface(cbq_state_t *); static int cbq_request(struct ifaltq *, int, void *); -static int cbq_enqueue(struct ifaltq *, struct mbuf *, - struct altq_pktattr *); +static int cbq_enqueue(struct ifaltq *, struct mbuf *); static struct mbuf *cbq_dequeue(struct ifaltq *, int); static void cbqrestart(struct ifaltq *); static void get_class_stats(class_stats_t *, struct rm_class *); @@ -483,7 +482,7 @@ cbq_getqstats(struct pf_altq *a, void *ubuf, int *nbytes) /* * int - * cbq_enqueue(struct ifaltq *ifq, struct mbuf *m, struct altq_pktattr *pattr) + * cbq_enqueue(struct ifaltq *ifq, struct mbuf *m) * - Queue data packets. * * cbq_enqueue is set to ifp->if_altqenqueue and called by an upper @@ -497,11 +496,12 @@ cbq_getqstats(struct pf_altq *a, void *ubuf, int *nbytes) */ static int -cbq_enqueue(struct ifaltq *ifq, struct mbuf *m, struct altq_pktattr *pktattr) +cbq_enqueue(struct ifaltq *ifq, struct mbuf *m) { cbq_state_t *cbqp = (cbq_state_t *)ifq->altq_disc; struct rm_class *cl; struct m_tag *t; + struct altq_pktattr *pktattr = &m->m_pkthdr.pattr; int len; /* grab class set by classifier */ diff --git a/sys/altq/altq_fifoq.c b/sys/altq/altq_fifoq.c index ff98c17..a906f0d 100644 --- a/sys/altq/altq_fifoq.c +++ b/sys/altq/altq_fifoq.c @@ -70,8 +70,7 @@ __KERNEL_RCSID(0, "$NetBSD: altq_fifoq.c,v 1.16 2007/03/04 05:59:01 christos Exp static fifoq_state_t *fifoq_list = NULL; /* internal function prototypes */ -static int fifoq_enqueue(struct ifaltq *, struct mbuf *, - struct altq_pktattr *); +static int fifoq_enqueue(struct ifaltq *, struct mbuf *); static struct mbuf *fifoq_dequeue(struct ifaltq *, int); static int fifoq_detach(fifoq_state_t *); static int fifoq_request(struct ifaltq *, int, void *); @@ -266,8 +265,7 @@ fifoqioctl(dev_t dev, ioctlcmd_t cmd, void *addr, int flag, * ENOBUFS when drop occurs. */ static int -fifoq_enqueue(struct ifaltq *ifq, struct mbuf *m, - struct altq_pktattr *pktattr) +fifoq_enqueue(struct ifaltq *ifq, struct mbuf *m) { fifoq_state_t *q = (fifoq_state_t *)ifq->altq_disc; diff --git a/sys/altq/altq_hfsc.c b/sys/altq/altq_hfsc.c index dd45ce6..73a54da 100644 --- a/sys/altq/altq_hfsc.c +++ b/sys/altq/altq_hfsc.c @@ -90,8 +90,7 @@ static struct hfsc_class *hfsc_class_create(struct hfsc_if *, struct hfsc_class *, int, int, int); static int hfsc_class_destroy(struct hfsc_class *); static struct hfsc_class *hfsc_nextclass(struct hfsc_class *); -static int hfsc_enqueue(struct ifaltq *, struct mbuf *, - struct altq_pktattr *); +static int hfsc_enqueue(struct ifaltq *, struct mbuf *); static struct mbuf *hfsc_dequeue(struct ifaltq *, int); static int hfsc_addq(struct hfsc_class *, struct mbuf *); @@ -666,11 +665,12 @@ hfsc_nextclass(struct hfsc_class *cl) * (*altq_enqueue) in struct ifaltq. */ static int -hfsc_enqueue(struct ifaltq *ifq, struct mbuf *m, struct altq_pktattr *pktattr) +hfsc_enqueue(struct ifaltq *ifq, struct mbuf *m) { struct hfsc_if *hif = (struct hfsc_if *)ifq->altq_disc; struct hfsc_class *cl; struct m_tag *t; + struct altq_pktattr *pktattr = &m->m_pkthdr.pattr; int len; /* grab class set by classifier */ diff --git a/sys/altq/altq_jobs.c b/sys/altq/altq_jobs.c index fc5e00f..3324d03 100644 --- a/sys/altq/altq_jobs.c +++ b/sys/altq/altq_jobs.c @@ -103,7 +103,7 @@ static void jobs_purge(struct jobs_if *); static struct jobs_class *jobs_class_create(struct jobs_if *, int, int64_t, int64_t, int64_t, int64_t, int64_t, int); static int jobs_class_destroy(struct jobs_class *); -static int jobs_enqueue(struct ifaltq *, struct mbuf *, struct altq_pktattr *); +static int jobs_enqueue(struct ifaltq *, struct mbuf *); static struct mbuf *jobs_dequeue(struct ifaltq *, int); static int jobs_addq(struct jobs_class *, struct mbuf *, struct jobs_if*); @@ -490,10 +490,11 @@ jobs_class_destroy(struct jobs_class *cl) * (*altq_enqueue) in struct ifaltq. */ static int -jobs_enqueue(struct ifaltq *ifq, struct mbuf *m, struct altq_pktattr *pktattr) +jobs_enqueue(struct ifaltq *ifq, struct mbuf *m) { struct jobs_if *jif = (struct jobs_if *)ifq->altq_disc; struct jobs_class *cl, *scan; + struct altq_pktattr *pktattr = &m->m_pkthdr.pattr; int len; int return_flag; int pri; diff --git a/sys/altq/altq_priq.c b/sys/altq/altq_priq.c index 10c376c..c1df067 100644 --- a/sys/altq/altq_priq.c +++ b/sys/altq/altq_priq.c @@ -76,7 +76,7 @@ static void priq_purge(struct priq_if *); static struct priq_class *priq_class_create(struct priq_if *, int, int, int, int); static int priq_class_destroy(struct priq_class *); -static int priq_enqueue(struct ifaltq *, struct mbuf *, struct altq_pktattr *); +static int priq_enqueue(struct ifaltq *, struct mbuf *); static struct mbuf *priq_dequeue(struct ifaltq *, int); static int priq_addq(struct priq_class *, struct mbuf *); @@ -438,11 +438,12 @@ priq_class_destroy(struct priq_class *cl) * (*altq_enqueue) in struct ifaltq. */ static int -priq_enqueue(struct ifaltq *ifq, struct mbuf *m, struct altq_pktattr *pktattr) +priq_enqueue(struct ifaltq *ifq, struct mbuf *m) { struct priq_if *pif = (struct priq_if *)ifq->altq_disc; struct priq_class *cl; struct m_tag *t; + struct altq_pktattr *pktattr = &m->m_pkthdr.pattr; int len; /* grab class set by classifier */ diff --git a/sys/altq/altq_red.c b/sys/altq/altq_red.c index a01be07..38f84fa 100644 --- a/sys/altq/altq_red.c +++ b/sys/altq/altq_red.c @@ -203,7 +203,7 @@ static int default_inv_pmax = INV_P_MAX; #ifdef ALTQ3_COMPAT /* internal function prototypes */ -static int red_enqueue(struct ifaltq *, struct mbuf *, struct altq_pktattr *); +static int red_enqueue(struct ifaltq *, struct mbuf *); static struct mbuf *red_dequeue(struct ifaltq *, int); static int red_request(struct ifaltq *, int, void *); static void red_purgeq(red_queue_t *); @@ -1011,9 +1011,10 @@ red_detach(red_queue_t *rqp) * ENOBUFS when drop occurs. */ static int -red_enqueue(struct ifaltq *ifq, struct mbuf *m, struct altq_pktattr *pktattr) +red_enqueue(struct ifaltq *ifq, struct mbuf *m) { red_queue_t *rqp = (red_queue_t *)ifq->altq_disc; + struct altq_pktattr *pktattr = &m->m_pkthdr.pattr; if (red_addq(rqp->rq_red, rqp->rq_q, m, pktattr) < 0) return ENOBUFS; diff --git a/sys/altq/altq_rio.c b/sys/altq/altq_rio.c index d43c4b9..019dae8 100644 --- a/sys/altq/altq_rio.c +++ b/sys/altq/altq_rio.c @@ -190,7 +190,7 @@ static struct redparams default_rio_params[RIO_NDROPPREC] = { /* internal function prototypes */ static int dscp2index(u_int8_t); #ifdef ALTQ3_COMPAT -static int rio_enqueue(struct ifaltq *, struct mbuf *, struct altq_pktattr *); +static int rio_enqueue(struct ifaltq *, struct mbuf *); static struct mbuf *rio_dequeue(struct ifaltq *, int); static int rio_request(struct ifaltq *, int, void *); static int rio_detach(rio_queue_t *); @@ -763,9 +763,10 @@ rio_request(struct ifaltq *ifq, int req, void *arg) * ENOBUFS when drop occurs. */ static int -rio_enqueue(struct ifaltq *ifq, struct mbuf *m, struct altq_pktattr *pktattr) +rio_enqueue(struct ifaltq *ifq, struct mbuf *m) { rio_queue_t *rqp = (rio_queue_t *)ifq->altq_disc; + struct altq_pktattr *pktattr = &m->m_pkthdr.pattr; int error = 0; if (rio_addq(rqp->rq_rio, rqp->rq_q, m, pktattr) == 0) diff --git a/sys/altq/altq_subr.c b/sys/altq/altq_subr.c index 2d6409b..2bb8bd2 100644 --- a/sys/altq/altq_subr.c +++ b/sys/altq/altq_subr.c @@ -125,7 +125,7 @@ altq_lookup(char *name, int type) int altq_attach(struct ifaltq *ifq, int type, void *discipline, - int (*enqueue)(struct ifaltq *, struct mbuf *, struct altq_pktattr *), + int (*enqueue)(struct ifaltq *, struct mbuf *), struct mbuf *(*dequeue)(struct ifaltq *, int), int (*request)(struct ifaltq *, int, void *), void *clfier, void *(*classify)(void *, struct mbuf *, int)) diff --git a/sys/altq/altq_wfq.c b/sys/altq/altq_wfq.c index 5961144..b0a8752 100644 --- a/sys/altq/altq_wfq.c +++ b/sys/altq/altq_wfq.c @@ -69,8 +69,7 @@ __KERNEL_RCSID(0, "$NetBSD: altq_wfq.c,v 1.20 2014/03/20 20:51:54 christos Exp $ static int wfq_setenable(struct wfq_interface *, int); static int wfq_ifattach(struct wfq_interface *); static int wfq_ifdetach(struct wfq_interface *); -static int wfq_ifenqueue(struct ifaltq *, struct mbuf *, - struct altq_pktattr *); +static int wfq_ifenqueue(struct ifaltq *, struct mbuf *); static u_long wfq_hash(struct flowinfo *, int); static inline u_long wfq_hashbydstaddr(struct flowinfo *, int); static inline u_long wfq_hashbysrcaddr(struct flowinfo *, int); @@ -249,10 +248,11 @@ wfq_classify(void *clfier, struct mbuf *m, int af) } static int -wfq_ifenqueue(struct ifaltq *ifq, struct mbuf *mp, struct altq_pktattr *pktattr) +wfq_ifenqueue(struct ifaltq *ifq, struct mbuf *mp) { wfq_state_t *wfqp; wfq *queue; + struct altq_pktattr *pktattr = &mp->m_pkthdr.pattr; int byte, error = 0; wfqp = (wfq_state_t *)ifq->altq_disc; diff --git a/sys/altq/if_altq.h b/sys/altq/if_altq.h index 0eaac94..887f7a1 100644 --- a/sys/altq/if_altq.h +++ b/sys/altq/if_altq.h @@ -53,8 +53,7 @@ struct ifaltq { void *altq_disc; /* for discipline-specific use */ struct ifnet *altq_ifp; /* back pointer to interface */ - int (*altq_enqueue)(struct ifaltq *, struct mbuf *, - struct altq_pktattr *); + int (*altq_enqueue)(struct ifaltq *, struct mbuf *); struct mbuf *(*altq_dequeue)(struct ifaltq *, int); int (*altq_request)(struct ifaltq *, int, void *); @@ -146,8 +145,8 @@ struct tb_regulator { #define ALTQ_CLEAR_CNDTNING(ifq) ((ifq)->altq_flags &= ~ALTQF_CNDTNING) #define ALTQ_IS_ATTACHED(ifq) ((ifq)->altq_disc != NULL) -#define ALTQ_ENQUEUE(ifq, m, pa, err) \ - (err) = (*(ifq)->altq_enqueue)((ifq),(m),(pa)) +#define ALTQ_ENQUEUE(ifq, m, err) \ + (err) = (*(ifq)->altq_enqueue)((ifq),(m)) #define ALTQ_DEQUEUE(ifq, m) \ (m) = (*(ifq)->altq_dequeue)((ifq), ALTDQ_REMOVE) #define ALTQ_POLL(ifq, m) \ @@ -158,8 +157,7 @@ struct tb_regulator { #define TBR_IS_ENABLED(ifq) ((ifq)->altq_tbr != NULL) extern int altq_attach(struct ifaltq *, int, void *, - int (*)(struct ifaltq *, struct mbuf *, - struct altq_pktattr *), + int (*)(struct ifaltq *, struct mbuf *), struct mbuf *(*)(struct ifaltq *, int), int (*)(struct ifaltq *, int, void *), void *, diff --git a/sys/net/if.h b/sys/net/if.h index d452746..95d0439 100644 --- a/sys/net/if.h +++ b/sys/net/if.h @@ -757,10 +757,9 @@ struct if_addrprefreq { #define IFQ_ENQUEUE(ifq, m, err) \ do { \ IFQ_LOCK((ifq)); \ - if (ALTQ_IS_ENABLED((ifq))) { \ - struct altq_pktattr *pattr = &(m)->m_pkthdr.pattr; \ - ALTQ_ENQUEUE((ifq), (m), pattr, (err)); \ - } else { \ + if (ALTQ_IS_ENABLED((ifq))) \ + ALTQ_ENQUEUE((ifq), (m), (err)); \ + else { \ if (IF_QFULL((ifq))) { \ m_freem((m)); \ (err) = ENOBUFS; \ -- 2.1.0