[gegl] buffer: gegl_tile_lock do context switches when tile is locked
- From: Øyvind "pippin" Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] buffer: gegl_tile_lock do context switches when tile is locked
- Date: Tue, 28 Apr 2020 19:30:01 +0000 (UTC)
commit 9f134d4e14b8d3108de61972f2a91ba3863d3539
Author: Øyvind Kolås <pippin gimp org>
Date: Tue Apr 28 21:23:29 2020 +0200
buffer: gegl_tile_lock do context switches when tile is locked
On hyper threading systems the number of active threads can be higher
than the number of actual processing cores, by adding sleeps between
attempts after a limit, we avoid some starvation that happens in these
cases. Patch from @suzu in gimp#4955.
gegl/buffer/gegl-tile.c | 5 +++++
1 file changed, 5 insertions(+)
---
diff --git a/gegl/buffer/gegl-tile.c b/gegl/buffer/gegl-tile.c
index 353d3dbc9..68f239eed 100644
--- a/gegl/buffer/gegl-tile.c
+++ b/gegl/buffer/gegl-tile.c
@@ -296,6 +296,7 @@ end:
void
gegl_tile_lock (GeglTile *tile)
{
+ unsigned int count = 0;
g_atomic_int_inc (&tile->lock_count);
while (TRUE)
@@ -321,6 +322,10 @@ gegl_tile_lock (GeglTile *tile)
case CLONE_STATE_UNCLONING:
break;
}
+
+ ++count;
+ if (count > 32)
+ usleep (1);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]