From owner-svn-src-all@FreeBSD.ORG Tue Sep 18 12:34:36 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 607DC106566B; Tue, 18 Sep 2012 12:34:36 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4B6B48FC16; Tue, 18 Sep 2012 12:34:36 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q8ICYa9A091113; Tue, 18 Sep 2012 12:34:36 GMT (envelope-from glebius@svn.freebsd.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q8ICYaFB091109; Tue, 18 Sep 2012 12:34:36 GMT (envelope-from glebius@svn.freebsd.org) Message-Id: <201209181234.q8ICYaFB091109@svn.freebsd.org> From: Gleb Smirnoff Date: Tue, 18 Sep 2012 12:34:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r240646 - head/sys/contrib/altq/altq X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Sep 2012 12:34:36 -0000 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.