All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: y2038@lists.linaro.org
Cc: achim_leubner@adaptec.com, JBottomley@odin.com,
	Alison Schofield <amsfield22@gmail.com>,
	linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org
Subject: Re: [PATCH v2] scsi: gdth: replace struct timeval with ktime_get_real_seconds()
Date: Wed, 25 Nov 2015 10:03:57 +0100	[thread overview]
Message-ID: <3133545.iF2pfcmJbC@wuerfel> (raw)
In-Reply-To: <1448412247-2716-1-git-send-email-amsfield22@gmail.com>

On Tuesday 24 November 2015 16:44:07 Alison Schofield wrote:
> struct timeval will overflow on 32-bit systems in y2038 and is being
> removed from the kernel. Replace the use of struct timeval and
> do_gettimeofday() with ktime_get_real_seconds() which provides a 64-bit
> seconds value and is y2038 safe.
> 
> gdth driver requires changes in two areas:
> 
> 1) gdth_store_event() loads two u32 timestamp fields for ioctl GDTIOCTL_EVENT
> 
>    These timestamp fields are part of struct gdth_evt_str used for passing
>    event data to userspace. At the first instance of an event we do
>    (first_stamp=last_stamp="current time"). If that same event repeats,
>    we do (last_stamp="current time") AND increment same_count to indicate
>    how many times the event has repeated since first_stamp.
> 
>    This patch replaces the use of timeval and do_gettimeofday() with
>    ktime_get_real_seconds() cast to u32 to extend the timestamp fields
>    to y2106.
> 
>    Beyond y2106, the userspace tools (ie. RAID controller monitors) can
>    work around the time rollover and this driver would still not need to
>    change.
> 
>    Alternative: The alternative approach is to introduce a new ioctl in gdth
>    with the u32 time fields defined as u64.  This would require userspace
>    changes now, but not in y2106.
> 
> 2)  gdth_show_info() calculates elapsed time using u32 first_stamp
> 
>     It is adding events with timestamps to a seq_file.  Timestamps are
>     calculated as the "current time" minus the first_stamp.
> 
>     This patch replaces the use of timeval and do_gettimeofday() with
>     ktime_get_real_seconds() cast to u32 to calculate the timestamp.
> 
>     This elapsed time calculation is safe even when the time wraps (beyond
>     y2106) due to how unsigned subtraction works. A comment has been added
>     to the code to indicate this safety.
> 
>     Alternative: This piece itself doesn't warrant an alternative, but
>     if we do introduce a new structure & ioctl with u64 timestamps, this
>     would change accordingly.
> 
> Signed-off-by: Alison Schofield <amsfield22@gmail.com>

Reviewed-by: Arnd Bergmann <arnd@arndb.de>
_______________________________________________
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038

WARNING: multiple messages have this Message-ID (diff)
From: Arnd Bergmann <arnd@arndb.de>
To: y2038@lists.linaro.org
Cc: Alison Schofield <amsfield22@gmail.com>,
	achim_leubner@adaptec.com, JBottomley@odin.com,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [Y2038] [PATCH v2] scsi: gdth: replace struct timeval with ktime_get_real_seconds()
Date: Wed, 25 Nov 2015 10:03:57 +0100	[thread overview]
Message-ID: <3133545.iF2pfcmJbC@wuerfel> (raw)
In-Reply-To: <1448412247-2716-1-git-send-email-amsfield22@gmail.com>

On Tuesday 24 November 2015 16:44:07 Alison Schofield wrote:
> struct timeval will overflow on 32-bit systems in y2038 and is being
> removed from the kernel. Replace the use of struct timeval and
> do_gettimeofday() with ktime_get_real_seconds() which provides a 64-bit
> seconds value and is y2038 safe.
> 
> gdth driver requires changes in two areas:
> 
> 1) gdth_store_event() loads two u32 timestamp fields for ioctl GDTIOCTL_EVENT
> 
>    These timestamp fields are part of struct gdth_evt_str used for passing
>    event data to userspace. At the first instance of an event we do
>    (first_stamp=last_stamp="current time"). If that same event repeats,
>    we do (last_stamp="current time") AND increment same_count to indicate
>    how many times the event has repeated since first_stamp.
> 
>    This patch replaces the use of timeval and do_gettimeofday() with
>    ktime_get_real_seconds() cast to u32 to extend the timestamp fields
>    to y2106.
> 
>    Beyond y2106, the userspace tools (ie. RAID controller monitors) can
>    work around the time rollover and this driver would still not need to
>    change.
> 
>    Alternative: The alternative approach is to introduce a new ioctl in gdth
>    with the u32 time fields defined as u64.  This would require userspace
>    changes now, but not in y2106.
> 
> 2)  gdth_show_info() calculates elapsed time using u32 first_stamp
> 
>     It is adding events with timestamps to a seq_file.  Timestamps are
>     calculated as the "current time" minus the first_stamp.
> 
>     This patch replaces the use of timeval and do_gettimeofday() with
>     ktime_get_real_seconds() cast to u32 to calculate the timestamp.
> 
>     This elapsed time calculation is safe even when the time wraps (beyond
>     y2106) due to how unsigned subtraction works. A comment has been added
>     to the code to indicate this safety.
> 
>     Alternative: This piece itself doesn't warrant an alternative, but
>     if we do introduce a new structure & ioctl with u64 timestamps, this
>     would change accordingly.
> 
> Signed-off-by: Alison Schofield <amsfield22@gmail.com>

Reviewed-by: Arnd Bergmann <arnd@arndb.de>

  reply	other threads:[~2015-11-25  9:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20151119214304.GA16713@d830.WORKGROUP>
2015-11-25  0:44 ` [PATCH v2] scsi: gdth: replace struct timeval with ktime_get_real_seconds() Alison Schofield
2015-11-25  0:44   ` Alison Schofield
2015-11-25  9:03   ` Arnd Bergmann [this message]
2015-11-25  9:03     ` [Y2038] " Arnd Bergmann
2016-02-18  5:29 ` [RESEND PATCH " Alison Schofield
2016-02-26  2:17   ` Martin K. Petersen
2016-02-26  2:17     ` Martin K. Petersen

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=3133545.iF2pfcmJbC@wuerfel \
    --to=arnd@arndb.de \
    --cc=JBottomley@odin.com \
    --cc=achim_leubner@adaptec.com \
    --cc=amsfield22@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@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.