[PATCH] lib: Add documentation to explain concurrent htab resizing.

2022-08-05 Thread Mark Wielaard
Document which lock is held by which thread and how moving the
htab data is coordinated.

Signed-off-by: Mark Wielaard 
---
 lib/ChangeLog|  8 
 lib/dynamicsizehash_concurrent.c | 26 --
 2 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/lib/ChangeLog b/lib/ChangeLog
index 32dda566..36c3131f 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,3 +1,11 @@
+2022-08-05  Mark Wielaard  
+
+   * dynamicsizehash_concurrent.c (resize_helper): Add documentation.
+   (resize_master): Renamed to...
+   (resize_coordinator): ...this. And add documentation.
+   (resize_worker): Add documentation.
+   (FIND): Add documentation.
+
 2022-04-25  Mark Wielaard  
 
* printversion.c (print_version): Update copyright year.
diff --git a/lib/dynamicsizehash_concurrent.c b/lib/dynamicsizehash_concurrent.c
index 4e2e2476..7c4fedfc 100644
--- a/lib/dynamicsizehash_concurrent.c
+++ b/lib/dynamicsizehash_concurrent.c
@@ -179,7 +179,8 @@ insert_helper (NAME *htab, HASHTYPE hval, TYPE val)
 #define CEIL(A, B) (((A) + (B) - 1) / (B))
 
 /* Initializes records and copies the data from the old table.
-   It can share work with other threads */
+   It can share work with other threads.  Only the coordinator
+   will pass blocking as 1, other worker threads pass 0.  */
 static void resize_helper(NAME *htab, int blocking)
 {
   size_t num_old_blocks = CEIL(htab->old_size, MOVE_BLOCK_SIZE);
@@ -244,13 +245,18 @@ static void resize_helper(NAME *htab, int blocking)
   atomic_fetch_add_explicit(&htab->num_moved_blocks, num_finished_blocks,
 memory_order_release);
 
+  /* The coordinating thread will block here waiting for all blocks to
+ be moved.  */
   if (blocking)
   while (atomic_load_explicit(&htab->num_moved_blocks,
   memory_order_acquire) != num_old_blocks);
 }
 
+/* Called by the main thread holding the htab->resize_rwl lock to
+   coordinate the moving of hash table data. Allocates the new hash
+   table and frees the old one when moving all data is done.  */
 static void
-resize_master(NAME *htab)
+resize_coordinator(NAME *htab)
 {
   htab->old_size = htab->size;
   htab->old_table = htab->table;
@@ -290,6 +296,10 @@ resize_master(NAME *htab)
 
 }
 
+/* Called by any thread that wants to do an insert or find operation
+   but notices it cannot get the htab->resize_rwl lock because another
+   thread is resizing the hash table.  Try to help out by moving table
+   data if still necessary.  */
 static void
 resize_worker(NAME *htab)
 {
@@ -391,6 +401,8 @@ INSERT(NAME) (NAME *htab, HASHTYPE hval, TYPE data)
 
   for(;;)
 {
+  /* If we cannot get the resize_rwl lock someone is resizing
+hash table, try to help out by moving table data.  */
   while (pthread_rwlock_tryrdlock(&htab->resize_rwl) != 0)
   resize_worker(htab);
 
@@ -421,17 +433,17 @@ INSERT(NAME) (NAME *htab, HASHTYPE hval, TYPE data)
   memory_order_acquire,
   memory_order_acquire))
 {
-  /* Master thread */
+  /* Main resizing thread, will coordinate moving data.  */
   pthread_rwlock_unlock(&htab->resize_rwl);
 
   pthread_rwlock_wrlock(&htab->resize_rwl);
-  resize_master(htab);
+  resize_coordinator(htab);
   pthread_rwlock_unlock(&htab->resize_rwl);
 
 }
   else
 {
-  /* Worker thread */
+  /* Worker thread, will help moving data.  */
   pthread_rwlock_unlock(&htab->resize_rwl);
   resize_worker(htab);
 }
