All of lore.kernel.org
 help / color / mirror / Atom feed
From: Deepa Dinamani <deepa.kernel@gmail.com>
To: Dave Chinner <david@fromorbit.com>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	y2038@lists.linaro.org
Subject: Re: [RFC 02/15] vfs: Change all structures to support 64 bit time
Date: Mon, 11 Jan 2016 21:42:36 -0800	[thread overview]
Message-ID: <20160112054235.GA63984@myubuntu.deepaubuntu.g7.internal.cloudapp.net> (raw)
In-Reply-To: <20160110230339.GD10456@dastard>

> On Jan 11, 2016, at 04:33, Dave Chinner <david@fromorbit.com> wrote:
>
>> On Wed, Jan 06, 2016 at 09:35:59PM -0800, Deepa Dinamani wrote:
>> The current representation of inode times in struct inode, struct iattr,
>> and struct kstat use struct timespec. timespec is not y2038 safe.
>>
>> Use scalar data types (seconds and nanoseconds stored separately) to
>> represent timestamps in struct inode in order to maintain same size for
>> times across 32 bit and 64 bit architectures.
>> In addition, lay them out such that they are packed on a naturally
>> aligned boundary on 64 bit arch as 4 bytes are used to store nsec.
>> This makes each tuple(sec, nscec) use 12 bytes instead of 16 bytes.
>> This will help save RAM space as inode structure is cached in memory.
>> The other structures are transient and do not benefit from these
>> changes.
>
> IMO, this decisions sends the patch series immediately down the
> wrong path.

There are other things the patch does that I would like to get comments
on: inode_timespec aliases, range check, individual fs changes etc.
These are independent of the inode timestamp representation changes.

>TO me, this is a severe case of premature optimisation
> because everything gets way more complex just to save those 8 bytes,
> especially as those holes can be filled simply by changing the
> variable declaration order in the structure and adding a simple
> comment.

I had tried rearranging the structure and the pahole tool does not show
any difference unless you pack and align the struct to 4 bytes on 64
bit arch.  The change actually saves 16 bytes on x86_64 and adds 12
bytes on i386.

Here is the breakdown for struct inode before and after the patch:

x86_64:
/* size: 544, cachelines: 9, members: 44 */           |
/* size: 528, cachelines: 9, members: 47 */
/* sum members: 534, holes: 3, sum holes: 10 */       |
/* sum members: 522, holes: 2, sum holes: 6 */

i386:
/* size: 328, cachelines: 6, members: 45 */           |
/* size: 340, cachelines: 6, members: 48 */
/* sum members: 326, holes: 1, sum holes: 2 */        |
/* sum members: 338, holes: 1, sum holes: 2 */

According to /proc/slabinfo I estimated savings of 4MB on a lightly
loaded system.

> And, really, I don't like those VFS_INODE_[GS]ET_XTIME macros at
> all; you've got to touch lots of code(*), making it all shouty and
> harder to read.  They seem only to exist because of the above
> structural change requires an abstract timestamp accessor while
> CONFIG_FS_USES_64BIT_TIME exists.
> Given that goes away at the end o
> the series, so should the macro - if we use a struct timespec64 in
> the first place, it isn't even necessary as a temporary construct

timespec64 was the first option considered here.  The problem with using
timespec64 is the long data type to represent nsec.  If it were possible
to change timespec64 nsec to int data type then it might be okay  to use
that if we are not worried about holes.  I do not see why time stamps
should have different representations on a 32 bit vs a 64 bit arch.
This left us with the option define a new data type to represent
timestamps.  I agreed with the concerns on the earlier RFC series that
there are already very many data types to represent time in the kernel.
So this left me with the option of using scalar types to represent these.
The scalar types were not used for optimization. They just happened to
serve that purpose as well.  This could be in a follow on patch, but as
long as we are changing the representation everywhere, I don't see why
there should be an intermediate step to change it to timespec64 only to
change it to this representation later.

As far as accessors are concerned, there already are accessors in the
VFS: generic_fillattr() and setattr_copy(). The problem really is that
there is more than one way of updating these attributes(timestamps in
this particular case). The side effect of this is that we don't always
call timespec_trunc() before assigning timestamps which can lead to
inconsistencies between on disk and in memory inode timestamps. Also,
since these also touch other attributes, these become more restrictive.
The accessors were an idea to streamline all accesses to timestamps in
inode.  Right now the accessor macros also figure out if the timestamps
were clamped and then call the registered callback.  But, this can be
extended to include fs_time_trunc() and then all the end users can
just use these and not worry about the right granularity or range.
As the commit text says, these can be changed to inline functions to
avoid shouty case.

> (*) I note you haven't touched XFS, which means you've probably
> broken lots of other filesystem code. e.g. in XFS, functions like
> xfs_vn_getattr() and xfs_vn_update_time() access inode->i_[acm]time
> directly and hence are not going to compile after this patch series.

