From owner-p4-projects@FreeBSD.ORG Mon Jul 12 18:26:29 2010 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 5E7DF1065675; Mon, 12 Jul 2010 18:26:29 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 232F51065670 for ; Mon, 12 Jul 2010 18:26:29 +0000 (UTC) (envelope-from trasz@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id EC2E48FC17 for ; Mon, 12 Jul 2010 18:26:28 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id o6CIQSR5080926 for ; Mon, 12 Jul 2010 18:26:28 GMT (envelope-from trasz@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id o6CIQS59080924 for perforce@freebsd.org; Mon, 12 Jul 2010 18:26:28 GMT (envelope-from trasz@freebsd.org) Date: Mon, 12 Jul 2010 18:26:28 GMT Message-Id: <201007121826.o6CIQS59080924@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to trasz@freebsd.org using -f From: Edward Tomasz Napierala To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 180840 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Jul 2010 18:26:29 -0000 http://p4web.freebsd.org/@@180840?ac=10 Change 180840 by trasz@trasz_victim on 2010/07/12 18:26:00 Remove unfinished optimisation that had no chance of working. Affected files ... .. //depot/projects/soc2009/trasz_limits/sys/kern/kern_hrl.c#85 edit Differences ... ==== //depot/projects/soc2009/trasz_limits/sys/kern/kern_hrl.c#85 (text+ko) ==== @@ -126,7 +126,6 @@ static struct mtx hrl_lock; MTX_SYSINIT(hrl_lock, &hrl_lock, "HRL lock", MTX_DEF); -static void hrl_compute_available(struct proc *p, int64_t (*availablep)[]); static int hrl_rule_fully_specified(const struct hrl_rule *rule); static void hrl_rule_to_sbuf(struct sbuf *sb, const struct hrl_rule *rule); @@ -267,7 +266,6 @@ int hrl_enforce_proc(struct proc *p, int resource, uint64_t amount) { - int64_t available[RUSAGE_MAX]; struct hrl_rule *rule; struct hrl_rule_link *link; struct sbuf sb; @@ -277,16 +275,6 @@ mtx_lock(&hrl_lock); /* - * XXX: Do this just before we start running on a CPU, not all the time. - */ - hrl_compute_available(p, &available); - - if (available[resource] >= amount) { - mtx_unlock(&hrl_lock); - return (0); - } - - /* * It seems we've hit a limit. Figure out what to do. There may * be more than one matching limit; go through all of them. Denial * should be done last, after logging and sending signals. @@ -363,39 +351,6 @@ return (0); } -/* - * Go through all the rules applicable to the process, filling the array - * with amount of resource left before hitting the next limit. - */ -static void -hrl_compute_available(struct proc *p, int64_t (*availablep)[]) -{ - int i, resource; - int64_t available; - struct hrl_rule_link *link; - struct hrl_rule *rule; - - mtx_assert(&hrl_lock, MA_OWNED); - - for (i = 0; i <= RUSAGE_MAX; i++) - (*availablep)[i] = INT64_MAX; - - LIST_FOREACH(link, &p->p_container.c_rule_links, hrl_next) { - rule = link->hrl_rule; - resource = rule->hr_resource; - available = hrl_available_resource(p, rule); - if (available < 0) { -#ifdef notyet - KASSERT(rule->hr_action != HRL_ACTION_DENY, - ("hrl_compute_available: deny rule already exceeded")); -#endif - continue; - } - if (available < (*availablep)[resource]) - (*availablep)[resource] = available; - } -} - static int hrl_rule_matches(const struct hrl_rule *rule, const struct hrl_rule *filter) {