Re: [PATCH 1/2] Make xmalloc and xrealloc thread-safe

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Shawn Pearce
Date: Wednesday, March 24, 2010 - 11:22 am

On Wed, Mar 24, 2010 at 10:53 AM, Nicolas Pitre <nico@fluxnic.net> wrote:

The easy solution is probably to remove the use of xmalloc from
find_deltas code path.  But then we run into hard failures when we
can't get the memory we need, there isn't a way to recover from a
malloc() failure deep within read_sha1_file for example.  The current
solution is the best we can do, try to ditch pack windows and hope
that releases sufficient virtual memory space that a second malloc()
attempt can succeed by increasing heap.

We could use a mutex during the malloc failure code-path of xmalloc,
to ensure only one thread goes through that pack window cleanup at a
time.  But that will still mess with the main thread which doesn't
really want to acquire mutexes during object access as it uses the
existing pack windows.

I thought pack-objects did all object access from the main thread and
only delta searches on the worker threads?  If that is true, maybe we
can have the worker threads signal the main thread on malloc failure
to release pack windows, and then wait for that signal to be
acknowledged before they attempt to retry the malloc.  This means the
main thread would need to periodically test that condition as its
dispatching batches of objects to the workers.

Ugly.

-- 
Shawn.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 1/2] Make xmalloc and xrealloc thread-safe, Fredrik Kuivinen, (Tue Mar 23, 10:31 am)
Re: [PATCH 1/2] Make xmalloc and xrealloc thread-safe, Shawn O. Pearce, (Tue Mar 23, 11:43 am)
Re: [PATCH 1/2] Make xmalloc and xrealloc thread-safe, Fredrik Kuivinen, (Tue Mar 23, 2:21 pm)
Re: [PATCH 1/2] Make xmalloc and xrealloc thread-safe, Nicolas Pitre, (Tue Mar 23, 4:50 pm)
Re: [PATCH 1/2] Make xmalloc and xrealloc thread-safe, Fredrik Kuivinen, (Wed Mar 24, 8:23 am)
Re: [PATCH 1/2] Make xmalloc and xrealloc thread-safe, Nicolas Pitre, (Wed Mar 24, 10:53 am)
Re: [PATCH 1/2] Make xmalloc and xrealloc thread-safe, Shawn Pearce, (Wed Mar 24, 11:22 am)
Re: [PATCH 1/2] Make xmalloc and xrealloc thread-safe, Junio C Hamano, (Wed Mar 24, 11:44 am)
Re: [PATCH 1/2] Make xmalloc and xrealloc thread-safe, Nicolas Pitre, (Wed Mar 24, 11:54 am)
Re: [PATCH 1/2] Make xmalloc and xrealloc thread-safe, Shawn Pearce, (Wed Mar 24, 12:57 pm)
[PATCH] Make xmalloc and xrealloc thread-safe, Nicolas Pitre, (Wed Mar 24, 1:22 pm)
Re: [PATCH] Make xmalloc and xrealloc thread-safe, Shawn O. Pearce, (Wed Mar 24, 1:28 pm)
Re: [PATCH] Make xmalloc and xrealloc thread-safe, Nicolas Pitre, (Wed Mar 24, 2:02 pm)
Re: [PATCH] Make xmalloc and xrealloc thread-safe, Junio C Hamano, (Wed Mar 24, 2:11 pm)
Re: [PATCH] Make xmalloc and xrealloc thread-safe, Junio C Hamano, (Wed Mar 24, 2:28 pm)
Re: [PATCH] Make xmalloc and xrealloc thread-safe, Fredrik Kuivinen, (Sat Mar 27, 6:26 am)
Re: [PATCH] Make xmalloc and xrealloc thread-safe, Nicolas Pitre, (Sat Mar 27, 11:59 am)
Re: [PATCH] Make xmalloc and xrealloc thread-safe, Fredrik Kuivinen, (Tue Mar 30, 11:57 pm)
[PATCH v2] Make xmalloc and xrealloc thread-safe, Nicolas Pitre, (Tue Apr 6, 7:57 pm)
Re: [PATCH v2] Make xmalloc and xrealloc thread-safe, Shawn O. Pearce, (Tue Apr 6, 8:16 pm)
Re: [PATCH v2] Make xmalloc and xrealloc thread-safe, Nicolas Pitre, (Tue Apr 6, 9:51 pm)
Re: [PATCH v2] Make xmalloc and xrealloc thread-safe, Junio C Hamano, (Tue Apr 6, 10:21 pm)
Re: [PATCH v2] Make xmalloc and xrealloc thread-safe, Shawn Pearce, (Wed Apr 7, 5:29 am)
Re: [PATCH v2] Make xmalloc and xrealloc thread-safe, Nicolas Pitre, (Wed Apr 7, 6:17 am)
Re: [PATCH v2] Make xmalloc and xrealloc thread-safe, Shawn Pearce, (Wed Apr 7, 7:30 am)
Re: [PATCH v2] Make xmalloc and xrealloc thread-safe, Fredrik Kuivinen, (Wed Apr 7, 7:45 am)
Re: [PATCH v2] Make xmalloc and xrealloc thread-safe, Nicolas Pitre, (Wed Apr 7, 7:47 am)
Re: [PATCH v2] Make xmalloc and xrealloc thread-safe, Nicolas Pitre, (Wed Apr 7, 8:08 am)
Re: [PATCH v2] Make xmalloc and xrealloc thread-safe, Sverre Rabbelier, (Wed Apr 7, 8:27 am)
Re: [PATCH v2] Make xmalloc and xrealloc thread-safe, Fredrik Kuivinen, (Wed Apr 7, 9:13 am)
Re: [PATCH v2] Make xmalloc and xrealloc thread-safe, Fredrik Kuivinen, (Wed Apr 7, 9:15 am)
Re: [PATCH v2] Make xmalloc and xrealloc thread-safe, Junio C Hamano, (Wed Apr 7, 9:17 am)
Re: [PATCH v2] Make xmalloc and xrealloc thread-safe, Erik Faye-Lund, (Wed Apr 7, 9:44 am)
Re: [PATCH v2] Make xmalloc and xrealloc thread-safe, Nicolas Pitre, (Wed Apr 7, 11:37 am)
Re: [PATCH v2] Make xmalloc and xrealloc thread-safe, Johannes Sixt, (Wed Apr 7, 11:49 am)