@@ -458,8 +470,10 @@ TYPE
   name##_find
 FIND(NAME) (NAME *htab, HASHTYPE hval)
 {
+  /* If we cannot get the resize_rwl lock someone is resizing
+ the hash table, try to help out by moving table data.  */
   while (pthread_rwlock_tryrdlock(&htab->resize_rwl) != 0)
-  resize_worker(htab);
+resize_worker(htab);
 
   size_t idx;
 
-- 
2.18.4



[PATCH] po: standardize Project-Id-Version to just elfutils

2022-08-05 Thread Mark Wielaard
The po/pl.po file already just said Project-Id-Version: elfutils\n
Do the same for the other po files which had somewhat odd names.
The generated pot file will still include the version number too.

Signed-off-by: Mark Wielaard 
---
 po/ChangeLog | 7 +++
 po/de.po | 2 +-
 po/es.po | 2 +-
 po/ja.po | 2 +-
 po/uk.po | 2 +-
 5 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/po/ChangeLog b/po/ChangeLog
index 6e610671..bee350db 100644
--- a/po/ChangeLog
+++ b/po/ChangeLog
@@ -1,3 +1,10 @@
+2022-08-05  Mark Wielaard  
+
+   * de.po: Set Project-Id-Version: to elfutils.
+   * es.po: Likewise.
+   * ja.po: Likewise.
+   * uk.po: Likewise.
+
 2022-04-25  Mark Wielaard  
 
* *.po: Update for 0.187.
diff --git a/po/de.po b/po/de.po
index 55445203..e406b786 100644
--- a/po/de.po
+++ b/po/de.po
@@ -9,7 +9,7 @@
 # Michael Münch , 2009.
 msgid ""
 msgstr ""
-"Project-Id-Version: elfutils VERSION\n"
+"Project-Id-Version: elfutils\n"
 "Report-Msgid-Bugs-To: https://sourceware.org/bugzilla/\n";
 "POT-Creation-Date: 2022-04-25 18:22+0200\n"
 "PO-Revision-Date: 2009-06-29 15:15+0200\n"
diff --git a/po/es.po b/po/es.po
index a08b4c2d..92c044f3 100644
--- a/po/es.po
+++ b/po/es.po
@@ -8,7 +8,7 @@
 #
 msgid ""
 msgstr ""
-"Project-Id-Version: elfutils.master.es\n"
+"Project-Id-Version: elfutils\n"
 "Report-Msgid-Bugs-To: https://sourceware.org/bugzilla/\n";
 "POT-Creation-Date: 2022-04-25 18:22+0200\n"
 "PO-Revision-Date: 2011-01-10 15:17-0300\n"
diff --git a/po/ja.po b/po/ja.po
index 8a987212..a4584572 100644
--- a/po/ja.po
+++ b/po/ja.po
@@ -6,7 +6,7 @@
 # Hyu_gabaru Ryu_ichi , 2009.
 msgid ""
 msgstr ""
-"Project-Id-Version: ja\n"
+"Project-Id-Version: elfutils\n"
 "Report-Msgid-Bugs-To: https://sourceware.org/bugzilla/\n";
 "POT-Creation-Date: 2022-04-25 18:22+0200\n"
 "PO-Revision-Date: 2009-09-20 15:32+0900\n"
diff --git a/po/uk.po b/po/uk.po
index ecdb85d3..df539f77 100644
--- a/po/uk.po
+++ b/po/uk.po
@@ -5,7 +5,7 @@
 # Yuri Chornoivan , 2010, 2011, 2012, 2013, 2014, 2015, 2020.
 msgid ""
 msgstr ""
-"Project-Id-Version: \n"
+"Project-Id-Version: elfutils\n"
 "Report-Msgid-Bugs-To: https://sourceware.org/bugzilla/\n";
 "POT-Creation-Date: 2022-04-25 18:22+0200\n"
 "PO-Revision-Date: 2020-03-28 14:59+0200\n"
-- 
2.18.4



Re: [PATCH] po: standardize Project-Id-Version to just elfutils

2022-08-05 Thread Dmitry V. Levin
On Fri, Aug 05, 2022 at 07:51:04PM +0200, Mark Wielaard wrote:
> The po/pl.po file already just said Project-Id-Version: elfutils\n
> Do the same for the other po files which had somewhat odd names.
> The generated pot file will still include the version number too.

That's obviously correct, thanks.


-- 
ldv


[Bug libdw/29450] New: run-low_high_pc.sh fails on i386 against binutils-2.39

2022-08-05 Thread slyich at gmail dot com via Elfutils-devel
https://sourceware.org/bugzilla/show_bug.cgi?id=29450

Bug ID: 29450
   Summary: run-low_high_pc.sh fails on i386 against binutils-2.39
   Product: elfutils
   Version: unspecified
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: libdw
  Assignee: unassigned at sourceware dot org
  Reporter: slyich at gmail dot com
CC: elfutils-devel at sourceware dot org
  Target Milestone: ---

binutils-2.39 is out:
https://sourceware.org/pipermail/binutils/2022-August/122246.html

I tried to package it in nixpkgs and found a few build or test failures.

elfutils-0.187 and elfutils from git both fail run-low_high_pc.sh as:

FAIL: run-low_high_pc.sh


[b] main.c
[2d] main

[b] ../sysdeps/i386/start.S
[26] _start
[40] ../sysdeps/x86/abi-note.c
[b52] init.c
[b8e] static-reloc.c
[2dba] _dl_relocate_static_pie
[2dd8] ../sysdeps/i386/crti.S
[2def] _init
lowpc: 8049000, highpc: 8049000lx
../sysdeps/i386/crti.S: [2def] '_init' highpc <= lowpc
FAIL run-low_high_pc.sh (exit status: 255)

Extra `lx` prefix looks minor. lowpc == highpc looks real. gdb somehow manages
to detect the PC range for _init. Not sure which of tested files is that.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

[Bug libdw/29450] run-low_high_pc.sh fails on i386 against binutils-2.39

2022-08-05 Thread slyich at gmail dot com via Elfutils-devel
https://sourceware.org/bugzilla/show_bug.cgi?id=29450

--- Comment #1 from Sergei Trofimovich  ---
Created attachment 14257
  --> https://sourceware.org/bugzilla/attachment.cgi?id=14257&action=edit
low_high_pc

Attaching the binary itself. It was a failing selftest:

$ LD_LIBRARY_PATH=$PWD/libdw:$PWD/libelf tests/low_high_pc -e tests/low_high_pc
[b] ../sysdeps/i386/start.S
[26] _start
[40] ../sysdeps/x86/abi-note.c
[b52] init.c
[b8e] static-reloc.c
[2dba] _dl_relocate_static_pie
[2dd8] ../sysdeps/i386/crti.S
[2def] _init
lowpc: 8049000, highpc: 8049000
../sysdeps/i386/crti.S: [2def] '_init' highpc <= lowpc

gdb somehow knows the size of the _init:

$ gdb /tmp/low_high_pc
Reading symbols from /tmp/low_high_pc...
(gdb) disassemble _init
Dump of assembler code for function _init:
   0x08049000 <+0>: endbr32
   0x08049004 <+4>: push   %ebx
   0x08049005 <+5>: sub$0x8,%esp
   0x08049008 <+8>: call   0x8049400 <__x86.get_pc_thunk.bx>
   0x0804900d <+13>:add$0x2f93,%ebx
   0x08049013 <+19>:mov0x5c(%ebx),%eax
   0x08049019 <+25>:test   %eax,%eax
   0x0804901b <+27>:je 0x804901f <_init+31>
   0x0804901d <+29>:call   *%eax
   0x0804901f <+31>:add$0x8,%esp
   0x08049022 <+34>:pop%ebx
   0x08049023 <+35>:ret
End of assembler dump.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

[Bug libdw/29450] run-low_high_pc.sh fails on i386 against binutils-2.39

2022-08-05 Thread slyich at gmail dot com via Elfutils-devel
https://sourceware.org/bugzilla/show_bug.cgi?id=29450

--- Comment #2 from Sergei Trofimovich  ---
Could it be that it's a mild `crti.o` corruption by new binutils? "MIPS
assembler" does not sound right.

```
$ readelf -aW crti.o --debug-dump
...
Contents of the .debug_info section:

  Compilation Unit @ offset 0x0:
   Length:0x49 (32-bit)
   Version:   2
   Abbrev Offset: 0x0
   Pointer Size:  4
 <0>: Abbrev Number: 1 (DW_TAG_compile_unit)
   DW_AT_stmt_list   : (data4) 0x0
<10>   DW_AT_ranges  : (data4) 0x0
<14>   DW_AT_name: (strp) (offset: 0x0): ../sysdeps/i386/crti.S
<18>   DW_AT_comp_dir: (strp) (offset: 0x17): /build/glibc-2.35/csu
<1c>   DW_AT_producer: (strp) (offset: 0x2d): GNU AS 2.39
<20>   DW_AT_language: (data2) 32769(MIPS assembler)
 <1><22>: Abbrev Number: 2 (DW_TAG_subprogram)
<23>   DW_AT_name: (strp) (offset: 0x39): _init
<27>   DW_AT_external: (flag) 1
<28>   DW_AT_low_pc  : (addr) 0x0
<2c>   DW_AT_high_pc : (addr) 0x0
 <1><30>: Abbrev Number: 2 (DW_TAG_subprogram)
<31>   DW_AT_name: (strp) (offset: 0x3f): __x86.get_pc_thunk.bx
<35>   DW_AT_external: (flag) 1
<36>   DW_AT_low_pc  : (addr) 0x0
<3a>   DW_AT_high_pc : (addr) 0x4
 <1><3e>: Abbrev Number: 2 (DW_TAG_subprogram)
<3f>   DW_AT_name: (strp) (offset: 0x55): _fini
<43>   DW_AT_external: (flag) 1
<44>   DW_AT_low_pc  : (addr) 0x0
<48>   DW_AT_high_pc : (addr) 0x0
 <1><4c>: Abbrev Number: 0
...

```

-- 
You are receiving this mail because:
You are on the CC list for the bug.