Package: util-linux
Version: 2.41-5
Severity: normal

Dear Maintainer,

while strace'ing to find out why hardlink is so slow, IO found it does this 
sequence between every fstatat call:

   gettid()                                = 36482
   getpid()                                = 36482
   tgkill(36482, 36482, 0)                 = 0

this seems to be a pretty weird thing to do in a tighht scanning
loop. Looking at the code, handle_interrupt is responsible:

   /**
    * handle_interrupt - Handle a signal
    */
   static void handle_interrupt(void)
   {
           switch (last_signal) {  
           case SIGUSR1:           
                   print_stats();  
                   putchar('\n');  
                   break;          
           default:
                   signal(last_signal, SIG_DFL);
                   raise(last_signal);
                   break;
           }
           last_signal = 0;
   }

this is already a weird function to begin with, but crucially, it calls 
signal(0,... and raise(0).

it seems to me the former is likely undefined behaviour and the latter is
just unnecessartily slow.

most likely, handle_interrupt simply should not be called after every fstatat, 
or at all, without last_signal bering set beforehand.

-- System Information:
Debian Release: 13.5
  APT prefers stable-updates
  APT policy: (990, 'stable-updates'), (990, 'stable-security'), (990, 
'stable'), (500, 'unstable'), (500, 'testing'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386, x32

Kernel: Linux 6.12.90+deb13.1-amd64 (SMP w/28 CPU threads; PREEMPT)
Kernel taint flags: TAINT_USER, TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=en_IE.UTF-8, LC_CTYPE=en_IE.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages util-linux depends on:
ii  libblkid1       2.41-5
ii  libc6           2.41-12+deb13u3
ii  libcap-ng0      0.8.5-4+b1
ii  libcrypt1       1:4.4.38-1
ii  liblastlog2-2   2.41-5
ii  libmount1       2.41-5
ii  libpam-modules  1.7.0-5
ii  libpam-runtime  1.7.0-5
ii  libpam0g        1.7.0-5
ii  libselinux1     3.8.1-1
ii  libsmartcols1   2.41-5
ii  libsystemd0     257.13-1~deb13u1
ii  libtinfo6       6.5+20250216-2
ii  libudev1        257.13-1~deb13u1
ii  libuuid1        2.41-5

Versions of packages util-linux recommends:
ii  sensible-utils  0.0.25

Versions of packages util-linux suggests:
ii  dosfstools          4.2-1.2
ii  kbd                 2.7.1-2
ii  util-linux-extra    2.41-5
pn  util-linux-locales  <none>
ii  wtmpdb              0.73.0-3+deb13u1

-- no debconf information

Reply via email to