Re: NUMA, cpuset and malloc

2013-04-22 Thread John Baldwin
On Saturday, April 20, 2013 6:43:26 pm Robert Waksmundzki wrote: On NUMA systems allocated memory is striped across local and non-local banks in order to have consistent performance in case the task is rescheduled to a different CPU socket. When a process is pinned to a single CPU socket with

Re: NUMA, cpuset and malloc

2013-04-22 Thread Freddie Cash
On Mon, Apr 22, 2013 at 8:32 AM, John Baldwin j...@freebsd.org wrote: On Saturday, April 20, 2013 6:43:26 pm Robert Waksmundzki wrote: On NUMA systems allocated memory is striped across local and non-local banks in order to have consistent performance in case the task is rescheduled to a

Re: NUMA, cpuset and malloc

2013-04-22 Thread John Baldwin
On Monday, April 22, 2013 12:29:29 pm Freddie Cash wrote: On Mon, Apr 22, 2013 at 8:32 AM, John Baldwin j...@freebsd.org wrote: On Saturday, April 20, 2013 6:43:26 pm Robert Waksmundzki wrote: On NUMA systems allocated memory is striped across local and non-local banks in order to have

Re: NUMA, cpuset and malloc

2013-04-21 Thread David Xu
On 2013/04/21 06:43, Robert Waksmundzki wrote: On NUMA systems allocated memory is striped across local and non-local banks in order to have consistent performance in case the task is rescheduled to a different CPU socket. When a process is pinned to a single CPU socket with cpuset having the

NUMA, cpuset and malloc

2013-04-20 Thread Robert Waksmundzki
On NUMA systems allocated memory is striped across local and non-local banks in order to have consistent performance in case the task is rescheduled to a different CPU socket. When a process is pinned to a single CPU socket with cpuset having the memory allocator prefer local banks would

Re: malloc+utrace, tracking memory leaks in a running program.

2013-01-10 Thread Alfred Perlstein
/13e7228d5b83c8fcfc63a0803a374212018f6b68~1...utrace2 Why do you need to expedite the records through the ktrace at all ? Wouldn't direct write(2)s to a file allow for better performance due to not stressing kernel memory allocator and single writing thread ? Also, the malloc coupling to the single-system interface

Re: malloc+utrace, tracking memory leaks in a running program.

2013-01-10 Thread Konstantin Belousov
and single writing thread ? Also, the malloc coupling to the single-system interface would be prevented. I believe that other usermode tracers also behave in the similar way, using writes and not private kernel interface. Also, what /proc issues did you mentioned ? There is sysctl

Re: malloc+utrace, tracking memory leaks in a running program.

2013-01-10 Thread Alfred Perlstein
to not stressing kernel memory allocator and single writing thread ? Also, the malloc coupling to the single-system interface would be prevented. I believe that other usermode tracers also behave in the similar way, using writes and not private kernel interface. Also, what /proc issues did you mentioned

Re: malloc+utrace, tracking memory leaks in a running program.

2013-01-10 Thread Konstantin Belousov
? Wouldn't direct write(2)s to a file allow for better performance due to not stressing kernel memory allocator and single writing thread ? Also, the malloc coupling to the single-system interface would be prevented. I believe that other usermode tracers also behave in the similar way

Re: malloc+utrace, tracking memory leaks in a running program.

2013-01-09 Thread Alfred Perlstein
On 12/23/12 12:28 PM, Jason Evans wrote: On Dec 21, 2012, at 7:37 PM, Alfred Perlstein bri...@mu.org wrote: So the other day in an effort to debug a memory leak I decided to take a look at malloc+utrace(2) and decided to make a tool to debug where leaks are coming from. A few hours later I

Re: malloc+utrace, tracking memory leaks in a running program.

2013-01-09 Thread Alfred Perlstein
On 1/10/13 1:41 AM, Alfred Perlstein wrote: On 12/23/12 12:28 PM, Jason Evans wrote: On Dec 21, 2012, at 7:37 PM, Alfred Perlstein bri...@mu.org wrote: So the other day in an effort to debug a memory leak I decided to take a look at malloc+utrace(2) and decided to make a tool to debug where

Re: malloc+utrace, tracking memory leaks in a running program.

2013-01-09 Thread Konstantin Belousov
you need to expedite the records through the ktrace at all ? Wouldn't direct write(2)s to a file allow for better performance due to not stressing kernel memory allocator and single writing thread ? Also, the malloc coupling to the single-system interface would be prevented. I believe that other

Re: malloc+utrace, tracking memory leaks in a running program.

