Deleted Added
full compact
dtrace.c (192853) dtrace.c (209059)
1/*
2 * CDDL HEADER START
3 *
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

--- 4 unchanged lines hidden (view full) ---

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 *
1/*
2 * CDDL HEADER START
3 *
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

--- 4 unchanged lines hidden (view full) ---

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 * $FreeBSD: head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c 192853 2009-05-26 20:28:22Z sson $
21 * $FreeBSD: head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c 209059 2010-06-11 18:46:34Z jhb $
22 */
23
24/*
25 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
26 * Use is subject to license terms.
27 */
28
29#pragma ident "%Z%%M% %I% %E% SMI"

--- 10548 unchanged lines hidden (view full) ---

10578}
10579
10580static int
10581dtrace_buffer_alloc(dtrace_buffer_t *bufs, size_t size, int flags,
10582 processorid_t cpu)
10583{
10584#if defined(sun)
10585 cpu_t *cp;
22 */
23
24/*
25 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
26 * Use is subject to license terms.
27 */
28
29#pragma ident "%Z%%M% %I% %E% SMI"

--- 10548 unchanged lines hidden (view full) ---

10578}
10579
10580static int
10581dtrace_buffer_alloc(dtrace_buffer_t *bufs, size_t size, int flags,
10582 processorid_t cpu)
10583{
10584#if defined(sun)
10585 cpu_t *cp;
10586#else
10587 struct pcpu *cp;
10588#endif
10589 dtrace_buffer_t *buf;
10590
10591#if defined(sun)
10592 ASSERT(MUTEX_HELD(&cpu_lock));
10593 ASSERT(MUTEX_HELD(&dtrace_lock));
10594
10595 if (size > dtrace_nonroot_maxsize &&

--- 71 unchanged lines hidden (view full) ---

10667 * ask to malloc, so let's place a limit here before trying
10668 * to do something that might well end in tears at bedtime.
10669 */
10670 if (size > physmem * PAGE_SIZE / (128 * (mp_maxid + 1)))
10671 return(ENOMEM);
10672#endif
10673
10674 ASSERT(MUTEX_HELD(&dtrace_lock));
10586#endif
10587 dtrace_buffer_t *buf;
10588
10589#if defined(sun)
10590 ASSERT(MUTEX_HELD(&cpu_lock));
10591 ASSERT(MUTEX_HELD(&dtrace_lock));
10592
10593 if (size > dtrace_nonroot_maxsize &&

--- 71 unchanged lines hidden (view full) ---

10665 * ask to malloc, so let's place a limit here before trying
10666 * to do something that might well end in tears at bedtime.
10667 */
10668 if (size > physmem * PAGE_SIZE / (128 * (mp_maxid + 1)))
10669 return(ENOMEM);
10670#endif
10671
10672 ASSERT(MUTEX_HELD(&dtrace_lock));
10675 for (i = 0; i <= mp_maxid; i++) {
10676 if ((cp = pcpu_find(i)) == NULL)
10677 continue;
10678
10673 CPU_FOREACH(i) {
10679 if (cpu != DTRACE_CPUALL && cpu != i)
10680 continue;
10681
10682 buf = &bufs[i];
10683
10684 /*
10685 * If there is already a buffer allocated for this CPU, it
10686 * is only possible that this is a DR event. In this case,

--- 23 unchanged lines hidden (view full) ---

10710
10711 return (0);
10712
10713err:
10714 /*
10715 * Error allocating memory, so free the buffers that were
10716 * allocated before the failed allocation.
10717 */
10674 if (cpu != DTRACE_CPUALL && cpu != i)
10675 continue;
10676
10677 buf = &bufs[i];
10678
10679 /*
10680 * If there is already a buffer allocated for this CPU, it
10681 * is only possible that this is a DR event. In this case,

--- 23 unchanged lines hidden (view full) ---

10705
10706 return (0);
10707
10708err:
10709 /*
10710 * Error allocating memory, so free the buffers that were
10711 * allocated before the failed allocation.
10712 */
10718 for (i = 0; i <= mp_maxid; i++) {
10719 if ((cp = pcpu_find(i)) == NULL)
10720 continue;
10721
10713 CPU_FOREACH(i) {
10722 if (cpu != DTRACE_CPUALL && cpu != i)
10723 continue;
10724
10725 buf = &bufs[i];
10726
10727 if (buf->dtb_xamot != NULL) {
10728 ASSERT(buf->dtb_tomax != NULL);
10729 ASSERT(buf->dtb_size == size);

--- 1886 unchanged lines hidden (view full) ---

12616 */
12617 start = (dtrace_dynvar_t *)
12618 ((uintptr_t)base + hashsize * sizeof (dtrace_dynhash_t));
12619 limit = (uintptr_t)base + size;
12620
12621 maxper = (limit - (uintptr_t)start) / NCPU;
12622 maxper = (maxper / dstate->dtds_chunksize) * dstate->dtds_chunksize;
12623
10714 if (cpu != DTRACE_CPUALL && cpu != i)
10715 continue;
10716
10717 buf = &bufs[i];
10718
10719 if (buf->dtb_xamot != NULL) {
10720 ASSERT(buf->dtb_tomax != NULL);
10721 ASSERT(buf->dtb_size == size);

--- 1886 unchanged lines hidden (view full) ---

12608 */
12609 start = (dtrace_dynvar_t *)
12610 ((uintptr_t)base + hashsize * sizeof (dtrace_dynhash_t));
12611 limit = (uintptr_t)base + size;
12612
12613 maxper = (limit - (uintptr_t)start) / NCPU;
12614 maxper = (maxper / dstate->dtds_chunksize) * dstate->dtds_chunksize;
12615
12624 for (i = 0; i < NCPU; i++) {
12625#if !defined(sun)
12616#if !defined(sun)
12626 if (CPU_ABSENT(i))
12627 continue;
12617 CPU_FOREACH(i) {
12618#else
12619 for (i = 0; i < NCPU; i++) {
12628#endif
12629 dstate->dtds_percpu[i].dtdsc_free = dvar = start;
12630
12631 /*
12632 * If we don't even have enough chunks to make it once through
12633 * NCPUs, we're just going to allocate everything to the first
12634 * CPU. And if we're on the last CPU, we're going to allocate
12635 * whatever is left over. In either case, we set the limit to

--- 3885 unchanged lines hidden ---
12620#endif
12621 dstate->dtds_percpu[i].dtdsc_free = dvar = start;
12622
12623 /*
12624 * If we don't even have enough chunks to make it once through
12625 * NCPUs, we're just going to allocate everything to the first
12626 * CPU. And if we're on the last CPU, we're going to allocate
12627 * whatever is left over. In either case, we set the limit to

--- 3885 unchanged lines hidden ---