Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1427856

Re: [Y2038] [PATCH v2 00/24] Delete CURRENT_TIME and CURRENT_TIME_SEC macros

From Arnd Bergmann <arnd@arndb.de>
Newsgroups linux.kernel
Subject Re: [Y2038] [PATCH v2 00/24] Delete CURRENT_TIME and CURRENT_TIME_SEC macros
Date 2016-06-21 17:10 +0200
Message-ID <rMvtn-7tu-3@gated-at.bofh.it> (permalink)
References <rLVgd-11C-1@gated-at.bofh.it> <rMbO1-3aM-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Monday, June 20, 2016 11:03:01 AM CEST you wrote:
> On Sun, Jun 19, 2016 at 5:26 PM, Deepa Dinamani <deepa.kernel@gmail.com> wrote:
> > The series is aimed at getting rid of CURRENT_TIME and CURRENT_TIME_SEC macros.

> Gcc handles 8-byte structure returns (on most architectures) by
> returning them as two 32-bit registers (%edx:%eax on x86). But once it
> is timespec64, that will no longer be the case, and the calling
> convention will end up using a pointer to the local stack instead.

I guess we already have that today, as the implementation of
current_fs_time() is

static inline struct timespec64 tk_xtime(struct timekeeper *tk)
{
        struct timespec64 ts;

        ts.tv_sec = tk->xtime_sec;
        ts.tv_nsec = (long)(tk->tkr_mono.xtime_nsec >> tk->tkr_mono.shift);
        return ts;
}
extern struct timespec64 current_kernel_time64(void);
struct timespec64 current_kernel_time64(void)
{
        struct timekeeper *tk = &tk_core.timekeeper;
        struct timespec64 now;
        unsigned long seq;

        do {
                seq = read_seqcount_begin(&tk_core.seq);

                now = tk_xtime(tk);
        } while (read_seqcount_retry(&tk_core.seq, seq));

        return now;
}
static inline struct timespec current_kernel_time(void)
{
        struct timespec64 now = current_kernel_time64();

        return timespec64_to_timespec(now);
}
extern struct timespec current_fs_time(struct super_block *sb);
struct timespec current_fs_time(struct super_block *sb)
{       
        struct timespec now = current_kernel_time();
        return timespec_trunc(now, sb->s_time_gran);
}       

We can surely do a little better than this, independent of the
conversion in Deepa's patch set.

> So for 32-bit code generation, we *may* want to introduce a new model of doing
> 
>     set_inode_time(inode, ATTR_ATIME | ATTR_MTIME);
> 
> which basically just does
> 
>     inode->i_atime = inode->i_mtime = current_time(inode);
> 
> but with a much easier calling convention on 32-bit architectures.
> 
> But that is entirely orthogonal to this patch-set, and should be seen
> as a separate issue.

I've played around with that, but found it hard to avoid going
through memory other than going all the way to the tk_xtime()
access to copy both tk->xtime_sec and the nanoseconds into
the inode fields.

Without that, the set_inode_time() implementation ends up
being more expensive than
inode->i_atime = inode->i_ctime = inode->i_mtime = current_time(inode);
because we still copy through the stack but also have
a couple of conditional branches that we don't have at the
moment.

At the moment, the triple assignment becomes (here on ARM)

   c:   4668            mov     r0, sp
  12:   f7ff fffe       bl      0 <current_kernel_time64>
  3e:   f107 0520       add.w   r5, r7, #32
                        12: R_ARM_THM_CALL      current_kernel_time64
  16:   f106 0410       add.w   r4, r6, #16
  1a:   e89d 000f       ldmia.w sp, {r0, r1, r2, r3} # load from stack
  1e:   e885 000f       stmia.w r5, {r0, r1, r2, r3} # store into i_atime
  22:   e884 000f       stmia.w r4, {r0, r1, r2, r3} #            i_ctime
  26:   e886 000f       stmia.w r6, {r0, r1, r2, r3} #            i_mtime

