This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Question about madvise(DONTNEED) in glibc malloc


OndÅej BÃlka, le Mon 15 Apr 2013 14:35:04 +0200, a Ãcrit :
> On Mon, Apr 15, 2013 at 02:15:08PM +0200, Samuel Thibault wrote:
> > OndÅej BÃlka, le Mon 15 Apr 2013 14:11:41 +0200, a Ãcrit :
> > > On Mon, Apr 15, 2013 at 01:13:19PM +0200, Samuel Thibault wrote:
> > > > OndÅej BÃlka, le Mon 15 Apr 2013 12:14:39 +0200, a Ãcrit :
> > > > > On Sun, Apr 14, 2013 at 10:11:50PM -0700, KOSAKI Motohiro wrote:
> > > > > > (4/14/13 9:12 PM), Siddhesh Poyarekar wrote:
> > > > > > > On 14 April 2013 22:07, KOSAKI Motohiro <kosaki.motohiro@gmail.com> wrote:
> > > > > > >> Now, we linux MM folks discuss are discussing about new memory discarding feature.
> > > > > > >> (https://lkml.org/lkml/2013/3/12/105). The motivation is similar wtih MADV_FREE,
> > > > > > >> but more efficient. (http://lwn.net/Articles/230799)
> > > > > > > 
> > > > > > > I just went through this and it looks interesting as a replacement for
> > > > > > > MADV_DONTNEED in malloc.  Please let us know what becomes of this so
> > > > > > > that we could explore the possibility of using it in malloc.
> > > > > > 
> > > > > > Firstly, this api is still under discusstion and any feedback has a chance to change 
> > > > > > api design.
> > > > > > 
> > > > > > The idea is simple. vrange(VOLATILE) just mark the argument pages is discardable. but
> > > > > > doesn't discard. No page table walk, No TLB shootdown, No anything more.
> > > > > > Touching the VOLATILed range, makes SIGBUG. you need to call vrange(NOVOLATILE) because
> > > > > > you begin to use again.
> > > > > 
> > > > > A SIGBUS makes using vrange out of question. We simply cannot ignore user generated SIGBUS.
> > > > 
> > > > Such SIGBUS would not happen unless the user accesses some freed memory,
> > > > which he shouldn't be doing anyway.
> > > 
> > > When kill -BUS pid became illegal?
> > 
> > I don't understand how that relates to what we are talking about.  I've
> > never said sending -BUS was illegal.  I've said that accessing freed
> > memory is illegal.
> 
> Accessing freed memory is illegal but not only way how that SIGBUS could
> happen.

Sure

> It could be SIGBUS from kill which is perfectly legal.

Sure

So what?

What was said was just that glibc could use vrange(VOLATILE) on freed
memory.  If the user ever accesses that freed memory, he'll get SIGBUS,
which is completely fine since he's not supposed to access freed memory.
When glibc wants to reuse the memory, it can use vrange(NOVOLATILE), and
thus the memory becomes usable again.

Samuel


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]