2012-12-23 Thread Jason Evans
On Dec 21, 2012, at 7:37 PM, Alfred Perlstein bri...@mu.org wrote: So the other day in an effort to debug a memory leak I decided to take a look at malloc+utrace(2) and decided to make a tool to debug where leaks are coming from. A few hours later I have: 1) a new version of utrace(2

Re: malloc+utrace, tracking memory leaks in a running program.

2012-12-23 Thread Alfred Perlstein
On 12/23/12 9:28 AM, Jason Evans wrote: On Dec 21, 2012, at 7:37 PM, Alfred Perlstein bri...@mu.org wrote: So the other day in an effort to debug a memory leak I decided to take a look at malloc+utrace(2) and decided to make a tool to debug where leaks are coming from. A few hours later I

Re: malloc+utrace, tracking memory leaks in a running program.

2012-12-22 Thread Ed Maste
On 21 December 2012 22:37, Alfred Perlstein bri...@mu.org wrote: Is it time to start installing with some form of debug symbols? This would help us also with dtrace. I just posted a patch to add a knob to build and install standalone debug files. My intent is that we will build releases with

Re: malloc+utrace, tracking memory leaks in a running program.

2012-12-22 Thread Alfred Perlstein
On 12/22/12 8:56 AM, Ed Maste wrote: On 21 December 2012 22:37, Alfred Perlstein bri...@mu.org wrote: Is it time to start installing with some form of debug symbols? This would help us also with dtrace. I just posted a patch to add a knob to build and install standalone debug files. My

malloc+utrace, tracking memory leaks in a running program.

2012-12-21 Thread Alfred Perlstein
Hey guys. So the other day in an effort to debug a memory leak I decided to take a look at malloc+utrace(2) and decided to make a tool to debug where leaks are coming from. A few hours later I have: 1) a new version of utrace(2) (utrace2(2)) that uses structured data to prevent overloading

Re: malloc pages map to user space

2012-03-23 Thread John Baldwin
On Thursday, March 22, 2012 3:57:11 pm Eric Saint-Etienne wrote: If your kernel module creates a device in /dev that implements the mmap method, then you don't need to worry about mucking around with vm_maps and objects and whatnot. Your mmap method just needs to be able to convert

Re: BUG: REL 9.0 - MD malloc of custom sector size

2012-03-23 Thread rank1seeker
- Original Message - From: Benjamin Kaduk ka...@mit.edu To: rank1see...@gmail.com Cc: hack...@freebsd.org Date: Tue, 20 Mar 2012 23:42:44 -0400 (EDT) Subject: Re: BUG: REL 9.0 - MD malloc of custom sector size On Tue, 20 Mar 2012, rank1see...@gmail.com wrote: - Original Message

Re: malloc pages map to user space

2012-03-22 Thread Eric Saint-Etienne
I've refined the behaviour I observe, which isn't consistent depending on the size one mallocates. (see interleaved comments) In my driver, I need to map some malloc-ed memory, obtained from another module, into userspace. The problem: on the smaller mallocs, as well as on some bigeer ones

Re: malloc pages map to user space

