From owner-p4-projects@FreeBSD.ORG Tue Nov 11 20:32:52 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 70A5E16A4D0; Tue, 11 Nov 2003 20:32:52 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4C0C116A4CE for ; Tue, 11 Nov 2003 20:32:52 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 926D543FE5 for ; Tue, 11 Nov 2003 20:32:51 -0800 (PST) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.9/8.12.9) with ESMTP id hAC4WpXJ036922 for ; Tue, 11 Nov 2003 20:32:51 -0800 (PST) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.9/8.12.9/Submit) id hAC4WpNl036919 for perforce@freebsd.org; Tue, 11 Nov 2003 20:32:51 -0800 (PST) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Tue, 11 Nov 2003 20:32:51 -0800 (PST) Message-Id: <200311120432.hAC4WpNl036919@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson To: Perforce Change Reviews Subject: PERFORCE change 42098 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Nov 2003 04:32:52 -0000 http://perforce.freebsd.org/chv.cgi?CH=42098 Change 42098 by rwatson@rwatson_tislabs on 2003/11/11 20:32:06 Switch Biba and MLS to using UMA zones to allocate labels from, rather than malloc(), which should give more efficient use of memory. Affected files ... .. //depot/projects/trustedbsd/mac/sys/security/mac_biba/mac_biba.c#231 edit .. //depot/projects/trustedbsd/mac/sys/security/mac_mls/mac_mls.c#186 edit Differences ... ==== //depot/projects/trustedbsd/mac/sys/security/mac_biba/mac_biba.c#231 (text+ko) ==== @@ -77,6 +77,7 @@ #include #include +#include #include #include @@ -130,7 +131,7 @@ static int mac_biba_slot; #define SLOT(l) ((struct mac_biba *)LABEL_TO_SLOT((l), mac_biba_slot).l_ptr) -MALLOC_DEFINE(M_MACBIBA, "biba label", "MAC/Biba labels"); +static uma_zone_t zone_biba; static __inline int biba_bit_set_empty(u_char *set) { @@ -145,11 +146,8 @@ static struct mac_biba * biba_alloc(int flag) { - struct mac_biba *mac_biba; - mac_biba = malloc(sizeof(struct mac_biba), M_MACBIBA, M_ZERO | flag); - - return (mac_biba); + return (uma_zalloc(zone_biba, flag)); } static void @@ -157,7 +155,7 @@ { if (mac_biba != NULL) - free(mac_biba, M_MACBIBA); + uma_zfree(zone_biba, mac_biba); else atomic_add_int(&destroyed_not_inited, 1); } @@ -498,6 +496,8 @@ mac_biba_init(struct mac_policy_conf *conf) { + zone_biba = uma_zcreate("mac_biba", sizeof(struct mac_biba), NULL, + NULL, NULL, NULL, UMA_ALIGN_PTR, M_ZERO); } /* ==== //depot/projects/trustedbsd/mac/sys/security/mac_mls/mac_mls.c#186 (text+ko) ==== @@ -77,6 +77,7 @@ #include #include +#include #include #include @@ -118,7 +119,7 @@ static int mac_mls_slot; #define SLOT(l) ((struct mac_mls *)LABEL_TO_SLOT((l), mac_mls_slot).l_ptr) -MALLOC_DEFINE(M_MACMLS, "mls label", "MAC/MLS labels"); +static uma_zone_t zone_mls; static __inline int mls_bit_set_empty(u_char *set) { @@ -133,11 +134,8 @@ static struct mac_mls * mls_alloc(int flag) { - struct mac_mls *mac_mls; - mac_mls = malloc(sizeof(struct mac_mls), M_MACMLS, M_ZERO | flag); - - return (mac_mls); + return (uma_zalloc(zone_mls, flag)); } static void @@ -145,7 +143,7 @@ { if (mac_mls != NULL) - free(mac_mls, M_MACMLS); + uma_zfree(zone_mls, mac_mls); else atomic_add_int(&destroyed_not_inited, 1); } @@ -463,6 +461,8 @@ mac_mls_init(struct mac_policy_conf *conf) { + zone_mls = uma_zcreate("mac_mls", sizeof(struct mac_mls), NULL, + NULL, NULL, NULL, UMA_ALIGN_PTR, M_ZERO); } /*