Print this page
2831 svc.startd and svc.configd waste memory.


   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.

  24  */
  25 
  26 /*
  27  * startd.c - the master restarter
  28  *
  29  * svc.startd comprises two halves.  The graph engine is based in graph.c and
  30  * maintains the service dependency graph based on the information in the
  31  * repository.  For each service it also tracks the current state and the
  32  * restarter responsible for the service.  Based on the graph, events from the
  33  * repository (mostly administrative requests from svcadm), and messages from
  34  * the restarters, the graph engine makes decisions about how the services
  35  * should be manipulated and sends commands to the appropriate restarters.
  36  * Communication between the graph engine and the restarters is embodied in
  37  * protocol.c.
  38  *
  39  * The second half of svc.startd is the restarter for services managed by
  40  * svc.startd and is primarily contained in restarter.c.  It responds to graph
  41  * engine commands by executing methods, updating the repository, and sending
  42  * feedback (mostly state updates) to the graph engine.
  43  *


 126 
 127 const char * const instance_state_str[] = {
 128         "none",
 129         "uninitialized",
 130         "maintenance",
 131         "offline",
 132         "disabled",
 133         "online",
 134         "degraded"
 135 };
 136 
 137 static int finished = 0;
 138 static int opt_reconfig = 0;
 139 static uint8_t prop_reconfig = 0;
 140 
 141 #define INITIAL_REBIND_ATTEMPTS 5
 142 #define INITIAL_REBIND_DELAY    3
 143 
 144 pthread_mutexattr_t mutex_attrs;
 145 

 146 const char *
 147 _umem_debug_init(void)
 148 {
 149         return ("default,verbose");     /* UMEM_DEBUG setting */
 150 }
 151 
 152 const char *
 153 _umem_logging_init(void)
 154 {
 155         return ("fail,contents");       /* UMEM_LOGGING setting */
 156 }

 157 












 158 /*
 159  * startd_alloc_retry()
 160  *   Wrapper for allocation functions.  Retries with a decaying time
 161  *   value on failure to allocate, and aborts startd if failure is
 162  *   persistent.
 163  */
 164 void *
 165 startd_alloc_retry(void *f(size_t, int), size_t sz)
 166 {
 167         void *p;
 168         uint_t try, msecs;
 169 
 170         p = f(sz, UMEM_DEFAULT);
 171         if (p != NULL || sz == 0)
 172                 return (p);
 173 
 174         msecs = ALLOC_DELAY;
 175 
 176         for (try = 0; p == NULL && try < ALLOC_RETRY; ++try) {
 177                 (void) poll(NULL, 0, msecs);




   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright (c) 2012, Joyent, Inc. All rights reserved.
  25  */
  26 
  27 /*
  28  * startd.c - the master restarter
  29  *
  30  * svc.startd comprises two halves.  The graph engine is based in graph.c and
  31  * maintains the service dependency graph based on the information in the
  32  * repository.  For each service it also tracks the current state and the
  33  * restarter responsible for the service.  Based on the graph, events from the
  34  * repository (mostly administrative requests from svcadm), and messages from
  35  * the restarters, the graph engine makes decisions about how the services
  36  * should be manipulated and sends commands to the appropriate restarters.
  37  * Communication between the graph engine and the restarters is embodied in
  38  * protocol.c.
  39  *
  40  * The second half of svc.startd is the restarter for services managed by
  41  * svc.startd and is primarily contained in restarter.c.  It responds to graph
  42  * engine commands by executing methods, updating the repository, and sending
  43  * feedback (mostly state updates) to the graph engine.
  44  *


 127 
 128 const char * const instance_state_str[] = {
 129         "none",
 130         "uninitialized",
 131         "maintenance",
 132         "offline",
 133         "disabled",
 134         "online",
 135         "degraded"
 136 };
 137 
 138 static int finished = 0;
 139 static int opt_reconfig = 0;
 140 static uint8_t prop_reconfig = 0;
 141 
 142 #define INITIAL_REBIND_ATTEMPTS 5
 143 #define INITIAL_REBIND_DELAY    3
 144 
 145 pthread_mutexattr_t mutex_attrs;
 146 
 147 #ifdef DEBUG
 148 const char *
 149 _umem_debug_init(void)
 150 {
 151         return ("default,verbose");     /* UMEM_DEBUG setting */
 152 }
 153 
 154 const char *
 155 _umem_logging_init(void)
 156 {
 157         return ("fail,contents");       /* UMEM_LOGGING setting */
 158 }
 159 #endif
 160 
 161 const char *
 162 _umem_options_init(void)
 163 {
 164         /*
 165          * To reduce our memory footprint, we set our UMEM_OPTIONS to indicate
 166          * that we do not wish to have per-CPU magazines -- if svc.startd is so
 167          * hot on CPU such that this becomes a scalability problem, there are
 168          * likely deeper things amiss...
 169          */
 170         return ("nomagazines");         /* UMEM_OPTIONS setting */
 171 }
 172 
 173 /*
 174  * startd_alloc_retry()
 175  *   Wrapper for allocation functions.  Retries with a decaying time
 176  *   value on failure to allocate, and aborts startd if failure is
 177  *   persistent.
 178  */
 179 void *
 180 startd_alloc_retry(void *f(size_t, int), size_t sz)
 181 {
 182         void *p;
 183         uint_t try, msecs;
 184 
 185         p = f(sz, UMEM_DEFAULT);
 186         if (p != NULL || sz == 0)
 187                 return (p);
 188 
 189         msecs = ALLOC_DELAY;
 190 
 191         for (try = 0; p == NULL && try < ALLOC_RETRY; ++try) {
 192                 (void) poll(NULL, 0, msecs);