msqid_ds/semid_ds/shmid_ds and time fields

Steve Munroe sjmunroe at us.ibm.com
Tue Oct 1 01:38:16 EST 2002


We are trying to clean up the last of the 64-bit glibc-2.2.5 and glibc-2.3
changes for PPC64-linux and have run into a stumbling block.

We are running LTP test and fixing up both PPC32 and PPC64 bugs. And one
the key issues is getting structs used by the glibc and the kernel to
match. Many of the structs used in PPC32 have "unused" and "pad" fields
that don't seem to make any sense for PPC64. For example:

/* Structure of record for one message inside the kernel.
   The type `struct msg' is opaque.  */
struct msqid_ds
{
  struct ipc_perm msg_perm;    /* structure describing operation permission
*/
  unsigned int __unused1;
  __time_t msg_stime;          /* time of last msgsnd command */
  unsigned int __unused2;
  __time_t msg_rtime;          /* time of last msgrcv command */
  unsigned int __unused3;
  __time_t msg_ctime;          /* time of last change */
  unsigned long __msg_cbytes; /* current number of bytes on queue */
  msgqnum_t msg_qnum;          /* number of messages currently on queue */
  msglen_t msg_qbytes;         /* max number of bytes allowed on queue */
  __pid_t msg_lspid;           /* pid of last msgsnd() */
  __pid_t msg_lrpid;           /* pid of last msgrcv() */
  unsigned long __unused4;
  unsigned long __unused5;
};

Note that each __time_t field is preceded with a 32-bit "unused".

We assumed that the intent was to migrate to 64-bit __time_t and that PPC64
should just used a single 64-bit __time_t field without the "unused" cruft.
This aligns the 32-bit __time_t with the low order bits of the 64-bit
__time_t and provides a 64-bit upgrade path to PPC32.

So we defined a common (PPC32/PPC64) glibc powerpc/bits/msq.h as:

struct msqid_ds
{
  struct ipc_perm msg_perm;    /* structure describing operation permission
*/
#if __WORDSIZE == 32
  unsigned int __unused1;
#endif
  __time_t msg_stime;          /* time of last msgsnd command */
#if __WORDSIZE == 32
  unsigned int __unused2;
#endif
  __time_t msg_rtime;          /* time of last msgrcv command */
#if __WORDSIZE == 32
  unsigned int __unused3;
#endif
  __time_t msg_ctime;          /* time of last change */
  unsigned long __msg_cbytes; /* current number of bytes on queue */
  msgqnum_t msg_qnum;          /* number of messages currently on queue */
  msglen_t msg_qbytes;         /* max number of bytes allowed on queue */
  __pid_t msg_lspid;           /* pid of last msgsnd() */
  __pid_t msg_lrpid;           /* pid of last msgrcv() */
  unsigned long __unused4;
  unsigned long __unused5;
};

Which produced (what we though was the desired effect. Ditto for sem.h and
shm.h. But when I submitted the patches to glibc they where rejected with
the following not from Ulrich Drepper:

"That's stupid.  The unused field is meant to be used for sub-second
information.  There is (fortunately) again discussion about adding
support to the kernel.  You'd shut out ppc64 of this, doomed to live
with full second numbers."

When I pointed out to Ulrich the we (PPC64) where only following the lead
of s390 and x86_64 he responded:

"I don't say that these architectures don't have the same problem."

So "kernel folks":

Can anyone point me to the kernel discussions about adding sub-seconds to
structs used in these syscalls?

When sub-seconds are added how should it be layed out:

1) Like above with sub-seconds then seconds as implied above?
2) Replace __time_t with a __timeval (which would be seconds followed by
sub-seconds)?
3) Some other format?


** Sent via the linuxppc64-dev mail list. See http://lists.linuxppc.org/




More information about the Linuxppc64-dev mailing list