[PATCH] Linux: Fix '__close_nocancel_nostatus' clobbering 'errno' [BZ #33035]

Florian Weimer fweimer@redhat.com
Mon Jun 2 16:16:47 GMT 2025


* Maciej W. Rozycki:

> On Fri, 30 May 2025, Adhemerval Zanella Netto wrote:
>
>> >  You mean by keeping it inline?
>> > 
>> >  But unlike with '__writev_nocancel_nostatus', which is only called once 
>> > in resolv/herror.c and a couple of times in gmon/gmon.c, our code base is 
>> > sprinkled generously with calls to '__close_nocancel_nostatus', and for 
>> > example on 64-bit POWER the out-of-line compilation of the function 
>> > expands to 25 machine instructions (no extra stack frame is produced, so 
>> > no extra overhead).
>> > 
>> >  Are you sure it will be beneficial performance-wise to have such a large 
>> > chunk of code repeatedly pasted inline?
>> 
>> I would simplicity, the _nocancel and _nostatus are essentially wrappers
>> over INLINE_SYSCALL_CALL/INTERNAL_SYSCALL_CALLS that are mainly added
>> to abstract it for Hurd.
>> 
>> The inline also remove the need to export it from GLIBC_PRIVATE.
>
>  What was the rationale to make '__close_nocancel' standalone rather than 
> inline then?

Looking at this commit:

commit 329ea513b451ae8322aa7a24ed84da13992af2dd
Author: Zack Weinberg <zackw@panix.com>
Date:   Tue Apr 3 18:26:44 2018 -0400

    Avoid cancellable I/O primitives in ld.so.

I think it was just following the existing code which co-located
__close_nocancel with the regular close implementation, which is also
out-of-line.

Thanks,
Florian



More information about the Libc-alpha mailing list