[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[altq 1493] Re: Another source of HFSC-ALTQ unfairness




Oleg Cherevko wrote:
> > >    If so, is it safe to call MALLOC() with M_WAITOK in between?
> > 
> > As itojun said, no.  It's my mistake.  MALLOC() should be taken out of
> > the spl block.
> 
> Would you provide patch for this issue?

Attached.

-Kenjiro

Index: altq_hfsc.c
===================================================================
RCS file: /cvsroot/kame/kame/kame/sys/altq/altq_hfsc.c,v
retrieving revision 1.12
diff -u -r1.12 altq_hfsc.c
--- altq_hfsc.c	2002/05/08 05:41:36	1.12
+++ altq_hfsc.c	2002/05/15 03:20:10
@@ -481,9 +481,24 @@
 	struct hfsc_class *cl;
 	struct service_curve *rsc, *fsc;
 {
-	struct internal_sc *tmp;
+	struct internal_sc *rsc_tmp, *fsc_tmp;
 	int s;
 
+	if (rsc != NULL && (rsc->m1 != 0 || rsc->m2 != 0) &&
+	    cl->cl_rsc == NULL) {
+		MALLOC(rsc_tmp, struct internal_sc *,
+		       sizeof(struct internal_sc), M_DEVBUF, M_WAITOK);
+		if (rsc_tmp == NULL)
+			return (ENOMEM);
+	}
+	if (fsc != NULL && (fsc->m1 != 0 || fsc->m2 != 0) &&
+	    cl->cl_fsc == NULL) {
+		MALLOC(fsc_tmp, struct internal_sc *,
+		       sizeof(struct internal_sc), M_DEVBUF, M_WAITOK);
+		if (fsc_tmp == NULL)
+			return (ENOMEM);
+	}
+
 	s = splimp();
 	if (!qempty(cl->cl_q))
 		hfsc_purgeq(cl);
@@ -495,16 +510,8 @@
 				cl->cl_rsc = NULL;
 			}
 		} else {
-			if (cl->cl_rsc == NULL) {
-				MALLOC(tmp, struct internal_sc *,
-				       sizeof(struct internal_sc),
-				       M_DEVBUF, M_WAITOK);
-				if (tmp == NULL) {
-					splx(s);
-					return (ENOMEM);
-				}
-				cl->cl_rsc = tmp;
-			}
+			if (cl->cl_rsc == NULL)
+				cl->cl_rsc = rsc_tmp;
 			bzero(cl->cl_rsc, sizeof(struct internal_sc));
 			sc2isc(rsc, cl->cl_rsc);
 			rtsc_init(&cl->cl_deadline, cl->cl_rsc, 0, 0);
@@ -519,16 +526,8 @@
 				cl->cl_fsc = NULL;
 			}
 		} else {
-			if (cl->cl_fsc == NULL) {
-				MALLOC(tmp, struct internal_sc *,
-				       sizeof(struct internal_sc),
-				       M_DEVBUF, M_WAITOK);
-				if (tmp == NULL) {
-					splx(s);
-					return (ENOMEM);
-				}
-				cl->cl_fsc = tmp;
-			}
+			if (cl->cl_fsc == NULL)
+				cl->cl_fsc = fsc_tmp;
 			bzero(cl->cl_fsc, sizeof(struct internal_sc));
 			sc2isc(fsc, cl->cl_fsc);
 			rtsc_init(&cl->cl_virtual, cl->cl_fsc, 0, 0);