]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/profiling/profile-mk.c
xnu-3789.21.4.tar.gz
[apple/xnu.git] / osfmk / profiling / profile-mk.c
index 84174f5992cb13c29acfd86e32b59f78018ea87b..43e1376eaaf9147e5a1e5d6532dd890d69d54539 100644 (file)
@@ -1,23 +1,29 @@
 /*
  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
  *
 /*
  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
  *
- * @APPLE_LICENSE_HEADER_START@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * unlawful or unlicensed copies of an Apple operating system, or to
+ * circumvent, violate, or enable the circumvention or violation of, any
+ * terms of an Apple operating system software license agreement.
  * 
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * 
- * @APPLE_LICENSE_HEADER_END@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
  */
 /*
  * @OSF_COPYRIGHT@
  */
 /*
  * @OSF_COPYRIGHT@
 
 extern char etext[], pstart[];
 
 
 extern char etext[], pstart[];
 
-#if NCPUS > 1
-struct profile_vars *_profile_vars_cpus[NCPUS] = { &_profile_vars };
-struct profile_vars _profile_vars_aux[NCPUS-1];
-#endif
-
 void *
 _profile_alloc_pages (size_t size)
 {
 void *
 _profile_alloc_pages (size_t size)
 {
@@ -96,7 +97,6 @@ kmstartup(void)
        prof_uptrint_t monsize;
        prof_uptrint_t lowpc;
        prof_uptrint_t highpc;
        prof_uptrint_t monsize;
        prof_uptrint_t lowpc;
        prof_uptrint_t highpc;
-       int i;
        struct profile_vars *pv;
 
        /*
        struct profile_vars *pv;
 
        /*
@@ -109,48 +109,40 @@ kmstartup(void)
        textsize = highpc - lowpc;
        monsize = (textsize / HISTFRACTION) * sizeof(LHISTCOUNTER);
 
        textsize = highpc - lowpc;
        monsize = (textsize / HISTFRACTION) * sizeof(LHISTCOUNTER);
 
-       for (i = 0; i < NCPUS; i++) {
-               pv = PROFILE_VARS(i);
-
-#if NCPUS > 1
-               if (!pv) {
-                       _profile_vars_cpus[i] = pv = &_profile_vars_aux[i-i];
-               }
-#endif
+       pv = PROFILE_VARS(0);
 
 #ifdef DEBUG_PROFILE
 
 #ifdef DEBUG_PROFILE
-               pv->debug = 1;
+       pv->debug = 1;
 #endif
 #endif
-               pv->page_size = PAGE_SIZE;
-               _profile_md_init(pv, PROFILE_GPROF, PROFILE_ALLOC_MEM_YES);
-
-               /* Profil related variables */
-               pv->profil_buf = _profile_alloc (pv, monsize, ACONTEXT_PROFIL);
-               pv->profil_info.highpc = highpc;
-               pv->profil_info.lowpc = lowpc;
-               pv->profil_info.text_len = textsize;
-               pv->profil_info.profil_len = monsize;
-               pv->profil_info.counter_size = sizeof(LHISTCOUNTER);
-               pv->profil_info.scale = 0x10000 / HISTFRACTION;
-               pv->stats.profil_buckets = monsize / sizeof(LHISTCOUNTER);
-
-               /* Other gprof variables */
-               pv->stats.my_cpu = i;
-               pv->stats.max_cpu = NCPUS;
-               pv->init = 1;
-               pv->active = 1;
-               pv->use_dci = 0;
-               pv->use_profil = 1;
-               pv->check_funcs = 1;            /* for now */
-
-               if (pv->debug) {
-                       printf("Profiling kernel, s_textsize=%ld, monsize=%ld [0x%lx..0x%lx], cpu = %d\n",
-                              (long)textsize,
-                              (long)monsize,
-                              (long)lowpc,
-                              (long)highpc,
-                              i);
-               }
+       pv->page_size = PAGE_SIZE;
+       _profile_md_init(pv, PROFILE_GPROF, PROFILE_ALLOC_MEM_YES);
+
+       /* Profil related variables */
+       pv->profil_buf = _profile_alloc (pv, monsize, ACONTEXT_PROFIL);
+       pv->profil_info.highpc = highpc;
+       pv->profil_info.lowpc = lowpc;
+       pv->profil_info.text_len = textsize;
+       pv->profil_info.profil_len = monsize;
+       pv->profil_info.counter_size = sizeof(LHISTCOUNTER);
+       pv->profil_info.scale = 0x10000 / HISTFRACTION;
+       pv->stats.profil_buckets = monsize / sizeof(LHISTCOUNTER);
+
+       /* Other gprof variables */
+       pv->stats.my_cpu = 0;
+       pv->stats.max_cpu = 1;  /* initial number of cpus */
+       pv->init = 1;
+       pv->active = 1;
+       pv->use_dci = 0;
+       pv->use_profil = 1;
+       pv->check_funcs = 1;            /* for now */
+
+       if (pv->debug) {
+               printf("Profiling kernel, s_textsize=%ld, monsize=%ld [0x%lx..0x%lx], cpu = %d\n",
+                        (long)textsize,
+                       (long)monsize,
+                       (long)lowpc,
+                       (long)highpc,
+                       0);
        }
 
        _profile_md_start();
        }
 
        _profile_md_start();
@@ -201,7 +193,7 @@ gprofstrategy(io_req_t ior)
        long count = _profile_kgmon(!(ior->io_op & IO_READ),
                                    ior->io_count,
                                    ior->io_recnum,
        long count = _profile_kgmon(!(ior->io_op & IO_READ),
                                    ior->io_count,
                                    ior->io_recnum,
-                                   NCPUS,
+                                   1,
                                    &sys_ptr,
                                    (void (*)(kgmon_control_t))0);
 
                                    &sys_ptr,
                                    (void (*)(kgmon_control_t))0);