2012-03-22 Thread John Baldwin
On Wednesday, March 21, 2012 7:27:58 pm Eric Saint-Etienne wrote: Hi, From within the freeBSD kernel, not all malloc are made equal: * malloc() smaller than KMEM_ZMAX (set to one page size) end up in UMA SLABs, themselves laid out in powers of 2 (from 16 bytes, 32... to 4096 bytes

Re: malloc pages map to user space

2012-03-22 Thread Eric Saint-Etienne
By using kernel_map instead of kmem_map, vm_map_lookup() now always return a vm_object. That's a big progress. As expected, when this object is kmem_object, the user mapping works fine (for smaller or larger mallocs.) Otherwise that object doesn't match kernel_object. It's an anonymous

Re: malloc pages map to user space

2012-03-22 Thread Ryan Stone
On Thu, Mar 22, 2012 at 10:42 AM, Eric Saint-Etienne eric.saintetie...@gmail.com wrote: Actually when using kernel_map, the object returned is NULL! However the the vm_entry_t it returns seems a valid address, its 'object' field is NULL too (that's consistent) That's the reason why I didn't

Re: malloc pages map to user space

2012-03-22 Thread Eric Saint-Etienne
If your kernel module creates a device in /dev that implements the mmap method, then you don't need to worry about mucking around with vm_maps and objects and whatnot.  Your mmap method just needs to be able to convert offsets into the device into physical memory addresses, Yes I'm aware of

Re: malloc pages map to user space

2012-03-22 Thread Eric Saint-Etienne
Here is some code which fails with malloc 1 page and sometimes succeeds with large mallocs ( 16 pages) What's wrong? #include sys/param.h #include sys/proc.h #include sys/conf.h #include sys/module.h #include sys/sysent.h #include sys/kernel.h #include sys/systm.h #include sys/sysproto.h

malloc pages map to user space

2012-03-21 Thread Eric Saint-Etienne
Hi, From within the freeBSD kernel, not all malloc are made equal: * malloc() smaller than KMEM_ZMAX (set to one page size) end up in UMA SLABs, themselves laid out in powers of 2 (from 16 bytes, 32... to 4096 bytes) * bigger malloc() are done through uma_large_malloc() which uses

Re: BUG: REL 9.0 - MD malloc of custom sector size

2012-03-20 Thread rank1seeker
- Original Message - From: RW rwmailli...@googlemail.com To: freebsd-hackers@freebsd.org Date: Sun, 18 Mar 2012 13:41:56 + Subject: Re: BUG: REL 9.0 - MD malloc of custom sector size On Sun, 18 Mar 2012 14:01:39 +0100 rank1see...@gmail.com wrote: man mdconfig -S

Re: BUG: REL 9.0 - MD malloc of custom sector size

2012-03-20 Thread Benjamin Kaduk
On Tue, 20 Mar 2012, rank1see...@gmail.com wrote: - Original Message - From: RW rwmailli...@googlemail.com To: freebsd-hackers@freebsd.org Date: Sun, 18 Mar 2012 13:41:56 + Subject: Re: BUG: REL 9.0 - MD malloc of custom sector size On Sun, 18 Mar 2012 14:01:39 +0100 rank1see

BUG: REL 9.0 - MD malloc of custom sector size

2012-03-18 Thread rank1seeker
man mdconfig -S sectorsize to use for malloc backed device I want to create MD device, with sector size of 4 Kb. It is CRITICAL to NOT append ANY suffixes, when specifing size, via '-s' flag in order to use sectors, to set it's size. # mdconfig -a -t malloc -S 4096 -s 32768

Re: BUG: REL 9.0 - MD malloc of custom sector size

2012-03-18 Thread RW
On Sun, 18 Mar 2012 14:01:39 +0100 rank1see...@gmail.com wrote: man mdconfig -S sectorsize to use for malloc backed device I want to create MD device, with sector size of 4 Kb. It is CRITICAL to NOT append ANY suffixes, when specifing size, via '-s' flag in order to use

Re: Mem leak : malloc/free + pthreads = leakage?

2011-03-07 Thread Ivan Voras
malloc/free sequences that interact badly with with the per-thread caching that jemalloc performs. The first thing I would try is setting MALLOC_OPTIONS=7h to disable the caching. Wait, sorry, apparently this is a new option in HEAD. Under 8.1 MALLOC_OPTIONS=g will disable the thread-specific

Re: Mem leak : malloc/free + pthreads = leakage?

2011-03-06 Thread Vlad Galu
). It seems to leak memory (using standard malloc/free) badly. as opposed to what? OpenBSD? Linux? Windows? why do you think your problem is specific to FreeBSD (as evidenced by your post to a FreeBSD-specific list) or is related to threaded programs? OpenSolaris and Mac OS X. I didn't really

Re: Mem leak : malloc/free + pthreads = leakage?

2011-03-06 Thread Vlad Galu
(all C) I am working on (using pthreads, freebsd 8.1 64bit). It seems to leak memory (using standard malloc/free) badly. as opposed to what? OpenBSD? Linux? Windows? why do you think your problem is specific to FreeBSD (as evidenced by your post to a FreeBSD-specific list) or is related

Re: Mem leak : malloc/free + pthreads = leakage?

2011-03-06 Thread Ryan Stone
I would try playing with MALLOC_OPTIONS. I seriously doubt that there is an actual leak in jemalloc, but from my own experiences with it I suspect that there are certain multithreaded malloc/free sequences that interact badly with with the per-thread caching that jemalloc performs. The first

Re: Mem leak : malloc/free + pthreads = leakage?

2011-03-06 Thread Ryan Stone
On Sun, Mar 6, 2011 at 10:34 AM, Ryan Stone ryst...@gmail.com wrote: I would try playing with MALLOC_OPTIONS.  I seriously doubt that there is an actual leak in jemalloc, but from my own experiences with it I suspect that there are certain multithreaded malloc/free sequences that interact

Re: Mem leak : malloc/free + pthreads = leakage?

2011-03-06 Thread Eric Anderson
multithreaded malloc/free sequences that interact badly with with the per-thread caching that jemalloc performs. The first thing I would try is setting MALLOC_OPTIONS=7h to disable the caching. Wait, sorry, apparently this is a new option in HEAD. Under 8.1 MALLOC_OPTIONS=g will disable

Re: Mem leak : malloc/free + pthreads = leakage?

2011-03-06 Thread Eric Anderson
, I have a moderately threaded userland program (all C) I am working on (using pthreads, freebsd 8.1 64bit). It seems to leak memory (using standard malloc/free) badly. as opposed to what? OpenBSD? Linux? Windows? why do you think your problem is specific to FreeBSD (as evidenced

Re: Mem leak : malloc/free + pthreads = leakage?

2011-03-05 Thread Eygene Ryabinkin
Fri, Mar 04, 2011 at 10:02:45PM -0600, Eric Anderson wrote: I have a moderately threaded userland program (all C) I am working on (using pthreads, freebsd 8.1 64bit). It seems to leak memory (using standard malloc/free) badly. I am using pcap to capture packets and process them. I have

Re: Mem leak : malloc/free + pthreads = leakage?

2011-03-05 Thread Deomid Ryabkov
On 03/05/2011 04:02 AM, Eric Anderson wrote: Hi all, I have a moderately threaded userland program (all C) I am working on (using pthreads, freebsd 8.1 64bit). It seems to leak memory (using standard malloc/free) badly. as opposed to what? OpenBSD? Linux? Windows? why do you think your

Re: Mem leak : malloc/free + pthreads = leakage?

2011-03-05 Thread Eric Anderson
On Mar 5, 2011, at 6:23 AM, Eygene Ryabinkin wrote: Fri, Mar 04, 2011 at 10:02:45PM -0600, Eric Anderson wrote: I have a moderately threaded userland program (all C) I am working on (using pthreads, freebsd 8.1 64bit). It seems to leak memory (using standard malloc/free) badly. I am using

Re: Mem leak : malloc/free + pthreads = leakage?

2011-03-05 Thread Eric Anderson
On Mar 5, 2011, at 10:44 AM, Deomid Ryabkov wrote: On 03/05/2011 04:02 AM, Eric Anderson wrote: Hi all, I have a moderately threaded userland program (all C) I am working on (using pthreads, freebsd 8.1 64bit). It seems to leak memory (using standard malloc/free) badly. as opposed

Mem leak : malloc/free + pthreads = leakage?

2011-03-04 Thread Eric Anderson
Hi all, I have a moderately threaded userland program (all C) I am working on (using pthreads, freebsd 8.1 64bit). It seems to leak memory (using standard malloc/free) badly. I am using pcap to capture packets and process them. I have a handful of libs statically linked in (pcap is one

Strange problems in the old libc malloc routines

2011-02-02 Thread Andrew Duane
We are still using the FreeBSD 6 malloc routines, and are rather suddenly having a large number of problems with one or two of our programs. Before I dig into the 100+ crash dumps I have, I thought I'd see if anyone else has ever encountered this. The problems all seem to stem from some case

Re: Strange problems in the old libc malloc routines

2011-02-02 Thread John Baldwin
On Wednesday, February 02, 2011 01:04:15 pm Andrew Duane wrote: We are still using the FreeBSD 6 malloc routines, and are rather suddenly having a large number of problems with one or two of our programs. Before I dig into the 100+ crash dumps I have, I thought I'd see if anyone else has ever

Re: kernel malloc() and free()

2010-03-02 Thread Andrey Simonenko
On Mon, Mar 01, 2010 at 09:24:40PM -0600, Dan Nelson wrote: Hm. Even after some reading, I'm not sure how the slabs keep track of which elements are allocated or free. I expected to find a bitmap somewhere that malloc() sets and free() clears, but I don't see it. Maybe some kernel hacker

kernel malloc() and free()

2010-03-01 Thread Shrivatsan
Hi, I am looking at the code that allocates and frees kernel memory. I understand that allocating kernel memory is quite different from the user level mallocs. In case of user level mallocs, we allocate requested size + 4 bytes and store the requested size in the additional 4 bytes.

Re: kernel malloc() and free()

2010-03-01 Thread Dan Nelson
the requested size in the additional 4 bytes. Actually FreeBSD's userland malloc hasn't ever had a 4-byte-per-element overhead like this. All BSD mallocs have been block-based, where all objects in a page are the same size. The original bsd malloc had power-of-2 size groupings (blocks holding the same size

Calling malloc from a signal handler

2008-09-19 Thread Stephen Montgomery-Smith
I notice that if you use malloc from within a signal handler on FreeBSD-6.x, that you can potentially trigger a recursive call error. But this seems to have changed in FreeBSD-7.x. Is it now permissible to call malloc from within a signal handler in FreeBSD-7.x? If so, should the man page

Re: Calling malloc from a signal handler

2008-09-19 Thread Joerg Sonnenberger
On Fri, Sep 19, 2008 at 08:52:13AM -0500, Stephen Montgomery-Smith wrote: Is it now permissible to call malloc from within a signal handler in FreeBSD-7.x? No. Joerg ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman

Re: Calling malloc from a signal handler

2008-09-19 Thread Daniel Eischen
On Fri, 19 Sep 2008, Stephen Montgomery-Smith wrote: I notice that if you use malloc from within a signal handler on FreeBSD-6.x, that you can potentially trigger a recursive call error. But this seems to have changed in FreeBSD-7.x. Is it now permissible to call malloc from within a signal

unexpected behaviour of malloc() on 7.0/amd64

2008-09-17 Thread Andrew MacIntyre
[If this is not an appropriate forum for this query, please suggest a more appropriate one] In investigating a Python 2.6rc1 regression test failure on FreeBSD 7.0/amd64, as far as I can tell, malloc() does not return NULL when available memory (including swap) is exhausted - the process just

Re: unexpected behaviour of malloc() on 7.0/amd64

2008-09-17 Thread Pietro Cerutti
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 Andrew MacIntyre wrote: [snip] | In investigating a Python 2.6rc1 regression test failure on FreeBSD | 7.0/amd64, as far as I can tell, malloc() does not return NULL when | available memory (including swap) is exhausted - the process just gets

Re: unexpected behaviour of malloc() on 7.0/amd64

2008-09-17 Thread Jason Evans
Andrew MacIntyre wrote: In investigating a Python 2.6rc1 regression test failure on FreeBSD 7.0/amd64, as far as I can tell, malloc() does not return NULL when available memory (including swap) is exhausted - the process just gets KILLed. Using ulimit -v to set a virtual memory use limit below

Re: unexpected behaviour of malloc() on 7.0/amd64

2008-09-17 Thread Andrew MacIntyre
Jason Evans wrote: Andrew MacIntyre wrote: In investigating a Python 2.6rc1 regression test failure on FreeBSD 7.0/amd64, as far as I can tell, malloc() does not return NULL when available memory (including swap) is exhausted - the process just gets KILLed. Using ulimit -v to set a virtual

Re: unexpected behaviour of malloc() on 7.0/amd64

2008-09-17 Thread Jason Evans
Andrew MacIntyre wrote: However my reading of the updated man page suggests that the malloc options string should be Dm or m to turn off mmap() and only use sbrk() - could you clarify why d? Whoops, I meant m, not d. Jason ___ freebsd-hackers

Boot loader + malloc

2008-08-21 Thread Oliver Fromme
(memtop_copyin); #else heap_top = (void *)bios_basemem; heap_bottom = (void *)end; #endif setheap(heap_bottom, heap_top); If I understand correctly, the boot loader will use only low memory (i.e. below 0x10) for malloc by default. Extended memory is only used if bzip2 or firewire support

Re: Boot loader + malloc

2008-08-21 Thread Jordan Gordeev
; heap_bottom = PTOV(memtop_copyin); #else heap_top = (void *)bios_basemem; heap_bottom = (void *)end; #endif setheap(heap_bottom, heap_top); If I understand correctly, the boot loader will use only low memory (i.e. below 0x10) for malloc by default. Extended memory is only used if bzip2

Re: Boot loader + malloc

2008-08-21 Thread Oliver Fromme
Jordan Gordeev wrote: At present the amd64 kernel is loaded just above the first megabyte of physical memory. Yes, I know, and the standard i386 kernel is loaded at 4 MB, and the PAE kernel is loaded at 2 MB. It doesn't matter much, though. I have no idea if the loader uses malloc()/free

Re: Reason for doing malloc / bzero over calloc (performance)?

2007-06-15 Thread Joerg Sonnenberger
On Thu, Jun 14, 2007 at 06:04:27PM -0700, Matthew Dillon wrote: From this point of view it is much, much better to bzero() memory that is already mapped then it is to map/unmap new memory. For kernel land, you are right. For userland, there's one big down-side to always bzero/memset

Re: Reason for doing malloc / bzero over calloc (performance)?

2007-06-14 Thread Ivan Voras
[EMAIL PROTECTED] wrote: Hmmm... I wonder what the Mach kernel in OSX does to allocate memory then. I'll have to take a look at OpenDarwin's source sometime and see what it does. Following the link chain from the benchmark link posted in this thread I've come to the information that it's

Re: Reason for doing malloc / bzero over calloc (performance)?

2007-06-14 Thread youshi10
I've come to the information that it's similar to -CURRENT: small allocations are carved from the local pool, big ones from prezeroed pages (from kernel). Do you know if that's with malloc or calloc? What portion of the source demonstrates this? -Garrett

Re: Reason for doing malloc / bzero over calloc (performance)?

2007-06-14 Thread Ivan Voras
[EMAIL PROTECTED] wrote: Do you know if that's with malloc or calloc? What portion of the source demonstrates this? No source, but here's a quote from http://boredzo.org/blog/archives/2006-11-26/calloc-vs-malloc: For large blocks (where large is surprisingly small, something like 14 KB) Mac

Re: Reason for doing malloc / bzero over calloc (performance)?

2007-06-14 Thread Matthew Dillon
mapped then it is to map/unmap new memory. I recently audited DragonFly and found an insane number of IPIs flying about due to PAGE_SIZE'd kernel mallocs using the VM trick via kernel_map kmem_alloc(). They all went away when I made the kernel malloc use the slab cache

Re: Reason for doing malloc / bzero over calloc (performance)?

2007-06-14 Thread youshi10
() memory that is already mapped then it is to map/unmap new memory. I recently audited DragonFly and found an insane number of IPIs flying about due to PAGE_SIZE'd kernel mallocs using the VM trick via kernel_map kmem_alloc(). They all went away when I made the kernel malloc use

Re: Reason for doing malloc / bzero over calloc (performance)?

2007-06-13 Thread Garrett Cooper
Garrett Cooper wrote: Title says it all -- is there a particular reason why malloc/bzero should be used instead of calloc? -Garrett As someone just brought to my attention, I should do some Googling. Initial results brought up this: http://boredzo.org/blog/archives/2006-11-26/calloc-vs

Re: Reason for doing malloc / bzero over calloc (performance)?

2007-06-13 Thread Ed Schouten
* Garrett Cooper [EMAIL PROTECTED] wrote: Garrett Cooper wrote: Title says it all -- is there a particular reason why malloc/bzero should be used instead of calloc? -Garrett As someone just brought to my attention, I should do some Googling. Initial results brought up

Re: Reason for doing malloc / bzero over calloc (performance)?

2007-06-13 Thread youshi10
On Wed, 13 Jun 2007, Ed Schouten wrote: * Garrett Cooper [EMAIL PROTECTED] wrote: Garrett Cooper wrote: Title says it all -- is there a particular reason why malloc/bzero should be used instead of calloc? -Garrett As someone just brought to my attention, I should do some Googling

Reason for doing malloc / bzero over calloc?

2007-06-12 Thread Garrett Cooper
Title says it all -- is there a particular reason why malloc/bzero should be used instead of calloc? -Garrett ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail

Re: The optimization of malloc(3): FreeBSD vs GNU libc

2006-08-16 Thread Intron is my Internet alias
the copious assertions, not to mention the statistics gathering code. Before you do that though, it would be useful to turn statistics reporting on (add MALLOC_OPTIONS=P to your environment when running the test program) and see what malloc says is going on. [I am away from my -current system

Re: The optimization of malloc(3): FreeBSD vs GNU libc

2006-08-15 Thread Intron
2500+ (1.8GHz, 512KB L2 Cache). After hacking, I found that the problem is nested in malloc(3) of FreeBSD libc. Download the testing program: http://ftp.intron.ac/tmp/fdtd.tar.bz2 You may try to compile the program WITHOUT the macro MY_MALLOC defined (in Makefile) to use malloc(3) provided

Re: The optimization of malloc(3): FreeBSD vs GNU libc

2006-08-15 Thread Intron
was astonished by the real repeatable performance difference on AMD Athlon XP 2500+ (1.8GHz, 512KB L2 Cache). After hacking, I found that the problem is nested in malloc(3) of FreeBSD libc. Download the testing program: http://ftp.intron.ac/tmp/fdtd.tar.bz2 You may try to compile the program WITHOUT

Re: The optimization of malloc(3): FreeBSD vs GNU libc

2006-08-15 Thread Jason Evans
assertions, not to mention the statistics gathering code. Before you do that though, it would be useful to turn statistics reporting on (add MALLOC_OPTIONS=P to your environment when running the test program) and see what malloc says is going on. [I am away from my -current system at the moment, so

The optimization of malloc(3): FreeBSD vs GNU libc

2006-08-14 Thread Intron
is nested in malloc(3) of FreeBSD libc. Download the testing program: http://ftp.intron.ac/tmp/fdtd.tar.bz2 You may try to compile the program WITHOUT the macro MY_MALLOC defined (in Makefile) to use malloc(3) provided by FreeBSD 6.1. Then, time the running of the binary (on Athlon XP 2500+): #/usr/bin

Re: The optimization of malloc(3): FreeBSD vs GNU libc

2006-08-14 Thread Brooks Davis
L2 Cache). After hacking, I found that the problem is nested in malloc(3) of FreeBSD libc. Download the testing program: http://ftp.intron.ac/tmp/fdtd.tar.bz2 You may try to compile the program WITHOUT the macro MY_MALLOC defined (in Makefile) to use malloc(3) provided by FreeBSD 6.1

Re: The optimization of malloc(3): FreeBSD vs GNU libc

2006-08-14 Thread Vladimir Kushnir
repeatable performance difference on AMD Athlon XP 2500+ (1.8GHz, 512KB L2 Cache). After hacking, I found that the problem is nested in malloc(3) of FreeBSD libc. Download the testing program: http://ftp.intron.ac/tmp/fdtd.tar.bz2 You may try to compile the program WITHOUT the macro MY_MALLOC defined

Re: The optimization of malloc(3): FreeBSD vs GNU libc

2006-08-14 Thread (LI Xin)
在 2006-08-15二的 02:38 +0300,Vladimir Kushnir写道: On -CURENT amd64 (Athlon64 3000+, 512k L2 cache): With jemalloc (without MY_MALLOS): ~/fdtd /usr/bin/time ./fdtd.FreeBSD 500 500 1000 ... 116.34 real 113.69 user 0.00 sys With MY_MALLOC: ~/fdtd /usr/bin/time ./fdtd.FreeBSD

Re: Return value of malloc(0)

2006-07-05 Thread John Baldwin
On Saturday 01 July 2006 04:35, Matthias Andree wrote: Pat Lashley [EMAIL PROTECTED] writes: BUT, that said, the safest and most portable coding practice would be: // The C standard does not require malloc(0) to return NULL; // but whatever it returns MUST

Re: Return value of malloc(0)

2006-07-02 Thread Andre Albsmeier
On Sat, 01-Jul-2006 at 10:35:47 +0200, Matthias Andree wrote: Pat Lashley [EMAIL PROTECTED] writes: BUT, that said, the safest and most portable coding practice would be: // The C standard does not require malloc(0) to return NULL; // but whatever it returns MUST

Re: Return value of malloc(0)

2006-07-02 Thread Andre Albsmeier
On Fri, 30-Jun-2006 at 12:15:21 -0400, Pat Lashley wrote: I went wandering through the C Working Group archives for the heck of it, and apparently a lot of people were confused over this, thinking either as you did or that unique meant it would a value unique to the usage of malloc(0). It's

Re: Return value of malloc(0)

2006-07-01 Thread Matthias Andree
Pat Lashley [EMAIL PROTECTED] writes: BUT, that said, the safest and most portable coding practice would be: // The C standard does not require malloc(0) to return NULL; // but whatever it returns MUST NOT be dereferenced. ptr = ( size == 0 ) ? NULL : malloc( size

Re: FLEX, was Re: Return value of malloc(0)

2006-06-30 Thread Peter Jeremy
On Thu, 2006-Jun-29 15:09:23 -0700, Randall Hyde wrote: How about feeding the C source through the preprocessor, stripping out the #line directives, compiling it and posting the exact gcc error and source context. Okay, I'll try that when I get home. But I was kind of under the impression that

Re: Return value of malloc(0)

2006-06-30 Thread Bernd Walter
isn't any better). You might as well write: foo = malloc(0); /* make noise */ Ok, just for having it done: if (foo == (foo = some_val)) .. would be right to check if foo stayed the same. No? There is no way to see a 0x800 return from malloc(0) as error. So noone

Re: Return value of malloc(0)

2006-06-30 Thread Pat Lashley
I went wandering through the C Working Group archives for the heck of it, and apparently a lot of people were confused over this, thinking either as you did or that unique meant it would a value unique to the usage of malloc(0). It's been clarified recently (and will be in the next revision

Re: Return value of malloc(0)

2006-06-30 Thread Pat Lashley
No, sir. Operator precedence: assign first, and then compare, thus the comparison will always be true (else you'd be comparing to undefined values, which isn't any better). You might as well write: foo = malloc(0); /* make noise */ Ok, just for having it done: if (foo == (foo

Re: FLEX, was Re: Return value of malloc(0)

2006-06-29 Thread Steve Kargl
On Wed, Jun 28, 2006 at 10:40:45PM -0700, Randall Hyde wrote: Without seeing the code or the actual error message, I'm guessing the answer is 42. Perhaps, some detail might be appropriate. I seriously doubt seeing the code will do much good. Here's the offending line:

Re: FLEX, was Re: Return value of malloc(0)

2006-06-29 Thread Peter Jeremy
On Wed, 2006-Jun-28 22:40:45 -0700, Randall Hyde wrote: I seriously doubt seeing the code will do much good. Here's the offending line: YY_INPUT( (yy_current_buffer-yy_ch_buf[number_to_move]), yy_n_chars, num_to_read ); How about feeding the C source through the preprocessor, stripping out

Re: FLEX, was Re: Return value of malloc(0)

2006-06-29 Thread Thomas David Rivers
Randall Hyde [EMAIL PROTECTED] BTW, if anyone is intrested in the full FLEX source, it's part of the HLA (High Level Assembler) source package found here: http://webster.cs.ucr.edu/AsmTools/HLA/HLAv1.84/hlasrc.zip Just wondering if those guys knew that IBM calls their mainframe

Re: Return value of malloc(0)

2006-06-29 Thread Andre Albsmeier
On Wed, 28-Jun-2006 at 16:19:35 -0400, Lowell Gilbert wrote: Andre Albsmeier [EMAIL PROTECTED] writes: The manpage makes me think that when malloc is called with 0 as argument (and no V-flag had been set) the pointer it returns can actually be used (as a pointer to the so-called minimal

Re: Return value of malloc(0)

2006-06-29 Thread Pat Lashley
The C Standard says the following about malloc(0): If the size of the space requested is zero, the behavior is implementation-defined: either a null pointer is returned, or the behavior is as if the size were some nonzero value, except that the returned pointer shall not be used

Re: Return value of malloc(0)

2006-06-29 Thread Matthias Andree
Johannes Weiner [EMAIL PROTECTED] writes: Hi, On Wed, Jun 28, 2006 at 08:10:45PM +0200, Andre Albsmeier wrote: If you use malloc(0) and are crazy enough to access the 'allocated' memory we give you a SIGSEV to show you how dumb you are :-). They should check the return value of malloc

Re: Return value of malloc(0)

2006-06-29 Thread Johannes Weiner
On Thu, Jun 29, 2006 at 06:09:37PM +0200, Matthias Andree wrote: The value returned from malloc(0) must not be dereferenced whatever it was. It was 0x800, which doesn't count as failure. But this would be appropriate for catching the error: if ((foo = malloc(0)) == foo) /* make noise

Re: Return value of malloc(0)

2006-06-29 Thread Harti Brandt
On Thu, 29 Jun 2006, Johannes Weiner wrote: JWOn Thu, Jun 29, 2006 at 06:09:37PM +0200, Matthias Andree wrote: JW JW The value returned from malloc(0) must not be dereferenced whatever it JW was. It was 0x800, which doesn't count as failure. JW JWBut this would be appropriate for catching

Re: Return value of malloc(0)

2006-06-29 Thread joerg
On Thu, Jun 29, 2006 at 11:44:23AM -0400, Pat Lashley wrote: No, our implementation is NOT legal. We always return the SAME value. To be legal, we should not return that value again unless it has been free()-ed. It is legal due to brain damaged definition of implementation defined

Re: Return value of malloc(0)

2006-06-29 Thread Matthias Andree
Johannes Weiner [EMAIL PROTECTED] writes: On Thu, Jun 29, 2006 at 06:09:37PM +0200, Matthias Andree wrote: The value returned from malloc(0) must not be dereferenced whatever it was. It was 0x800, which doesn't count as failure. But this would be appropriate for catching the error

Re: Return value of malloc(0)

2006-06-29 Thread Harti Brandt
On Thu, 29 Jun 2006, Matthias Andree wrote: MAJohannes Weiner [EMAIL PROTECTED] writes: MA MA On Thu, Jun 29, 2006 at 06:09:37PM +0200, Matthias Andree wrote: MA MA The value returned from malloc(0) must not be dereferenced whatever it MA was. It was 0x800, which doesn't count as failure. MA MA

Re: Return value of malloc(0)

2006-06-29 Thread Erik Trulsson
On Thu, Jun 29, 2006 at 11:44:23AM -0400, Pat Lashley wrote: The C Standard says the following about malloc(0): If the size of the space requested is zero, the behavior is implementation-defined: either a null pointer is returned, or the behavior is as if the size were some nonzero

Re: Return value of malloc(0)

2006-06-29 Thread Pat Lashley
On Thu, Jun 29, 2006 at 11:44:23AM -0400, Pat Lashley wrote: No, our implementation is NOT legal. We always return the SAME value. To be legal, we should not return that value again unless it has been free()-ed. It is legal due to brain damaged definition of implementation defined

Re: Return value of malloc(0)

2006-06-29 Thread Lowell Gilbert
' (which cannot be legally de-referenced). I went wandering through the C Working Group archives for the heck of it, and apparently a lot of people were confused over this, thinking either as you did or that unique meant it would a value unique to the usage of malloc(0). It's been clarified recently

Re: FLEX, was Re: Return value of malloc(0)

2006-06-29 Thread Randall Hyde
-Original Message- How about feeding the C source through the preprocessor, stripping out the #line directives, compiling it and posting the exact gcc error and source context. Okay, I'll try that when I get home. But I was kind of under the impression that *GCC* runs the preprocessor

Re: FLEX, was Re: Return value of malloc(0)

2006-06-29 Thread Randall Hyde
-Original Message- From: Thomas David Rivers [EMAIL PROTECTED] Sent: Jun 29, 2006 3:17 AM To: freebsd-hackers@freebsd.org, [EMAIL PROTECTED] Subject: Re: FLEX, was Re: Return value of malloc(0) Randall Hyde [EMAIL PROTECTED] BTW, if anyone is intrested in the full FLEX source, it's

  1   2   3   >