and a slightly more verbose version of the same thing on x86
(storing only 12 bytes instead of 16 is cheaper there, while
ARM does a store-multiple to copy the entire structure).

        Arnd

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2 00/24] Delete CURRENT_TIME and CURRENT_TIME_SEC macros Deepa Dinamani <deepa.kernel@gmail.com> - 2016-06-20 02:30 +0200
  [PATCH v2 10/24] fs: cifs: Replace CURRENT_TIME by current_time() Deepa Dinamani <deepa.kernel@gmail.com> - 2016-06-20 02:30 +0200
  [PATCH v2 09/24] fs: udf: Replace CURRENT_TIME with current_time() Deepa Dinamani <deepa.kernel@gmail.com> - 2016-06-20 02:30 +0200
    Re: [Y2038] [PATCH v2 09/24] fs: udf: Replace CURRENT_TIME with current_time() Arnd Bergmann <arnd@arndb.de> - 2016-06-22 16:10 +0200
      Re: [Y2038] [PATCH v2 09/24] fs: udf: Replace CURRENT_TIME with current_time() Deepa Dinamani <deepa.kernel@gmail.com> - 2016-06-23 04:00 +0200
  [PATCH v2 07/24] fs: ubifs: Replace CURRENT_TIME_SEC with current_time Deepa Dinamani <deepa.kernel@gmail.com> - 2016-06-20 02:30 +0200
    Re: [PATCH v2 07/24] fs: ubifs: Replace CURRENT_TIME_SEC with current_time Arnd Bergmann <arnd@arndb.de> - 2016-06-22 15:50 +0200
  [PATCH v2 01/24] vfs: Add current_time() api Deepa Dinamani <deepa.kernel@gmail.com> - 2016-06-20 02:30 +0200
  [PATCH v2 06/24] fs: ext4: Use current_time() for inode timestamps Deepa Dinamani <deepa.kernel@gmail.com> - 2016-06-20 02:30 +0200
    Re: [PATCH v2 06/24] fs: ext4: Use current_time() for inode timestamps Arnd Bergmann <arnd@arndb.de> - 2016-06-22 15:40 +0200
  [PATCH v2 11/24] fs: cifs: Replace CURRENT_TIME with ktime_get_real_ts() Deepa Dinamani <deepa.kernel@gmail.com> - 2016-06-20 02:40 +0200
  [PATCH v2 05/24] fs: jfs: Replace CURRENT_TIME_SEC by current_time() Deepa Dinamani <deepa.kernel@gmail.com> - 2016-06-20 02:40 +0200
    Re: [Jfs-discussion] [PATCH v2 05/24] fs: jfs: Replace  CURRENT_TIME_SEC by current_time() Dave Kleikamp <dave.kleikamp@oracle.com> - 2016-06-20 21:20 +0200
  [PATCH v2 24/24] time: Delete current_fs_time() function Deepa Dinamani <deepa.kernel@gmail.com> - 2016-06-20 02:40 +0200
  [PATCH v2 23/24] time: Delete CURRENT_TIME_SEC and CURRENT_TIME macro Deepa Dinamani <deepa.kernel@gmail.com> - 2016-06-20 02:40 +0200
    Re: [PATCH v2 23/24] time: Delete CURRENT_TIME_SEC and CURRENT_TIME macro Arnd Bergmann <arnd@arndb.de> - 2016-06-22 17:50 +0200
  [PATCH v2 08/24] fs: btrfs: Use ktime_get_real_ts for root ctime Deepa Dinamani <deepa.kernel@gmail.com> - 2016-06-20 02:40 +0200
    Re: [PATCH v2 08/24] fs: btrfs: Use ktime_get_real_ts for root ctime David Sterba <dsterba@suse.cz> - 2016-06-20 11:50 +0200
  [PATCH v2 04/24] fs: Replace current_fs_time() with current_time() Deepa Dinamani <deepa.kernel@gmail.com> - 2016-06-20 02:40 +0200
  [PATCH v2 18/24] fs: nfs: Make nfs boot time y2038 safe Deepa Dinamani <deepa.kernel@gmail.com> - 2016-06-20 02:50 +0200
  [PATCH v2 16/24] fs: ocfs2: Replace CURRENT_TIME with ktime_get_real_seconds() Deepa Dinamani <deepa.kernel@gmail.com> - 2016-06-20 02:50 +0200
  [PATCH v2 22/24] fs: ceph: Replace current_fs_time for request stamp Deepa Dinamani <deepa.kernel@gmail.com> - 2016-06-20 02:50 +0200
  [PATCH v2 17/24] audit: Use timespec64 to represent audit timestamps Deepa Dinamani <deepa.kernel@gmail.com> - 2016-06-20 02:50 +0200
    Re: [PATCH v2 17/24] audit: Use timespec64 to represent audit  timestamps Richard Guy Briggs <rgb@redhat.com> - 2016-06-20 17:20 +0200
  [PATCH v2 19/24] fnic: Use time64_t to represent trace timestamps Deepa Dinamani <deepa.kernel@gmail.com> - 2016-06-20 03:30 +0200
    Re: [PATCH v2 19/24] fnic: Use time64_t to represent trace timestamps Arnd Bergmann <arnd@arndb.de> - 2016-06-22 16:10 +0200
      Re: [PATCH v2 19/24] fnic: Use time64_t to represent trace timestamps Deepa Dinamani <deepa.kernel@gmail.com> - 2016-06-23 04:00 +0200
  [PATCH v2 13/24] fs: f2fs: Use ktime_get_real_seconds for sit_info times Deepa Dinamani <deepa.kernel@gmail.com> - 2016-06-20 03:30 +0200
  [PATCH v2 14/24] drivers: staging: lustre: Replace CURRENT_TIME with current_time() Deepa Dinamani <deepa.kernel@gmail.com> - 2016-06-20 03:40 +0200
  [PATCH v2 15/24] fs: ocfs2: Use time64_t to represent orphan scan times Deepa Dinamani <deepa.kernel@gmail.com> - 2016-06-20 03:40 +0200
  [PATCH v2 21/24] libceph: Replace CURRENT_TIME with ktime_get_real_ts Deepa Dinamani <deepa.kernel@gmail.com> - 2016-06-20 03:40 +0200
  [PATCH v2 12/24] fs: cifs: Replace CURRENT_TIME by get_seconds Deepa Dinamani <deepa.kernel@gmail.com> - 2016-06-20 03:40 +0200
  [PATCH v2 20/24] block: Replace CURRENT_TIME with ktime_get_real_ts Deepa Dinamani <deepa.kernel@gmail.com> - 2016-06-20 04:40 +0200
  Re: [PATCH v2 00/24] Delete CURRENT_TIME and CURRENT_TIME_SEC macros Linus Torvalds <torvalds@linux-foundation.org> - 2016-06-20 20:10 +0200
    Re: [PATCH v2 00/24] Delete CURRENT_TIME and CURRENT_TIME_SEC macros Deepa Dinamani <deepa.kernel@gmail.com> - 2016-06-20 21:00 +0200
    Re: [Y2038] [PATCH v2 00/24] Delete CURRENT_TIME and CURRENT_TIME_SEC macros Arnd Bergmann <arnd@arndb.de> - 2016-06-21 17:10 +0200
  Re: [Y2038] [PATCH v2 00/24] Delete CURRENT_TIME and CURRENT_TIME_SEC macros Arnd Bergmann <arnd@arndb.de> - 2016-06-22 18:00 +0200

csiph-web