* [PATCH] Use __kernel_long_t/__kernel_ulong_t in <linux/resource.h>
@ 2013-12-25 14:54 H.J. Lu
2013-12-26 10:03 ` Christoph Hellwig
2013-12-26 15:36 ` H.J. Lu
0 siblings, 2 replies; 8+ messages in thread
From: H.J. Lu @ 2013-12-25 14:54 UTC (permalink / raw)
To: H. Peter Anvin, LKML
Both x32 and x86-64 use the same struct rusage and struct rlimit for
system calls. But x32 log is 32-bit. This patch change uapi
<linux/resource.h> to use __kernel_long_t in struct rusage and
__kernel_ulong_t in and struct rlimit.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
---
include/uapi/linux/resource.h | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/include/uapi/linux/resource.h b/include/uapi/linux/resource.h
index e0ed284..36fb3b5 100644
--- a/include/uapi/linux/resource.h
+++ b/include/uapi/linux/resource.h
@@ -23,25 +23,25 @@
struct rusage {
struct timeval ru_utime; /* user time used */
struct timeval ru_stime; /* system time used */
- long ru_maxrss; /* maximum resident set size */
- long ru_ixrss; /* integral shared memory size */
- long ru_idrss; /* integral unshared data size */
- long ru_isrss; /* integral unshared stack size */
- long ru_minflt; /* page reclaims */
- long ru_majflt; /* page faults */
- long ru_nswap; /* swaps */
- long ru_inblock; /* block input operations */
- long ru_oublock; /* block output operations */
- long ru_msgsnd; /* messages sent */
- long ru_msgrcv; /* messages received */
- long ru_nsignals; /* signals received */
- long ru_nvcsw; /* voluntary context switches */
- long ru_nivcsw; /* involuntary " */
+ __kernel_long_t ru_maxrss; /* maximum resident set size */
+ __kernel_long_t ru_ixrss; /* integral shared memory size */
+ __kernel_long_t ru_idrss; /* integral unshared data size */
+ __kernel_long_t ru_isrss; /* integral unshared stack size */
+ __kernel_long_t ru_minflt; /* page reclaims */
+ __kernel_long_t ru_majflt; /* page faults */
+ __kernel_long_t ru_nswap; /* swaps */
+ __kernel_long_t ru_inblock; /* block input operations */
+ __kernel_long_t ru_oublock; /* block output operations */
+ __kernel_long_t ru_msgsnd; /* messages sent */
+ __kernel_long_t ru_msgrcv; /* messages received */
+ __kernel_long_t ru_nsignals; /* signals received */
+ __kernel_long_t ru_nvcsw; /* voluntary context switches */
+ __kernel_long_t ru_nivcsw; /* involuntary " */
};
struct rlimit {
- unsigned long rlim_cur;
- unsigned long rlim_max;
+ __kernel_ulong_t rlim_cur;
+ __kernel_ulong_t rlim_max;
};
#define RLIM64_INFINITY (~0ULL)
--
1.8.4.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] Use __kernel_long_t/__kernel_ulong_t in <linux/resource.h>
2013-12-25 14:54 [PATCH] Use __kernel_long_t/__kernel_ulong_t in <linux/resource.h> H.J. Lu
@ 2013-12-26 10:03 ` Christoph Hellwig
2013-12-26 13:52 ` H.J. Lu
2013-12-26 15:36 ` H.J. Lu
1 sibling, 1 reply; 8+ messages in thread
From: Christoph Hellwig @ 2013-12-26 10:03 UTC (permalink / raw)
To: H.J. Lu; +Cc: H. Peter Anvin, LKML
On Wed, Dec 25, 2013 at 06:54:47AM -0800, H.J. Lu wrote:
> Both x32 and x86-64 use the same struct rusage and struct rlimit for
> system calls. But x32 log is 32-bit. This patch change uapi
> <linux/resource.h> to use __kernel_long_t in struct rusage and
> __kernel_ulong_t in and struct rlimit.
a) please send all your related patches as a series
b) explain how these changes to shared ABI headers:
1) do not break any architecture, especially mips N32 which is
the MIPS equivalent of x32
2) do not break existing x32 binaries
3) fix existing and future x32 binaries
c) why you suddenly need these changes now and not when the x32 ABI
support was submitted and hopefully heavily tested
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Use __kernel_long_t/__kernel_ulong_t in <linux/resource.h>
2013-12-26 10:03 ` Christoph Hellwig
@ 2013-12-26 13:52 ` H.J. Lu
2013-12-26 13:54 ` H.J. Lu
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: H.J. Lu @ 2013-12-26 13:52 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: H. Peter Anvin, LKML
On Thu, Dec 26, 2013 at 2:03 AM, Christoph Hellwig <hch@infradead.org> wrote:
> On Wed, Dec 25, 2013 at 06:54:47AM -0800, H.J. Lu wrote:
>> Both x32 and x86-64 use the same struct rusage and struct rlimit for
>> system calls. But x32 log is 32-bit. This patch change uapi
>> <linux/resource.h> to use __kernel_long_t in struct rusage and
>> __kernel_ulong_t in and struct rlimit.
>
> a) please send all your related patches as a series
My patches are independent of each other. They can
be applied in order.
> b) explain how these changes to shared ABI headers:
>
> 1) do not break any architecture, especially mips N32 which is
> the MIPS equivalent of x32
I am not familiar with N32 system call interface. My patch
may break N32 if N32 __kernel_long_t doesn't match
what is used. I will update my patches to limit my changes
to __BITS_PER_LONG == 64.
> 2) do not break existing x32 binaries
> 3) fix existing and future x32 binaries
My patches just update kernel uabi header files to match
x32 system calls. They don't break any x32 binaries,
current and future.
> c) why you suddenly need these changes now and not when the x32 ABI
> support was submitted and hopefully heavily tested
Kernel headers had been wrong for -m32/-mx32 on x86-64
for a long long time. Linux/x86-64 normally use header
files from glibc, which avoids broken kernel header files.
Kernel uabi header files fix -m32, but not -mx32, which I am
working on now.
Thanks.
--
H.J.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Use __kernel_long_t/__kernel_ulong_t in <linux/resource.h>
2013-12-26 13:52 ` H.J. Lu
@ 2013-12-26 13:54 ` H.J. Lu
2013-12-26 17:58 ` H. Peter Anvin
2013-12-26 19:13 ` H. Peter Anvin
2 siblings, 0 replies; 8+ messages in thread
From: H.J. Lu @ 2013-12-26 13:54 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: H. Peter Anvin, LKML
On Thu, Dec 26, 2013 at 5:52 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Thu, Dec 26, 2013 at 2:03 AM, Christoph Hellwig <hch@infradead.org> wrote:
>> On Wed, Dec 25, 2013 at 06:54:47AM -0800, H.J. Lu wrote:
>>> Both x32 and x86-64 use the same struct rusage and struct rlimit for
>>> system calls. But x32 log is 32-bit. This patch change uapi
>>> <linux/resource.h> to use __kernel_long_t in struct rusage and
>>> __kernel_ulong_t in and struct rlimit.
>>
>> a) please send all your related patches as a series
>
> My patches are independent of each other. They can
> be applied in order.
>
I meant to say "they can be applied in any order."
--
H.J.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Use __kernel_long_t/__kernel_ulong_t in <linux/resource.h>
2013-12-25 14:54 [PATCH] Use __kernel_long_t/__kernel_ulong_t in <linux/resource.h> H.J. Lu
2013-12-26 10:03 ` Christoph Hellwig
@ 2013-12-26 15:36 ` H.J. Lu
1 sibling, 0 replies; 8+ messages in thread
From: H.J. Lu @ 2013-12-26 15:36 UTC (permalink / raw)
To: H. Peter Anvin, LKML
[-- Attachment #1: Type: text/plain, Size: 408 bytes --]
On Wed, Dec 25, 2013 at 06:54:47AM -0800, H.J. Lu wrote:
> Both x32 and x86-64 use the same struct rusage and struct rlimit for
> system calls. But x32 log is 32-bit. This patch change uapi
> <linux/resource.h> to use __kernel_long_t in struct rusage and
> __kernel_ulong_t in and struct rlimit.
Here is the updated patch which uses __kernel_long_t/__kernel_ulong_t
only if __BITS_PER_LONG == 64.
H.J.
[-- Attachment #2: 0002-Use-__kernel_long_t-__kernel_ulong_t-in-linux-resour.patch --]
[-- Type: text/plain, Size: 2376 bytes --]
>From d2a3409eb9aecd545a3f9c384dd55cfc870122ac Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Wed, 25 Dec 2013 06:50:33 -0800
Subject: [PATCH] Use __kernel_long_t/__kernel_ulong_t in <linux/resource.h>
Both x32 and x86-64 use the same struct rusage and struct rlimit for
system calls. But x32 log is 32-bit. This patch change uapi
<linux/resource.h> to use __kernel_long_t in struct rusage and
__kernel_ulong_t in and struct rlimit if __BITS_PER_LONG == 64.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
---
include/uapi/linux/resource.h | 26 ++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
diff --git a/include/uapi/linux/resource.h b/include/uapi/linux/resource.h
index e0ed284..87d2daa 100644
--- a/include/uapi/linux/resource.h
+++ b/include/uapi/linux/resource.h
@@ -23,6 +23,22 @@
struct rusage {
struct timeval ru_utime; /* user time used */
struct timeval ru_stime; /* system time used */
+#if __BITS_PER_LONG == 64
+ __kernel_long_t ru_maxrss; /* maximum resident set size */
+ __kernel_long_t ru_ixrss; /* integral shared memory size */
+ __kernel_long_t ru_idrss; /* integral unshared data size */
+ __kernel_long_t ru_isrss; /* integral unshared stack size */
+ __kernel_long_t ru_minflt; /* page reclaims */
+ __kernel_long_t ru_majflt; /* page faults */
+ __kernel_long_t ru_nswap; /* swaps */
+ __kernel_long_t ru_inblock; /* block input operations */
+ __kernel_long_t ru_oublock; /* block output operations */
+ __kernel_long_t ru_msgsnd; /* messages sent */
+ __kernel_long_t ru_msgrcv; /* messages received */
+ __kernel_long_t ru_nsignals; /* signals received */
+ __kernel_long_t ru_nvcsw; /* voluntary context switches */
+ __kernel_long_t ru_nivcsw; /* involuntary " */
+#else
long ru_maxrss; /* maximum resident set size */
long ru_ixrss; /* integral shared memory size */
long ru_idrss; /* integral unshared data size */
@@ -37,11 +53,17 @@ struct rusage {
long ru_nsignals; /* signals received */
long ru_nvcsw; /* voluntary context switches */
long ru_nivcsw; /* involuntary " */
+#endif
};
struct rlimit {
- unsigned long rlim_cur;
- unsigned long rlim_max;
+#if __BITS_PER_LONG == 64
+ __kernel_ulong_t rlim_cur;
+ __kernel_ulong_t rlim_max;
+#else
+ unsigned long rlim_cur;
+ unsigned long rlim_max;
+#endif
};
#define RLIM64_INFINITY (~0ULL)
--
1.8.4.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] Use __kernel_long_t/__kernel_ulong_t in <linux/resource.h>
2013-12-26 13:52 ` H.J. Lu
2013-12-26 13:54 ` H.J. Lu
@ 2013-12-26 17:58 ` H. Peter Anvin
2013-12-26 18:08 ` H.J. Lu
2013-12-26 19:13 ` H. Peter Anvin
2 siblings, 1 reply; 8+ messages in thread
From: H. Peter Anvin @ 2013-12-26 17:58 UTC (permalink / raw)
To: H.J. Lu, Christoph Hellwig; +Cc: LKML
On 12/26/2013 05:52 AM, H.J. Lu wrote:
>
>> c) why you suddenly need these changes now and not when the x32 ABI
>> support was submitted and hopefully heavily tested
>
> Kernel headers had been wrong for -m32/-mx32 on x86-64
> for a long long time. Linux/x86-64 normally use header
> files from glibc, which avoids broken kernel header files.
> Kernel uabi header files fix -m32, but not -mx32, which I am
> working on now.
>
In other words, this work is really part of making *libc make use the
kernel uabi headers, which is a valuable work. The fact that the kernel
headers never got fully ported to x32 is a big reason why x32 is still
labeled experimental.
MIPS N32 and ARM64 ILP32 are x32-like ABIs which of course need to not
be broken. However, currently __kernel_[u]long_t is [unsigned] long for
all ABIs other than x32, so changing [unsigned] long to
__kernel_[u]long_t will be a null change for anything but x32. They
perhaps *SHOULD* be different for N32 or ARM64 ILP32, but that is for
those arch maintainers to set.
However, I believe H.J.'s patches from this morning conditionalizing
this on __BITS_PER_LONG are just plain wrong.
-hpa
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Use __kernel_long_t/__kernel_ulong_t in <linux/resource.h>
2013-12-26 17:58 ` H. Peter Anvin
@ 2013-12-26 18:08 ` H.J. Lu
0 siblings, 0 replies; 8+ messages in thread
From: H.J. Lu @ 2013-12-26 18:08 UTC (permalink / raw)
To: H. Peter Anvin; +Cc: Christoph Hellwig, LKML
[-- Attachment #1: Type: text/plain, Size: 1511 bytes --]
On Thu, Dec 26, 2013 at 9:58 AM, H. Peter Anvin <hpa@zytor.com> wrote:
> On 12/26/2013 05:52 AM, H.J. Lu wrote:
>>
>>> c) why you suddenly need these changes now and not when the x32 ABI
>>> support was submitted and hopefully heavily tested
>>
>> Kernel headers had been wrong for -m32/-mx32 on x86-64
>> for a long long time. Linux/x86-64 normally use header
>> files from glibc, which avoids broken kernel header files.
>> Kernel uabi header files fix -m32, but not -mx32, which I am
>> working on now.
>>
>
> In other words, this work is really part of making *libc make use the
> kernel uabi headers, which is a valuable work. The fact that the kernel
> headers never got fully ported to x32 is a big reason why x32 is still
> labeled experimental.
>
> MIPS N32 and ARM64 ILP32 are x32-like ABIs which of course need to not
> be broken. However, currently __kernel_[u]long_t is [unsigned] long for
> all ABIs other than x32, so changing [unsigned] long to
> __kernel_[u]long_t will be a null change for anything but x32. They
> perhaps *SHOULD* be different for N32 or ARM64 ILP32, but that is for
> those arch maintainers to set.
>
> However, I believe H.J.'s patches from this morning conditionalizing
> this on __BITS_PER_LONG are just plain wrong.
FWIW, I prefer my first alternative. I only added the second one
since I can't test for other ABIs.
I am enclosing my kernel header file checker. It compares
kernel header files against glibc header files for -m64, -m32
and -mx32.
--
H.J.
[-- Attachment #2: kernel-headers.tar.xz --]
[-- Type: application/x-xz, Size: 1296 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Use __kernel_long_t/__kernel_ulong_t in <linux/resource.h>
2013-12-26 13:52 ` H.J. Lu
2013-12-26 13:54 ` H.J. Lu
2013-12-26 17:58 ` H. Peter Anvin
@ 2013-12-26 19:13 ` H. Peter Anvin
2 siblings, 0 replies; 8+ messages in thread
From: H. Peter Anvin @ 2013-12-26 19:13 UTC (permalink / raw)
To: H.J. Lu, Christoph Hellwig; +Cc: LKML
On 12/26/2013 05:52 AM, H.J. Lu wrote:
>>
>> a) please send all your related patches as a series
>
> My patches are independent of each other. They can
> be applied in order.
>
Sure, but the convention in the Linux community is to send them all as a
"series" using git send-email, preferably with a introductory cover
letter as the "0/N patch" so they arrive in a single thread and can be
reviewed together. Otherwise bits tend to get lost in the enormous
flood of email that is LKML.
-hpa
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2013-12-26 19:14 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-25 14:54 [PATCH] Use __kernel_long_t/__kernel_ulong_t in <linux/resource.h> H.J. Lu
2013-12-26 10:03 ` Christoph Hellwig
2013-12-26 13:52 ` H.J. Lu
2013-12-26 13:54 ` H.J. Lu
2013-12-26 17:58 ` H. Peter Anvin
2013-12-26 18:08 ` H.J. Lu
2013-12-26 19:13 ` H. Peter Anvin
2013-12-26 15:36 ` H.J. Lu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox