Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 Sep 2012 12:34:36 +0000 (UTC)
From:      Gleb Smirnoff <glebius@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r240646 - head/sys/contrib/altq/altq
Message-ID:  <201209181234.q8ICYaFB091109@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: glebius
Date: Tue Sep 18 12:34:35 2012
New Revision: 240646
URL: http://svn.freebsd.org/changeset/base/240646

Log:
  Do more than r236298 did in the projects/pf branch: use M_NOWAIT in
  altq_add() and its descendants. Currently altq(4) in FreeBSD is configured
  via pf(4) ioctls, which can't configure altq(4) w/o holding locks.
  Fortunately, altq(4) code in spife of using M_WAITOK is ready to receive
  NULL from malloc(9), so change is mostly mechanical. While here, utilize
  M_ZERO instead of bzero().
  
  A large redesign needed to achieve M_WAITOK usage when configuring altq(4).
  Or an alternative (not pf(4)) configuration interface should be implemented.
  
  Reported by:	pluknet

Modified:
  head/sys/contrib/altq/altq/altq_hfsc.c
  head/sys/contrib/altq/altq/altq_priq.c
  head/sys/contrib/altq/altq/altq_rmclass.c

Modified: head/sys/contrib/altq/altq/altq_hfsc.c
==============================================================================
--- head/sys/contrib/altq/altq/altq_hfsc.c	Tue Sep 18 12:25:14 2012	(r240645)
+++ head/sys/contrib/altq/altq/altq_hfsc.c	Tue Sep 18 12:34:35 2012	(r240646)
@@ -400,15 +400,13 @@ hfsc_class_create(struct hfsc_if *hif, s
 	}
 #endif
 
-	cl = malloc(sizeof(struct hfsc_class), M_DEVBUF, M_WAITOK);
+	cl = malloc(sizeof(struct hfsc_class), M_DEVBUF, M_NOWAIT | M_ZERO);
 	if (cl == NULL)
 		return (NULL);
-	bzero(cl, sizeof(struct hfsc_class));
 
-	cl->cl_q = malloc(sizeof(class_queue_t), M_DEVBUF, M_WAITOK);
+	cl->cl_q = malloc(sizeof(class_queue_t), M_DEVBUF, M_NOWAIT | M_ZERO);
 	if (cl->cl_q == NULL)
 		goto err_ret;
-	bzero(cl->cl_q, sizeof(class_queue_t));
 
 	cl->cl_actc = actlist_alloc();
 	if (cl->cl_actc == NULL)
@@ -466,7 +464,7 @@ hfsc_class_create(struct hfsc_if *hif, s
 
 	if (rsc != NULL && (rsc->m1 != 0 || rsc->m2 != 0)) {
 		cl->cl_rsc = malloc(sizeof(struct internal_sc),
-		    M_DEVBUF, M_WAITOK);
+		    M_DEVBUF, M_NOWAIT);
 		if (cl->cl_rsc == NULL)
 			goto err_ret;
 		sc2isc(rsc, cl->cl_rsc);
@@ -475,7 +473,7 @@ hfsc_class_create(struct hfsc_if *hif, s
 	}
 	if (fsc != NULL && (fsc->m1 != 0 || fsc->m2 != 0)) {
 		cl->cl_fsc = malloc(sizeof(struct internal_sc),
-		    M_DEVBUF, M_WAITOK);
+		    M_DEVBUF, M_NOWAIT);
 		if (cl->cl_fsc == NULL)
 			goto err_ret;
 		sc2isc(fsc, cl->cl_fsc);
@@ -483,7 +481,7 @@ hfsc_class_create(struct hfsc_if *hif, s
 	}
 	if (usc != NULL && (usc->m1 != 0 || usc->m2 != 0)) {
 		cl->cl_usc = malloc(sizeof(struct internal_sc),
-		    M_DEVBUF, M_WAITOK);
+		    M_DEVBUF, M_NOWAIT);
 		if (cl->cl_usc == NULL)
 			goto err_ret;
 		sc2isc(usc, cl->cl_usc);

Modified: head/sys/contrib/altq/altq/altq_priq.c
==============================================================================
--- head/sys/contrib/altq/altq/altq_priq.c	Tue Sep 18 12:25:14 2012	(r240645)
+++ head/sys/contrib/altq/altq/altq_priq.c	Tue Sep 18 12:34:35 2012	(r240646)
@@ -316,17 +316,15 @@ priq_class_create(struct priq_if *pif, i
 			red_destroy(cl->cl_red);
 #endif
 	} else {
-		cl = malloc(sizeof(struct priq_class),
-		       M_DEVBUF, M_WAITOK);
+		cl = malloc(sizeof(struct priq_class), M_DEVBUF,
+		    M_NOWAIT | M_ZERO);
 		if (cl == NULL)
 			return (NULL);
-		bzero(cl, sizeof(struct priq_class));
 
-		cl->cl_q = malloc(sizeof(class_queue_t),
-		       M_DEVBUF, M_WAITOK);
+		cl->cl_q = malloc(sizeof(class_queue_t), M_DEVBUF,
+		    M_NOWAIT | M_ZERO);
 		if (cl->cl_q == NULL)
 			goto err_ret;
-		bzero(cl->cl_q, sizeof(class_queue_t));
 	}
 
 	pif->pif_classes[pri] = cl;

Modified: head/sys/contrib/altq/altq/altq_rmclass.c
==============================================================================
--- head/sys/contrib/altq/altq/altq_rmclass.c	Tue Sep 18 12:25:14 2012	(r240645)
+++ head/sys/contrib/altq/altq/altq_rmclass.c	Tue Sep 18 12:34:35 2012	(r240646)
@@ -218,19 +218,15 @@ rmc_newclass(int pri, struct rm_ifdat *i
 	}
 #endif
 
-	cl = malloc(sizeof(struct rm_class),
-	       M_DEVBUF, M_WAITOK);
+	cl = malloc(sizeof(struct rm_class), M_DEVBUF, M_NOWAIT | M_ZERO);
 	if (cl == NULL)
 		return (NULL);
-	bzero(cl, sizeof(struct rm_class));
 	CALLOUT_INIT(&cl->callout_);
-	cl->q_ = malloc(sizeof(class_queue_t),
-	       M_DEVBUF, M_WAITOK);
+	cl->q_ = malloc(sizeof(class_queue_t), M_DEVBUF, M_NOWAIT | M_ZERO);
 	if (cl->q_ == NULL) {
 		free(cl, M_DEVBUF);
 		return (NULL);
 	}
-	bzero(cl->q_, sizeof(class_queue_t));
 
 	/*
 	 * Class initialization.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201209181234.q8ICYaFB091109>