rcapd_collection.c revision 0209230bf1261579beab4f55226bb509e6b850cb
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include "rcapd.h"
#include "utils.h"
/*
* An abstract "collection" of processes. Multiple types of collections can
* exist, one of which is selected at run-time. Currently, the only one
* defined corresponds to project(4)s.
*/
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
typedef struct {
extern void lcollection_update_project(lcollection_update_type_t,
void(*)(char *, char *, int, uint64_t, int));
extern void lcollection_update_zone(lcollection_update_type_t,
void(*)(char *, char *, int, uint64_t, int));
static void lcollection_update_notification_cb(char *, char *, int, uint64_t,
int);
uint64_t phys_total = 0;
void
{
}
/*
* Inserts a collection with the supplied identity, or updates the caps of an
* existing one. The return value will have these bits set, depending on the
* previous and new cap values. If no cap was displaced, and the requested cap
* is 0, no collection will be added, and the applicable *ZERO flags will be
* set.
*
* LCST_CAP_CHANGED
* LCST_CAP_REMOVED
* LCSS_CAP_ZERO
*/
int *changes)
{
*changes = 0;
if (rss_cap == 0)
*changes |= LCST_CAP_ZERO;
/*
* If the specified collection is capped, add it to lcollection.
*/
/*
* If the cap has been zeroed and the collection doesn't exist,
* don't create the collection just to remvoe the cap later.
*/
if (rss_cap == 0)
return (NULL);
*changes |= LCST_CAP_CHANGED;
debug("not enough memory to monitor %s %s",
return (NULL);
}
if (lcollection_head != NULL)
}
/*
*/
/*
* Set cap flags.
*/
*changes |= LCST_CAP_CHANGED;
if (lcol->lcol_rss_cap == 0)
*changes |= LCST_CAP_REMOVED;
}
if (rss_cap > 0)
return (lcol);
}
static void
{
/*
* Assume the collection has been updated redundantly if its mark count
* exceeds 1, and that another notification is unnecessary.
*/
if (mark > 1)
return;
if (changes & LCST_CAP_ZERO)
else
(unsigned long long)rss_cap);
}
/*
* Function to walk list of collections and invoke the specified callback with
* the specified argument. Callbacks are allowed to change the linkage of the
* collection on which they act.
*/
void
{
return;
}
}
/*
* Returns a nonzero value if an lprocess_t is still a valid member of a given
* collection.
*/
int
{
return (1);
else
return (0);
}
static int
{
return (1);
}
return (0);
}
{
}
/*
* Unlinks a collection from lcollection.
*/
void
{
}
/*
* Unlink the collection.
*/
if (lcollection_head == lcol)
}