I think I should have explained this more in my cover letter, as this
has come up twice now.  Patches 1-7 are the only ones that are relevant
and compiled and tested.  These change three example filesystems as an
illustration of the proposed solution.  Of course, every filesystem will
have to be changed similarly before patches 8-15 and a few more to change
additional filesystems to use timespec64 can be merged.  Patches 8-15 were
included merely to provide a complete picture, as I thought patches
explained the concept better than words only. These have not even been
compiled, as these are for illustration purposes as noted in the cover
letter.

-Deepa

  reply	other threads:[~2016-01-12  5:43 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-07  5:35 [RFC 00/15] Add 64 bit timestamp support Deepa Dinamani
2016-01-07  5:35 ` [RFC 01/15] fs: add Kconfig entry CONFIG_FS_USES_64BIT_TIME Deepa Dinamani
2016-01-07  5:35 ` [RFC 02/15] vfs: Change all structures to support 64 bit time Deepa Dinamani
2016-01-10 23:03   ` Dave Chinner
2016-01-12  5:42     ` Deepa Dinamani [this message]
2016-01-12  8:29       ` Dave Chinner
2016-01-12  9:27         ` [Y2038] " Arnd Bergmann
2016-01-13  6:27           ` Dave Chinner
2016-01-13  9:20             ` Arnd Bergmann
2016-01-13  9:20               ` Arnd Bergmann
2016-01-13 16:33         ` Deepa Dinamani
2016-01-13 21:04           ` Dave Chinner
2016-01-14 16:53             ` [Y2038] " Arnd Bergmann
2016-01-14 18:00               ` Deepa Dinamani
2016-01-14 21:00               ` Dave Chinner
2016-01-14 22:46                 ` Arnd Bergmann
2016-01-14 22:54                   ` Arnd Bergmann
2016-01-15  2:27                     ` Dave Chinner
2016-01-15 17:01                       ` Arnd Bergmann
2016-01-15 22:41                         ` Dave Chinner
2016-01-15  2:49                   ` Dave Chinner
2016-01-15 16:50                     ` Arnd Bergmann
2016-01-16 19:14                       ` Andreas Dilger
2016-01-16 23:36                         ` Arnd Bergmann
2016-01-17  2:30                           ` Andreas Dilger
2016-01-18  6:09                             ` Deepa Dinamani
2016-01-18 10:56                               ` Arnd Bergmann
2016-01-18 17:40                                 ` Deepa Dinamani
2016-01-18 19:53                                   ` Arnd Bergmann
2016-01-18 21:14                                     ` Dave Chinner
2016-01-18 21:46                                       ` Arnd Bergmann
2016-01-19  1:38                                         ` Dave Chinner
2016-01-19  5:27                                           ` Deepa Dinamani
2016-01-19 20:49                                             ` Dave Chinner
2016-01-19 22:25                                               ` Arnd Bergmann
2016-01-20  5:12                                                 ` Deepa Dinamani
2016-01-20 15:04                                                   ` Deepa Dinamani
2016-01-20 23:06                                                 ` Dave Chinner
2016-01-20 23:17                                                   ` [Y2038] " Arnd Bergmann
2016-01-27  6:26                                                     ` Deepa Dinamani
2016-01-15  5:03                 ` Deepa Dinamani
2016-01-07  5:36 ` [RFC 03/15] kernel: time: Add macros and functions " Deepa Dinamani
2016-01-07  5:36 ` [RFC 04/15] vfs: Add support for vfs code to use " Deepa Dinamani
2016-01-07  5:36 ` [RFC 05/15] fs: cifs: Add support for cifs " Deepa Dinamani
2016-01-07  5:36 ` [RFC 06/15] fs: fat: convert fat to " Deepa Dinamani
2016-01-07  5:36 ` [RFC 07/15] fs: ext4: convert to use " Deepa Dinamani
2016-01-07  5:36 ` [RFC 08/15] fs: Enable " Deepa Dinamani
2016-01-07  5:36 ` [RFC 09/15] fs: cifs: replace inode_timespec with timespec64 Deepa Dinamani
2016-01-07  5:36 ` [RFC 10/15] fs: fat: " Deepa Dinamani
2016-01-07  5:36 ` [RFC 11/15] fs: ext4: " Deepa Dinamani
2016-01-07  5:36 ` [RFC 12/15] vfs: remove inode_timespec and timespec references Deepa Dinamani
2016-01-07  5:36 ` [RFC 13/15] kernel: time: change inode_timespec to timespec64 Deepa Dinamani
2016-01-07  8:50   ` Michael Adam
2016-01-07 10:42     ` Deepa Dinamani
2016-01-07  5:36 ` [RFC 14/15] vfs: Remove inode_timespec aliases Deepa Dinamani
2016-01-07  5:36 ` [RFC 15/15] fs: Drop CONFIG_FS_USES_64BIT_TIME Deepa Dinamani

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160112054235.GA63984@myubuntu.deepaubuntu.g7.internal.cloudapp.net \
    --to=deepa.kernel@gmail.com \
    --cc=david@fromorbit.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=y2038@lists.linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.