Message ID | 895e17d7b3fe3d689f8803a5541c75e7fdfcbd59.1561421042.git.alistair.francis@wdc.com |
---|---|
State | New, archived |
Headers |
Received: (qmail 20231 invoked by alias); 25 Jun 2019 00:11:43 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: <libc-alpha.sourceware.org> List-Unsubscribe: <mailto:libc-alpha-unsubscribe-##L=##H@sourceware.org> List-Subscribe: <mailto:libc-alpha-subscribe@sourceware.org> List-Archive: <http://sourceware.org/ml/libc-alpha/> List-Post: <mailto:libc-alpha@sourceware.org> List-Help: <mailto:libc-alpha-help@sourceware.org>, <http://sourceware.org/ml/#faqs> Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 20170 invoked by uid 89); 25 Jun 2019 00:11:42 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=HX-Languages-Length:1519 X-HELO: esa6.hgst.iphmx.com DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1561421502; x=1592957502; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mYLwQ5LzDSPwJKGE3KaQxcIDONhNfPn+y6mgCWOY0C4=; b=iPsxqvpjKqcZswldxRJyyl2XSC6KQA75ageDJ8DgFNXgMHKnbkcK6Keb imf/XtsZREaFCZMi50afYCcwxGQuRqStFRvuu8iLuqbf00G8VLyL/PtiR KzU1Kqo+iS+PqpTeE081Cr1ogwwnDeol4fioXjBP52SY71xAvzy1ix1IA Ga9YrMXR/6b83y/cF0P9KA30JSJckRaW7wh7jjF8c67F6cDqAof11pDJh UcxE/oZzS4NzJtO7/jSU4PzlzeWjKCKoq+Xe8lQDSvA8CmK/WFNJgNzrU 48NqKDaAwZXXxn+IDcvlIJ1BECT72B1Z7fBya4R9a1bXgxsaKBSJuYQ2T A==; IronPort-SDR: R2FpMz04/sTjsX3jU4fs+ssYUa4o8Ynnfc+BCXuGvoEy/DYEk17f1ISxuEz1F55d740A4BWHFy DJ6SjtAZHNK936Q1tnZioaQ2fMjFHN5wM0fSEBux1pmNxmysWgTpjkkVIDClM1Cg+YD7UIa0dT XbpnvQQ36OWawqVTdCi366/3FmeWrEuzS68PQHfG+Mi2KxgQ5qle7qBiPTJt5f5/AvygLmlZTQ /rg38bqrcOGCwIpt5rSztqpxqmBeUESy5yUxFTpcgq6CFKQKQbYJ7ftcXQI1ezGbAgpGegXys7 YWQgA05dyw74E99yqRFyCEh6 IronPort-SDR: uGFUSsaafGV7VfI//GflATwZ78gyZoeX4+ljnEKkh2KcfMY9kNi3ep9Ibk7A9MtGMI5DkJaPq4 tHfunHiaU2aNtkRUd//SF9Xo4G89IDXmd0i0KESd74quJ5pISxMddzk0uw7zuBFUMHjeYVPXlo u7VIGpdoX4oMgB+mfyTgE1EFnn4uooW4KPibMsTo8Z/w0UasJp49qzpguai/jgTC6MvpJvFdSe iUbedefwUmAclOoYwRpw8/x7TdHyMm1sqNJz+gZWcVgYN+1ZkfaMSLxGevCZVB3J+bJtddJyru u9A= From: Alistair Francis <alistair.francis@wdc.com> To: libc-alpha@sourceware.org Cc: arnd@arndb.de, adhemerval.zanella@linaro.org, fweimer@redhat.com, palmer@sifive.com, macro@wdc.com, zongbox@gmail.com, zong@andestech.com, alistair.francis@wdc.com, alistair23@gmail.com Subject: [RFC v2 09/20] sysdeps/getrlimit: Use prlimit64 if avaliable Date: Mon, 24 Jun 2019 17:09:10 -0700 Message-Id: <895e17d7b3fe3d689f8803a5541c75e7fdfcbd59.1561421042.git.alistair.francis@wdc.com> In-Reply-To: <cover.1561421042.git.alistair.francis@wdc.com> References: <cover.1561421042.git.alistair.francis@wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit |
Commit Message
Alistair Francis
June 25, 2019, 12:09 a.m. UTC
If the prlimit64 syscall is avaliable let's use that instead of
ugetrlimit as it isn't always avaliable (they aren't avaliable
on RV32).
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
---
ChangeLog | 1 +
sysdeps/unix/sysv/linux/getrlimit.c | 9 +++++++++
2 files changed, 10 insertions(+)
Comments
* Alistair Francis: > If the prlimit64 syscall is avaliable let's use that instead of > ugetrlimit as it isn't always avaliable (they aren't avaliable > on RV32). > diff --git a/sysdeps/unix/sysv/linux/getrlimit.c b/sysdeps/unix/sysv/linux/getrlimit.c > index 10c0176619..741b065b25 100644 > --- a/sysdeps/unix/sysv/linux/getrlimit.c > +++ b/sysdeps/unix/sysv/linux/getrlimit.c > @@ -35,7 +35,16 @@ > int > __new_getrlimit (enum __rlimit_resource resource, struct rlimit *rlim) > { > +#ifdef __ASSUME_RLIM64_SYSCALLS > + return INLINE_SYSCALL_CALL (prlimit64, 0, resource, rlim, NULL); > +#else > +# ifdef __NR_prlimit64 > + long int ret = INLINE_SYSCALL_CALL (prlimit64, 0, resource, rlim, NULL); > + if (ret == 0 || errno != ENOSYS) > + return ret; > +# endif > return INLINE_SYSCALL_CALL (ugetrlimit, resource, rlim); > +#endif I think that's not correct because with this change, defining __ASSUME_RLIM64_SYSCALLS changes the struct expected by getrlimit. I believe the expectation is that such definitions only alter the set of system calls glibc assumes to be present. They should not affect the external glibc ABI exposed on its function call interface. Thanks, Florian
On Tue, Jun 25, 2019 at 4:11 AM Florian Weimer <fweimer@redhat.com> wrote: > > * Alistair Francis: > > > If the prlimit64 syscall is avaliable let's use that instead of > > ugetrlimit as it isn't always avaliable (they aren't avaliable > > on RV32). > > > diff --git a/sysdeps/unix/sysv/linux/getrlimit.c b/sysdeps/unix/sysv/linux/getrlimit.c > > index 10c0176619..741b065b25 100644 > > --- a/sysdeps/unix/sysv/linux/getrlimit.c > > +++ b/sysdeps/unix/sysv/linux/getrlimit.c > > @@ -35,7 +35,16 @@ > > int > > __new_getrlimit (enum __rlimit_resource resource, struct rlimit *rlim) > > { > > +#ifdef __ASSUME_RLIM64_SYSCALLS > > + return INLINE_SYSCALL_CALL (prlimit64, 0, resource, rlim, NULL); > > +#else > > +# ifdef __NR_prlimit64 > > + long int ret = INLINE_SYSCALL_CALL (prlimit64, 0, resource, rlim, NULL); > > + if (ret == 0 || errno != ENOSYS) > > + return ret; > > +# endif > > return INLINE_SYSCALL_CALL (ugetrlimit, resource, rlim); > > +#endif > > I think that's not correct because with this change, defining > __ASSUME_RLIM64_SYSCALLS changes the struct expected by getrlimit. I'm not clear what you mean here, why is the struct expected by getrlimit different? > I believe the expectation is that such definitions only alter the set of > system calls glibc assumes to be present. They should not affect the > external glibc ABI exposed on its function call interface. I agree, I don't see how this changes the function call interface though. Alistair > > Thanks, > Florian
* Alistair Francis: > On Tue, Jun 25, 2019 at 4:11 AM Florian Weimer <fweimer@redhat.com> wrote: >> >> * Alistair Francis: >> >> > If the prlimit64 syscall is avaliable let's use that instead of >> > ugetrlimit as it isn't always avaliable (they aren't avaliable >> > on RV32). >> >> > diff --git a/sysdeps/unix/sysv/linux/getrlimit.c b/sysdeps/unix/sysv/linux/getrlimit.c >> > index 10c0176619..741b065b25 100644 >> > --- a/sysdeps/unix/sysv/linux/getrlimit.c >> > +++ b/sysdeps/unix/sysv/linux/getrlimit.c >> > @@ -35,7 +35,16 @@ >> > int >> > __new_getrlimit (enum __rlimit_resource resource, struct rlimit *rlim) >> > { >> > +#ifdef __ASSUME_RLIM64_SYSCALLS >> > + return INLINE_SYSCALL_CALL (prlimit64, 0, resource, rlim, NULL); >> > +#else >> > +# ifdef __NR_prlimit64 >> > + long int ret = INLINE_SYSCALL_CALL (prlimit64, 0, resource, rlim, NULL); >> > + if (ret == 0 || errno != ENOSYS) >> > + return ret; >> > +# endif >> > return INLINE_SYSCALL_CALL (ugetrlimit, resource, rlim); >> > +#endif >> >> I think that's not correct because with this change, defining >> __ASSUME_RLIM64_SYSCALLS changes the struct expected by getrlimit. > > I'm not clear what you mean here, why is the struct expected by > getrlimit different? On current 32-bit architectures, ugetrlimit expects a 32-bit rlim_t type. But prlimit64 assumes a 64-bit rlim_t type. Maybe this goes wrong in either case, just by the existence of the prlimit64 system call number, whether or not __ASSUME_RLIM64_SYSCALLS is defined. But maybe I'm missing something? Thanks, Florian
On Tue, Jun 25, 2019 at 2:10 PM Florian Weimer <fweimer@redhat.com> wrote: > > * Alistair Francis: > > > On Tue, Jun 25, 2019 at 4:11 AM Florian Weimer <fweimer@redhat.com> wrote: > >> > >> * Alistair Francis: > >> > >> > If the prlimit64 syscall is avaliable let's use that instead of > >> > ugetrlimit as it isn't always avaliable (they aren't avaliable > >> > on RV32). > >> > >> > diff --git a/sysdeps/unix/sysv/linux/getrlimit.c b/sysdeps/unix/sysv/linux/getrlimit.c > >> > index 10c0176619..741b065b25 100644 > >> > --- a/sysdeps/unix/sysv/linux/getrlimit.c > >> > +++ b/sysdeps/unix/sysv/linux/getrlimit.c > >> > @@ -35,7 +35,16 @@ > >> > int > >> > __new_getrlimit (enum __rlimit_resource resource, struct rlimit *rlim) > >> > { > >> > +#ifdef __ASSUME_RLIM64_SYSCALLS > >> > + return INLINE_SYSCALL_CALL (prlimit64, 0, resource, rlim, NULL); > >> > +#else > >> > +# ifdef __NR_prlimit64 > >> > + long int ret = INLINE_SYSCALL_CALL (prlimit64, 0, resource, rlim, NULL); > >> > + if (ret == 0 || errno != ENOSYS) > >> > + return ret; > >> > +# endif > >> > return INLINE_SYSCALL_CALL (ugetrlimit, resource, rlim); > >> > +#endif > >> > >> I think that's not correct because with this change, defining > >> __ASSUME_RLIM64_SYSCALLS changes the struct expected by getrlimit. > > > > I'm not clear what you mean here, why is the struct expected by > > getrlimit different? > > On current 32-bit architectures, ugetrlimit expects a 32-bit rlim_t > type. But prlimit64 assumes a 64-bit rlim_t type. Maybe this goes > wrong in either case, just by the existence of the prlimit64 system call > number, whether or not __ASSUME_RLIM64_SYSCALLS is defined. Ah, I see what you mean now. Yes they do end up being different rlimit structs. I also just realised that I don't need this patch, as __RLIM_T_MATCHES_RLIM64_T is now defined, I'm going to drop this patch. Alistair > > But maybe I'm missing something? > > Thanks, > Florian
diff --git a/ChangeLog b/ChangeLog index 9ed9bea8b1..1f1070ebc3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,7 @@ * sysdeps/unix/sysv/linux/wait.c: Use __NR_waitid if avaliable. * sysdeps/unix/sysv/linux/waitpid.c: Likewise. * sysdeps/unix/sysv/linux/waitpid_nocancel.c: Likewise. + * sysdeps/unix/sysv/linux/getrlimit.c: Use __NR_prlimit64 if avaliable 2019-06-20 Dmitry V. Levin <ldv@altlinux.org> Florian Weimer <fweimer@redhat.com> diff --git a/sysdeps/unix/sysv/linux/getrlimit.c b/sysdeps/unix/sysv/linux/getrlimit.c index 10c0176619..741b065b25 100644 --- a/sysdeps/unix/sysv/linux/getrlimit.c +++ b/sysdeps/unix/sysv/linux/getrlimit.c @@ -35,7 +35,16 @@ int __new_getrlimit (enum __rlimit_resource resource, struct rlimit *rlim) { +#ifdef __ASSUME_RLIM64_SYSCALLS + return INLINE_SYSCALL_CALL (prlimit64, 0, resource, rlim, NULL); +#else +# ifdef __NR_prlimit64 + long int ret = INLINE_SYSCALL_CALL (prlimit64, 0, resource, rlim, NULL); + if (ret == 0 || errno != ENOSYS) + return ret; +# endif return INLINE_SYSCALL_CALL (ugetrlimit, resource, rlim); +#endif } weak_alias (__new_getrlimit, __getrlimit) hidden_weak (__getrlimit)