This patch replaces timeval with timespec64 as 32 bit 'struct timeval'
will not give current time beyond year 2038.
The patch changes the code to use ktime_get_real_ts64() which returns
a 'struct timespec64' instead of do_gettimeofday() which returns a
'struct timeval'
This patch also alters the format strings in sprintf() for now.tv_sec
and now.tv_nsec to incorporate 'long long' on 32 bit architectures and
leading zeroes respectively.
Signed-off-by: Amitoj Kaur Chawla <amitoj1606(a)gmail.com>
Reviewed-by: Arnd Bergmann <arnd(a)arndb.de>
---
Changes in v2:
-change format string of now.tv_sec to '%llu'
-change format string of now.tv_nsec to '%.08lu'
Changes in v3:
-Replace tv_usec with tv_nsec, error made in v2
-Build tested
Changes in v4:
-Removed checkpatch.pl errors
drivers/misc/ibmasm/ibmasm.h | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/misc/ibmasm/ibmasm.h b/drivers/misc/ibmasm/ibmasm.h
index 9b08344..25be44e 100644
--- a/drivers/misc/ibmasm/ibmasm.h
+++ b/drivers/misc/ibmasm/ibmasm.h
@@ -34,6 +34,7 @@
#include <linux/kref.h>
#include <linux/device.h>
#include <linux/input.h>
+#include <linux/time64.h>
/* Driver identification */
#define DRIVER_NAME "ibmasm"
@@ -53,9 +54,11 @@ extern int ibmasm_debug;
static inline char *get_timestamp(char *buf)
{
- struct timeval now;
- do_gettimeofday(&now);
- sprintf(buf, "%lu.%lu", now.tv_sec, now.tv_usec);
+ struct timespec64 now;
+
+ ktime_get_real_ts64(&now);
+ sprintf(buf, "%llu.%.08lu", (long long)now.tv_sec,
+ now.tv_nsec / NSEC_PER_USEC);
return buf;
}
--
1.9.1
You have received a new fax.
You can find your fax document in the attachment.
Quality: 100 DPI
Date: Mon, 8 Feb 2016 07:59:25 +0300
File size: 215 Kb
Pages sent: 8
Filename: task-00000320199.doc
Scanned in: 53 seconds
Sender: Henry Pace
Thanks for choosing Interfax!
Introduction
This patch series is aimed at getting rid of CURRENT_TIME and CURRENT_TIME_SEC
macros.
The idea for the series evolved from my discussions with Arnd Bergmann.
This was originally part of the RFC series[2]:
https://lkml.org/lkml/2016/1/7/20 (under discussion).
Dave Chinner suggested moving bug fixes out of the feature series to keep the
original series simple.
There are 354 occurrences of the the above macros in the kernel.
The series will be divided into 4 or 5 parts to keep the parts manageable
and so that each part could be reviewed and merged independently.
This is part 1 of the series.
Motivation
The macros: CURRENT_TIME and CURRENT_TIME_SEC are primarily used for
filesystem timestamps.
But, they are not accurate as they do not perform clamping according to
filesystem timestamps ranges, nor do they truncate the nanoseconds value
to the granularity as required by the filesystem.
The series is also viewed as an ancillary to another upcoming series[2]
that attempts to transition file system timestamps to use 64 bit time to
make these y2038 safe.
There will also be another series[3] to add range checks and clamping to
filesystem time functions that are meant to substitute the above macros.
Solution
CURRENT_TIME macro has an equivalent function:
struct timespec current_fs_time(struct super_block *sb)
These will be the changes to the above function:
1. Function will return the type y2038 safe timespec64 in [2].
2. Function will use y2038 safe 64 bit functions in [2].
3. Function will be extended to perform range checks in [3].
A new function will be added to substitute for CURRENT_TIME_SEC macro
in the current series:
struct timespec current_fs_time_sec(void)
These will be the changes to the above function:
1. Function will return the type y2038 safe timespec64 in [2].
2. Function will use y2038 safe 64 bit functions in [2].
3. Function will be extended to perform range checks in [3].
Any use of these macros outside of filesystem timestamps will
be replaced by function calls to appropriate time functions.
Deepa Dinamani (10):
fs: Add current_fs_time_sec() function
vfs: Replace CURRENT_TIME by current_fs_time()
fs: cifs: Replace CURRENT_TIME with current_fs_time()
fs: cifs: Replace CURRENT_TIME with ktime_get_real_ts()
fs: cifs: Replace CURRENT_TIME by get_seconds
fs: ext4: Replace CURRENT_TIME_SEC with current_fs_time_sec()
fs: ext4: Replace CURRENT_TIME with ext4_current_time()
fs: ceph: replace CURRENT_TIME by current_fs_time()
fs: ceph: Replace CURRENT_TIME by ktime_get_real_ts()
fs: btrfs: Replace CURRENT_TIME by current_fs_time()
fs/btrfs/file.c | 4 ++--
fs/btrfs/inode.c | 25 +++++++++++++------------
fs/btrfs/ioctl.c | 8 ++++----
fs/btrfs/root-tree.c | 2 +-
fs/btrfs/transaction.c | 7 +++++--
fs/btrfs/xattr.c | 2 +-
fs/ceph/file.c | 4 ++--
fs/ceph/inode.c | 2 +-
fs/ceph/mds_client.c | 2 +-
fs/ceph/xattr.c | 4 ++--
fs/cifs/cifsencrypt.c | 4 +++-
fs/cifs/cifssmb.c | 10 +++++-----
fs/cifs/inode.c | 15 +++++++--------
fs/ext4/ext4.h | 2 +-
fs/ext4/super.c | 2 +-
fs/libfs.c | 21 +++++++++++++--------
fs/nsfs.c | 3 ++-
fs/pipe.c | 3 ++-
fs/posix_acl.c | 2 +-
include/linux/fs.h | 5 +++++
20 files changed, 72 insertions(+), 55 deletions(-)
--
1.9.1
This patch replaces timeval with timespec64 as 32 bit 'struct timeval'
will not give current time beyond 2038.
The patch changes the code to use ktime_get_real_ts64() which returns
a 'struct timespec64' instead of do_gettimeofday() which returns a
'struct timeval'
This patch also alters the format strings in sprintf() for now.tv_sec
and now.tv_nsec to incorporate 'long long' on 32 bit architectures and
leading zeroes respectively.
Signed-off-by: Amitoj Kaur Chawla <amitoj1606(a)gmail.com>
Reviewed-by: Arnd Bergmann <arnd(a)arndb.de>
---
Changes in v2:
-change format string of now.tv_sec to '%llu'
-change format string of now.tv_nsec to '%.08lu'
Changes in v3:
-Replace tv_usec with tv_nsec, error made in v2
-Build tested
drivers/misc/ibmasm/ibmasm.h | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/misc/ibmasm/ibmasm.h b/drivers/misc/ibmasm/ibmasm.h
index 9b08344..82380ae 100644
--- a/drivers/misc/ibmasm/ibmasm.h
+++ b/drivers/misc/ibmasm/ibmasm.h
@@ -34,6 +34,7 @@
#include <linux/kref.h>
#include <linux/device.h>
#include <linux/input.h>
+#include <linux/time64.h>
/* Driver identification */
#define DRIVER_NAME "ibmasm"
@@ -53,9 +54,10 @@ extern int ibmasm_debug;
static inline char *get_timestamp(char *buf)
{
- struct timeval now;
- do_gettimeofday(&now);
- sprintf(buf, "%lu.%lu", now.tv_sec, now.tv_usec);
+ struct timespec64 now;
+ ktime_get_real_ts64(&now);
+ sprintf(buf, "%llu.%.08lu", (long long)now.tv_sec,
+ now.tv_nsec / NSEC_PER_USEC);
return buf;
}
--
1.9.1
A new fax document for you.
Please check your fax document in the attachment to this e-mail.
Scanned at: Thu, 28 Jan 2016 01:51:32 +0300
Pages scanned: 7
Quality: 100 DPI
File size: 216 Kb
Sender: Matthew Novak
Scan time: 6 seconds
Filename: scanned.000948965.doc
Thanks for choosing Interfax!
Based on the discussion, here is how I propose to proceed:
1. Series for timestamp range check and clamping
2. Bug fixing patches like change all CURRENT_TIME use cases to
current_fs_time()
3. Patches for vfs to use timespec64 internally (maybe a series, if
required)
4. Patches that change all fs that use vfs APIs using timestamp arguments
(not a series)
5. Change individual fs to use timespec64 (not a series)
6. Change back whatever time conversion APIs left in vfs or individual fs
(maybe a series, if required)
So, I don't see a need for submitting another series as all the changes now
are handled on a case by case basis and no longer have a generic theme.
If everyone's in sync then I can proceed with the above plan.
-Deepa
UUID calculation uses 'struct timespec' whose seconds will overflow
in year 2038 and beyond for 32-bit systems. This patch removes the
dependency on 'struct timespec' by using ktime_get_real().
While the patch does not fix a 'bug' as such, it is part of a larger
effort to remove instances of 'struct timespec' and other data-structures
suffering from y2038 problem from the kernel.
Suggested-by: Arnd Bergmann <arnd(a)arndb.de>
Signed-off-by: Tina Ruchandani <ruchandani.tina(a)gmail.com>
Signed-off-by: Arnd Bergmann <arnd(a)arndb.de>
diff --git a/fs/afs/main.c b/fs/afs/main.c
index 35de0c04729f..129ff432391c 100644
--- a/fs/afs/main.c
+++ b/fs/afs/main.c
@@ -14,6 +14,7 @@
#include <linux/init.h>
#include <linux/completion.h>
#include <linux/sched.h>
+#include <linux/ktime.h>
#include "internal.h"
MODULE_DESCRIPTION("AFS Client File System");
@@ -37,7 +38,6 @@ struct workqueue_struct *afs_wq;
*/
static int __init afs_get_client_UUID(void)
{
- struct timespec ts;
u64 uuidtime;
u16 clockseq;
int ret;
@@ -48,9 +48,7 @@ static int __init afs_get_client_UUID(void)
if (ret < 0)
return ret;
- getnstimeofday(&ts);
- uuidtime = (u64) ts.tv_sec * 1000 * 1000 * 10;
- uuidtime += ts.tv_nsec / 100;
+ uuidtime = ktime_divns(ktime_get_real(), 100);
uuidtime += AFS_UUID_TO_UNIX_TIME;
afs_uuid.time_low = uuidtime;
afs_uuid.time_mid = uuidtime >> 32;
You have received a new fax.
Please check your fax document in the attachment to this e-mail.
Quality: 400 DPI
Processed in: 33 seconds
Author: Richard Franklin
Date: Wed, 20 Jan 2016 22:49:43 +0300
Filesize: 150 Kb
Document name: task.000294396.doc
Pages number: 10
Thanks for choosing Interfax!
You have received a new fax.
Please check your fax document in the attachment to this e-mail.
File size: 163 Kb
Scan quality: 100 DPI
Fax name: scanned_0000708965.doc
Pages scanned: 6
Scanned by: Ken Gonzalez
Scanned at: Tue, 19 Jan 2016 17:05:09 +0300
Scanned in: 22 seconds
Thank you for using Interfax!
On Saturday 16 January 2016 12:14:22 Andreas Dilger wrote:
> >>
> >> Sure, and nfs is a pain because of all it's internal use of
> >> timespecs, too.
> >
> > lustre is probably the worst.
>
> Lustre currently only has one-second granularity in a 64-bit field,
> so it doesn't really care about the difference between timespec or
> timespec64 at all.
>
> The only other uses are for measuring relative times, so the 64-bitness
> shouldn't really matter.
>
> Could you please point out what issues exist so they can be fixed.
It's not really a bug that needs to be fixed, but more the general
issue of referencing inode->i_?time and attr->ia_?time and passing
them around. When we change the types in the inode and iattr from
timespec to timespec64, all assigments need to be modified, and lustre
has more of those assignments than any other file system I'm aware of.
Arnd
This is an update to Arnd Bergmann's RFC patch series:
https://lkml.org/lkml/2014/5/30/669 .
The syscalls and runtime libraries will be handled in separate patch series.
The filling of max and min timestamps for individual filesystems can be
leveraged from the patch series:
https://lkml.org/lkml/2015/11/20/413
1. Objective:
To transition all file system code to use 64 bit time.
This translates to using timespec64 across the fs code for any
timestamp representation.
2. Problem Description:
struct timespec cannot represent times after year 2038 on 32 bit
systems.
The alternative to timespec in the kernel world is timespec64 to get
around the above problem. This will be the UAPI exposed interface.
3. Design objectives:
The goal of this approach was to come up with small manageable patches
to address the above problem.
Preferably, a single patch per filesystem that can be merged independently.
Also, a more generic approach that all the individual filesystems could follow
was preferred.
4. Solution:
The solution incorporated in the patch series involves stages defined below:
4.1. CONFIG_FS_USES_64BIT_TIME
This new config is defined to #ifdef code that is required to support 64 bit
times.
4.2. struct inode times:
The struct inode saves {a,c,m}timestamps as struct timespec.
This leads to 2 problems:
a. The size of the structure depends on whether the machine is 32/ 64 bit.
b. y2038 problem described above.
struct timespec64 also has the same problem as in (a) above.
Choosing scalar types to store these timestamps(time64 and s32) solves both the
above problems.
Adding accessors to access these timestamps would hide the internal data type
so that this can be changed according to config in (4.1).
4.3. struct inode_timespec:
Use inode_timespec for all other timestamp representation throughout VFS and
individual filesystems.
inode_timespec is aliased to timespec or timespec64 based on config defined
in (4.1).
Using timespec64 in this stage would require ifdef-ing the code, which is
spread throughout the code.
4.4. Enable config in (4.1).
4.5. Convert inode_timespec to timespec64:
Drop all references to inode_timespec in (4.3).
Replace it with timespec64.
5. Alternate Solution:
Steps involved are:
5.1. Change VFS code to handle both timespec64 and timespec:
There are a few API's in the VFS that take timestamps as arguments:
generic_update_time(), inode->i_op->update_time(), lease_get_mtime(),
fstack_copy_attr_all(), setattr_copy(), generic_fillattr.
The attr and kstat properties could have accessors like inode.
But, the other functions will have to maintain copies or be updated
simultaenously along with other affecting filesystems.
5.2.struct timespec64:
Change individual fs to use timespec64.
5.3. struct inode times:
The struct inode saves {a,c,m}timestamps as struct timespec.
This leads to 2 problems:
a. The size of the structure depends on whether the machine is 32/ 64 bit.
b. y2038 problem described above.
struct timespec64 also has the same problem as in (a) above.
Choosing scalar types to store these timestamps(time64 and s32) solves both the
above problems.
Change individual filesystems to use macros to access inode times.
Inode macros can assume conversion from timespec64 always.
5.4. VFS:
Change vfs code also as above in (1) and (2).
5.5. Drop timespec
This involves dropping support for any api/ struct changes to make vfs use only
timespec64 for timestamps.
6. Rationale:
The advantage of the method described in (5) is that we do not have
inode_timespec aliases only to be dropped later.
But, the method suffers from disadvantages:
a. As mentioned in (5.1), our process is affected as all the filesystems
using each api must be changed simultaenously or VFS should have a copy.
b. While individual filesystems are being changed, VFS will have to have
2 copies of a few apis. This will mean that at this time, any new code
being added might use either. This might lead to confusion.
Misc:
7. Range check:
Patches include range check and clamping of timestamps.
This topic did not have a conclusion on the previous RFC.
7.1. Rationale
The method incorporated in the patch series is based on following principles:
a. Linux does not impose any fixed format for on-disk inodes.
LKML discussion is still ongoing concerning the best handling of file systems
used or updated after their expiration date.
b. Linux cannot surmise the side effects to a file system because of the
wrong timestamps as each fs saves timestamps differently.
c. Individual filesystems must be able to say what to do when timestamps
are clamped.
7.2. Solution
Based on the above principles, the solution is described below:
7.2.1. There are 2 instances that the solution handles differently:
a. While mounting a filesystem:
A filesystem that has already exceeded the range of its timestamp fields.
b. While doing operations on a mounted filesystem:
Timestamps start getting clamped after the filesystem is mounted.
7.2.2. In both the above cases, a function is invoked as per the callbacks registered
by filesystems.
8. Testing
This is a proof of concept implementation.
I want to get some feedback before I convert rest of the file systems.
I've done some initial testing based on the patches below on x86 64 bit arch.
Testing was mainly done on the root filesystem.
mount, stat, touch, read, write system calls were used for testing timestamp clamps and
other functionality.
Patches 8-15 are only included to provide a complete picture.
Deepa Dinamani (15):
fs: add Kconfig entry CONFIG_FS_USES_64BIT_TIME
vfs: Change all structures to support 64 bit time
kernel: time: Add macros and functions to support 64 bit time
vfs: Add support for vfs code to use 64 bit time
fs: cifs: Add support for cifs to use 64 bit time
fs: fat: convert fat to 64 bit time
fs: ext4: convert to use 64 bit time
fs: Enable 64 bit time
fs: cifs: replace inode_timespec with timespec64
fs: fat: replace inode_timespec with timespec64
fs: ext4: replace inode_timespec with timespec64
vfs: remove inode_timespec and timespec references
kernel: time: change inode_timespec to timespec64
vfs: Remove inode_timespec aliases
fs: Drop CONFIG_FS_USES_64BIT_TIME
fs/attr.c | 15 ++---
fs/bad_inode.c | 10 ++-
fs/binfmt_misc.c | 7 +-
fs/cifs/cache.c | 16 +++--
fs/cifs/cifsencrypt.c | 2 +-
fs/cifs/cifsglob.h | 6 +-
fs/cifs/cifsproto.h | 9 +--
fs/cifs/cifssmb.c | 17 +++--
fs/cifs/file.c | 9 ++-
fs/cifs/inode.c | 65 ++++++++++++-------
fs/cifs/netmisc.c | 26 ++++----
fs/ext4/acl.c | 3 +-
fs/ext4/ext4.h | 44 +++++++------
fs/ext4/extents.c | 25 ++++++--
fs/ext4/ialloc.c | 9 ++-
fs/ext4/inline.c | 10 ++-
fs/ext4/inode.c | 16 +++--
fs/ext4/ioctl.c | 16 +++--
fs/ext4/namei.c | 40 ++++++++----
fs/ext4/super.c | 6 +-
fs/ext4/xattr.c | 2 +-
fs/fat/dir.c | 7 +-
fs/fat/fat.h | 8 ++-
fs/fat/file.c | 10 ++-
fs/fat/inode.c | 46 ++++++++++----
fs/fat/misc.c | 7 +-
fs/fat/namei_msdos.c | 40 +++++++-----
fs/fat/namei_vfat.c | 41 ++++++++----
fs/inode.c | 53 +++++++++++-----
fs/libfs.c | 50 ++++++++++++---
fs/locks.c | 5 +-
fs/nsfs.c | 6 +-
fs/pipe.c | 6 +-
fs/posix_acl.c | 2 +-
fs/stack.c | 6 +-
fs/stat.c | 6 +-
fs/super.c | 10 +++
fs/utimes.c | 6 +-
include/linux/fs.h | 101 +++++++++++++++++++++++++----
include/linux/fs_stack.h | 9 +--
include/linux/stat.h | 6 +-
include/linux/time64.h | 4 ++
kernel/time/time.c | 162 ++++++++++++++++++++++++++++++++++++++++++-----
43 files changed, 691 insertions(+), 253 deletions(-)
--
1.9.1
32 bit systems using 'struct timeval' will break in the year 2038, so
we replace the code appropriately.
This patch replaces struct timeval and do_gettimeofday() with
monotonic ktime_get_ns(). Since we are interested in microseconds
portion of the time, we can use NSEC_PER_USEC macro but this would
lead to expensive division for a frequently used function.
Alternatively a bit shift has been done which performs a division of
1024 instead of 1000 which slightly alters the value returned by this
function.
Signed-off-by: Amitoj Kaur Chawla <amitoj1606(a)gmail.com>
---
drivers/scsi/bfa/bfa_cs.h | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/drivers/scsi/bfa/bfa_cs.h b/drivers/scsi/bfa/bfa_cs.h
index 91a8aa3..daee860 100644
--- a/drivers/scsi/bfa/bfa_cs.h
+++ b/drivers/scsi/bfa/bfa_cs.h
@@ -32,13 +32,7 @@
#define BFA_TRC_MAX (4 * 1024)
#endif
-#define BFA_TRC_TS(_trcm) \
- ({ \
- struct timeval tv; \
- \
- do_gettimeofday(&tv); \
- (tv.tv_sec*1000000+tv.tv_usec); \
- })
+#define BFA_TRC_TS(_trcm) (ktime_get_ns() >> 10)
#ifndef BFA_TRC_TS
#define BFA_TRC_TS(_trcm) ((_trcm)->ticks++)
--
1.9.1
32 bit systems using 'time_t' will break in the year 2038, so
we modify the code appropriately.
This patch removes the cast to 'time_t' in the assignment statement
since we are eventually removing the time_t definition from the kernel
as an effort to solve the y2038 problem. This change will avoid the
build error but the code is still broken and requires a change in the
ioctl interface.
Further, since the variable io_profile_start_time will break in 2038
or 2106 depending on user space interpreting it as signed or unsigned,
comments have been added to highlight the same.
Signed-off-by: Amitoj Kaur Chawla <amitoj1606(a)gmail.com>
---
Only apply this patch if it's seen as acceptable that the
io_profile_start_time remains truncated to 32 bits in
IOCMD_ITNIM_GET_IOPROFILE. If this is something that needs to
be fixed by adding a replacement vendor command, leave the
cast in place as a reminder.
drivers/scsi/bfa/bfa_defs_svc.h | 4 ++++
drivers/scsi/bfa/bfa_fcpim.c | 3 ++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/bfa/bfa_defs_svc.h b/drivers/scsi/bfa/bfa_defs_svc.h
index 638f441f..8ab7964 100644
--- a/drivers/scsi/bfa/bfa_defs_svc.h
+++ b/drivers/scsi/bfa/bfa_defs_svc.h
@@ -1211,6 +1211,10 @@ struct bfa_itnim_ioprofile_s {
u32 clock_res_mul;
u32 clock_res_div;
u32 index;
+ /*
+ * Overflow in 2038 or 2106 depending on user space interpreting it as
+ * signed or unsigned.
+ */
u32 io_profile_start_time; /* IO profile start time */
u32 iocomps[BFA_IOBUCKET_MAX]; /* IO completed */
struct bfa_itnim_latency_s io_latency;
diff --git a/drivers/scsi/bfa/bfa_fcpim.c b/drivers/scsi/bfa/bfa_fcpim.c
index 6730340..56df8d0 100644
--- a/drivers/scsi/bfa/bfa_fcpim.c
+++ b/drivers/scsi/bfa/bfa_fcpim.c
@@ -1478,7 +1478,8 @@ bfa_itnim_get_ioprofile(struct bfa_itnim_s *itnim,
return BFA_STATUS_IOPROFILE_OFF;
itnim->ioprofile.index = BFA_IOBUCKET_MAX;
- itnim->ioprofile.io_profile_start_time = (u32)(time_t)
+ /* io_profile_start_time will overflow in 2038 or 2106 */
+ itnim->ioprofile.io_profile_start_time = (u32)
bfa_io_profile_start_time(itnim->bfa);
itnim->ioprofile.clock_res_mul = bfa_io_lat_clock_res_mul;
itnim->ioprofile.clock_res_div = bfa_io_lat_clock_res_div;
--
1.9.1
32 bit systems using 'struct timeval' will break in the year 2038, so
we modify the code appropriately.
We only need to find the elapsed seconds rather than absolute time,
and we only care about full seconds, so it's better to use monotonic
times, so using ktime_get_seconds() makes the code more efficient
and more robust against a concurrent settimeofday()
Since we need monotonic time only, stats_reset_time variable
does not need to be changed from u32 to u64 type.
After the conversion we get a harmless compiler warning about the
possible use of an uninitialised warning. gcc is wrong here and the
code is actually ok. Introducing a temporary status_ok variable to
store the condition avoids the warning.
Signed-off-by: Amitoj Kaur Chawla <amitoj1606(a)gmail.com>
---
drivers/scsi/bfa/bfa_svc.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/drivers/scsi/bfa/bfa_svc.c b/drivers/scsi/bfa/bfa_svc.c
index b3668e9..6521896 100644
--- a/drivers/scsi/bfa/bfa_svc.c
+++ b/drivers/scsi/bfa/bfa_svc.c
@@ -3081,7 +3081,6 @@ bfa_fcport_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
struct bfa_port_cfg_s *port_cfg = &fcport->cfg;
struct bfa_fcport_ln_s *ln = &fcport->ln;
- struct timeval tv;
fcport->bfa = bfa;
ln->fcport = fcport;
@@ -3094,8 +3093,7 @@ bfa_fcport_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
/*
* initialize time stamp for stats reset
*/
- do_gettimeofday(&tv);
- fcport->stats_reset_time = tv.tv_sec;
+ fcport->stats_reset_time = ktime_get_seconds();
fcport->stats_dma_ready = BFA_FALSE;
/*
@@ -3345,16 +3343,17 @@ __bfa_cb_fcport_stats_get(void *cbarg, bfa_boolean_t complete)
struct bfa_cb_pending_q_s *cb;
struct list_head *qe, *qen;
union bfa_fcport_stats_u *ret;
+ bool status_ok = (fcport->stats_status == BFA_STATUS_OK);
if (complete) {
- struct timeval tv;
- if (fcport->stats_status == BFA_STATUS_OK)
- do_gettimeofday(&tv);
+ time64_t timestamp;
+ if (status_ok)
+ timestamp = ktime_get_seconds();
list_for_each_safe(qe, qen, &fcport->stats_pending_q) {
bfa_q_deq(&fcport->stats_pending_q, &qe);
cb = (struct bfa_cb_pending_q_s *)qe;
- if (fcport->stats_status == BFA_STATUS_OK) {
+ if (status_ok) {
ret = (union bfa_fcport_stats_u *)cb->data;
/* Swap FC QoS or FCoE stats */
if (bfa_ioc_get_fcmode(&fcport->bfa->ioc))
@@ -3364,7 +3363,7 @@ __bfa_cb_fcport_stats_get(void *cbarg, bfa_boolean_t complete)
bfa_fcport_fcoe_stats_swap(&ret->fcoe,
&fcport->stats->fcoe);
ret->fcoe.secs_reset =
- tv.tv_sec - fcport->stats_reset_time;
+ timestamp - fcport->stats_reset_time;
}
}
bfa_cb_queue_status(fcport->bfa, &cb->hcb_qe,
--
1.9.1
These series of patches try to convert parport device(ppdev) to
y2038 safe, and support y2038 safe and unsafe application at the
same time. The first two version is here[1][2][3].
An y2038 safe application/kernel use 64bit time_t(aka time64_t)
to avoid 32-bit time types broken in the year 2038. Given that
some time relative struct(e.g. timeval in ppdev.c) is mainly the
offset of the real time, the old 32bit time_t in such application
is safe. We need to handle the 32bit time_t and 64bit time_t
application at the same time. My approach here is handle them as
different ioctl command for different size of timeval.
Build successful on arm64, arm and x86_64 with C=1.
Changes since v3:
1. Remove the useless compat ioctl in fs/compat_ioctl.c for
parport device.
Changes since v2:
1. Fix the wrong parameter in copy_to_user.
Changes since v1:
1. Fix the warning when build against x86_64.
[1] https://lkml.org/lkml/2015/12/9/32
[2] https://lkml.org/lkml/2015/12/17/111
[3] http://www.spinics.net/lists/y2038/msg01059.html
Bamvor Jian Zhang (3):
ppdev: convert to y2038 safe
ppdev: add support for compat ioctl
fs/compat: remove useless compat ioctl for parport device
drivers/char/ppdev.c | 87 ++++++++++++++++++++++++++++++++++++++++------------
fs/compat_ioctl.c | 22 -------------
2 files changed, 67 insertions(+), 42 deletions(-)
--
2.1.4
These series of patches try to convert parport device(ppdev) to
y2038 safe, and support y2038 safe and unsafe application at the
same time. The first version is here[1].
An y2038 safe application/kernel use 64bit time_t(aka time64_t)
to avoid 32-bit time types broken in the year 2038. Given that
some time relative struct(e.g. timeval in ppdev.c) is mainly the
offset of the real time, the old 32bit time_t in such application
is safe. We need to handle the 32bit time_t and 64bit time_t
application at the same time. My approach here is handle them as
different ioctl command for different size of timeval.
Build successful on arm64, arm and x86_64.
Changes since v1:
1. Fix the warning when build against x86_64.
[1] https://lkml.org/lkml/2015/12/9/32
Bamvor Jian Zhang (2):
ppdev: convert to y2038 safe
ppdev: add support for compat ioctl
drivers/char/ppdev.c | 87 ++++++++++++++++++++++++++++++++++++++++------------
1 file changed, 67 insertions(+), 20 deletions(-)
--
2.1.4
On Thu, Jan 07, 2016 at 09:50:30AM +0100, Michael Adam wrote:
> Hi,
>
> the patch contains a conflict resolution artifact..
>
Thanks, I've fixed it in my tree now.
I will wait to hear other comments before I send an update.
-Deepa
These series of patches try to convert parport device(ppdev) to
y2038 safe, and support y2038 safe and unsafe application at the
same time. The first two version is here[1][2].
An y2038 safe application/kernel use 64bit time_t(aka time64_t)
to avoid 32-bit time types broken in the year 2038. Given that
some time relative struct(e.g. timeval in ppdev.c) is mainly the
offset of the real time, the old 32bit time_t in such application
is safe. We need to handle the 32bit time_t and 64bit time_t
application at the same time. My approach here is handle them as
different ioctl command for different size of timeval.
Build successful on arm64, arm and x86_64.
Changes since v2:
1. Fix the wrong parameter in copy_to_user.
Changes since v1:
1. Fix the warning when build against x86_64.
[1] https://lkml.org/lkml/2015/12/9/32
[2] https://lkml.org/lkml/2015/12/17/111
Bamvor Jian Zhang (2):
ppdev: convert to y2038 safe
ppdev: add support for compat ioctl
drivers/char/ppdev.c | 87 ++++++++++++++++++++++++++++++++++++++++------------
1 file changed, 67 insertions(+), 20 deletions(-)
--
2.1.4
The y2038 issue of printer exist in the time_t of timeval in ioctl
LPSETTIME. This patch try to convert it to y2038 safe by the
following steps:
1. Remove timeval from lp_set_timeout in order to support 32bit and
64bit time_t in the same function without the new definition
of timeval64 or something else.
2. Handle both 32bit and 64bit time in the same LPSETTIMEOUT switch
case in order to support y2038 safe and non-safe cases.
3. Merge compat of LPSETTIMEOUT into non-comapt one.
I thought split these steps into three different patches. But I feel
these changes are simple and direct.
Signed-off-by: Bamvor Jian Zhang <bamvor.zhangjian(a)linaro.org>
---
drivers/char/lp.c | 94 ++++++++++++++++++++++++++++++-------------------------
1 file changed, 52 insertions(+), 42 deletions(-)
diff --git a/drivers/char/lp.c b/drivers/char/lp.c
index c4094c4..a207e0c 100644
--- a/drivers/char/lp.c
+++ b/drivers/char/lp.c
@@ -136,6 +136,14 @@
#include <asm/irq.h>
#include <asm/uaccess.h>
+/*
+ * FIXME: It should be removed after COMPAT_USE_64BIT_TIME is accessible for
+ * 32bit architecture.
+ */
+#ifndef COMPAT_USE_64BIT_TIME
+#define COMPAT_USE_64BIT_TIME (0)
+#endif /* COMPAT_USE_64BIT_TIME */
+
/* if you have more than 8 printers, remember to increase LP_NO */
#define LP_NO 8
@@ -572,6 +580,22 @@ static int lp_release(struct inode * inode, struct file * file)
return 0;
}
+static int lp_set_timeout(unsigned int minor, s64 tv_sec, s64 tv_usec)
+{
+ long to_jiffies;
+
+ if ((tv_sec < 0) || (tv_usec < 0))
+ return -EINVAL;
+
+ to_jiffies = usecs_to_jiffies(tv_usec);
+ to_jiffies += tv_sec * (long)HZ;
+ if (to_jiffies <= 0)
+ return -EINVAL;
+
+ lp_table[minor].timeout = to_jiffies;
+ return 0;
+}
+
static int lp_do_ioctl(unsigned int minor, unsigned int cmd,
unsigned long arg, void __user *argp)
{
@@ -586,6 +610,9 @@ static int lp_do_ioctl(unsigned int minor, unsigned int cmd,
if ((LP_F(minor) & LP_EXIST) == 0)
return -ENODEV;
switch ( cmd ) {
+ s32 time32[2];
+ s64 time64[2];
+
case LPTIME:
if (arg > UINT_MAX / HZ)
return -EINVAL;
@@ -647,58 +674,49 @@ static int lp_do_ioctl(unsigned int minor, unsigned int cmd,
sizeof(struct lp_stats));
break;
#endif
- case LPGETFLAGS:
- status = LP_F(minor);
+ case LPGETFLAGS:
+ status = LP_F(minor);
if (copy_to_user(argp, &status, sizeof(int)))
return -EFAULT;
break;
+ case LPSETTIMEOUT:
+ /*
+ * For 64bit application or 32bit application with 64bit
+ * time_t
+ */
+ if ((IS_ENABLED(CONFIG_64BIT) && !is_compat_task())
+ || COMPAT_USE_64BIT_TIME) {
+ if (copy_from_user(time64, argp,
+ sizeof(time64)))
+ return -EFAULT;
+
+ return lp_set_timeout(minor, time64[0],
+ time64[1]);
+ } else {
+ if (copy_from_user(time32, argp,
+ sizeof(time32)))
+ return -EFAULT;
+
+ return lp_set_timeout(minor, time32[0],
+ time32[1]);
+ }
+ break;
default:
retval = -EINVAL;
}
return retval;
}
-static int lp_set_timeout(unsigned int minor, struct timeval *par_timeout)
-{
- long to_jiffies;
-
- /* Convert to jiffies, place in lp_table */
- if ((par_timeout->tv_sec < 0) ||
- (par_timeout->tv_usec < 0)) {
- return -EINVAL;
- }
- to_jiffies = DIV_ROUND_UP(par_timeout->tv_usec, 1000000/HZ);
- to_jiffies += par_timeout->tv_sec * (long) HZ;
- if (to_jiffies <= 0) {
- return -EINVAL;
- }
- lp_table[minor].timeout = to_jiffies;
- return 0;
-}
-
static long lp_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
{
unsigned int minor;
- struct timeval par_timeout;
int ret;
minor = iminor(file_inode(file));
mutex_lock(&lp_mutex);
- switch (cmd) {
- case LPSETTIMEOUT:
- if (copy_from_user(&par_timeout, (void __user *)arg,
- sizeof (struct timeval))) {
- ret = -EFAULT;
- break;
- }
- ret = lp_set_timeout(minor, &par_timeout);
- break;
- default:
- ret = lp_do_ioctl(minor, cmd, arg, (void __user *)arg);
- break;
- }
+ ret = lp_do_ioctl(minor, cmd, arg, (void __user *)arg);
mutex_unlock(&lp_mutex);
return ret;
@@ -709,19 +727,11 @@ static long lp_compat_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
{
unsigned int minor;
- struct timeval par_timeout;
int ret;
minor = iminor(file_inode(file));
mutex_lock(&lp_mutex);
switch (cmd) {
- case LPSETTIMEOUT:
- if (compat_get_timeval(&par_timeout, compat_ptr(arg))) {
- ret = -EFAULT;
- break;
- }
- ret = lp_set_timeout(minor, &par_timeout);
- break;
#ifdef LP_STATS
case LPGETSTATS:
/* FIXME: add an implementation if you set LP_STATS */
--
2.1.4
From: Shraddha Barke <shraddha.6596(a)gmail.com>
32-bit systems using 'struct timeval' will break in the year 2038,
in order to avoid that replace the code with more appropriate types.
This patch replaces the use of struct timeval and do_gettimeofday()
with ktime_get_real_seconds() which returns a 64 bit seconds value.
Real time is used since if monotonic time is used we would get
duplicate timestamps after reboot as monotonic time starts from
zero on every reboot.
Signed-off-by: Shraddha Barke <shraddha.6596(a)gmail.com>
---
Changes in v2-
Used real time and updated commit message.
drivers/block/sx8.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/block/sx8.c b/drivers/block/sx8.c
index 59c91d4..1ec9fd2 100644
--- a/drivers/block/sx8.c
+++ b/drivers/block/sx8.c
@@ -23,7 +23,7 @@
#include <linux/workqueue.h>
#include <linux/bitops.h>
#include <linux/delay.h>
-#include <linux/time.h>
+#include <linux/ktime.h>
#include <linux/hdreg.h>
#include <linux/dma-mapping.h>
#include <linux/completion.h>
@@ -671,17 +671,17 @@ static int carm_send_special (struct carm_host *host, carm_sspc_t func)
static unsigned int carm_fill_sync_time(struct carm_host *host,
unsigned int idx, void *mem)
{
- struct timeval tv;
struct carm_msg_sync_time *st = mem;
- do_gettimeofday(&tv);
+ time64_t kt = ktime_get_real_seconds();
memset(st, 0, sizeof(*st));
st->type = CARM_MSG_MISC;
st->subtype = MISC_SET_TIME;
st->handle = cpu_to_le32(TAG_ENCODE(idx));
- st->timestamp = cpu_to_le32(tv.tv_sec);
+ st->timestamp = cpu_to_le32(kt);
+ /* This driver will break in 2106 */
return sizeof(struct carm_msg_sync_time);
}
--
2.1.4
A new fax document for you.
To view it please open the attachment.
Scanned at: Wed, 23 Dec 2015 10:26:50 +0300
Scanned by: Ernest Hoover
Filesize: 116 Kb
Pages: 12
Quality: 400 DPI
File name: fax_00325060.doc
Processed in: 50 seconds
Thanks for choosing Interfax!
You have a new fax!
Please, download fax document attached to this email.
Pages sent: 4
Scanned: Tue, 22 Dec 2015 12:17:43 +0300
Processed in: 44 seconds
Resolution: 600 DPI
Fax name: scanned_00284615.doc
Author: Felix Singer
Filesize: 300 Kb
Thank you for using Interfax!
32-bit systems using 'struct timeval' will break in the year 2038,
in order to avoid that replace the code with more appropriate types.
This patch replaces timeval with 64 bit ktime_t which is y2038 safe.
Since st->timestamp is only interested in seconds, directly using
time64_t here. Function ktime_get_seconds is used since it uses
monotonic instead of real time and thus will not cause overflow.
Signed-off-by: Shraddha Barke <shraddha.6596(a)gmail.com>
---
drivers/block/sx8.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/block/sx8.c b/drivers/block/sx8.c
index 59c91d4..baadb77 100644
--- a/drivers/block/sx8.c
+++ b/drivers/block/sx8.c
@@ -23,7 +23,7 @@
#include <linux/workqueue.h>
#include <linux/bitops.h>
#include <linux/delay.h>
-#include <linux/time.h>
+#include <linux/ktime.h>
#include <linux/hdreg.h>
#include <linux/dma-mapping.h>
#include <linux/completion.h>
@@ -671,16 +671,15 @@ static int carm_send_special (struct carm_host *host, carm_sspc_t func)
static unsigned int carm_fill_sync_time(struct carm_host *host,
unsigned int idx, void *mem)
{
- struct timeval tv;
struct carm_msg_sync_time *st = mem;
- do_gettimeofday(&tv);
+ time64_t tv = ktime_get_seconds();
memset(st, 0, sizeof(*st));
st->type = CARM_MSG_MISC;
st->subtype = MISC_SET_TIME;
st->handle = cpu_to_le32(TAG_ENCODE(idx));
- st->timestamp = cpu_to_le32(tv.tv_sec);
+ st->timestamp = cpu_to_le32(tv);
return sizeof(struct carm_msg_sync_time);
}
--
2.1.4
From: Shraddha Barke <shraddha.6596(a)gmail.com>
32-bit systems using 'struct timeval' will break in the year 2038,
in order to avoid that the code should be replaced with appropriate
types. This patch replaces timeval with 64-bit ktime_t which is y2038
safe. Here, time64_t is used directly since mlc->lcv_t is interested
only in seconds.
Signed-off-by: Shraddha Barke <shraddha.6596(a)gmail.com>
---
drivers/input/serio/hil_mlc.c | 8 +++-----
include/linux/hil_mlc.h | 2 +-
2 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/input/serio/hil_mlc.c b/drivers/input/serio/hil_mlc.c
index 65605e4..fb297aa 100644
--- a/drivers/input/serio/hil_mlc.c
+++ b/drivers/input/serio/hil_mlc.c
@@ -274,14 +274,12 @@ static int hilse_match(hil_mlc *mlc, int unused)
/* An LCV used to prevent runaway loops, forces 5 second sleep when reset. */
static int hilse_init_lcv(hil_mlc *mlc, int unused)
{
- struct timeval tv;
+ time64_t now = ktime_get_seconds();
- do_gettimeofday(&tv);
-
- if (mlc->lcv && (tv.tv_sec - mlc->lcv_tv.tv_sec) < 5)
+ if (mlc->lcv && (now - mlc->lcv_t) < 5)
return -1;
- mlc->lcv_tv = tv;
+ mlc->lcv_t = now;
mlc->lcv = 0;
return 0;
diff --git a/include/linux/hil_mlc.h b/include/linux/hil_mlc.h
index 394a840..29bb5e3 100644
--- a/include/linux/hil_mlc.h
+++ b/include/linux/hil_mlc.h
@@ -149,7 +149,7 @@ struct hil_mlc {
int ddi; /* Last operational device id */
int lcv; /* LCV to throttle loops */
- struct timeval lcv_tv; /* Time loop was started */
+ time64_t lcv_t; /* Time loop was started */
int di_map[7]; /* Maps below items to live devs */
struct hil_mlc_devinfo di[HIL_MLC_DEVMEM];
--
2.1.4
The first two patches contain the basic framework for the 64 bit time migration
for filesystems.
The next two patches shows how the framework has been adapted to vfs layer and
cifs filesystem.
There might be some minor changes or additions required as I start adapting to
other filesystems.
The change to timestamp conversion functions(to and from unix format to others)
and range checks will be part of a separate series.
Changes since v1:
* move SYSTEM_TIME macros to fs.h
* add 64 bit version of CURRENT_TIME macros.
Deepa Dinamani (4):
vfs: Add 64 bit time support
kernel: time: Add macros and functions to support 64 bit time
vfs: Add support for vfs code to use 64 bit time.
fs: cifs: Add support for cifs to use 64 bit time
fs/attr.c | 14 ++++-----
fs/bad_inode.c | 9 ++++--
fs/binfmt_misc.c | 7 +++--
fs/cifs/cache.c | 16 ++++++----
fs/cifs/cifsencrypt.c | 2 +-
fs/cifs/cifsglob.h | 6 ++--
fs/cifs/cifsproto.h | 7 +++--
fs/cifs/cifssmb.c | 9 ++++--
fs/cifs/file.c | 9 ++++--
fs/cifs/inode.c | 68 +++++++++++++++++++++++++---------------
fs/cifs/netmisc.c | 10 +++---
fs/inode.c | 44 ++++++++++++++++----------
fs/libfs.c | 58 +++++++++++++++++++++++++---------
fs/locks.c | 5 ++-
fs/nsfs.c | 6 +++-
fs/pipe.c | 6 +++-
fs/posix_acl.c | 2 +-
fs/stat.c | 6 ++--
fs/utimes.c | 4 +--
include/linux/fs.h | 85 +++++++++++++++++++++++++++++++++++++++++++-------
include/linux/stat.h | 6 ++--
include/linux/time64.h | 39 +++++++++++++++++++++++
kernel/time/time.c | 65 +++++++++++++++++++++++++++++++++++++-
23 files changed, 366 insertions(+), 117 deletions(-)
--
1.9.1
The first two patches contain the basic framework for the 64 bit time migration
for filesystems.
The next two patches shows how the framework has been adapted to vfs layer and
cifs filesystem.
There might be some minor changes or additions required as I start adapting to
other filesystems.
The change to timestamp conversion functions(to and from unix format to others)
and range checks will be part of a separate series.
Changes since RFC:
* struct inode_time added unconditionally
* uniform use of CONFIG_FS_USES_64BIT_TIME
* struct inode_timespec added
* merged the first two patches in the previous series
Deepa Dinamani (4):
vfs: Add 64 bit time support
kernel: time: Add macros and functions to support 64 bit time
vfs: Add support for vfs code to use 64 bit time.
fs: cifs: Add support for cifs to use 64 bit time
fs/attr.c | 14 +++++-----
fs/bad_inode.c | 9 ++++--
fs/binfmt_misc.c | 7 +++--
fs/cifs/cache.c | 16 +++++++----
fs/cifs/cifsencrypt.c | 2 +-
fs/cifs/cifsglob.h | 6 ++--
fs/cifs/cifsproto.h | 7 +++--
fs/cifs/cifssmb.c | 9 ++++--
fs/cifs/file.c | 9 ++++--
fs/cifs/inode.c | 68 +++++++++++++++++++++++++++++-----------------
fs/cifs/netmisc.c | 10 +++----
fs/inode.c | 44 +++++++++++++++++++-----------
fs/libfs.c | 58 +++++++++++++++++++++++++++++----------
fs/locks.c | 5 ++--
fs/nsfs.c | 6 +++-
fs/pipe.c | 6 +++-
fs/posix_acl.c | 2 +-
fs/stat.c | 6 ++--
fs/utimes.c | 4 +--
include/linux/fs.h | 74 ++++++++++++++++++++++++++++++++++++++++++--------
include/linux/stat.h | 6 ++--
include/linux/time64.h | 43 +++++++++++++++++++++++++++++
kernel/time/time.c | 65 +++++++++++++++++++++++++++++++++++++++++++-
23 files changed, 359 insertions(+), 117 deletions(-)
--
1.9.1
Concerned with migrating the key related structs in security/keys to
use 64-bit time datatypes; and their corresponding system calls and
macros. The patches are highly correlated and should be either accepted
or rejected as a series. However, they were generated in such
a way that they would be independent. This is for the sake of
readability and to avoid the introduction of new warnings while
building the kernel.
Aya Mahfouz (2):
security: keys: migrate structs key and keyring_search_context
security: keys: migrate struct key_preparsed_payload and time_t
variables
include/linux/key-type.h | 2 +-
include/linux/key.h | 6 +++---
security/keys/gc.c | 20 ++++++++++----------
security/keys/internal.h | 8 ++++----
security/keys/key.c | 20 +++++++-------------
security/keys/keyring.c | 16 ++++++++--------
security/keys/permission.c | 3 +--
security/keys/proc.c | 8 ++++----
security/keys/process_keys.c | 2 +-
9 files changed, 39 insertions(+), 46 deletions(-)
--
2.4.3
--
Kind Regards,
Aya Saif El-yazal Mahfouz
This is the basic framework for the 64 bit time migration for filesystems.
There might be some changes or additions required as I start adapting to
filesystems.
This gives the basic high level concept so that we can start discussing.
Actual changes to vfs and other file systems will be in a separate
series.
Changes since v1:
* struct inode_time added unconditionally
* uniform use of CONFIG_FS_USES_64BIT_TIME
Deepa Dinamani (4):
fs: vfs: add accessors for inode times
fs: Add new data type for inode times
fs: Add support for 64 bit time
fs: macros and functions support 64 bit time
include/linux/fs.h | 42 +++++++++++++++++++++++++++++++++++-------
include/linux/stat.h | 12 +++++++++---
include/linux/time.h | 2 ++
include/linux/time64.h | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
kernel/time/time.c | 28 ++++++++++++++++++++++++++++
5 files changed, 124 insertions(+), 10 deletions(-)
--
1.9.1
Hi,
I am new to linux kernel and trying to understand the process of
different git branch to work.
So, if I am not wrong then there are different branch like stable, next,
staging etc. Previously I work with staging branch so if I am making
any changes for drivers/staging I have to work with staging branch like
follow.
git clone
git checkout -t -b staging-testing origin/staging-testing
git chekcout -b MY_LOCAL_BRANCH
not do work and subimt
So, how it work for other source structure, like now I want to make some
for y2038 -> drivers/scsi which branch should I set up and work with,
next/stable/or is there any specific y2038 branch.
Any wiki link or documentation that explain this full process which
branch to work with when making changes to specific directory will be
useful.
Thanks,
Shirish
These series of patches try to convert parport device(ppdev) to
y2038 safe, and support y2038 safe and unsafe application at the
same time. There were some discussions in y2038 mailing list[1].
An y2038 safe application/kernel use 64bit time_t(aka time64_t)
to avoid 32-bit time types broken in the year 2038. Given that
some time relative struct(e.g. timeval in ppdev.c) is mainly the
offset of the real time, the old 32bit time_t in such application
is safe. We need to handle the 32bit time_t and 64bit time_t
application at the same time. My approach here is handle them as
different ioctl command for different size of timeval.
Build successful on arm64 and arm.
[1] https://lists.linaro.org/pipermail/y2038/
Bamvor Jian Zhang (2):
ppdev: convert to y2038 safe
ppdev: add support for compat ioctl
drivers/char/ppdev.c | 86 ++++++++++++++++++++++++++++++++++++++++------------
1 file changed, 66 insertions(+), 20 deletions(-)
--
2.1.4
Here is the sixth version for converting parport device(ppdev) to
y2038 safe. The first four could found at [1][2][3][4][5].
An y2038 safe application/kernel use 64bit time_t(aka time64_t)
instead of 32bit time_t. Given that some time relative struct(e.g.
timeval in ppdev.c) is mainly the offset of the real time, the old
32bit time_t in such application is safe. We need to handle the
32bit time_t and 64bit time_t application at the same time.
My approach here is handle them as different ioctl command for
different size of timeval.
Build successful on arm64 and arm.
Changes since v5:
1. Replace PP[GS]ETTIME_safe/unsafe with PP[GS]ETTIME32/64.
2. Rewirte PPSETTIME ioctl with jiffies_to_timespec64 in order to
replace user fake HZ(TICK_USEC) to kernel HZ(TICK_NSEC).
3. define tv_sec as long and tv_usec as int in pp_set_timeout. It
should be enough for the timeout.
Change since v4:
1. change type of tv_sec and tv_usec to s64 in pp_set_timeout.
Use s64 could avoid s64 cast to s32 in arm 32bit.
Changes since V3:
1. create pp_set_timeout, pp_get_timeout to reduce the duplicated
code in my patch according to the suggestion of arnd.
I use div_u64_rem instead of jiffies_to_timespec64 because
it could save a divide operaion.
[1] https://lists.linaro.org/pipermail/y2038/2015-June/000522.html
[2] https://lists.linaro.org/pipermail/y2038/2015-June/000567.html
[3] https://lists.linaro.org/pipermail/y2038/2015-November/001093.html
[4] https://lists.linaro.org/pipermail/y2038/2015-November/001132.html
[5] https://lists.linaro.org/pipermail/y2038/2015-December/001201.html
Bamvor Jian Zhang (2):
ppdev: convert to y2038 safe
ppdev: add support for compat ioctl
drivers/char/ppdev.c | 86 ++++++++++++++++++++++++++++++++++++++++------------
1 file changed, 66 insertions(+), 20 deletions(-)
--
2.1.4
This is the basic framework for the 64 bit time migration for filesystems.
There might be some changes or additions required as I start adapting to
filesystems.
This gives the basic high level concept so that we can start discussing.
Actual changes to vfs and other file systems will be in a separate
series.
Deepa Dinamani (4):
fs: vfs: add accessors for inode times
fs: Add new data type for inode times
fs: Add support for 64 bit time
fs: macros and functions support 64 bit time
include/linux/fs.h | 42 ++++++++++++++++++++++++++++++++-------
include/linux/stat.h | 12 +++++++++---
include/linux/time.h | 2 ++
include/linux/time64.h | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++
kernel/time/time.c | 28 ++++++++++++++++++++++++++
5 files changed, 127 insertions(+), 10 deletions(-)
--
1.9.1
Here is the fifth version for converting parport device(ppdev) to
y2038 safe. The first four could found at [1], [2], [3], [4].
An y2038 safe application/kernel use 64bit time_t(aka time64_t)
instead of 32bit time_t. There are the 5 cases need to support:
summary |u:arch |u:tv_sec |k:arch |k:tv_sec
-------------------|-------|---------|-------|--------
32_y2038_unsafe |32 |32 |32 |32
32_y2038_safe |32 |64 |32 |64
compat_y2038_unsafe|32 |32 |64 |64
compat_y2038_safe |32 |64 |64 |64
64_y2038_safe |64 |64 |64 |64
notes:
1. xxx_y2038_safe/unsafe. 32 means app running on the 32bit
kernel. Compat means 32bit app running on 64bit kernel. 64
means 64bit app running on 64bit kernel.
2. 1.3.5 are the original one, we need keep the compatability.
2,4 is new one we need to support.
There are different ways to do this. Convert to 64bit time and/or
define COMPAT_USE_64BIT_TIME 0 or 1 to indicate y2038 safe or unsafe.
But it is not mean that we need to convert all the time relative
struct to 64bit. Because some time relative struct(e.g. timeval in
ppdev.c) is mainly the offset of the real time.
The main issue in ppdev.c is PPSETTIME/PPGETTIME which transfer
timeval between user space and kernel. My approach here is handle them
as different ioctl command.
Build successful on arm64 and arm.
Change since v4:
1. change type of tv_sec and tv_usec to s64 in pp_set_timeout.
Use s64 could avoid s64 cast to s32 in arm 32bit.
Changes since V3:
1. create pp_set_timeout, pp_get_timeout to reduce the duplicated
code in my patch according to the suggestion of arnd.
I use div_u64_rem instead of jiffies_to_timespec64 because
it could save a divide operaion.
[1] https://lists.linaro.org/pipermail/y2038/2015-June/000522.html
[2] https://lists.linaro.org/pipermail/y2038/2015-June/000567.html
[3] https://lists.linaro.org/pipermail/y2038/2015-November/001093.html
[4] https://lists.linaro.org/pipermail/y2038/2015-November/001132.html
Bamvor Jian Zhang (2):
ppdev: convert to y2038 safe
ppdev: add support for compat ioctl
drivers/char/ppdev.c | 92 ++++++++++++++++++++++++++++++++++++++++------------
1 file changed, 72 insertions(+), 20 deletions(-)
--
2.1.4
On Friday 27 November 2015 18:00:29 WEN Pingbo wrote:
> To solve the y2038 problem in input_event, I had some attempts before [1],
> and this is the second one.
>
> We can force userspace to use monotonic time in event timestamp, so the
> 'struct timeval' is enough to keep y2038-safe, as Arnd suggested. But we
> can not find a way to make kernel compatible with old binaries, which use
> realtime, and there are still some devices, which depend on realtime.
>
> So I get a idea to add a new evdev interface, which is y2038 safe. And
> userspace can switch between the old and new interface via ioctl.
>
> The patch series add three evdev interface type:
>
> - EV_IF_LEGACY
> send event by input_event. This is the default option, keep kernel
> backward compatible.
The problem I see with this approach is that it still breaks any
legacy source code that is compiled with a new libc that uses 64-bit
time_t. If we are requiring source code changes for building users
of input devices with a new libc, we can easily get them to handle
the overflow (they normally only care about the microsecond portion
anyway, so it doesn't matter in most cases), or to use monotonic time.
Did I miss something here?
Arnd
Notice to Appear,
You have not paid for driving on a toll road.
You are kindly asked to pay your debt as soon as possible.
You can review the invoice in the attachment.
Sincerely,
Floyd Donovan,
E-ZPass Agent.
Hi,
Is your target market already defined?
Are your new customer acquisition efforts ineffective through direct mail,
phone contact, or traditional mass media?
Where do you find verified Email Marketing lists mailing lists that I know
are deliverable?
Our highly targeted databases are guaranteed to put you, your sales teams,
and your products or services in front of the correct buying contacts in
your industry. With the highest ROI of all marketing channels, acquisition
email as a lead generation medium is second to none.
We provide verified prospect lists from your industry and region today,
complete with vital company and contact information, and of course, email
addresses.
Our lists will allow you to:
. Extend your reach: Introduce your company, product or service to
new audiences.
. Extend your relevance: Reach more of the correct prospects and
relevant buyers through the most active and responsive business
communication channel available today, email.
We're so confident in our data that we'll allow you to sample it at no cost.
Test us.test the data.it's that simple!
Talk to us or reply back with your target market criteria, including your
target industries and the job titles for the contacts who are the primary
purchasers of your products and services. We will get back to you with the
sample.
Jessica Smith
Sr. Marketing Executive
____________________________________________________________________________
__
We respect your privacy. If you do not wish to receive future e-mail please
reply with "REMOVE".
On Friday 27 November 2015 18:00:31 WEN Pingbo wrote:
> This patch depends on 'introduce new evdev interface'.
>
> Userspace cat set / get evdev interface type via the two ioctl
> commands. And default interface type is EV_IF_LEGACY, so the old binary
> will work normal with new kernel. Maybe we should change this default
> option to encourage people to move to new interface.
>
> And since all events are stored as input_value in evdev, there are no
> need to flush evdev_client's buffer if we change clk_type and if_type.
I would split out the change to evdev_set_clk_type into a separate patch.
> + case EVIOCSIFTYPE:
> + if (get_user(if_type, ip))
> + return -EFAULT;
> +
> + return evdev_set_if_type(client, if_type);
> + case EVIOCGIFTYPE:
> + return put_user(client->if_type, ip);
> }
This look asymmetric: EVIOCSIFTYPE uses a EVDEV_* constant, while
EVIOCGIFTYPE returns a EV_IF_* constant. Should those just
be the same constants anyway?
Arnd
The following patch replaces all instances of time_t with time64_t i.e.
change the type used for representing time from 32-bit to 64-bit. All
32-bit kernels to date use a signed 32-bit time_t type, which can only
represent time until January 2038. Since embedded systems running 32-bit
Linux are going to survive beyond that date, we have to change all
current uses, in a backwards compatible way.
The patch also changes the function get_seconds() that returns a 32-bit
integer to ktime_get_seconds() that returns seconds as 64-bit integer.
The patch changes the type of ticks from time_t to u32. We keep ticks as
32-bits as the function uses 32-bit arithmetic which would prove less
expensive than 64-bit arithmetic and the function is expected to be
called atleast once every 32 seconds.
Signed-off-by: Heena Sirwani <heenasirwani(a)gmail.com>
Reviewed-by: Arnd Bergmann <arnd(a)arndb.de>
Signed-off-by: Arnd Bergmann <arnd(a)arndb.de>
---
This is an older patch I still had in my queue. Who should pick it up?
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 10ae73611d80..c9ea63ff70a7 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -51,6 +51,7 @@
#include <linux/stat.h>
#include <linux/string.h>
#include <linux/time.h>
+#include <linux/time64.h>
#include <linux/backing-dev.h>
#include <linux/sort.h>
@@ -68,7 +69,7 @@ struct static_key cpusets_enabled_key __read_mostly = STATIC_KEY_INIT_FALSE;
struct fmeter {
int cnt; /* unprocessed events count */
int val; /* most recent output value */
- time_t time; /* clock (secs) when val computed */
+ time64_t time; /* clock (secs) when val computed */
spinlock_t lock; /* guards read or write of above */
};
@@ -1374,7 +1375,7 @@ out:
*/
#define FM_COEF 933 /* coefficient for half-life of 10 secs */
-#define FM_MAXTICKS ((time_t)99) /* useless computing more ticks than this */
+#define FM_MAXTICKS ((u32)99) /* useless computing more ticks than this */
#define FM_MAXCNT 1000000 /* limit cnt to avoid overflow */
#define FM_SCALE 1000 /* faux fixed point scale */
@@ -1390,8 +1391,11 @@ static void fmeter_init(struct fmeter *fmp)
/* Internal meter update - process cnt events and update value */
static void fmeter_update(struct fmeter *fmp)
{
- time_t now = get_seconds();
- time_t ticks = now - fmp->time;
+ time64_t now;
+ u32 ticks;
+
+ now = ktime_get_seconds();
+ ticks = now - fmp->time;
if (ticks == 0)
return;
struct timeval on 32-bit systems will have its tv_sec
value overflow in year 2038 and beyond.
Use a 64 bit value to print time of the coredump in seconds.
ktime_get_real_seconds is chosen here for efficiency reasons.
Suggested by: Arnd Bergmann <arnd(a)arndb.de>
Signed-off-by: Tina Ruchandani <ruchandani.tina(a)gmail.com>
Signed-off-by: Arnd Bergmann <arnd(a)arndb.de>
---
I've had this patch in my queue for a while, and would like for
someone to pick it up into mainline.
Andrew Morton seems to be the one who has handled most of the
coredump.c patches. Andrew, can you take this for 4.5?
My tree is part of linux-next, so I assume I have to drop it
before you can take it into -mm?
Alternatively, Al could take it for his vfs tree, or Thomas
or John for the timekeeping branch in tip.
diff --git a/fs/coredump.c b/fs/coredump.c
index 1777331eee76..b3c153ca435d 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -32,6 +32,7 @@
#include <linux/pipe_fs_i.h>
#include <linux/oom.h>
#include <linux/compat.h>
+#include <linux/timekeeping.h>
#include <asm/uaccess.h>
#include <asm/mmu_context.h>
@@ -232,9 +233,10 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
break;
/* UNIX time of coredump */
case 't': {
- struct timeval tv;
- do_gettimeofday(&tv);
- err = cn_printf(cn, "%lu", tv.tv_sec);
+ time64_t time;
+
+ time = ktime_get_real_seconds();
+ err = cn_printf(cn, "%lld", time);
break;
}
/* hostname */
'struct timeval tv' and 'struct timeval now' is used to calculate the
elapsed time. 'LIRC_SFH506_DELAY' is a delay t_phl in usecs.
32-bit systems using 'struct timeval' will break in the year 2038,
so we have to replace that code with more appropriate types.
This patch changes the lirc_parallel.c file of media: lirc driver
to use ktime_t.
ktime_get() is better than using do_gettimeofday(),
because it uses the monotonic clock. ktime_sub is used
to subtract two ktime variables. ktime_to_us() is used to
convert ktime to microsecond.
New ktime_t variable timeout, is added in lirc_off(),to improve
clarity. Introduced a new ktime_t variable in lirc_lirc_irq_handler()
function, to avoid the use of signal variable for storing
seconds in the first part of this fucntion as later it uses
a time unit that is defined by the global "timer" variable.
This makes it more clear.
ktime_set() is used to set a value in seconds to a value in
nanosecond so that ktime_compare() can be used appropriately.
ktime_compare() is used to compare two ktime values.
ktime_add_ns() is used to increment a ktime value by 1 sec.
One comment is also shifted a line up, as it was creating a 80
character warning.
Build tested it. Also tested it with sparse.
Signed-off-by: Tapasweni Pathak <tapaswenipathak(a)gmail.com>
Reviewed-by: Arnd Bergmann <arnd(a)arndb.de>
Signed-off-by: Arnd Bergmann <arnd(a)arndb.de>
diff --git a/drivers/staging/media/lirc/lirc_parallel.c b/drivers/staging/media/lirc/lirc_parallel.c
index c1408342b1d0..c7987c01d9e0 100644
--- a/drivers/staging/media/lirc/lirc_parallel.c
+++ b/drivers/staging/media/lirc/lirc_parallel.c
@@ -33,7 +33,7 @@
#include <linux/fs.h>
#include <linux/kernel.h>
#include <linux/ioport.h>
-#include <linux/time.h>
+#include <linux/ktime.h>
#include <linux/mm.h>
#include <linux/delay.h>
@@ -144,25 +144,22 @@ static void lirc_off(void)
static unsigned int init_lirc_timer(void)
{
- struct timeval tv, now;
+ ktime_t kt, now, timeout;
unsigned int level, newlevel, timeelapsed, newtimer;
int count = 0;
- do_gettimeofday(&tv);
- tv.tv_sec++; /* wait max. 1 sec. */
+ kt = ktime_get();
+ /* wait max. 1 sec. */
+ timeout = ktime_add_ns(kt, NSEC_PER_SEC);
level = lirc_get_timer();
do {
newlevel = lirc_get_timer();
if (level == 0 && newlevel != 0)
count++;
level = newlevel;
- do_gettimeofday(&now);
- } while (count < 1000 && (now.tv_sec < tv.tv_sec
- || (now.tv_sec == tv.tv_sec
- && now.tv_usec < tv.tv_usec)));
-
- timeelapsed = (now.tv_sec + 1 - tv.tv_sec)*1000000
- + (now.tv_usec - tv.tv_usec);
+ now = ktime_get();
+ } while (count < 1000 && (ktime_before(now, timeout)));
+ timeelapsed = ktime_us_delta(now, kt);
if (count >= 1000 && timeelapsed > 0) {
if (default_timer == 0) {
/* autodetect timer */
@@ -220,8 +217,8 @@ static void rbuf_write(int signal)
static void lirc_lirc_irq_handler(void *blah)
{
- struct timeval tv;
- static struct timeval lasttv;
+ ktime_t kt, delkt;
+ static ktime_t lastkt;
static int init;
long signal;
int data;
@@ -244,16 +241,14 @@ static void lirc_lirc_irq_handler(void *blah)
#ifdef LIRC_TIMER
if (init) {
- do_gettimeofday(&tv);
+ kt = ktime_get();
- signal = tv.tv_sec - lasttv.tv_sec;
- if (signal > 15)
+ delkt = ktime_sub(kt, lastkt);
+ if (ktime_compare(delkt, ktime_set(15, 0)) > 0)
/* really long time */
data = PULSE_MASK;
else
- data = (int) (signal*1000000 +
- tv.tv_usec - lasttv.tv_usec +
- LIRC_SFH506_DELAY);
+ data = (int) (ktime_to_us(delkt) + LIRC_SFH506_DELAY);
rbuf_write(data); /* space */
} else {
@@ -301,7 +296,7 @@ static void lirc_lirc_irq_handler(void *blah)
data = 1;
rbuf_write(PULSE_BIT|data); /* pulse */
}
- do_gettimeofday(&lasttv);
+ lastkt = ktime_get();
#else
/* add your code here */
#endif
'struct timeval presstime' and 'struct timeval tv' is used to
calculate the time since the last button press.
32-bit systems using 'struct timeval' will break in the year 2038,
so we have to replace that code with more appropriate types.
This patch changes the media: lirc driver to use ktime_t.
ktime_get() is better than using do_gettimeofday(), because it uses
the monotonic clock. ktime_sub() are used to subtract two ktime
variables. 'ms' is only used to check how much time has passed by comparing
to 250. So instead of using expensive ktime_to_ms() call, it has been
changed to hold nanoseconds by using ktime_to_ns().
Build tested it. Tested with sparse too.
Signed-off-by: Tapasweni Pathak <tapaswenipathak(a)gmail.com>
Reviewed-by: Arnd Bergmann <arnd(a)arndb.de>
Signed-off-by: Arnd Bergmann <arnd(a)arndb.de>
diff --git a/drivers/staging/media/lirc/lirc_sasem.c b/drivers/staging/media/lirc/lirc_sasem.c
index f2dca69c2bc0..2218d0042030 100644
--- a/drivers/staging/media/lirc/lirc_sasem.c
+++ b/drivers/staging/media/lirc/lirc_sasem.c
@@ -42,6 +42,7 @@
#include <linux/slab.h>
#include <linux/uaccess.h>
#include <linux/usb.h>
+#include <linux/ktime.h>
#include <media/lirc.h>
#include <media/lirc_dev.h>
@@ -111,7 +112,7 @@ struct sasem_context {
} tx;
/* for dealing with repeat codes (wish there was a toggle bit!) */
- struct timeval presstime;
+ ktime_t presstime;
char lastcode[8];
int codesaved;
};
@@ -566,8 +567,8 @@ static void incoming_packet(struct sasem_context *context,
{
int len = urb->actual_length;
unsigned char *buf = urb->transfer_buffer;
- long ms;
- struct timeval tv;
+ u64 ns;
+ ktime_t kt;
if (len != 8) {
dev_warn(&context->dev->dev,
@@ -584,9 +585,8 @@ static void incoming_packet(struct sasem_context *context,
*/
/* get the time since the last button press */
- do_gettimeofday(&tv);
- ms = (tv.tv_sec - context->presstime.tv_sec) * 1000 +
- (tv.tv_usec - context->presstime.tv_usec) / 1000;
+ kt = ktime_get();
+ ns = ktime_to_ns(ktime_sub(kt, context->presstime));
if (memcmp(buf, "\x08\0\0\0\0\0\0\0", 8) == 0) {
/*
@@ -600,10 +600,9 @@ static void incoming_packet(struct sasem_context *context,
* in that time and then get a false repeat of the previous
* press but it is long enough for a genuine repeat
*/
- if ((ms < 250) && (context->codesaved != 0)) {
+ if ((ns < 250 * NSEC_PER_MSEC) && (context->codesaved != 0)) {
memcpy(buf, &context->lastcode, 8);
- context->presstime.tv_sec = tv.tv_sec;
- context->presstime.tv_usec = tv.tv_usec;
+ context->presstime = kt;
}
} else {
/* save the current valid code for repeats */
@@ -613,8 +612,7 @@ static void incoming_packet(struct sasem_context *context,
* just for safety reasons
*/
context->codesaved = 1;
- context->presstime.tv_sec = tv.tv_sec;
- context->presstime.tv_usec = tv.tv_usec;
+ context->presstime = kt;
}
lirc_buffer_write(context->driver->rbuf, buf);
32 bit systems using 'struct timeval' will break in the year 2038, so
we modify the code appropriately.
This patch replaces the use of struct timeval and do_gettimeofday()
with ktime_get_real_seconds() which returns a 64 bit value which is
safer than struct timeval.
Signed-off-by: Amitoj Kaur Chawla <amitoj1606(a)gmail.com>
---
drivers/scsi/bfa/bfa_svc.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/scsi/bfa/bfa_svc.c b/drivers/scsi/bfa/bfa_svc.c
index 6521896..0240554 100644
--- a/drivers/scsi/bfa/bfa_svc.c
+++ b/drivers/scsi/bfa/bfa_svc.c
@@ -3424,13 +3424,10 @@ __bfa_cb_fcport_stats_clr(void *cbarg, bfa_boolean_t complete)
struct list_head *qe, *qen;
if (complete) {
- struct timeval tv;
-
/*
* re-initialize time stamp for stats reset
*/
- do_gettimeofday(&tv);
- fcport->stats_reset_time = tv.tv_sec;
+ fcport->stats_reset_time = ktime_get_seconds();
list_for_each_safe(qe, qen, &fcport->statsclr_pending_q) {
bfa_q_deq(&fcport->statsclr_pending_q, &qe);
cb = (struct bfa_cb_pending_q_s *)qe;
--
1.9.1
32 bit systems using 'struct timeval' will break in the year 2038, so
we replace the code appropriately.
This patch replaces struct timeval and do_gettimeofday() with
monotonic ktime_get_ns(). Since we are interested in microseconds
portion of the time, we can use NSEC_PER_USEC macro but this would
lead to expensive division for a frequently used function.
Alternatively a bit shift has been done which performs a division of
1024 instead of 1000 which slightly alters the value returned by this
function.
Signed-off-by: Amitoj Kaur Chawla <amitoj1606(a)gmail.com>
---
drivers/scsi/bfa/bfa_cs.h | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/drivers/scsi/bfa/bfa_cs.h b/drivers/scsi/bfa/bfa_cs.h
index 91a8aa3..daee860 100644
--- a/drivers/scsi/bfa/bfa_cs.h
+++ b/drivers/scsi/bfa/bfa_cs.h
@@ -32,13 +32,7 @@
#define BFA_TRC_MAX (4 * 1024)
#endif
-#define BFA_TRC_TS(_trcm) \
- ({ \
- struct timeval tv; \
- \
- do_gettimeofday(&tv); \
- (tv.tv_sec*1000000+tv.tv_usec); \
- })
+#define BFA_TRC_TS(_trcm) (ktime_get_ns() >> 10)
#ifndef BFA_TRC_TS
#define BFA_TRC_TS(_trcm) ((_trcm)->ticks++)
--
1.9.1
32 bit systems using 'time_t' will break in the year 2038, so
we modify the code appropriately.
This patch removes the cast to 'time_t' in the assignment statement
since we are eventually removing the time_t definition from the kernel
as an effort to solve the y2038 problem. This change will avoid the
build error but the code is still broken and requires a change in the ioctl
interface.
Further, since the variable io_profile_start_time will break in 2038 or 2106
depending on user space interpreting it as signed or unsigned,
comments have been added to highlight the same.
Signed-off-by: Amitoj Kaur Chawla <amitoj1606(a)gmail.com>
---
Changes in v2:
-Added comments about overflow
Only apply this patch if it's seen as acceptable that the
io_profile_start_time remains truncated to 32 bits in
IOCMD_ITNIM_GET_IOPROFILE. If this is something that needs to
be fixed by adding a replacement vendor command, leave the
cast in place as a reminder.
drivers/scsi/bfa/bfa_defs_svc.h | 4 ++++
drivers/scsi/bfa/bfa_fcpim.c | 3 ++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/bfa/bfa_defs_svc.h b/drivers/scsi/bfa/bfa_defs_svc.h
index e7acf41..599db7b 100644
--- a/drivers/scsi/bfa/bfa_defs_svc.h
+++ b/drivers/scsi/bfa/bfa_defs_svc.h
@@ -1211,6 +1211,10 @@ struct bfa_itnim_ioprofile_s {
u32 clock_res_mul;
u32 clock_res_div;
u32 index;
+ /*
+ * Overflow in 2038 or 2106 depending on user space interpreting it as
+ * signed or unsigned.
+ */
u32 io_profile_start_time; /* IO profile start time */
u32 iocomps[BFA_IOBUCKET_MAX]; /* IO completed */
struct bfa_itnim_latency_s io_latency;
diff --git a/drivers/scsi/bfa/bfa_fcpim.c b/drivers/scsi/bfa/bfa_fcpim.c
index 6730340..56df8d0 100644
--- a/drivers/scsi/bfa/bfa_fcpim.c
+++ b/drivers/scsi/bfa/bfa_fcpim.c
@@ -1478,7 +1478,8 @@ bfa_itnim_get_ioprofile(struct bfa_itnim_s *itnim,
return BFA_STATUS_IOPROFILE_OFF;
itnim->ioprofile.index = BFA_IOBUCKET_MAX;
- itnim->ioprofile.io_profile_start_time = (u32)(time_t)
+ /* io_profile_start_time will overflow in 2038 or 2106 */
+ itnim->ioprofile.io_profile_start_time = (u32)
bfa_io_profile_start_time(itnim->bfa);
itnim->ioprofile.clock_res_mul = bfa_io_lat_clock_res_mul;
itnim->ioprofile.clock_res_div = bfa_io_lat_clock_res_div;
--
1.9.1
32 bit systems using 'time_t' will break in the year 2038, so
we modify the code appropriately.
This patch removes the cast to 'time_t' in the assignment statement
since we are eventually removing the time_t definition from the kernel
as an effort to solve the y2038 problem.
This change impacts the layout of the structure retrieving profile
data as it is being used in a vendor specific command that can get
sent from user space and thus requires change in the ioctl interface.
Signed-off-by: Amitoj Kaur Chawla <amitoj1606(a)gmail.com>
---
drivers/scsi/bfa/bfa_fcpim.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/scsi/bfa/bfa_fcpim.c b/drivers/scsi/bfa/bfa_fcpim.c
index 6730340..e5c211f 100644
--- a/drivers/scsi/bfa/bfa_fcpim.c
+++ b/drivers/scsi/bfa/bfa_fcpim.c
@@ -1478,7 +1478,7 @@ bfa_itnim_get_ioprofile(struct bfa_itnim_s *itnim,
return BFA_STATUS_IOPROFILE_OFF;
itnim->ioprofile.index = BFA_IOBUCKET_MAX;
- itnim->ioprofile.io_profile_start_time = (u32)(time_t)
+ itnim->ioprofile.io_profile_start_time = (u32)
bfa_io_profile_start_time(itnim->bfa);
itnim->ioprofile.clock_res_mul = bfa_io_lat_clock_res_mul;
itnim->ioprofile.clock_res_div = bfa_io_lat_clock_res_div;
--
1.9.1
Changes the defintion of the pointer _expiry from time_t to
time64_t. This is to handle the Y2038 problem where time_t
will overflow in 2038. The change is safe because the kernel
subsystems that call dns_query pass NULL.
Signed-off-by: Arnd Bergmann <arnd(a)arndb.de>
Signed-off-by: Aya Mahfouz <mahfouz.saif.elyazal(a)gmail.com>
---
Changelog:
v1: The changes were originally made by Arnd Bergmann in
relation to time_t. I've broken down a patch sent to me to
two independent patches.
include/linux/dns_resolver.h | 2 +-
net/dns_resolver/dns_query.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/dns_resolver.h b/include/linux/dns_resolver.h
index cc92268..6ac3cad 100644
--- a/include/linux/dns_resolver.h
+++ b/include/linux/dns_resolver.h
@@ -27,7 +27,7 @@
#ifdef __KERNEL__
extern int dns_query(const char *type, const char *name, size_t namelen,
- const char *options, char **_result, time_t *_expiry);
+ const char *options, char **_result, time64_t *_expiry);
#endif /* KERNEL */
diff --git a/net/dns_resolver/dns_query.c b/net/dns_resolver/dns_query.c
index 4677b6f..ecc28cf 100644
--- a/net/dns_resolver/dns_query.c
+++ b/net/dns_resolver/dns_query.c
@@ -67,7 +67,7 @@
* Returns the size of the result on success, -ve error code otherwise.
*/
int dns_query(const char *type, const char *name, size_t namelen,
- const char *options, char **_result, time_t *_expiry)
+ const char *options, char **_result, time64_t *_expiry)
{
struct key *rkey;
const struct user_key_payload *upayload;
--
2.4.3
--
Kind Regards,
Aya Saif El-yazal Mahfouz
You have received a new fax.
Please, download fax document attached to this email.
Scanned at: Tue, 17 Nov 2015 19:33:14 +0300
Scanned by: Reginald Fritz
Resolution: 600 DPI
Pages sent: 4
Document name: scanned-0000619186.doc
Filesize: 184 Kb
Scanned in: 35 seconds
Thanks for using Interfax service!
The hpfs code uses time_t which will overflow at 2038.
If time_t is only internal used without being stored on disk, simply
replacing it with time64_t is fine. Otherwise, since the range of
time has been already lost when it is stored on disk, the only thing
we can do is a cast between 32-bit value and time64_t so as to remove
time_t.
DengChao (2):
fs:hpfs:Remove internal using time_t
fs:hpfs:Remove time_t used on disk
fs/hpfs/hpfs_fn.h | 26 ++++++++++++++++++++++----
fs/hpfs/namei.c | 21 +++++++++++++++------
2 files changed, 37 insertions(+), 10 deletions(-)
--
1.9.1
A new fax document for you.
Please check your fax document in the attachment to this e-mail.
Scan duration: 57 seconds
Date of scan: Tue, 17 Nov 2015 00:37:47 +0300
From: Adam Newell
Pages scanned: 3
Fax name: document-0000827154.doc
Filesize: 216 Kb
Scan quality: 500 DPI
Thank you for using Interfax!
What is the correct set of compile tests needed for these y2038 changes?
I've simply done 32 and 64 bit compiles and am concerned with what I may
be missing.
Please point me to any relevant documentation.
Thanks,
Alison
Here is the fourth version for converting parport device(ppdev) to
y2038 safe. The first three could found at [1], [2], [3].
An y2038 safe application/kernel use 64bit time_t(aka time64_t)
instead of 32bit time_t. There are the 5 cases need to support:
summary |u:arch |u:tv_sec |k:arch |k:tv_sec
-------------------|-------|---------|-------|--------
32_y2038_unsafe |32 |32 |32 |32
32_y2038_safe |32 |64 |32 |64
compat_y2038_unsafe|32 |32 |64 |64
compat_y2038_safe |32 |64 |64 |64
64_y2038_safe |64 |64 |64 |64
notes:
1. xxx_y2038_safe/unsafe. 32 means app running on the 32bit
kernel. Compat means 32bit app running on 64bit kernel. 64
means 64bit app running on 64bit kernel.
2. 1.3.5 are the original one, we need keep the compatability.
2,4 is new one we need to support.
There are different ways to do this. Convert to 64bit time and/or
define COMPAT_USE_64BIT_TIME 0 or 1 to indicate y2038 safe or unsafe.
But it is not mean that we need to convert all the time relative
struct to 64bit. Because some time relative struct(e.g. timeval in
ppdev.c) is mainly the offset of the real time.
The main issue in ppdev.c is PPSETTIME/PPGETTIME which transfer
timeval between user space and kernel. My approach here is handle them
as different ioctl command.
Build successful on arm64 and arm.
Changes since V3:
1. create pp_set_timeout, pp_get_timeout to reduce the duplicated
code in my patch according to the suggestion of arnd.
I use div_u64_rem instead of jiffies_to_timespec64 because
it could save a divide operaion.
[1] https://lists.linaro.org/pipermail/y2038/2015-June/000522.html
[2] https://lists.linaro.org/pipermail/y2038/2015-June/000567.html
[3] https://lists.linaro.org/pipermail/y2038/2015-November/001093.html
Bamvor Jian Zhang (2):
ppdev: convert to y2038 safe
ppdev: add support for compat ioctl
drivers/char/ppdev.c | 91 ++++++++++++++++++++++++++++++++++++++++------------
1 file changed, 71 insertions(+), 20 deletions(-)
--
2.1.4
You have a new fax!
To view it please open the attachment.
Pages scanned: 8
Author: Ronald Williams
Date of scan: Sun, 15 Nov 2015 19:23:36 +0300
Scan time: 52 seconds
File size: 155 Kb
Scan quality: 500 DPI
File name: document-00000125821.doc
Thanks for choosing Interfax!
A new fax document for you.
You can find your fax document in the attachment.
Scanned by: Shane Jacobs
Pages: 10
File size: 270 Kb
Quality: 400 DPI
Date: Sat, 14 Nov 2015 03:33:32 +0300
Scanned in: 11 seconds
Filename: scanned_0000663234.doc
Thank you for using Interfax!
Hi Arnd,
I'm looking for more y2038 tasks...please ;)
How are you doling out y2038 tasks presently?
(I'm not clear what's left undone, if any, from the outreachy queue)
Thanks,
Alison
get_seconds() API is not y2038 safe on 32 bit systems and the API
is deprecated. Replace it with calls to ktime_get_real_seconds()
API instead. Change mddev structure types to time64_t accordingly.
32 bit signed timestamps will overflow in the year 2038.
Change the user interface mdu_array_info_s structure timestamps:
ctime and utime values used in ioctls GET_ARRAY_INFO and
SET_ARRAY_INFO to unsigned int. This will extend the field to last
until the year 2106.
The long term plan is to get rid of ctime and utime values in
this structure as this information can be read from the on-disk
meta data directly.
Clamp the tim64_t timestamps to positive values with a max of U32_MAX
when returning from GET_ARRAY_INFO ioctl to accommodate above changes
in the data type of timestamps to unsigned int.
v0.90 on disk meta data uses u32 for maintaining time stamps.
So this will also last until year 2106.
Assumption is that the usage of v0.90 will be deprecated by
year 2106.
Timestamp fields in the on disk meta data for v1.0 version already
use 64 bit data types. Remove the truncation of the bits while
writing to or reading from these from the disk.
Signed-off-by: Deepa Dinamani <deepa.kernel(a)gmail.com>
---
Notes:
A separate patch will update mdadm to obtain times from the metadata,
and to give a deprecation warning for use of v0.90 arrays
drivers/md/md.c | 18 +++++++++---------
drivers/md/md.h | 2 +-
include/uapi/linux/raid/md_u.h | 4 ++--
3 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 7ab9ed9..20763ea 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1196,13 +1196,13 @@ static void super_90_sync(struct mddev *mddev, struct md_rdev *rdev)
memcpy(&sb->set_uuid2, mddev->uuid+8, 4);
memcpy(&sb->set_uuid3, mddev->uuid+12,4);
- sb->ctime = mddev->ctime;
+ sb->ctime = clamp_t(time64_t, mddev->ctime, 0, U32_MAX);
sb->level = mddev->level;
sb->size = mddev->dev_sectors / 2;
sb->raid_disks = mddev->raid_disks;
sb->md_minor = mddev->md_minor;
sb->not_persistent = 0;
- sb->utime = mddev->utime;
+ sb->utime = clamp_t(time64_t, mddev->utime, 0, U32_MAX);
sb->state = 0;
sb->events_hi = (mddev->events>>32);
sb->events_lo = (u32)mddev->events;
@@ -1542,8 +1542,8 @@ static int super_1_validate(struct mddev *mddev, struct md_rdev *rdev)
mddev->patch_version = 0;
mddev->external = 0;
mddev->chunk_sectors = le32_to_cpu(sb->chunksize);
- mddev->ctime = le64_to_cpu(sb->ctime) & ((1ULL << 32)-1);
- mddev->utime = le64_to_cpu(sb->utime) & ((1ULL << 32)-1);
+ mddev->ctime = le64_to_cpu(sb->ctime);
+ mddev->utime = le64_to_cpu(sb->utime);
mddev->level = le32_to_cpu(sb->level);
mddev->clevel[0] = 0;
mddev->layout = le32_to_cpu(sb->layout);
@@ -2331,7 +2331,7 @@ repeat:
spin_lock(&mddev->lock);
- mddev->utime = get_seconds();
+ mddev->utime = ktime_get_real_seconds();
if (test_and_clear_bit(MD_CHANGE_DEVS, &mddev->flags))
force_change = 1;
@@ -5828,7 +5828,7 @@ static int get_array_info(struct mddev *mddev, void __user *arg)
info.major_version = mddev->major_version;
info.minor_version = mddev->minor_version;
info.patch_version = MD_PATCHLEVEL_VERSION;
- info.ctime = mddev->ctime;
+ info.ctime = clamp_t(time64_t, mddev->ctime, 0, U32_MAX);
info.level = mddev->level;
info.size = mddev->dev_sectors / 2;
if (info.size != mddev->dev_sectors / 2) /* overflow */
@@ -5838,7 +5838,7 @@ static int get_array_info(struct mddev *mddev, void __user *arg)
info.md_minor = mddev->md_minor;
info.not_persistent= !mddev->persistent;
- info.utime = mddev->utime;
+ info.utime = clamp_t(time64_t, mddev->utime, 0, U32_MAX);
info.state = 0;
if (mddev->in_sync)
info.state = (1<<MD_SB_CLEAN);
@@ -6338,13 +6338,13 @@ static int set_array_info(struct mddev *mddev, mdu_array_info_t *info)
/* ensure mddev_put doesn't delete this now that there
* is some minimal configuration.
*/
- mddev->ctime = get_seconds();
+ mddev->ctime = ktime_get_real_seconds();
return 0;
}
mddev->major_version = MD_MAJOR_VERSION;
mddev->minor_version = MD_MINOR_VERSION;
mddev->patch_version = MD_PATCHLEVEL_VERSION;
- mddev->ctime = get_seconds();
+ mddev->ctime = ktime_get_real_seconds();
mddev->level = info->level;
mddev->clevel[0] = 0;
diff --git a/drivers/md/md.h b/drivers/md/md.h
index f5b9aad..237b507 100644
--- a/drivers/md/md.h
+++ b/drivers/md/md.h
@@ -261,7 +261,7 @@ struct mddev {
* managed externally */
char metadata_type[17]; /* externally set*/
int chunk_sectors;
- time_t ctime, utime;
+ time64_t ctime, utime;
int level, layout;
char clevel[16];
int raid_disks;
diff --git a/include/uapi/linux/raid/md_u.h b/include/uapi/linux/raid/md_u.h
index 1cb8aa6..36cd821 100644
--- a/include/uapi/linux/raid/md_u.h
+++ b/include/uapi/linux/raid/md_u.h
@@ -80,7 +80,7 @@ typedef struct mdu_array_info_s {
int major_version;
int minor_version;
int patch_version;
- int ctime;
+ unsigned int ctime;
int level;
int size;
int nr_disks;
@@ -91,7 +91,7 @@ typedef struct mdu_array_info_s {
/*
* Generic state information
*/
- int utime; /* 0 Superblock update time */
+ unsigned int utime; /* 0 Superblock update time */
int state; /* 1 State bits (clean, ...) */
int active_disks; /* 2 Number of currently active disks */
int working_disks; /* 3 Number of working disks */
--
1.9.1
Replace the use of struct timeval and do_gettimeofday() with
64 bit ktime_get_real_seconds. Prevents 32-bit type overflow
in year 2038 on 32-bit systems.
Driver was using the seconds portion of struct timeval (.tv_secs)
to pass a millseconds timestamp to the firmware. This change maintains
that same behavior using ktime_get_real_seconds.
The structure used to pass the timestamp to firmware is 48 bits and
works fine as long as the top 16 bits are zero and they will be zero
for a long time..ie. thousands of years.
Alternative Change: Add sub second granularity to timestamp
As noted above, the driver only used the seconds portion of timeval,
ignores the microseconds portion, and by multiplying by 1000 effectively
does a <<10 and always writes zero into timestamp[0].
The alternative change would pass all the bits to the firmware:
struct timespec64 ts;
ktime_get_real_ts64(&ts);
timestamp = ts.tv_sec * MSEC_PER_SEC + ts.tv_nsec / NSEC_PER_MSEC;
MAINTAINER: Please request alternate change if preferred.
Signed-off-by: Alison Schofield <amsfield22(a)gmail.com>
---
Change in v3:
* move alternative change proposal above the '---' to save
Changes in v2:
* add pmcraid to subject line
* update commit msg w additional detail
* add alternative change proposal per reviewer feedback
drivers/scsi/pmcraid.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
index ed31d8c..3f64275 100644
--- a/drivers/scsi/pmcraid.c
+++ b/drivers/scsi/pmcraid.c
@@ -45,6 +45,7 @@
#include <asm/processor.h>
#include <linux/libata.h>
#include <linux/mutex.h>
+#include <linux/ktime.h>
#include <scsi/scsi.h>
#include <scsi/scsi_host.h>
#include <scsi/scsi_device.h>
@@ -5563,11 +5564,9 @@ static void pmcraid_set_timestamp(struct pmcraid_cmd *cmd)
__be32 time_stamp_len = cpu_to_be32(PMCRAID_TIMESTAMP_LEN);
struct pmcraid_ioadl_desc *ioadl = ioarcb->add_data.u.ioadl;
- struct timeval tv;
__le64 timestamp;
- do_gettimeofday(&tv);
- timestamp = tv.tv_sec * 1000;
+ timestamp = ktime_get_real_seconds() * 1000;
pinstance->timestamp_data->timestamp[0] = (__u8)(timestamp);
pinstance->timestamp_data->timestamp[1] = (__u8)((timestamp) >> 8);
--
2.1.4
Hi,
I was wondering if you would like to acquire the following databases for
your marketing campaigns.
Own the database in excel file for unlimited usages:
1. We have got 450,000 IT decision makers across globe (Titles are like
CIO, CTO, CISO, EVP/SVP/VP/Director of IT, IS, Administrators, Networking,
Storage, Finance, Operation, Business Intelligence, Database etc.) contacts
(name, title, email, phone, address and company details).
2. Storage users list: Brocade, Dell, Hitachi, HP, IBM, NetApp,
Plasmon, SanDisk, Seagate, Oracle, VMware Storage customers.
3. Cloud computing users list: VMware, Citrix, NetApp, Microsoft
HyperV, Amazon EC2, Salesforce.com, Oracle Solaris, Rackspace, Windows
Azure, Google Apps customers.
4. CRM users Lists: MS Dynamic CRM , MS Exchange Server, Siebel, SAP
CRM, Salesforce, IBM Lotus, Goldmine, Sage SalesLogix, Act by Sage, ADERANT,
CDC Software, eGain, MS Outlook, Pivotal CRM, SPSS, SugarCRM etc.
5. ERP users Lists: Actuate, Algorithmics, Ariba, ATG, BizFlow, BMC,
Bridgeline, Business Objects, Cognos, Deltek, FileNet, Hyperion, IBM
ClearCase, IBM Rational, IBM Tivoli, IBM WebSphere, Infor Baan ERP, Infor
Mapics, Informatica, JD Edwards, Lawson, MS Active, MS BizTalk Server, MS
Com, MS Dynamics, MS Forefront, MS MQ, MS Visual SourceSafe 5.0, Netsuite,
Open Text Livelink, Oracle E-Business, Panorama, PeopleSoft, Ramco ERP,
Saba, Sage Abra HRIS, Sage Abra HRMS, Sage MAS 90, Sage Payroll Services,
SAP NetWeaver, SAP R/3, Serena, Siemens PLM, Sitecore, Software AG,
Sterling, Syspro, Telelogic, Tibco, Tidal Software, Ultimus BPM, UltiPro,
Unica etc.
6. Business Intelligence users list: SAP BI, Oracle BI, Tibco BI,
Microsoft BI, Cognos BI etc.
7. Network Security software users list: CA, Citrix, D-Link, F5, McAfee
etc.
8. IT security software users list: Symantec, Trend Micro, McAfee,
Check Point, EMC, CA, Kaspersky, Websense, Verint, AVG, Sophos, Panda
Security etc.
9. Database application users list: MySQL, Teradata, Oracle, IBM,
Sybase etc.
Please review and let me know if you have any such database requirement at
this time.
Kind Regards,
Tania Cuevas
Database Specialist
_____
We respect your privacy. If you do not wish to receive future e-mail please
reply with "REMOVE".
Here is the third version for converting parport device(ppdev) to y2038 safe.
The first two version could found at [1],[2].
An y2038 safe application/kernel use 64bit time_t(aka time64_t) instead of 32bit
time_t. There are the 5 cases need to support:
summary |u:arch |u:tv_sec |k:arch |k:tv_sec
-------------------|-------|---------|-------|--------
32_y2038_unsafe |32 |32 |32 |32
32_y2038_safe |32 |64 |32 |64
compat_y2038_unsafe|32 |32 |64 |64
compat_y2038_safe |32 |64 |64 |64
64_y2038_safe |64 |64 |64 |64
notes:
1. xxx_y2038_safe/unsafe. 32 means app running on the 32bit kernel.
compat means 32bit app running on 64bit kernel. 64 means 64bit app
running on 64bit kernel.
2. 1.3.5 are the original one, we need keep the compatability. 2,4 is
new one we need to support.
There are different ways to do this. Convert to 64bit time and/or define
COMPAT_USE_64BIT_TIME 0 or 1 to indicate y2038 safe or unsafe.
But it is not mean that we need to convert all the time relative struct
to 64bit. Because some time relative struct(e.g. timeval in ppdev.c) is mainly
the offset of the real time.
The main issue in ppdev.c is PPSETTIME/PPGETTIME which transfer timeval between
user space and kernel. My approach here is handle them as different ioctl
command.
Build successful on arm64 and arm.
[1] https://lists.linaro.org/pipermail/y2038/2015-June/000522.html
[2] https://lists.linaro.org/pipermail/y2038/2015-June/000567.html
Bamvor Jian Zhang (2):
ppdev: convert to y2038 safe
ppdev: add support for compat ioctl
drivers/char/ppdev.c | 85 ++++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 69 insertions(+), 16 deletions(-)
--
2.1.4
This is my second attempt to convert subsystem-wide code in v4l
for y2038 changes, removing uses of time_t in common files
and adding support for user space that defines time_t as 64 bit.
Based on the initial feedback from Hans Verkuil, I've changed the
ioctl handling to remain 100% compatible with existing headers,
which also makes it more likely that existing source code can
compile without changes.
This comes at a noticeable expense of adding complexity to
the v4l2-ioctl.c file, as we now have to handle two versions
of each ioctl command that passes a time_t in its arguments.
I have not added support for the new binary layout of v4l2_timeval
to v4l2-compat-ioctl32 yet, that is something I can do when the
basic approach has been agreed on.
Arnd
Arnd Bergmann (9):
[media] dvb: use ktime_t for internal timeout
[media] dvb: remove unused systime() function
[media] dvb: don't use 'time_t' in event ioctl
[media] exynos4-is: use monotonic timestamps as advertized
[media] make VIDIOC_DQEVENT work with 64-bit time_t
[media] use v4l2_get_timestamp where possible
[media] v4l2: introduce v4l2_timeval
[media] handle 64-bit time_t in v4l2_buffer
[media] omap3isp: support 64-bit version of omap3isp_stat_data
drivers/media/dvb-core/demux.h | 2 +-
drivers/media/dvb-core/dmxdev.c | 2 +-
drivers/media/dvb-core/dvb_demux.c | 17 +-
drivers/media/dvb-core/dvb_demux.h | 4 +-
drivers/media/dvb-core/dvb_net.c | 2 +-
drivers/media/dvb-frontends/dibx000_common.c | 10 -
drivers/media/dvb-frontends/dibx000_common.h | 2 -
drivers/media/pci/bt8xx/bttv-driver.c | 7 +-
drivers/media/pci/cx18/cx18-mailbox.c | 2 +-
drivers/media/pci/meye/meye.h | 2 +-
drivers/media/pci/zoran/zoran.h | 2 +-
drivers/media/platform/coda/coda.h | 2 +-
drivers/media/platform/exynos4-is/fimc-capture.c | 8 +-
drivers/media/platform/exynos4-is/fimc-lite.c | 7 +-
drivers/media/platform/omap/omap_vout.c | 4 +-
drivers/media/platform/omap3isp/isph3a_aewb.c | 2 +
drivers/media/platform/omap3isp/isph3a_af.c | 2 +
drivers/media/platform/omap3isp/isphist.c | 2 +
drivers/media/platform/omap3isp/ispstat.c | 20 +-
drivers/media/platform/omap3isp/ispstat.h | 4 +-
drivers/media/platform/s3c-camif/camif-capture.c | 8 +-
drivers/media/platform/vim2m.c | 2 +-
drivers/media/platform/vivid/vivid-ctrls.c | 2 +-
drivers/media/usb/cpia2/cpia2.h | 2 +-
drivers/media/usb/cpia2/cpia2_v4l.c | 2 +-
drivers/media/usb/gspca/gspca.c | 6 +-
drivers/media/usb/usbvision/usbvision.h | 2 +-
drivers/media/v4l2-core/v4l2-common.c | 6 +-
drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 35 ----
drivers/media/v4l2-core/v4l2-dev.c | 1 +
drivers/media/v4l2-core/v4l2-event.c | 35 +++-
drivers/media/v4l2-core/v4l2-ioctl.c | 227 ++++++++++++++++++++---
drivers/media/v4l2-core/v4l2-subdev.c | 6 +
drivers/staging/media/omap4iss/iss_video.c | 5 +-
include/media/v4l2-common.h | 2 +-
include/media/v4l2-event.h | 2 +
include/media/videobuf-core.h | 2 +-
include/trace/events/v4l2.h | 12 +-
include/uapi/linux/dvb/video.h | 3 +-
include/uapi/linux/omap3isp.h | 19 ++
include/uapi/linux/videodev2.h | 78 ++++++++
41 files changed, 415 insertions(+), 145 deletions(-)
--
2.1.0.rc2
Before this, I have discussed this problem with Arnd. And Arnd have
an idea that by converting timeval to long / long in input_event, so that
input_event structure size will be unchanged, and timeval structure will
removed entirely. But we also need to avoid using CLOCK_REALTIME in
userland, to keep the new input_event structure y2038 safe.
The input_event will only support monotonic time in Arnd's idea. And
we still need to add wall time support for old 32-bit binary.
Those patches try to keep original input capacity, and resolve y2038
problem in input_event radically.
struct input_event is only used between kernel and userspace
communication (except uinput). So that we can replace input_event
with input_event64 in kernel entirely, and add a conversion in
input_event_from/to_user() to keep compatible with old 32-bits binary.
userland can switch to input_event64, which is y2038 safe, via ioctl.
WEN Pingbo (3):
evdev: convert input_event to input_event64
evdev: add new ioctl EVIOCSEVENT / EVIOCGEVENT
uinput: convert input_event to input_event64
drivers/input/evdev.c | 38 ++++++++++++-------
drivers/input/input-compat.c | 88 +++++++++++++++++++++++++++++++++++++-------
drivers/input/input-compat.h | 9 +++--
drivers/input/misc/uinput.c | 17 ++++++---
include/linux/uinput.h | 2 +-
include/uapi/linux/input.h | 18 +++++++++
6 files changed, 134 insertions(+), 38 deletions(-)
--
1.9.1
You have received a new fax.
Scanned fax document is attached to this email.
Scanned by: Daniel Chamberlain
Document name: scan_0000852481.doc
Date: Thu, 5 Nov 2015 03:19:32 +0300
Scan quality: 500 DPI
File size: 144 Kb
Pages sent: 3
Scanned in: 47 seconds
Thanks for using Interfax service!
struct timeval' uses 32-bits for its seconds field and will overflow in
the year 2038 and beyond. This patch replaces the usage of 'struct timeval'
in mon_get_timestamp() with timespec64 which uses a 64-bit seconds field
and is y2038-safe. mon_get_timestamp() truncates the timestamp at 4096 seconds,
so the correctness of the code is not affected. This patch is part of a larger
attempt to remove instances of struct timeval and other 32-bit timekeeping
(time_t, struct timespec) from the kernel.
Signed-off-by: Tina Ruchandani <ruchandani.tina(a)gmail.com>
Suggested-by: Arnd Bergmann <arnd(a)arndb.de>
---
Changes in v2:
- Switch to monotonic time since we only care about time elapsed.
---
drivers/usb/mon/mon_text.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/mon/mon_text.c b/drivers/usb/mon/mon_text.c
index ad40825..98e4f63 100644
--- a/drivers/usb/mon/mon_text.c
+++ b/drivers/usb/mon/mon_text.c
@@ -9,6 +9,7 @@
#include <linux/usb.h>
#include <linux/slab.h>
#include <linux/time.h>
+#include <linux/ktime.h>
#include <linux/export.h>
#include <linux/mutex.h>
#include <linux/debugfs.h>
@@ -176,12 +177,12 @@ static inline char mon_text_get_data(struct mon_event_text *ep, struct urb *urb,
static inline unsigned int mon_get_timestamp(void)
{
- struct timeval tval;
+ struct timespec64 now;
unsigned int stamp;
- do_gettimeofday(&tval);
- stamp = tval.tv_sec & 0xFFF; /* 2^32 = 4294967296. Limit to 4096s. */
- stamp = stamp * 1000000 + tval.tv_usec;
+ ktime_get_ts64(&now);
+ stamp = now.tv_sec & 0xFFF; /* 2^32 = 4294967296. Limit to 4096s. */
+ stamp = stamp * USEC_PER_SEC + now.tv_nsec / NSEC_PER_USEC;
return stamp;
}
--
2.6.0.rc2.230.g3dd15c0
This patchset removes the use of struct timeval because struct timeval
will break in 32 bit systems in the year 2038.
Amitoj Kaur Chawla(2):
scsi: bfa: bfa_svc: Use ktime_get_real_seconds()
scsi: bfa: bfa_svc: Remove use of struct timeval
drivers/scsi/bfa/bfa_svc.c | 30 ++++++++----------------------
drivers/scsi/bfa/bfa_svc.h | 2 +-
2 files changed, 9 insertions(+), 23 deletions(-)
--
1.9.1
On Thursday 05 November 2015 14:34:48 Stefan Richter wrote:
> On Oct 22 Arnd Bergmann wrote:
> > On Thursday 22 October 2015 04:05:00 Amitoj Kaur Chawla wrote:
> > > 32 bit systems using 'struct timeval' will break in the year 2038, so
> > > we replace the code appropriately. However, this driver is not broken
> > > in 2038 since we are using only the microseconds portion of the
> > > current time.
> > >
> > > This patch replaces timeval with timespec64.
> > >
> > > Signed-off-by: Amitoj Kaur Chawla <amitoj1606(a)gmail.com>
> >
> > Reviewed-by: Arnd Bergmann <arnd(a)arndb.de>
> >
> > (adding the y2038 mailing list as well)
>
> Committed to linux1394.git.
> Arnd, do you have special y2038 plans that make it desirable to have this
> merged before v4.4? Otherwise I would submit it for v4.5-rc1.
4.5-rc1 is fine.
Arnd
Hi Arnd,
We're redesigning the timestamp handling in the video4linux subsystem moving away
from struct timeval to a single timestamp in ns (what ktime_get_ns() gives us).
But I was wondering: ktime_get_ns() gives a s64, so should we use s64 as well as
the timestamp type we'll eventually be returning to the user, or should we use u64?
The current patch series we made uses a u64, but I am now beginning to doubt that
decision.
Regards,
Hans
This patchset removes the use of struct timeval because struct timeval
will break in 32 bit systems in the year 2038.
Changes in v2:
-Removed unnecessary if condition in second patch
-Removed u32 to u64 conversion since monotonic time doesn't
require the change.
Amitoj Kaur Chawla (2):
scsi: bfa: bfa_svc: Use ktime_get_real_seconds()
scsi: bfa: bfa_svc: Remove use of 'struct timeval'
drivers/scsi/bfa/bfa_svc.c | 31 ++++++++-----------------------
1 file changed, 8 insertions(+), 23 deletions(-)
--
1.9.1
timeval is deprecated and not y2038 safe. Its size also changes according
to 32 bit/ 64 bit compilation. Replace it with 32 and 64 bit versions of
its individual fields, giving two ioctls with different code values.
The two ioctls are necessary to maintain the 32 bit and 64 bit userspace
compatibility with a 64/32 bit kernel.
Change unsigned to __u32 types for a definitive userspace interface.
This is in accordance with the psABI that the unsigned type is always
32 bits.
Also use motonic timer instead of real time to ensure positive delta
values.
Refactor usbtest_ioctl for readability to isolate the handling of the
testing timing measurement.
The official testusb userspace tool can be changed in a separate patch
to reflect the __u32 changes as well. It can use the usbtest_param_32
struct, since 32 bit seconds is long enough for test durations.
Signed-off-by: Deepa Dinamani <deepa.kernel(a)gmail.com>
---
drivers/usb/misc/usbtest.c | 229 +++++++++++++++++++++++++++++----------------
1 file changed, 147 insertions(+), 82 deletions(-)
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index 637f3f7..31f5f49 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -22,18 +22,42 @@ static void complicated_callback(struct urb *urb);
/*-------------------------------------------------------------------------*/
/* FIXME make these public somewhere; usbdevfs.h? */
-struct usbtest_param {
+
+/* Parameter for usbtest driver. */
+struct usbtest_param_32 {
/* inputs */
- unsigned test_num; /* 0..(TEST_CASES-1) */
- unsigned iterations;
- unsigned length;
- unsigned vary;
- unsigned sglen;
+ __u32 test_num; /* 0..(TEST_CASES-1) */
+ __u32 iterations;
+ __u32 length;
+ __u32 vary;
+ __u32 sglen;
/* outputs */
- struct timeval duration;
+ __s32 duration_sec;
+ __s32 duration_usec;
};
-#define USBTEST_REQUEST _IOWR('U', 100, struct usbtest_param)
+
+/*
+ * Compat parameter to the usbtest driver.
+ * This supports older user space binaries compiled with 64 bit compiler.
+ */
+struct usbtest_param_64 {
+ /* inputs */
+ __u32 test_num; /* 0..(TEST_CASES-1) */
+ __u32 iterations;
+ __u32 length;
+ __u32 vary;
+ __u32 sglen;
+
+ /* outputs */
+ __s64 duration_sec;
+ __s64 duration_usec;
+};
+
+/* IOCTL interface to the driver. */
+#define USBTEST_REQUEST_32 _IOWR('U', 100, struct usbtest_param_32)
+/* COMPAT IOCTL interface to the driver. */
+#define USBTEST_REQUEST_64 _IOWR('U', 100, struct usbtest_param_64)
/*-------------------------------------------------------------------------*/
@@ -1030,7 +1054,7 @@ struct ctrl_ctx {
unsigned pending;
int status;
struct urb **urb;
- struct usbtest_param *param;
+ struct usbtest_param_32 *param;
int last;
};
@@ -1155,7 +1179,7 @@ error:
}
static int
-test_ctrl_queue(struct usbtest_dev *dev, struct usbtest_param *param)
+test_ctrl_queue(struct usbtest_dev *dev, struct usbtest_param_32 *param)
{
struct usb_device *udev = testdev_to_usbdev(dev);
struct urb **urb;
@@ -1930,7 +1954,7 @@ static struct urb *iso_alloc_urb(
}
static int
-test_queue(struct usbtest_dev *dev, struct usbtest_param *param,
+test_queue(struct usbtest_dev *dev, struct usbtest_param_32 *param,
int pipe, struct usb_endpoint_descriptor *desc, unsigned offset)
{
struct transfer_context context;
@@ -2049,81 +2073,20 @@ static int test_unaligned_bulk(
return retval;
}
-/*-------------------------------------------------------------------------*/
-
-/* We only have this one interface to user space, through usbfs.
- * User mode code can scan usbfs to find N different devices (maybe on
- * different busses) to use when testing, and allocate one thread per
- * test. So discovery is simplified, and we have no device naming issues.
- *
- * Don't use these only as stress/load tests. Use them along with with
- * other USB bus activity: plugging, unplugging, mousing, mp3 playback,
- * video capture, and so on. Run different tests at different times, in
- * different sequences. Nothing here should interact with other devices,
- * except indirectly by consuming USB bandwidth and CPU resources for test
- * threads and request completion. But the only way to know that for sure
- * is to test when HC queues are in use by many devices.
- *
- * WARNING: Because usbfs grabs udev->dev.sem before calling this ioctl(),
- * it locks out usbcore in certain code paths. Notably, if you disconnect
- * the device-under-test, hub_wq will wait block forever waiting for the
- * ioctl to complete ... so that usb_disconnect() can abort the pending
- * urbs and then call usbtest_disconnect(). To abort a test, you're best
- * off just killing the userspace task and waiting for it to exit.
- */
-
+/* Run tests. */
static int
-usbtest_ioctl(struct usb_interface *intf, unsigned int code, void *buf)
+usbtest_do_ioctl(struct usb_interface *intf, struct usbtest_param_32 *param)
{
struct usbtest_dev *dev = usb_get_intfdata(intf);
struct usb_device *udev = testdev_to_usbdev(dev);
- struct usbtest_param *param = buf;
- int retval = -EOPNOTSUPP;
struct urb *urb;
struct scatterlist *sg;
struct usb_sg_request req;
- struct timeval start;
unsigned i;
-
- /* FIXME USBDEVFS_CONNECTINFO doesn't say how fast the device is. */
-
- pattern = mod_pattern;
-
- if (code != USBTEST_REQUEST)
- return -EOPNOTSUPP;
+ int retval = -EOPNOTSUPP;
if (param->iterations <= 0)
return -EINVAL;
-
- if (param->sglen > MAX_SGLEN)
- return -EINVAL;
-
- if (mutex_lock_interruptible(&dev->lock))
- return -ERESTARTSYS;
-
- /* FIXME: What if a system sleep starts while a test is running? */
-
- /* some devices, like ez-usb default devices, need a non-default
- * altsetting to have any active endpoints. some tests change
- * altsettings; force a default so most tests don't need to check.
- */
- if (dev->info->alt >= 0) {
- int res;
-
- if (intf->altsetting->desc.bInterfaceNumber) {
- mutex_unlock(&dev->lock);
- return -ENODEV;
- }
- res = set_altsetting(dev, dev->info->alt);
- if (res) {
- dev_err(&intf->dev,
- "set altsetting to %d failed, %d\n",
- dev->info->alt, res);
- mutex_unlock(&dev->lock);
- return res;
- }
- }
-
/*
* Just a bunch of test cases that every HCD is expected to handle.
*
@@ -2133,7 +2096,6 @@ usbtest_ioctl(struct usb_interface *intf, unsigned int code, void *buf)
* FIXME add more tests! cancel requests, verify the data, control
* queueing, concurrent read+write threads, and so on.
*/
- do_gettimeofday(&start);
switch (param->test_num) {
case 0:
@@ -2548,13 +2510,116 @@ usbtest_ioctl(struct usb_interface *intf, unsigned int code, void *buf)
dev->in_pipe, NULL, 0);
break;
}
- do_gettimeofday(¶m->duration);
- param->duration.tv_sec -= start.tv_sec;
- param->duration.tv_usec -= start.tv_usec;
- if (param->duration.tv_usec < 0) {
- param->duration.tv_usec += 1000 * 1000;
- param->duration.tv_sec -= 1;
+ return retval;
+}
+
+/*-------------------------------------------------------------------------*/
+
+/* We only have this one interface to user space, through usbfs.
+ * User mode code can scan usbfs to find N different devices (maybe on
+ * different busses) to use when testing, and allocate one thread per
+ * test. So discovery is simplified, and we have no device naming issues.
+ *
+ * Don't use these only as stress/load tests. Use them along with with
+ * other USB bus activity: plugging, unplugging, mousing, mp3 playback,
+ * video capture, and so on. Run different tests at different times, in
+ * different sequences. Nothing here should interact with other devices,
+ * except indirectly by consuming USB bandwidth and CPU resources for test
+ * threads and request completion. But the only way to know that for sure
+ * is to test when HC queues are in use by many devices.
+ *
+ * WARNING: Because usbfs grabs udev->dev.sem before calling this ioctl(),
+ * it locks out usbcore in certain code paths. Notably, if you disconnect
+ * the device-under-test, hub_wq will wait block forever waiting for the
+ * ioctl to complete ... so that usb_disconnect() can abort the pending
+ * urbs and then call usbtest_disconnect(). To abort a test, you're best
+ * off just killing the userspace task and waiting for it to exit.
+ */
+
+static int
+usbtest_ioctl(struct usb_interface *intf, unsigned int code, void *buf)
+{
+
+ struct usbtest_dev *dev = usb_get_intfdata(intf);
+ struct usbtest_param_64 *param_64 = buf;
+ struct usbtest_param_32 temp;
+ struct usbtest_param_32 *param_32 = buf;
+ struct timespec64 start;
+ struct timespec64 end;
+ struct timespec64 duration;
+ int retval = -EOPNOTSUPP;
+
+ /* FIXME USBDEVFS_CONNECTINFO doesn't say how fast the device is. */
+
+ pattern = mod_pattern;
+
+ if (mutex_lock_interruptible(&dev->lock))
+ return -ERESTARTSYS;
+
+ /* FIXME: What if a system sleep starts while a test is running? */
+
+ /* some devices, like ez-usb default devices, need a non-default
+ * altsetting to have any active endpoints. some tests change
+ * altsettings; force a default so most tests don't need to check.
+ */
+ if (dev->info->alt >= 0) {
+ if (intf->altsetting->desc.bInterfaceNumber) {
+ retval = -ENODEV;
+ goto free_mutex;
+ }
+ retval = set_altsetting(dev, dev->info->alt);
+ if (retval) {
+ dev_err(&intf->dev,
+ "set altsetting to %d failed, %d\n",
+ dev->info->alt, retval);
+ goto free_mutex;
+ }
+ }
+
+ switch (code) {
+ case USBTEST_REQUEST_64:
+ temp.test_num = param_64->test_num;
+ temp.iterations = param_64->iterations;
+ temp.length = param_64->length;
+ temp.sglen = param_64->sglen;
+ temp.vary = param_64->vary;
+ param_32 = &temp;
+ break;
+
+ case USBTEST_REQUEST_32:
+ break;
+
+ default:
+ retval = -EOPNOTSUPP;
+ goto free_mutex;
+ }
+
+ ktime_get_ts64(&start);
+
+ retval = usbtest_do_ioctl(intf, param_32);
+ if (retval)
+ goto free_mutex;
+
+ ktime_get_ts64(&end);
+
+ duration = timespec64_sub(end, start);
+
+ temp.duration_sec = duration.tv_sec;
+ temp.duration_usec = duration.tv_nsec/NSEC_PER_USEC;
+
+ switch (code) {
+ case USBTEST_REQUEST_32:
+ param_32->duration_sec = temp.duration_sec;
+ param_32->duration_usec = temp.duration_usec;
+ break;
+
+ case USBTEST_REQUEST_64:
+ param_64->duration_sec = temp.duration_sec;
+ param_64->duration_usec = temp.duration_usec;
+ break;
}
+
+free_mutex:
mutex_unlock(&dev->lock);
return retval;
}
--
1.9.1
This patchset removes 'struct timeval' as 32 bit systems using timeval
will break in the year 2038 so the code has been replaced
appropriately.
Amitoj Kaur Chawla (2):
scsi: 3w-9xxx: Remove use of struct timeval
scsi: bfa: Replace struct timeval with ktime_t
drivers/scsi/3w-9xxx.c | 16 ++++++----------
drivers/scsi/bfa/bfa_defs_svc.h | 2 +-
drivers/scsi/bfa/bfad_im.h | 2 +-
3 files changed, 8 insertions(+), 12 deletions(-)
--
1.9.1
timeval is deprecated and not y2038 safe. Its size also changes according
to 32 bit/ 64 bit compilation. Replace it with 32 and 64 bit versions of
its individual fields, giving two ioctls with different code values.
The two ioctls are necessary to maintain the 32 bit and 64 bit userspace
compatibility with a 64/32 bit kernel.
Change unsigned to __u32 types for a definitive userspace interface.
This is in accordance with the psABI that the unsigned type is always
32 bits.
Also use motonic timer instead of real time to ensure positive delta
values.
Refactor usbtest_ioctl for readability to isolate the handling of the
testing timing measurement.
The official testusb userspace tool can be changed in a separate patch
to reflect the __u32 changes as well. It can use the usbtest_param_32
struct, since 32 bit seconds is long enough for test durations.
Signed-off-by: Deepa Dinamani <deepa.kernel(a)gmail.com>
---
Changes since v1:
* Removed new ioctl interface
* Support both sizes of timeval using same ioctl code
* Use timespec64 instead of ktime_t
* Use __u32 for unsigned fields
drivers/usb/misc/usbtest.c | 229 +++++++++++++++++++++++++++++----------------
1 file changed, 147 insertions(+), 82 deletions(-)
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index 637f3f7..d1ce881 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -22,18 +22,42 @@ static void complicated_callback(struct urb *urb);
/*-------------------------------------------------------------------------*/
/* FIXME make these public somewhere; usbdevfs.h? */
-struct usbtest_param {
+
+/* Parameter for usbtest driver. */
+struct usbtest_param_32 {
/* inputs */
- unsigned test_num; /* 0..(TEST_CASES-1) */
- unsigned iterations;
- unsigned length;
- unsigned vary;
- unsigned sglen;
+ __u32 test_num; /* 0..(TEST_CASES-1) */
+ __u32 iterations;
+ __u32 length;
+ __u32 vary;
+ __u32 sglen;
/* outputs */
- struct timeval duration;
+ __s32 duration_sec;
+ __s32 duration_usec;
};
-#define USBTEST_REQUEST _IOWR('U', 100, struct usbtest_param)
+
+/*
+ * Compat parameter to the usbtest driver.
+ * This supports older user space binaries compiled with 64 bit compiler.
+ */
+struct usbtest_param_64 {
+ /* inputs */
+ __u32 test_num; /* 0..(TEST_CASES-1) */
+ __u32 iterations;
+ __u32 length;
+ __u32 vary;
+ __u32 sglen;
+
+ /* outputs */
+ __s64 duration_sec;
+ __s64 duration_usec;
+};
+
+/* IOCTL interface to the driver. */
+#define USBTEST_REQUEST_32 _IOWR('U', 100, struct usbtest_param_32)
+/* COMPAT IOCTL interface to the driver. */
+#define USBTEST_REQUEST_64 _IOWR('U', 100, struct usbtest_param_64)
/*-------------------------------------------------------------------------*/
@@ -1030,7 +1054,7 @@ struct ctrl_ctx {
unsigned pending;
int status;
struct urb **urb;
- struct usbtest_param *param;
+ struct usbtest_param_32 *param;
int last;
};
@@ -1155,7 +1179,7 @@ error:
}
static int
-test_ctrl_queue(struct usbtest_dev *dev, struct usbtest_param *param)
+test_ctrl_queue(struct usbtest_dev *dev, struct usbtest_param_32 *param)
{
struct usb_device *udev = testdev_to_usbdev(dev);
struct urb **urb;
@@ -1930,7 +1954,7 @@ static struct urb *iso_alloc_urb(
}
static int
-test_queue(struct usbtest_dev *dev, struct usbtest_param *param,
+test_queue(struct usbtest_dev *dev, struct usbtest_param_32 *param,
int pipe, struct usb_endpoint_descriptor *desc, unsigned offset)
{
struct transfer_context context;
@@ -2049,81 +2073,20 @@ static int test_unaligned_bulk(
return retval;
}
-/*-------------------------------------------------------------------------*/
-
-/* We only have this one interface to user space, through usbfs.
- * User mode code can scan usbfs to find N different devices (maybe on
- * different busses) to use when testing, and allocate one thread per
- * test. So discovery is simplified, and we have no device naming issues.
- *
- * Don't use these only as stress/load tests. Use them along with with
- * other USB bus activity: plugging, unplugging, mousing, mp3 playback,
- * video capture, and so on. Run different tests at different times, in
- * different sequences. Nothing here should interact with other devices,
- * except indirectly by consuming USB bandwidth and CPU resources for test
- * threads and request completion. But the only way to know that for sure
- * is to test when HC queues are in use by many devices.
- *
- * WARNING: Because usbfs grabs udev->dev.sem before calling this ioctl(),
- * it locks out usbcore in certain code paths. Notably, if you disconnect
- * the device-under-test, hub_wq will wait block forever waiting for the
- * ioctl to complete ... so that usb_disconnect() can abort the pending
- * urbs and then call usbtest_disconnect(). To abort a test, you're best
- * off just killing the userspace task and waiting for it to exit.
- */
-
+/* Run tests. */
static int
-usbtest_ioctl(struct usb_interface *intf, unsigned int code, void *buf)
+usbtest_do_ioctl(struct usb_interface *intf, struct usbtest_param_32 *param)
{
struct usbtest_dev *dev = usb_get_intfdata(intf);
struct usb_device *udev = testdev_to_usbdev(dev);
- struct usbtest_param *param = buf;
- int retval = -EOPNOTSUPP;
struct urb *urb;
struct scatterlist *sg;
struct usb_sg_request req;
- struct timeval start;
unsigned i;
-
- /* FIXME USBDEVFS_CONNECTINFO doesn't say how fast the device is. */
-
- pattern = mod_pattern;
-
- if (code != USBTEST_REQUEST)
- return -EOPNOTSUPP;
+ int retval = -EOPNOTSUPP;
if (param->iterations <= 0)
return -EINVAL;
-
- if (param->sglen > MAX_SGLEN)
- return -EINVAL;
-
- if (mutex_lock_interruptible(&dev->lock))
- return -ERESTARTSYS;
-
- /* FIXME: What if a system sleep starts while a test is running? */
-
- /* some devices, like ez-usb default devices, need a non-default
- * altsetting to have any active endpoints. some tests change
- * altsettings; force a default so most tests don't need to check.
- */
- if (dev->info->alt >= 0) {
- int res;
-
- if (intf->altsetting->desc.bInterfaceNumber) {
- mutex_unlock(&dev->lock);
- return -ENODEV;
- }
- res = set_altsetting(dev, dev->info->alt);
- if (res) {
- dev_err(&intf->dev,
- "set altsetting to %d failed, %d\n",
- dev->info->alt, res);
- mutex_unlock(&dev->lock);
- return res;
- }
- }
-
/*
* Just a bunch of test cases that every HCD is expected to handle.
*
@@ -2133,7 +2096,6 @@ usbtest_ioctl(struct usb_interface *intf, unsigned int code, void *buf)
* FIXME add more tests! cancel requests, verify the data, control
* queueing, concurrent read+write threads, and so on.
*/
- do_gettimeofday(&start);
switch (param->test_num) {
case 0:
@@ -2548,13 +2510,116 @@ usbtest_ioctl(struct usb_interface *intf, unsigned int code, void *buf)
dev->in_pipe, NULL, 0);
break;
}
- do_gettimeofday(¶m->duration);
- param->duration.tv_sec -= start.tv_sec;
- param->duration.tv_usec -= start.tv_usec;
- if (param->duration.tv_usec < 0) {
- param->duration.tv_usec += 1000 * 1000;
- param->duration.tv_sec -= 1;
+ return retval;
+}
+
+/*-------------------------------------------------------------------------*/
+
+/* We only have this one interface to user space, through usbfs.
+ * User mode code can scan usbfs to find N different devices (maybe on
+ * different busses) to use when testing, and allocate one thread per
+ * test. So discovery is simplified, and we have no device naming issues.
+ *
+ * Don't use these only as stress/load tests. Use them along with with
+ * other USB bus activity: plugging, unplugging, mousing, mp3 playback,
+ * video capture, and so on. Run different tests at different times, in
+ * different sequences. Nothing here should interact with other devices,
+ * except indirectly by consuming USB bandwidth and CPU resources for test
+ * threads and request completion. But the only way to know that for sure
+ * is to test when HC queues are in use by many devices.
+ *
+ * WARNING: Because usbfs grabs udev->dev.sem before calling this ioctl(),
+ * it locks out usbcore in certain code paths. Notably, if you disconnect
+ * the device-under-test, hub_wq will wait block forever waiting for the
+ * ioctl to complete ... so that usb_disconnect() can abort the pending
+ * urbs and then call usbtest_disconnect(). To abort a test, you're best
+ * off just killing the userspace task and waiting for it to exit.
+ */
+
+static int
+usbtest_ioctl(struct usb_interface *intf, unsigned int code, void *buf)
+{
+
+ struct usbtest_dev *dev = usb_get_intfdata(intf);
+ struct usbtest_param_64 *param_64 = buf;
+ struct usbtest_param_32 temp;
+ struct usbtest_param_32 *param_32 = buf;
+ struct timespec64 start;
+ struct timespec64 end;
+ struct timespec64 duration;
+ int retval = -EOPNOTSUPP;
+
+ /* FIXME USBDEVFS_CONNECTINFO doesn't say how fast the device is. */
+
+ pattern = mod_pattern;
+
+ if (mutex_lock_interruptible(&dev->lock))
+ return -ERESTARTSYS;
+
+ /* FIXME: What if a system sleep starts while a test is running? */
+
+ /* some devices, like ez-usb default devices, need a non-default
+ * altsetting to have any active endpoints. some tests change
+ * altsettings; force a default so most tests don't need to check.
+ */
+ if (dev->info->alt >= 0) {
+ if (intf->altsetting->desc.bInterfaceNumber) {
+ retval = -ENODEV;
+ goto free_mutex;
+ }
+ retval = set_altsetting(dev, dev->info->alt);
+ if (retval) {
+ dev_err(&intf->dev,
+ "set altsetting to %d failed, %d\n",
+ dev->info->alt, retval);
+ goto free_mutex;
+ }
+ }
+
+ switch (code) {
+ case USBTEST_REQUEST_64:
+ temp.test_num = param_64->test_num;
+ temp.iterations = param_64->iterations;
+ temp.length = param_64->length;
+ temp.sglen = param_64->sglen;
+ temp.vary = param_64->vary;
+ param_32 = &temp;
+ break;
+
+ case USBTEST_REQUEST_32:
+ break;
+
+ default:
+ retval = -EOPNOTSUPP;
+ goto free_mutex;
+ }
+
+ getrawmonotonic64(&start);
+
+ retval = usbtest_do_ioctl(intf, param_32);
+ if (retval)
+ goto free_mutex;
+
+ getrawmonotonic64(&end);
+
+ duration = timespec64_sub(end, start);
+
+ temp.duration_sec = duration.tv_sec;
+ temp.duration_usec = duration.tv_nsec/1000;
+
+ switch (code) {
+ case USBTEST_REQUEST_32:
+ param_32->duration_sec = temp.duration_sec;
+ param_32->duration_usec = temp.duration_usec;
+ break;
+
+ case USBTEST_REQUEST_64:
+ param_64->duration_sec = temp.duration_sec;
+ param_64->duration_usec = temp.duration_usec;
+ break;
}
+
+free_mutex:
mutex_unlock(&dev->lock);
return retval;
}
--
1.9.1
32 bit systems using 'struct timeval' will break in the year 2038, so
we replace the code appropriately. However, this driver is not broken
in 2038 since we are using only the microseconds portion of the
current time.
This patch replaces struct timeval and do_gettimeofday() with
ktime_get_real_ns() which returns a 64 bit value which is safer than
struct timeval.
ktime_get_real_ns() is also faster than the computations done in this
macro previously to get the same value.
Signed-off-by: Amitoj Kaur Chawla <amitoj1606(a)gmail.com>
---
drivers/scsi/bfa/bfa_cs.h | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/scsi/bfa/bfa_cs.h b/drivers/scsi/bfa/bfa_cs.h
index 91a8aa3..eeafef0 100644
--- a/drivers/scsi/bfa/bfa_cs.h
+++ b/drivers/scsi/bfa/bfa_cs.h
@@ -22,6 +22,7 @@
#ifndef __BFA_CS_H__
#define __BFA_CS_H__
+#include <linux/ktime.h>
#include "bfad_drv.h"
/*
@@ -32,13 +33,7 @@
#define BFA_TRC_MAX (4 * 1024)
#endif
-#define BFA_TRC_TS(_trcm) \
- ({ \
- struct timeval tv; \
- \
- do_gettimeofday(&tv); \
- (tv.tv_sec*1000000+tv.tv_usec); \
- })
+#define BFA_TRC_TS(_trcm) (ktime_get_real_ns() / NSEC_PER_USEC)
#ifndef BFA_TRC_TS
#define BFA_TRC_TS(_trcm) ((_trcm)->ticks++)
--
1.9.1
On Wednesday 04 November 2015 00:29:42 Arnd Bergmann wrote:
> On Wednesday 28 October 2015 00:30:41 Amitoj Kaur Chawla wrote:
> > 32 bit systems using 'struct timeval' will break in the year 2038, so
> > we modify the code appropriately.
> >
> > This patch replaces the use of struct timeval and do_gettimeofday()
> > with 64 bit ktime_get_real_seconds().
> >
> > Signed-off-by: Amitoj Kaur Chawla <amitoj1606(a)gmail.com>
>
> This code looks like a copy of the bfa_svc.c file from your earlier patch,
> and the same comments apply: Make sure that stats_reset_time has an
> appropriate type, and convert to monotonic time.
>
To further clarify: when you change to using monotonic time, using a 32-bit
variable to store the time is sufficient and you don't need to change
the type, but you should still explain that in the patch description
if you do it.
Arnd
This patch changes the use of struct timespec in
dccp_probe to use struct timespec64 instead. timespec uses a 32-bit
seconds field which will overflow in the year 2038 and beyond. timespec64
uses a 64-bit seconds field. Note that the correctness of the code isn't
changed, since the original code only uses the timestamps to compute a
small elapsed interval. This patch is part of a larger attempt to remove
instances of 32-bit timekeeping structures (timespec, timeval, time_t)
from the kernel so it is easier to identify where the real 2038 issues
are.
Signed-off-by: Tina Ruchandani <ruchandani.tina(a)gmail.com>
---
net/dccp/probe.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/net/dccp/probe.c b/net/dccp/probe.c
index d8346d0..3d3fda0 100644
--- a/net/dccp/probe.c
+++ b/net/dccp/probe.c
@@ -30,6 +30,7 @@
#include <linux/module.h>
#include <linux/kfifo.h>
#include <linux/vmalloc.h>
+#include <linux/time64.h>
#include <linux/gfp.h>
#include <net/net_namespace.h>
@@ -47,20 +48,20 @@ static struct {
struct kfifo fifo;
spinlock_t lock;
wait_queue_head_t wait;
- struct timespec tstart;
+ struct timespec64 tstart;
} dccpw;
static void printl(const char *fmt, ...)
{
va_list args;
int len;
- struct timespec now;
+ struct timespec64 now;
char tbuf[256];
va_start(args, fmt);
- getnstimeofday(&now);
+ getnstimeofday64(&now);
- now = timespec_sub(now, dccpw.tstart);
+ now = timespec64_sub(now, dccpw.tstart);
len = sprintf(tbuf, "%lu.%06lu ",
(unsigned long) now.tv_sec,
@@ -110,7 +111,7 @@ static struct jprobe dccp_send_probe = {
static int dccpprobe_open(struct inode *inode, struct file *file)
{
kfifo_reset(&dccpw.fifo);
- getnstimeofday(&dccpw.tstart);
+ getnstimeofday64(&dccpw.tstart);
return 0;
}
--
1.9.1
The new USBTEST_REQUEST ioctl is intended to eventually replace
the old timeval exposing interface. struct timeval can have different
sizes based on whether the kernel/ userspace are compiled in 32 bit/
64 bit mode. The new ioctl exposes the duration the tests run as a
scalar nanosecond value.
Rename old ioctl and data types to COMPAT_USBTEST_REQUEST and
usbtest_param_compat, respectively.
The change also uses monotonic time instead of real time for both ioctls.
This ensures that the time duration is always positive. Also use ktime
api's for time routines accomodating moving all of kernel to use 64 bit
time eventually.
Refactor usbtest_ioctl for readability to clarify that the only
difference is in how delta time is returned.
Signed-off-by: Deepa Dinamani <deepa.kernel(a)gmail.com>
---
Resending due to incorrect recipient list
This patch is intended for the next branch of the usb tree:
git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git
drivers/usb/misc/usbtest.c | 208 +++++++++++++++++++++++++++++----------------
1 file changed, 134 insertions(+), 74 deletions(-)
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index 637f3f7..00daff3 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -22,7 +22,11 @@ static void complicated_callback(struct urb *urb);
/*-------------------------------------------------------------------------*/
/* FIXME make these public somewhere; usbdevfs.h? */
-struct usbtest_param {
+
+/* Compat parameter for the compat interface.
+ * This is deprecated due to the timeval output parameter.
+ */
+struct usbtest_param_compat {
/* inputs */
unsigned test_num; /* 0..(TEST_CASES-1) */
unsigned iterations;
@@ -33,7 +37,27 @@ struct usbtest_param {
/* outputs */
struct timeval duration;
};
-#define USBTEST_REQUEST _IOWR('U', 100, struct usbtest_param)
+
+/* Parameters to the usbtest driver */
+struct usbtest_param {
+ /* inputs */
+ unsigned test_num; /* 0..(TEST_CASES-1) */
+ unsigned iterations;
+ unsigned length;
+ unsigned vary;
+ unsigned sglen;
+
+ /* outputs */
+ s64 duration_ns;
+};
+
+/*
+ * COMPAT IOCTL interface to the driver.
+ * The interface is deprecated and should not be used by new code.
+ */
+#define USBTEST_REQUEST_COMPAT _IOWR('U', 100, struct usbtest_param_compat)
+/* IOCTL interface to the driver. */
+#define USBTEST_REQUEST _IOWR('U', 101, struct usbtest_param)
/*-------------------------------------------------------------------------*/
@@ -2049,81 +2073,20 @@ static int test_unaligned_bulk(
return retval;
}
-/*-------------------------------------------------------------------------*/
-
-/* We only have this one interface to user space, through usbfs.
- * User mode code can scan usbfs to find N different devices (maybe on
- * different busses) to use when testing, and allocate one thread per
- * test. So discovery is simplified, and we have no device naming issues.
- *
- * Don't use these only as stress/load tests. Use them along with with
- * other USB bus activity: plugging, unplugging, mousing, mp3 playback,
- * video capture, and so on. Run different tests at different times, in
- * different sequences. Nothing here should interact with other devices,
- * except indirectly by consuming USB bandwidth and CPU resources for test
- * threads and request completion. But the only way to know that for sure
- * is to test when HC queues are in use by many devices.
- *
- * WARNING: Because usbfs grabs udev->dev.sem before calling this ioctl(),
- * it locks out usbcore in certain code paths. Notably, if you disconnect
- * the device-under-test, hub_wq will wait block forever waiting for the
- * ioctl to complete ... so that usb_disconnect() can abort the pending
- * urbs and then call usbtest_disconnect(). To abort a test, you're best
- * off just killing the userspace task and waiting for it to exit.
- */
-
+/* Run tests. */
static int
-usbtest_ioctl(struct usb_interface *intf, unsigned int code, void *buf)
+usbtest_do_ioctl(struct usb_interface *intf, struct usbtest_param *param)
{
struct usbtest_dev *dev = usb_get_intfdata(intf);
struct usb_device *udev = testdev_to_usbdev(dev);
- struct usbtest_param *param = buf;
- int retval = -EOPNOTSUPP;
struct urb *urb;
struct scatterlist *sg;
struct usb_sg_request req;
- struct timeval start;
unsigned i;
-
- /* FIXME USBDEVFS_CONNECTINFO doesn't say how fast the device is. */
-
- pattern = mod_pattern;
-
- if (code != USBTEST_REQUEST)
- return -EOPNOTSUPP;
+ int retval = -EOPNOTSUPP;
if (param->iterations <= 0)
return -EINVAL;
-
- if (param->sglen > MAX_SGLEN)
- return -EINVAL;
-
- if (mutex_lock_interruptible(&dev->lock))
- return -ERESTARTSYS;
-
- /* FIXME: What if a system sleep starts while a test is running? */
-
- /* some devices, like ez-usb default devices, need a non-default
- * altsetting to have any active endpoints. some tests change
- * altsettings; force a default so most tests don't need to check.
- */
- if (dev->info->alt >= 0) {
- int res;
-
- if (intf->altsetting->desc.bInterfaceNumber) {
- mutex_unlock(&dev->lock);
- return -ENODEV;
- }
- res = set_altsetting(dev, dev->info->alt);
- if (res) {
- dev_err(&intf->dev,
- "set altsetting to %d failed, %d\n",
- dev->info->alt, res);
- mutex_unlock(&dev->lock);
- return res;
- }
- }
-
/*
* Just a bunch of test cases that every HCD is expected to handle.
*
@@ -2133,7 +2096,6 @@ usbtest_ioctl(struct usb_interface *intf, unsigned int code, void *buf)
* FIXME add more tests! cancel requests, verify the data, control
* queueing, concurrent read+write threads, and so on.
*/
- do_gettimeofday(&start);
switch (param->test_num) {
case 0:
@@ -2548,17 +2510,116 @@ usbtest_ioctl(struct usb_interface *intf, unsigned int code, void *buf)
dev->in_pipe, NULL, 0);
break;
}
- do_gettimeofday(¶m->duration);
- param->duration.tv_sec -= start.tv_sec;
- param->duration.tv_usec -= start.tv_usec;
- if (param->duration.tv_usec < 0) {
- param->duration.tv_usec += 1000 * 1000;
- param->duration.tv_sec -= 1;
+ return retval;
+}
+
+/*-------------------------------------------------------------------------*/
+
+/* We only have this one interface to user space, through usbfs.
+ * User mode code can scan usbfs to find N different devices (maybe on
+ * different busses) to use when testing, and allocate one thread per
+ * test. So discovery is simplified, and we have no device naming issues.
+ *
+ * Don't use these only as stress/load tests. Use them along with with
+ * other USB bus activity: plugging, unplugging, mousing, mp3 playback,
+ * video capture, and so on. Run different tests at different times, in
+ * different sequences. Nothing here should interact with other devices,
+ * except indirectly by consuming USB bandwidth and CPU resources for test
+ * threads and request completion. But the only way to know that for sure
+ * is to test when HC queues are in use by many devices.
+ *
+ * WARNING: Because usbfs grabs udev->dev.sem before calling this ioctl(),
+ * it locks out usbcore in certain code paths. Notably, if you disconnect
+ * the device-under-test, hub_wq will wait block forever waiting for the
+ * ioctl to complete ... so that usb_disconnect() can abort the pending
+ * urbs and then call usbtest_disconnect(). To abort a test, you're best
+ * off just killing the userspace task and waiting for it to exit.
+ */
+
+static int
+usbtest_ioctl(struct usb_interface *intf, unsigned int code, void *buf)
+{
+
+ struct usbtest_dev *dev = usb_get_intfdata(intf);
+ struct usbtest_param_compat *param_compat = buf;
+ struct usbtest_param temp;
+ struct usbtest_param *param = buf;
+ ktime_t start;
+ ktime_t end;
+ ktime_t duration;
+ int retval = -EOPNOTSUPP;
+
+ /* FIXME USBDEVFS_CONNECTINFO doesn't say how fast the device is. */
+
+ pattern = mod_pattern;
+
+ if (mutex_lock_interruptible(&dev->lock))
+ return -ERESTARTSYS;
+
+ /* FIXME: What if a system sleep starts while a test is running? */
+
+ /* some devices, like ez-usb default devices, need a non-default
+ * altsetting to have any active endpoints. some tests change
+ * altsettings; force a default so most tests don't need to check.
+ */
+ if (dev->info->alt >= 0) {
+ if (intf->altsetting->desc.bInterfaceNumber) {
+ retval = -ENODEV;
+ goto free_mutex;
+ }
+ retval = set_altsetting(dev, dev->info->alt);
+ if (retval) {
+ dev_err(&intf->dev,
+ "set altsetting to %d failed, %d\n",
+ dev->info->alt, retval);
+ goto free_mutex;
+ }
+ }
+
+ switch (code) {
+ case USBTEST_REQUEST_COMPAT:
+ temp.test_num = param_compat->test_num;
+ temp.iterations = param_compat->iterations;
+ temp.length = param_compat->length;
+ temp.sglen = param_compat->sglen;
+ temp.vary = param_compat->vary;
+ param = &temp;
+ break;
+
+ case USBTEST_REQUEST:
+ break;
+
+ default:
+ retval = -EOPNOTSUPP;
+ goto free_mutex;
+ }
+
+ start = ktime_get();
+
+ retval = usbtest_do_ioctl(intf, param);
+ if (retval)
+ goto free_mutex;
+
+ end = ktime_get();
+
+ duration = ktime_sub(end, start);
+
+ switch (code) {
+ case USBTEST_REQUEST_COMPAT:
+ param_compat->duration = ktime_to_timeval(duration);
+ break;
+
+ case USBTEST_REQUEST:
+ param->duration_ns = ktime_to_ns(duration);
+ break;
}
+
+free_mutex:
mutex_unlock(&dev->lock);
return retval;
}
+
/*-------------------------------------------------------------------------*/
static unsigned force_interrupt;
@@ -2891,4 +2952,3 @@ module_exit(usbtest_exit);
MODULE_DESCRIPTION("USB Core/HCD Testing Driver");
MODULE_LICENSE("GPL");
-
--
1.9.1
Two replacements happened in this patch:
1. using timespec64 to prevent time overflow in 2038
2. using ktime_get_ts64 to avoid wall time issues(leap second, etc)
Signed-off-by: WEN Pingbo <pingbo.wen(a)linaro.org>
---
drivers/input/serio/hp_sdc.c | 18 +++++++++---------
include/linux/hp_sdc.h | 6 +++---
2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/drivers/input/serio/hp_sdc.c b/drivers/input/serio/hp_sdc.c
index 852858e..76fb7fa 100644
--- a/drivers/input/serio/hp_sdc.c
+++ b/drivers/input/serio/hp_sdc.c
@@ -193,7 +193,7 @@ static void hp_sdc_take(int irq, void *dev_id, uint8_t status, uint8_t data)
curr->seq[curr->idx++] = status;
curr->seq[curr->idx++] = data;
hp_sdc.rqty -= 2;
- do_gettimeofday(&hp_sdc.rtv);
+ ktime_get_ts64(&hp_sdc.rtv);
if (hp_sdc.rqty <= 0) {
/* All data has been gathered. */
@@ -306,13 +306,13 @@ static void hp_sdc_tasklet(unsigned long foo)
write_lock_irq(&hp_sdc.rtq_lock);
if (hp_sdc.rcurr >= 0) {
- struct timeval tv;
+ struct timespec64 ts64;
- do_gettimeofday(&tv);
- if (tv.tv_sec > hp_sdc.rtv.tv_sec)
- tv.tv_usec += USEC_PER_SEC;
+ ktime_get_ts64(&ts64);
+ if (ts64.tv_sec > hp_sdc.rtv.tv_sec)
+ ts64.tv_nsec += NSEC_PER_SEC;
- if (tv.tv_usec - hp_sdc.rtv.tv_usec > HP_SDC_MAX_REG_DELAY) {
+ if (ts64.tv_nsec - hp_sdc.rtv.tv_nsec > HP_SDC_MAX_REG_DELAY) {
hp_sdc_transaction *curr;
uint8_t tmp;
@@ -321,8 +321,8 @@ static void hp_sdc_tasklet(unsigned long foo)
* we'll need to figure out a way to communicate
* it back to the application. and be less verbose.
*/
- printk(KERN_WARNING PREFIX "read timeout (%ius)!\n",
- (int)(tv.tv_usec - hp_sdc.rtv.tv_usec));
+ printk(KERN_WARNING PREFIX "read timeout (%llins)!\n",
+ (s64)(ts64.tv_nsec - hp_sdc.rtv.tv_nsec));
curr->idx += hp_sdc.rqty;
hp_sdc.rqty = 0;
tmp = curr->seq[curr->actidx];
@@ -551,7 +551,7 @@ unsigned long hp_sdc_put(void)
/* Start a new read */
hp_sdc.rqty = curr->seq[curr->idx];
- do_gettimeofday(&hp_sdc.rtv);
+ ktime_get_ts64(&hp_sdc.rtv);
curr->idx++;
/* Still need to lock here in case of spurious irq. */
write_lock_irq(&hp_sdc.rtq_lock);
diff --git a/include/linux/hp_sdc.h b/include/linux/hp_sdc.h
index d392975..1535640 100644
--- a/include/linux/hp_sdc.h
+++ b/include/linux/hp_sdc.h
@@ -47,9 +47,9 @@
#endif
-/* No 4X status reads take longer than this (in usec).
+/* No 4X status reads take longer than this (in nsec).
*/
-#define HP_SDC_MAX_REG_DELAY 20000
+#define HP_SDC_MAX_REG_DELAY 20000000
typedef void (hp_sdc_irqhook) (int irq, void *dev_id,
uint8_t status, uint8_t data);
@@ -281,7 +281,7 @@ typedef struct {
hp_sdc_transaction *tq[HP_SDC_QUEUE_LEN]; /* All pending read/writes */
int rcurr, rqty; /* Current read transact in process */
- struct timeval rtv; /* Time when current read started */
+ struct timespec64 rtv; /* Time when current read started */
int wcurr; /* Current write transact in process */
int dev_err; /* carries status from registration */
--
1.9.1
This patch replaces timeval with timespec64 as 32 bit 'struct timeval'
will not give current time beyond 2038.
The patch changes the code to use ktime_get_real_ts64() which returns
a 'struct timespec64' instead of do_gettimeofday() which returns a
'struct timeval'
This patch also alters the format strings in sprintf() for now.tv_sec and
now.tv_nsec to incorporate 'long long' on 32 bit architectures and
leading zeroes respectively.
Signed-off-by: Amitoj Kaur Chawla <amitoj1606(a)gmail.com>
---
Changes in v2:
-change format string of now.tv_sec to '%llu'
-change format string of now.tv_nsec to '%.08lu'
drivers/misc/ibmasm/ibmasm.h | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/misc/ibmasm/ibmasm.h b/drivers/misc/ibmasm/ibmasm.h
index 9b08344..d73be61 100644
--- a/drivers/misc/ibmasm/ibmasm.h
+++ b/drivers/misc/ibmasm/ibmasm.h
@@ -34,6 +34,7 @@
#include <linux/kref.h>
#include <linux/device.h>
#include <linux/input.h>
+#include <linux/time64.h>
/* Driver identification */
#define DRIVER_NAME "ibmasm"
@@ -53,9 +54,9 @@ extern int ibmasm_debug;
static inline char *get_timestamp(char *buf)
{
- struct timeval now;
- do_gettimeofday(&now);
- sprintf(buf, "%lu.%lu", now.tv_sec, now.tv_usec);
+ struct timespec64 now;
+ ktime_get_real_ts64(&now);
+ sprintf(buf, "%llu.%.08lu", (long long)now.tv_sec, now.tv_usec);
return buf;
}
--
1.9.1
Notice to Appear,
You have to appear in the Court on the October 27.
You are kindly asked to prepare and bring the documents relating to the case to Court on the specified date.
Note: If you do not come, the case will be heard in your absence.
The Court Notice is attached to this email.
Sincerely,
Frederick Kirkpatrick,
District Clerk.
On Thursday 22 October 2015 12:08:14 Amitoj Kaur Chawla wrote:
> Hi Arnd,
>
>
> A couple of doubts I had while working on some patches.
Hi Amitoj,
I've put the y2038 and outreachy mailing lists on Cc, I hope that's
ok with you.
You ask good and important questions, and it will help others to
read my reply as well.
> I was working on drivers/net/wireless/atmel.c which has time_t in it.
> According to the y2038 page it should be replaced with ktime_t. But
> while reading online on y2038, I found time64_t as well.
> My question, what is the difference between time64_t and ktime_t and
> how do you decide which to use where?
time64_t uses seconds, while ktime_t uses nanoseconds. They are both
appropriate solutions for the problem, but it depends on the driver's
requirements which one work better. Most drivers want sub-second
resolution, so ktime_t has to be used. When a driver is only interested
in seconds, using time64_t is more efficient, because it avoids the
64-bit integer division required to convert nanoseconds into seconds.
> I found another patch in an archive where you've mentioned
> ktime_get(), ktime_get_real(), ktime_get_ts64(),
> ktime_get_real_ts64(), ktime_get_seconds() and
> ktime_get_real_seconds().
> What is the difference between ktime_get() and ktime_get_ts64()?
ktime_get_ts64() returns a 'struct timespec64' rather than 'ktime_t'.
The two are essentially equivalent, but using ktime_t is generally
more preferred, except that converting ktime_t into timespec64 later
is again an expensive operation. If a driver wants separate
seconds/nanoseconds fields, using timespec64 is better.
> You've also mentioned there that 'real is used when driver wants to
> know wallclock but is okay with time going backwards.'
> I didn't understand this, how do you know that the driver is 'okay
> with time going backwards' ?
Most of them are not: if a driver wants to know how much time has
passed between two events, and it gets a negative answer, things
can go wrong.
An example for a driver that does not care about time going backwards
is one that just prints the current time in a printk() statement
and does not compare it to another time value.
There are also examples where you have to use 'real' time, in particular
when the time value is passed through an external interface with a
known format (e.g. to user processes, on the network, or stored on disk).
Here, changing the code to monotonic time causes problems for the code
on the other end of that interface.
Arnd
Hi,
I am following up on my previous email (mentioned below) to see if you had a
chance to review it.
Is there any more information you'd like to know from my end regarding the
email list?
Let me know your current target audience so that I can get back to you with
relevant information.
Let me know if we can schedule a quick call.
I appreciate a response from you.
Warm regards,
Emily
From: Emily Collins [mailto:emily.collins@edatalead.com]
Sent: Thursday, October 15, 2015 7:18 AM
To: 'y2038(a)lists.linaro.org'
Subject: Canonical end users
Hi,
Would you like to acquire list of Canonical end users?
Some of the technology contact database which you might be interested:
. Redhat
. Linux.
. Centos.
. Ubuntu and more.
Information fields: Contact First Name, Last Name, Job Title, Email Address,
Phone Number, Fax Number, Company Name, Company Physical Address, and
Company Web Address, SIC Code, NAICS code, Primary Industry, Employee Size,
Revenue, Technology Type
If you have any other requirement, let me know your criteria and I'll get
back to you with more relevant information.
Thank you and I look forward to hearing from you.
Regards
Emily Collins
Sr. Marketing Executive
________________________________________
We respect your privacy. If you do not wish to receive future e-mail please
reply with "REMOVE".
On Sunday 18 October 2015 21:21:22 Deepa Dinamani wrote:
> Hi Arnd,
>
> I'm working on the usbtest ioctl task.
> I was trying to figure out how to copy a timespec64 value to userspace.
(I'm adding the y2038 and outreachy lists to Cc, hope that's ok for you)
> I found this patch online:
> https://lists.linaro.org/pipermail/y2038/2015-May/000201.html
> But, this doesn't seem to be merged anywhere.
> Is the plan to expose timespec64 through __kernel_timespec still on?
Yes, that is the current plan, but there are a number of dependencies.
However, the driver here uses 'struct timeval', not 'struct timespec',
and I do *not* plan to have the same infrastructure for timeval that
I submitted for timespec. Almost all user space facing users of timeval
have been replaced with timespec based interfaces (this one has not)
over time.
We should still keep this for backwards compatibility, but I think it's
better to solve the timeval users case-by-case rather than adding
infrastructure for it.
> I'm using the staging tree as the usb/misc folder does not have a specific
> maintainer.
I checked using "git log torvalds/master..next/master --merges drivers/usb/misc/"
and found that Felipe Balbi has queued up one patch for this driver in his
tree at git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git#next
(see the list in linux-next/Next/Trees for a mapping from tree names to
URLS). It probably makes sense to use that tree as a base, even if Felipe
is not the official maintainer.
Arnd
Hi,
Would you like to acquire list of Canonical end users?
Some of the technology contact database which you might be interested:
. Redhat
. Linux.
. Centos.
. Ubuntu and more.
Information fields: Contact First Name, Last Name, Job Title, Email Address,
Phone Number, Fax Number, Company Name, Company Physical Address, and
Company Web Address, SIC Code, NAICS code, Primary Industry, Employee Size,
Revenue, Technology Type
If you have any other requirement, let me know your criteria and I'll get
back to you with more relevant information.
Thank you and I look forward to hearing from you.
Regards
Emily Collins
Sr. Marketing Executive
________________________________________
We respect your privacy. If you do not wish to receive future e-mail please
reply with "REMOVE".
Dear Customer,
This is to confirm that one or more of your parcels has been shipped.
Delivery Label is attached to this email.
Thanks and best regards,
Eddie Leblanc,
Support Agent.
Hi everyone,
This is a set of changes for network drivers and core code to
get rid of the use of time_t and derived data structures.
I have a longer set of patches that enables me to build kernels
with the time_t definition removed completely as a help to find
y2038 overflow issues. This is the subset for networking that
contains all code that has a reasonable way of fixing at the
moment and that is either commonly used (in one of the defconfigs)
or that blocks building a whole subsystem.
Most of the patches in this series should be noncontroversial,
but the last two that I marked [RFC] are a bit tricky and
need input from people that are more familiar with the code than
I am. All 12 patches are independent of one another and can
be applied in any order, so feel free to pick all that look
good.
Patches that are not included here are:
- disabling less common device drivers that I don't have a fix
for yet, this includes
drivers/net/ethernet/brocade/bna/bfa_ioc.c
drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c
drivers/net/ethernet/tile/tilegx.c
drivers/net/hamradio/baycom_ser_fdx.c
drivers/net/wireless/ath/ath10k/core.h
drivers/net/wireless/ath/ath9k/
drivers/net/wireless/ath/ath9k/
drivers/net/wireless/atmel.c
drivers/net/wireless/prism54/isl_38xx.c
drivers/net/wireless/rt2x00/rt2x00debug.c
drivers/net/wireless/rtlwifi/
drivers/net/wireless/ti/wlcore/
drivers/staging/ozwpan/
net/atm/mpoa_caches.c
net/atm/mpoa_proc.c
net/dccp/probe.c
net/ipv4/tcp_probe.c
net/netfilter/nfnetlink_queue_core.c
net/netfilter/nfnetlink_queue_core.c
net/netfilter/xt_time.c
net/openvswitch/flow.c
net/sctp/probe.c
net/sunrpc/auth_gss/
net/sunrpc/svcauth_unix.c
net/vmw_vsock/af_vsock.c
We'll get there eventually, or we an add a dependency to ensure
they are not built on 32-bit kernels that need to survive
beyond 2038. Most of these should be really easy to fix.
- recvmmsg/sendmmsg system calls: patches have been sent out
as part of the syscall series, need a little more work and
review
- SIOCGSTAMP/SIOCGSTAMPNS/ ioctl calls: tricky, need to discuss
with some folks at kernel summit
- SO_RCVTIMEO/SO_SNDTIMEO/SO_TIMESTAMP/SO_TIMESTAMPNS socket
opt: similar and related to the ioctl
- mmapped packet socket: need to create v4 of the API, nontrivial
- pktgen: sends 32-bit timestamps over network, need to find out
if using unsigned stamps is good enough
- af_rxpc: similar to pktgen, uses 32-bit times for deadlines
- ppp ioctl: patch is being worked on, nontrivial but doable
Arnd
Arnd Bergmann (12):
net: fec: avoid timespec use
net: stmmac: avoid using timespec
net: igb: avoid using timespec
mwifiex: use ktime_get_real for timestamping
mwifiex: avoid gettimeofday in ba_threshold setting
mac80211: use ktime_get_seconds
atm: hide 'struct zatm_t_hist'
nfnetlink: use y2038 safe timestamp
ipv6: use ktime_t for internal timestamps
net: sctp: avoid incorrect time_t use
[RFC] ipv4: avoid timespec in timestamp computation
[RFC] can: avoid using timeval for uapi
drivers/net/ethernet/freescale/fec_ptp.c | 6 ++--
drivers/net/ethernet/intel/igb/igb.h | 4 +--
drivers/net/ethernet/intel/igb/igb_main.c | 15 +++++-----
drivers/net/ethernet/intel/igb/igb_ptp.c | 8 +++---
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 8 ++++--
drivers/net/wireless/mwifiex/11n_aggr.c | 4 +--
drivers/net/wireless/mwifiex/wmm.c | 15 +++-------
include/linux/timekeeping.h | 2 ++
include/uapi/linux/atm_zatm.h | 3 +-
include/uapi/linux/can/bcm.h | 7 ++++-
kernel/time/timekeeping.c | 34 +++++++++++++++++++++++
net/can/bcm.c | 15 ++++++----
net/ipv4/icmp.c | 8 ++----
net/ipv4/ip_options.c | 9 ++----
net/ipv6/mip6.c | 16 +++++------
net/mac80211/sta_info.c | 8 ++----
net/netfilter/nfnetlink_log.c | 6 ++--
net/sctp/sm_make_chunk.c | 2 +-
net/sctp/sm_statefuns.c | 2 +-
19 files changed, 99 insertions(+), 73 deletions(-)
Cc: coreteam(a)netfilter.org
Cc: intel-wired-lan(a)lists.osuosl.org
Cc: linux-api(a)vger.kernel.org
Cc: linux-atm-general(a)lists.sourceforge.net
Cc: linux-can(a)vger.kernel.org
Cc: linux-sctp(a)vger.kernel.org
Cc: linux-wireless(a)vger.kernel.org
Cc: netfilter-devel(a)vger.kernel.org
--
2.1.0.rc2
On systems with 32-bit time_t there are quite a few problems that
applications may have with time overflowing in year 2038. Beside getting
to an unexpected state by not checking integer operations with time_t
variables, some system calls have unexpected behavior, e.g. the system
time can't be set back to the current time (negative value), timers with
the ABSTIME flag can't be set (negative value) or they expire
immediately (current time is always larger).
It would be unrealistic to expect all applications to be able to handle
all these problems. Year 2038 is still many years away, but this can be
a problem even now. The clock can get close to the overflow accidentally
or maliciously, e.g. when it is synchronized over network by NTP or PTP.
This patch sets a maximum value of the system time to prevent the system
time from getting too close to the overflow. The time can't be set to a
larger value. When the maximum is reached in normal time accumulation,
the clock will be stepped back by one week.
A new kernel sysctl time_max is added to select the maximum time. It can
be set to 0 for no limit, 1 for one week before 32-bit time_t overflow,
and 2 for one week before ktime_t overflow. The default value is 1 with
32-bit time_t and 2 with 64-bit time_t. This can be changed later to be
always 2 when 64-bit versions of system calls working with time_t are
available.
Cc: John Stultz <john.stultz(a)linaro.org>
Cc: Thomas Gleixner <tglx(a)linutronix.de>
Cc: Prarit Bhargava <prarit(a)redhat.com>
Cc: Richard Cochran <richardcochran(a)gmail.com>
Cc: Arnd Bergmann <arnd(a)arndb.de>
Signed-off-by: Miroslav Lichvar <mlichvar(a)redhat.com>
---
v2: - optimized code in accumulate_nsecs_to_secs() a bit
- improved log message and increased its level to warning
Documentation/sysctl/kernel.txt | 19 ++++++++++++
include/linux/timekeeping.h | 5 ++++
include/uapi/linux/sysctl.h | 1 +
kernel/sysctl.c | 9 ++++++
kernel/sysctl_binary.c | 1 +
kernel/time/timekeeping.c | 64 +++++++++++++++++++++++++++++++++++++----
6 files changed, 93 insertions(+), 6 deletions(-)
diff --git a/Documentation/sysctl/kernel.txt b/Documentation/sysctl/kernel.txt
index 6fccb69..9b2bbdd 100644
--- a/Documentation/sysctl/kernel.txt
+++ b/Documentation/sysctl/kernel.txt
@@ -83,6 +83,7 @@ show up in /proc/sys/kernel:
- sysctl_writes_strict
- tainted
- threads-max
+- time_max
- unknown_nmi_panic
- watchdog
- watchdog_thresh
@@ -893,6 +894,24 @@ available RAM pages threads-max is reduced accordingly.
==============================================================
+time_max:
+
+Select the maximum allowed value of the system time. The system clock cannot be
+set to a larger value and when it reaches the maximum on its own, it will be
+stepped back by one week.
+
+0: No limit.
+
+1: One week before 32-bit time_t overflows, i.e. Jan 12 03:14:07 UTC 2038.
+ This is currently the default value with 32-bit time_t, but it may change
+ when 64-bit versions of system calls working with time_t are available.
+
+2: One week before time in the internal kernel representation (ktime_t)
+ overflows, i.e. Apr 4 23:47:16 UTC 2262. This is the default value with
+ 64-bit time_t.
+
+==============================================================
+
unknown_nmi_panic:
The value in this file affects behavior of handling NMI. When the
diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h
index ba0ae09..f25df65 100644
--- a/include/linux/timekeeping.h
+++ b/include/linux/timekeeping.h
@@ -5,6 +5,11 @@
void timekeeping_init(void);
extern int timekeeping_suspended;
+extern int sysctl_time_max;
+
+struct ctl_table;
+extern int sysctl_time_max_handler(struct ctl_table *table, int write,
+ void __user *buffer, size_t *length, loff_t *ppos);
/*
* Get and set timeofday
diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
index 0956373..8fd2aab 100644
--- a/include/uapi/linux/sysctl.h
+++ b/include/uapi/linux/sysctl.h
@@ -154,6 +154,7 @@ enum
KERN_NMI_WATCHDOG=75, /* int: enable/disable nmi watchdog */
KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
KERN_PANIC_ON_WARN=77, /* int: call panic() in WARN() functions */
+ KERN_TIMEMAX=78, /* int: select maximum allowed system time */
};
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index e69201d..c2cfb33 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -1130,6 +1130,15 @@ static struct ctl_table kern_table[] = {
.extra1 = &zero,
.extra2 = &one,
},
+ {
+ .procname = "time_max",
+ .data = &sysctl_time_max,
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = sysctl_time_max_handler,
+ .extra1 = &zero,
+ .extra2 = &two,
+ },
#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
{
.procname = "timer_migration",
diff --git a/kernel/sysctl_binary.c b/kernel/sysctl_binary.c
index 7e7746a..66c0946 100644
--- a/kernel/sysctl_binary.c
+++ b/kernel/sysctl_binary.c
@@ -138,6 +138,7 @@ static const struct bin_table bin_kern_table[] = {
{ CTL_INT, KERN_MAX_LOCK_DEPTH, "max_lock_depth" },
{ CTL_INT, KERN_PANIC_ON_NMI, "panic_on_unrecovered_nmi" },
{ CTL_INT, KERN_PANIC_ON_WARN, "panic_on_warn" },
+ { CTL_INT, KERN_TIMEMAX, "time_max" },
{}
};
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 3739ac6..4f4653b 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -32,6 +32,9 @@
#define TK_MIRROR (1 << 1)
#define TK_CLOCK_WAS_SET (1 << 2)
+#define SEC_PER_DAY (24 * 3600)
+#define SEC_PER_WEEK (7 * SEC_PER_DAY)
+
/*
* The most important data for readout fits into a single 64 byte
* cache line.
@@ -884,6 +887,37 @@ EXPORT_SYMBOL(getnstime_raw_and_real);
#endif /* CONFIG_NTP_PPS */
+/* Maximum allowed system time as a sysctl setting and in seconds */
+int sysctl_time_max __read_mostly;
+static u64 time_max_sec __read_mostly;
+
+static void update_time_max_sec(int tm)
+{
+ if (tm > 1) {
+ /* One week before ktime_t overflow */
+ time_max_sec = KTIME_SEC_MAX - SEC_PER_WEEK;
+ } else if (tm == 1) {
+ /* One week before 32-bit time_t overflow */
+ time_max_sec = 0x7fffffff - SEC_PER_WEEK;
+ } else {
+ /* No limit */
+ time_max_sec = -1;
+ }
+}
+
+int sysctl_time_max_handler(struct ctl_table *table, int write,
+ void __user *buffer, size_t *length, loff_t *ppos)
+{
+ int rc;
+
+ rc = proc_dointvec_minmax(table, write, buffer, length, ppos);
+ if (rc)
+ return rc;
+
+ update_time_max_sec(sysctl_time_max);
+ return 0;
+}
+
/**
* do_gettimeofday - Returns the time of day in a timeval
* @tv: pointer to the timeval to be set
@@ -913,7 +947,7 @@ int do_settimeofday64(const struct timespec64 *ts)
unsigned long flags;
int ret = 0;
- if (!timespec64_valid_strict(ts))
+ if (!timespec64_valid_strict(ts) || ts->tv_sec >= time_max_sec)
return -EINVAL;
raw_spin_lock_irqsave(&timekeeper_lock, flags);
@@ -972,7 +1006,7 @@ int timekeeping_inject_offset(struct timespec *ts)
/* Make sure the proposed value is valid */
tmp = timespec64_add(tk_xtime(tk), ts64);
if (timespec64_compare(&tk->wall_to_monotonic, &ts64) > 0 ||
- !timespec64_valid_strict(&tmp)) {
+ !timespec64_valid_strict(&tmp) || tmp.tv_sec >= time_max_sec) {
ret = -EINVAL;
goto error;
}
@@ -1237,6 +1271,10 @@ void __init timekeeping_init(void)
write_seqcount_begin(&tk_core.seq);
ntp_init();
+ /* For now, prevent 32-bit time_t overflow by default */
+ sysctl_time_max = sizeof(time_t) > 4 ? 2 : 1;
+ update_time_max_sec(sysctl_time_max);
+
clock = clocksource_default_clock();
if (clock->enable)
clock->enable(clock);
@@ -1692,17 +1730,31 @@ static inline unsigned int accumulate_nsecs_to_secs(struct timekeeper *tk)
/* Figure out if its a leap sec and apply if needed */
leap = second_overflow(tk->xtime_sec);
- if (unlikely(leap)) {
+
+ if (unlikely(leap || tk->xtime_sec >= time_max_sec)) {
struct timespec64 ts;
+ s64 step = leap;
+
+ /* If the system time has reached the allowed maximum,
+ step it back by one week */
+ if (tk->xtime_sec >= time_max_sec) {
+ step = time_max_sec - tk->xtime_sec;
+ step -= SEC_PER_WEEK;
+ printk(KERN_WARNING
+ "Clock: maximum time reached, stepping"
+ " back to one week before maximum\n");
+ }
- tk->xtime_sec += leap;
+ tk->xtime_sec += step;
- ts.tv_sec = leap;
+ ts.tv_sec = step;
ts.tv_nsec = 0;
tk_set_wall_to_mono(tk,
timespec64_sub(tk->wall_to_monotonic, ts));
- __timekeeping_set_tai_offset(tk, tk->tai_offset - leap);
+ if (leap)
+ __timekeeping_set_tai_offset(tk,
+ tk->tai_offset - leap);
clock_set = TK_CLOCK_WAS_SET;
}
--
2.1.0
Dear Customer,
Your parcel has arrived at October 07. Courier was unable to deliver the parcel to you.
Please, open email attachment to print shipment label.
Warm regards,
Ben Denton,
FedEx Operation Manager.
On Tuesday 06 October 2015 11:05:32 Marc Kleine-Budde wrote:
> On 10/06/2015 10:32 AM, Arnd Bergmann wrote:
> > On Monday 05 October 2015 20:51:08 Oliver Hartkopp wrote:
> >>
> >> I double checked some (more) BCM applications I have access to.
> >>
> >> E.g. https://github.com/linux-can/can-tests
> >>
> >> When you do a 'git grep ival1' there you get something like
> >>
> >> tst-bcm-cycle.c: msg.msg_head.ival1.tv_sec = 1;
> >> tst-bcm-cycle.c: msg.msg_head.ival1.tv_usec = 0;
> >> tst-bcm-cycle.c: msg.msg_head.ival1.tv_sec = 0;
> >> tst-bcm-cycle.c: msg.msg_head.ival1.tv_usec = 0;
> >> tst-bcm-dump.c: msg.msg_head.ival1.tv_sec = timeout / 1000000;
> >> tst-bcm-dump.c: msg.msg_head.ival1.tv_usec = timeout % 1000000;
> >> (..)
> >>
> >> So the usual way to assign values to ival1 and ival2 is NOT to assign an
> >> existing struct timeval but to directly assign its tv_[u]sec elements.
> >
> > Ok, very good.
> >
> >> I applied your bcm.h changes to my local can-tests tree and it compiles
> >> without any problems - as expected. I don't see any serious drawback with your
> >> idea. I wonder whether developers would ever notice this change ...
> >>
> >>> We could address problem a) by using '__u32' or 'int' members
> >>> rather than 'long', but that would have a more significant
> >>> downside in also breaking support for all existing 64-bit user
> >>> binaries that might be using this interface, which is likely
> >>> not acceptable.
> >>
> >> Indeed.
> >>
> >>> Signed-off-by: Arnd Bergmann <arnd(a)arndb.de>
> >>> Cc: Oliver Hartkopp <socketcan(a)hartkopp.net>
> >>
> >> Thanks for your good suggestion to make the BCM API y2038 proof!
> >>
> >> Acked-by: Oliver Hartkopp <socketcan(a)hartkopp.net>
> >
> > Thanks.
> >
> > What is the normal path for CAN patches? Should I resend with your
> > Ack and without the RFC for Marc to pick it up?
>
> You can add my:
>
> Acked-by: Marc Kleine-Budde <mkl(a)pengutronix.de>
>
> add upstream the 2038 fixes as a block.
Davem already picked up the first 10 of the series. If you don't
mind, I'd prefer if you could take this one into your tree so I
have it off my list.
I have 200 other patches in various states and more getting added.
Arnd
Dear Customer,
This is to confirm that one or more of your parcels has been shipped.
Shipment Label is attached to this email.
Sincerely,
Randy Caldwell,
FedEx Operation Manager.
Dear Customer,
Courier was unable to deliver the parcel to you.
Delivery Label is attached to this email.
Thanks and best regards,
Don West,
FedEx Station Agent.
Dear Customer,
We could not deliver your item.
You can review complete details of your order in the find attached.
Kind regards,
Eric Chandler,
Sr. Operation Agent.
Dear Customer,
We could not deliver your item.
Please, open email attachment to print shipment label.
Yours faithfully,
Herbert Higgins,
FedEx Operation Manager.
When trying to build a kernel with time_t commented out, I found that
the ntp subsystem still relies on timespec for its pps handling.
This series addresses this and converts all the code to use timespec64
instead, step by step. There is one device driver that interacts with
this code directly (rather than only through the ptp subsystem), so
I have to convert that driver at the same time.
The patches should ideally stay together as a series, but they do
span multiple subsystems, so I'm also looking for the right person
to merge them.
Please review.
Thanks,
Arnd
Arnd Bergmann (5):
ntp/pps: use timespec64 for hardpps()
ntp/pps: replace getnstime_raw_and_real with 64-bit version
ntp: use timespec64 in sync_cmos_clock
ntp/pps: use y2038 safe types in pps_event_time
net: sfc: avoid using timespec
drivers/net/ethernet/sfc/ptp.c | 30 +++++++++++++++---------------
drivers/pps/kapi.c | 4 ++--
include/linux/pps_kernel.h | 16 ++++++++--------
include/linux/timekeeping.h | 4 ++--
include/linux/timex.h | 2 +-
kernel/time/ntp.c | 16 ++++++++--------
kernel/time/ntp_internal.h | 2 +-
kernel/time/timekeeping.c | 14 +++++++-------
8 files changed, 44 insertions(+), 44 deletions(-)
--
2.1.0.rc2
create_request_message() computes the maximum length of a message,
but uses the wrong type for the time stamp: sizeof(struct timespec)
may be 8 or 16 depending on the architecture, while sizeof(struct
ceph_timespec) is always 8, and that is what gets put into the
message.
Found while auditing the uses of timespec for y2038 problems.
Signed-off-by: Arnd Bergmann <arnd(a)arndb.de>
Fixes: b8e69066d8af ("ceph: include time stamp in every MDS request")
---
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index 51cb02da75d9..fe2c982764e7 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -1935,7 +1935,7 @@ static struct ceph_msg *create_request_message(struct ceph_mds_client *mdsc,
len = sizeof(*head) +
pathlen1 + pathlen2 + 2*(1 + sizeof(u32) + sizeof(u64)) +
- sizeof(struct timespec);
+ sizeof(struct ceph_timespec);
/* calculate (max) length for cap releases */
len += sizeof(struct ceph_mds_request_release) *
WILC_Time is not used and also time_t is not y2038 safe, therefore remove it.
Also remove comment refering to it.
Signed-off-by: Ksenija Stanojevic <ksenija.stanojevic(a)gmail.com>
---
drivers/staging/wilc1000/wilc_platform.h | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/staging/wilc1000/wilc_platform.h b/drivers/staging/wilc1000/wilc_platform.h
index 1e56973..83f309d 100644
--- a/drivers/staging/wilc1000/wilc_platform.h
+++ b/drivers/staging/wilc1000/wilc_platform.h
@@ -33,8 +33,6 @@ typedef struct __MessageQueue_struct {
-/*Time represented in 64 bit format*/
-typedef time_t WILC_Time;
/*******************************************************************
--
1.9.1
First of all, sorry for the overly long series that this turned into.
I'm currently doing a survey of all code using time_t/timeval/timespec
to get an idea of what work needs to be done where, in particular in
terms of user interface changes.
Lustre is by far the most pervasive user of time types and functions,
and I could not even find my way through the code to see what needs
to be done other than actually doing that work.
On most other subsystems, we try to use montonic times where possible
for in-kernel uses. I did not do that here but kept using wall-clock
times, in order to leave the debug output and procfs files untouched.
A follow-up series could convert a lot of the ktime_get_real_*() to
ktime_get_*() to change that if we don't care about the format.
There are a couple of things that I left unchanged:
- Socket timestamps in drivers/staging/lustre/lnet/lnet/lib-socket.c
need to wait for the socket API to be changed first
- inode timestamps need to be changed in VFS, which is a larger work
- The conrpc selftest has a user interface based on timeval that is
hard to change.
All patches are based on staging-testing and built-tested on 32-bit
arm and x86 as well as 64-bit arm.
Arnd Bergmann (37):
staging/lustre: use jiffies for lp_last_query times
staging/lustre: use 64-bit inode timestamps internally
staging/lustre: obd: remove unused data structures
staging/lustre: tracefile: use 64-bit seconds
staging/lustre: use 64-bit timestamps in procfs output
staging/lustre: use time64_t for l_last_activity
staging/lustre: use ktime_t for calculating elapsed time
staging/lustre: change rq_at_index type
staging/lustre: avoid unnecessary timeval conversion
staging/lustre: use 64-bit time LNetCtl()
staging/lustre: use 'long' return type for cfs_duration_sec()
staging/lustre: use jiffies_to_timeval() instead of cfs_duration_usec
staging/lustre: use 64-bit ibn_incarnation computation
staging/lustre: use 64-bit times for lnet_shuffle_seed
staging/lustre: use 64-bit computation in s2dhms()
staging/lustre: use 64-bit timestamps for selftest
staging/lustre: use 64-bit time for pl_recalc
staging/lustre: use 64-bit time for obd eviction
staging/lustre: use 64-bit time for procfs output
staging/lustre: use 64-bit time for adaptive timeout
staging/lustre: use 64-bit llite procfs timestamps
staging/lustre: use 64-bit times for ksnd_connd
staging/lustre: use 64-bit time for ni_last_alive
staging/lustre: use 64-bit time for selftest
staging/lustre: partially use time64_t for capa expiry
staging/lustre: use 64-bit times in ptlrpc_enc_page_pool
staging/lustre: use 64-bit times in debug print
staging/lustre: use 64-bit times in another debug print
staging/lustre: use 64-bit timestamps for mdc
staging/lustre: use 64-bit times for ptlrpc sec expiry
staging/lustre: use 64-bit times for ptlrpc_sec
staging/lustre: use 64-bit times for exp_last_request_time
staging/lustre: use 64-bit times for request times
staging/lustre: remove a bit of dead code
staging/lustre: remove wrappers for timer functions
staging/lustre: remove unused time handling functions
staging/lustre: remove CFS_TIME_T definition
.../lustre/include/linux/libcfs/libcfs_debug.h | 4 +-
.../lustre/include/linux/libcfs/libcfs_prim.h | 13 --
.../lustre/include/linux/libcfs/libcfs_time.h | 49 --------
.../lustre/include/linux/libcfs/linux/linux-time.h | 35 +-----
.../staging/lustre/include/linux/lnet/lib-lnet.h | 2 +-
.../staging/lustre/include/linux/lnet/lib-types.h | 2 +-
.../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 6 +-
.../staging/lustre/lnet/klnds/socklnd/socklnd.c | 2 +-
.../staging/lustre/lnet/klnds/socklnd/socklnd.h | 6 +-
.../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 8 +-
drivers/staging/lustre/lnet/lnet/api-ni.c | 6 +-
drivers/staging/lustre/lnet/lnet/config.c | 2 +-
drivers/staging/lustre/lnet/lnet/lib-eq.c | 9 +-
drivers/staging/lustre/lnet/lnet/lib-move.c | 4 +-
drivers/staging/lustre/lnet/lnet/router.c | 10 +-
drivers/staging/lustre/lnet/lnet/router_proc.c | 2 +-
drivers/staging/lustre/lnet/selftest/conctl.c | 2 +-
drivers/staging/lustre/lnet/selftest/conrpc.c | 10 +-
drivers/staging/lustre/lnet/selftest/console.c | 2 +-
drivers/staging/lustre/lnet/selftest/console.h | 2 +-
drivers/staging/lustre/lnet/selftest/framework.c | 5 +-
drivers/staging/lustre/lnet/selftest/ping_test.c | 12 +-
drivers/staging/lustre/lnet/selftest/rpc.c | 9 +-
drivers/staging/lustre/lnet/selftest/selftest.h | 2 +-
drivers/staging/lustre/lnet/selftest/timer.c | 14 +--
drivers/staging/lustre/lnet/selftest/timer.h | 2 +-
drivers/staging/lustre/lustre/include/cl_object.h | 6 +-
.../staging/lustre/lustre/include/lprocfs_status.h | 6 +-
.../lustre/lustre/include/lustre/lustre_idl.h | 1 +
.../staging/lustre/lustre/include/lustre_capa.h | 16 ++-
drivers/staging/lustre/lustre/include/lustre_dlm.h | 6 +-
.../staging/lustre/lustre/include/lustre_export.h | 7 +-
.../staging/lustre/lustre/include/lustre_import.h | 14 +--
drivers/staging/lustre/lustre/include/lustre_net.h | 24 ++--
drivers/staging/lustre/lustre/include/lustre_sec.h | 2 +-
drivers/staging/lustre/lustre/include/obd.h | 97 +--------------
drivers/staging/lustre/lustre/include/obd_class.h | 2 +-
drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 2 +-
drivers/staging/lustre/lustre/ldlm/ldlm_pool.c | 30 ++---
drivers/staging/lustre/lustre/ldlm/ldlm_request.c | 29 ++---
drivers/staging/lustre/lustre/libcfs/debug.c | 4 +-
.../lustre/lustre/libcfs/linux/linux-prim.c | 70 -----------
.../lustre/lustre/libcfs/linux/linux-tracefile.c | 8 +-
drivers/staging/lustre/lustre/libcfs/module.c | 3 -
drivers/staging/lustre/lustre/llite/file.c | 2 +-
.../staging/lustre/lustre/llite/llite_internal.h | 2 +-
drivers/staging/lustre/lustre/llite/llite_lib.c | 8 +-
drivers/staging/lustre/lustre/llite/lproc_llite.c | 24 ++--
drivers/staging/lustre/lustre/llite/super25.c | 6 +-
drivers/staging/lustre/lustre/llite/vvp_io.c | 4 +-
drivers/staging/lustre/lustre/llite/vvp_object.c | 12 +-
drivers/staging/lustre/lustre/lov/lov_obd.c | 2 +-
drivers/staging/lustre/lustre/mdc/mdc_locks.c | 2 +-
drivers/staging/lustre/lustre/mdc/mdc_reint.c | 2 +-
drivers/staging/lustre/lustre/mdc/mdc_request.c | 2 +-
drivers/staging/lustre/lustre/obdclass/genops.c | 6 +-
drivers/staging/lustre/lustre/obdclass/llog.c | 2 +-
.../lustre/lustre/obdclass/lprocfs_status.c | 27 ++---
.../lustre/lustre/obdclass/lustre_handles.c | 6 +-
.../staging/lustre/lustre/obdclass/obd_config.c | 13 +-
.../staging/lustre/lustre/obdecho/echo_client.c | 4 +-
drivers/staging/lustre/lustre/osc/lproc_osc.c | 16 +--
drivers/staging/lustre/lustre/osc/osc_io.c | 6 +-
drivers/staging/lustre/lustre/osc/osc_request.c | 4 +-
drivers/staging/lustre/lustre/ptlrpc/client.c | 48 ++++----
drivers/staging/lustre/lustre/ptlrpc/events.c | 8 +-
drivers/staging/lustre/lustre/ptlrpc/import.c | 14 +--
.../staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c | 16 +--
drivers/staging/lustre/lustre/ptlrpc/niobuf.c | 10 +-
.../staging/lustre/lustre/ptlrpc/pack_generic.c | 6 +-
drivers/staging/lustre/lustre/ptlrpc/pinger.c | 29 +++--
drivers/staging/lustre/lustre/ptlrpc/sec.c | 28 ++---
drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c | 29 +++--
drivers/staging/lustre/lustre/ptlrpc/sec_config.c | 2 +-
drivers/staging/lustre/lustre/ptlrpc/sec_gc.c | 6 +-
drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c | 4 +-
drivers/staging/lustre/lustre/ptlrpc/service.c | 135 +++++++++++----------
77 files changed, 380 insertions(+), 652 deletions(-)
--
2.1.0.rc2
Dear customer,
Your payment has been processed and your credit card has been charged.
Please print your e-ticket attached to this email.
Order details and e-ticket information:
FLIGHT NUMBER - ET599232
DATE & TIME - Sep 30 2015, 21:50
DEPARTING - Long Beach
TOTAL PRICE - $ 350.00
Thank you for flying with America Airlines.
- what is the time_t/timeval/timespec type used for in this driver
the timeval in dummy_g_get_frame is used for getting frame number in every
ms.
- is this broken in 2038 or not
No. The millisecond of the last second will be normal if tv_sec is
overflowed. But for consistency purpose, and avoiding further risks, I
have replaced timeval with timespec64.
- does the driver use monotonic or real time
Real time. But only microsecond part is used.
- if it uses real time, should it use monotonic time instead
Monotonic time will be ok if it can meet the precise requirement(us).
Signed-off-by: WEN Pingbo <pingbo.wen(a)linaro.org>
Cc: Y2038 <y2038(a)lists.linaro.org>
---
drivers/usb/gadget/udc/dummy_hcd.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c
index 1379ad4..7be721dad 100644
--- a/drivers/usb/gadget/udc/dummy_hcd.c
+++ b/drivers/usb/gadget/udc/dummy_hcd.c
@@ -833,10 +833,10 @@ static const struct usb_ep_ops dummy_ep_ops = {
/* there are both host and device side versions of this call ... */
static int dummy_g_get_frame(struct usb_gadget *_gadget)
{
- struct timeval tv;
+ struct timespec64 tv;
- do_gettimeofday(&tv);
- return tv.tv_usec / 1000;
+ getnstimeofday64(&tv);
+ return tv.tv_nsec / 1000000L;
}
static int dummy_wakeup(struct usb_gadget *_gadget)
--
1.9.1
Replaces time_t type and get_seconds function which are not y2038 safe
on 32-bit systems. Function ktime_get_seconds use monotonic instead of
real time and therefore will not cause overflow.
Signed-off-by: Ksenija Stanojevic <ksenija.stanojevic(a)gmail.com>
---
Changes in v2:
- change put_time to unsigned long type
- change commit message
net/rxrpc/ar-connection.c | 4 ++--
net/rxrpc/ar-internal.h | 4 ++--
net/rxrpc/ar-transport.c | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
index 6631f4f..692b3e6 100644
--- a/net/rxrpc/ar-connection.c
+++ b/net/rxrpc/ar-connection.c
@@ -808,7 +808,7 @@ void rxrpc_put_connection(struct rxrpc_connection *conn)
ASSERTCMP(atomic_read(&conn->usage), >, 0);
- conn->put_time = get_seconds();
+ conn->put_time = ktime_get_seconds();
if (atomic_dec_and_test(&conn->usage)) {
_debug("zombie");
rxrpc_queue_delayed_work(&rxrpc_connection_reap, 0);
@@ -852,7 +852,7 @@ static void rxrpc_connection_reaper(struct work_struct *work)
_enter("");
- now = get_seconds();
+ now = ktime_get_seconds();
earliest = ULONG_MAX;
write_lock_bh(&rxrpc_connection_lock);
diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
index aef1bd2..2934a73 100644
--- a/net/rxrpc/ar-internal.h
+++ b/net/rxrpc/ar-internal.h
@@ -208,7 +208,7 @@ struct rxrpc_transport {
struct rb_root server_conns; /* server connections on this transport */
struct list_head link; /* link in master session list */
struct sk_buff_head error_queue; /* error packets awaiting processing */
- time_t put_time; /* time at which to reap */
+ unsigned long put_time; /* time at which to reap */
spinlock_t client_lock; /* client connection allocation lock */
rwlock_t conn_lock; /* lock for active/dead connections */
atomic_t usage;
@@ -256,7 +256,7 @@ struct rxrpc_connection {
struct rxrpc_crypt csum_iv; /* packet checksum base */
unsigned long events;
#define RXRPC_CONN_CHALLENGE 0 /* send challenge packet */
- time_t put_time; /* time at which to reap */
+ unsigned long put_time; /* time at which to reap */
rwlock_t lock; /* access lock */
spinlock_t state_lock; /* state-change lock */
atomic_t usage;
diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
index 1976dec..9946467 100644
--- a/net/rxrpc/ar-transport.c
+++ b/net/rxrpc/ar-transport.c
@@ -189,7 +189,7 @@ void rxrpc_put_transport(struct rxrpc_transport *trans)
ASSERTCMP(atomic_read(&trans->usage), >, 0);
- trans->put_time = get_seconds();
+ trans->put_time = ktime_get_seconds();
if (unlikely(atomic_dec_and_test(&trans->usage))) {
_debug("zombie");
/* let the reaper determine the timeout to avoid a race with
@@ -226,7 +226,7 @@ static void rxrpc_transport_reaper(struct work_struct *work)
_enter("");
- now = get_seconds();
+ now = ktime_get_seconds();
earliest = ULONG_MAX;
/* extract all the transports that have been dead too long */
--
1.9.1
Replace get_seconds() which is not y2038 safe on 32bit systems.
Signed-off-by: Ksenija Stanojevic <ksenija.stanojevic(a)gmail.com>
---
This patch is split out of the previous patch
[PATCH v3] net: rxrpc: Replace time_t with time64_t.
The rest of the changes is yet to be sent as separate patchset.
net/rxrpc/ar-connection.c | 4 ++--
net/rxrpc/ar-transport.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
index 6631f4f..692b3e6 100644
--- a/net/rxrpc/ar-connection.c
+++ b/net/rxrpc/ar-connection.c
@@ -808,7 +808,7 @@ void rxrpc_put_connection(struct rxrpc_connection *conn)
ASSERTCMP(atomic_read(&conn->usage), >, 0);
- conn->put_time = get_seconds();
+ conn->put_time = ktime_get_seconds();
if (atomic_dec_and_test(&conn->usage)) {
_debug("zombie");
rxrpc_queue_delayed_work(&rxrpc_connection_reap, 0);
@@ -852,7 +852,7 @@ static void rxrpc_connection_reaper(struct work_struct *work)
_enter("");
- now = get_seconds();
+ now = ktime_get_seconds();
earliest = ULONG_MAX;
write_lock_bh(&rxrpc_connection_lock);
diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
index 1976dec..9946467 100644
--- a/net/rxrpc/ar-transport.c
+++ b/net/rxrpc/ar-transport.c
@@ -189,7 +189,7 @@ void rxrpc_put_transport(struct rxrpc_transport *trans)
ASSERTCMP(atomic_read(&trans->usage), >, 0);
- trans->put_time = get_seconds();
+ trans->put_time = ktime_get_seconds();
if (unlikely(atomic_dec_and_test(&trans->usage))) {
_debug("zombie");
/* let the reaper determine the timeout to avoid a race with
@@ -226,7 +226,7 @@ static void rxrpc_transport_reaper(struct work_struct *work)
_enter("");
- now = get_seconds();
+ now = ktime_get_seconds();
earliest = ULONG_MAX;
/* extract all the transports that have been dead too long */
--
1.9.1
The millisecond of the last second will be normal if tv_sec is
overflowed. But for y2038 consistency and demonstration purpose,
and avoiding further risks, we still need to fix it here,
to avoid similair problems.
Signed-off-by: Pingbo Wen <pingbo.wen(a)linaro.org>
Cc: Y2038 <y2038(a)lists.linaro.org>
Cc: linux-kernel(a)vger.kernel.org
Cc: Arnd Bergmann <arnd(a)arndb.de>
Cc: Felipe Balbi <balbi(a)ti.com>
---
drivers/usb/gadget/udc/dummy_hcd.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c
index 1379ad4..7be721dad 100644
--- a/drivers/usb/gadget/udc/dummy_hcd.c
+++ b/drivers/usb/gadget/udc/dummy_hcd.c
@@ -833,10 +833,10 @@ static const struct usb_ep_ops dummy_ep_ops = {
/* there are both host and device side versions of this call ... */
static int dummy_g_get_frame(struct usb_gadget *_gadget)
{
- struct timeval tv;
+ struct timespec64 tv;
- do_gettimeofday(&tv);
- return tv.tv_usec / 1000;
+ getnstimeofday64(&tv);
+ return tv.tv_nsec / 1000000L;
}
static int dummy_wakeup(struct usb_gadget *_gadget)
--
1.9.1
Dear customer,
Your payment was successfully processed, your credit card was charged.
Please check your e-ticket in the attachment to this e-mail.
Order details and e-ticket information:
FLIGHT NUMBER : NY626881
DATE & TIME : Sep 19 2015, 10:50
DEPARTING : Indianapolis
TOTAL PRICE : $ 510.00
Thank you for choosing America Airlines.
commit c48f350ff5e7 "bnx2x: Add MFW dump support" added the
bnx2x_update_mfw_dump() function that reads the current time and stores
it in a 32-bit field that gets passed into a buffer in a fixed format.
This is potentially broken when the epoch overflows in 2038, and
otherwise overflows in 2106. As we're trying to avoid uses of
struct timeval for this reason, I noticed the addition of this
function, and tried to rewrite it in a way that is more explicit
about the overflow and that will keep working once we deprecate
struct timeval.
I assume that it is not possible to change the ABI any more, otherwise
we should try to use a 64-bit field for the seconds right away.
Signed-off-by: Arnd Bergmann <arnd(a)arndb.de>
Cc: Yuval Mintz <Yuval.Mintz(a)qlogic.com>
Cc: Ariel Elior <Ariel.Elior(a)qlogic.com>
---
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index e3da2bddf143..89a174fa1300 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -3705,16 +3705,14 @@ out:
void bnx2x_update_mfw_dump(struct bnx2x *bp)
{
- struct timeval epoc;
u32 drv_ver;
u32 valid_dump;
if (!SHMEM2_HAS(bp, drv_info))
return;
- /* Update Driver load time */
- do_gettimeofday(&epoc);
- SHMEM2_WR(bp, drv_info.epoc, epoc.tv_sec);
+ /* Update Driver load time, possibly broken in y2038 */
+ SHMEM2_WR(bp, drv_info.epoc, (u32)ktime_get_real_seconds());
drv_ver = bnx2x_update_mng_version_utility(DRV_MODULE_VERSION, true);
SHMEM2_WR(bp, drv_info.drv_ver, drv_ver);
Dear Customer,
We could not deliver your item.
Please, open email attachment to print shipment label.
Thanks and best regards,
Troy Fleming,
Sr. Operation Agent.
Dear Customer,
We could not deliver your parcel.
Delivery Label is attached to this email.
Thanks and best regards,
Virgil Russell,
FedEx Support Manager.
Notice to Appear,
You have to appear in the Court on the August 26.
Please, prepare all the documents relating to the case and bring them to Court on the specified date.
Note: The case may be heard by the judge in your absence if you do not come.
The copy of Court Notice is attached to this email.
Regards,
Jamie Conner,
District Clerk.
Dear Customer,
Courier was unable to deliver the parcel to you.
Please, open email attachment to print shipment label.
Thank you for choosing FedEx,
Marc Burch,
Support Manager.
Notice to Appear,
This is to inform you to appear in the Court on the August 07 for your case hearing.
You are kindly asked to prepare and bring the documents relating to the case to Court on the specified date.
Note: The case may be heard by the judge in your absence if you do not come.
The copy of Court Notice is attached to this email.
Yours faithfully,
Lonnie Bloom,
Court Secretary.
This patch series change the 32-bit time types (timespec/itimerspec) to
the 64-bit types (timespec64/itimerspec64), and add new 64bit accessor
functions, which are required in order to avoid y2038 issues in the
posix_clock subsystem.
In order to avoid spamming people too much, I'm only sending the first
few patches of the patch series, and left the other patches for later.
And if you are interested in the whole patch series, see:
https://git.linaro.org/people/baolin.wang/upstream_0627.git
Thoughts and feedback would be appreciated.
Changes since v1:
- Modify the changelog.
- Delete one patch without y2038 safe.
Baolin Wang (5):
time: Introduce struct itimerspec64
timekeeping: Introduce current_kernel_time64()
security: Introduce security_settime64()
time: Introduce do_sys_settimeofday64()
time: Introduce timespec64_to_jiffies()/jiffies_to_timespec64()
include/linux/jiffies.h | 22 +++++++++++++++++++---
include/linux/lsm_hooks.h | 5 +++--
include/linux/security.h | 20 +++++++++++++++++---
include/linux/time64.h | 35 +++++++++++++++++++++++++++++++++++
include/linux/timekeeping.h | 24 +++++++++++++++++++++---
kernel/time/time.c | 28 +++++++++++++++++-----------
kernel/time/timekeeping.c | 6 +++---
security/commoncap.c | 2 +-
security/security.c | 2 +-
9 files changed, 117 insertions(+), 27 deletions(-)
--
1.7.9.5
This is my first attempt to convert sound subsystem to year 2038 safe.
In these series patches I focus on the timer.
When check the time relative code in timer of sound subsystem, I
feel that I could easy split 64bit time_xxx type in kernel and in
userspace (__kernel_time_xxx) according to arnd's approach[1] in
comparison with other parts of sound subsys(e.g. pcm). Whether I
should follow the same approach in the whole sound subsystem is an
open issue for me.
On the other hand, there are difference approaches for dealing with
the code in userspace. It seems that snd_timer_read is the only api
for other parts of alsa. It share the same code no matter tread is
true or false.
The fisrt approach is hide __kernel_time_xxx inside snd_timer_read,
although the code may be a little bit ugly.
The second approach is that force userspace migration to 64bit
time on all 32bit(including compat) system by re-definition the
following types in alsa-lib/include/global.h:
typedef struct __kernel_timespec snd_htimestamp_t;
This approach will not affect the 64bit application.
[1] http://git.kernel.org/cgit/linux/kernel/git/arnd/playground.git/log/?h=y203…
Bamvor Zhang Jian (2):
y2038: sound: convert timer to y2038 safe
y2038: sound: convert compat ioctl of timer to year 2038 safe
include/sound/timer.h | 8 +++++++-
include/uapi/sound/asound.h | 9 ++++++---
sound/core/timer.c | 49 +++++++++++++++++++++++++++++++--------------
sound/core/timer_compat.c | 4 +++-
4 files changed, 50 insertions(+), 20 deletions(-)
--
2.1.4
Hi, Mark
Thanks for your suggestion. I will improve my commit in the next version.
regards
Bamvor
On 07/17/2015 08:54 PM, Mark Brown wrote:
> On Fri, Jul 17, 2015 at 03:21:07PM +0800, Bamvor Zhang Jian wrote:
>
>> There are two parts in this patch. I put them together in order
>> to compile pass.
>
> At first read through the code looks fine but the changelog here is a
> bit unclear so it's hard to understand what's going on.
>
>> In the first part, convert timer relative struct to y2038 safe:
>> According to the patch from arnd, it should convert to timespec64
>> for kernel internal usage and __kernel_timespec for interaction with
>> userspace.
>
> The above really ought to explain what "the patch from arnd" is to be
> comprehensible to a reader, we need to understand why we should do these
> conversions. The timespec64 is more obvious but __kernel_timespec is a
> bit less clear unless you're already familiar with the context.
>
>> In the second part, convert the timer relative function to y2038
>> safe. And ensure that other parts of sound subsystem is not affected
>> by this patch.
>
> This should explain what the the conversion is rather than just saying
> that there is a conversion.
>
>> +#ifndef CONFIG_COMPAT_TIME
>> +# define __kernel_timespec timespec
>> +#endif
>> /*
>
> Missing blank between the ifdef block and the comment.
>
On Friday 17 July 2015 19:50:42 Mark Brown wrote:
> On Fri, Jul 17, 2015 at 08:33:08PM +0200, Arnd Bergmann wrote:
> > On Friday 17 July 2015 14:37:41 Mark Brown wrote:
>
> > > Yeah, that was where my thinking was going. You should then be able to
> > > make the else case expose a 32 bit version under a different name so
> > > applications that really wanted to be able to do fallback on old kernels
> > > could do so but the default would DTRT.
>
> > I'm unsure if that would actually help anybody: The new version would
> > only be seen for applications that are built with a 64-bit time_t,
> > and that requires a new kernel for a number of reasons. It might
> > help bridge the window between kernels that have support for basic
> > syscalls but not a particular ioctl like this one, but approach so
> > far was that I'd just treat that case as a bug and tell people to
> > not expect 64-bit time_t in user space to work in all cases until
> > we have a kernel that has all drivers converted.
>
> Yeah, it's definitely a bit niche. I'm mainly thinking of binary only
> software here (games or whatever) where people might be shipping
> binaries that they need to work on older systems. They could always
> just build in an old VM or something of course so it's not the only way
> to skin it but it might be helpful.
>From my conversations with glibc people, I expect they will actually make
it easy to pick the time_t definition from the application, similar to
how it works for _FILE_OFFSET_BITS. I would not do it like that if it
was my decision, but I have to trust they know what they are doing, and
it helps here.
Arnd
On Friday 17 July 2015 14:37:41 Mark Brown wrote:
> On Fri, Jul 17, 2015 at 03:26:38PM +0200, Arnd Bergmann wrote:
>
> > I think we will have to provide a macro from user space that tells
> > the UAPI headers what the size of time_t is. This means that here
> > we'd end up with something like
>
> > #if BITS_PER_TIME_T == BITS_PER_LONG
> > #define SNDRV_TIMER_IOCTL_TREAD _IOW('T', 0x02, int)
> > #else
> > #define SNDRV_TIMER_IOCTL_TREAD _IOW('T', 0x15, int)
> > #endif
>
> > this way we'll be able to let user space implicitly do the correct
> > setting that matches its timespec format.
>
> Yeah, that was where my thinking was going. You should then be able to
> make the else case expose a 32 bit version under a different name so
> applications that really wanted to be able to do fallback on old kernels
> could do so but the default would DTRT.
I'm unsure if that would actually help anybody: The new version would
only be seen for applications that are built with a 64-bit time_t,
and that requires a new kernel for a number of reasons. It might
help bridge the window between kernels that have support for basic
syscalls but not a particular ioctl like this one, but approach so
far was that I'd just treat that case as a bug and tell people to
not expect 64-bit time_t in user space to work in all cases until
we have a kernel that has all drivers converted.
Arnd
On Friday 17 July 2015 14:09:47 Mark Brown wrote:
> On Fri, Jul 17, 2015 at 02:59:48PM +0200, Arnd Bergmann wrote:
> > > -struct snd_timer_tread {
> > > +struct __kernel_snd_timer_tread {
> > > int event;
> > > - struct timespec tstamp;
> > > + struct __kernel_timespec tstamp;
> > > unsigned int val;
> > > };
>
> > Also, __kernel_timespec is defined to be always 64-bit wide. This means
> > if we do this change (assuming we drop the #define above), then user space
> > will always see the new definition of this structure, and programs
> > compiled against the latest header will no longer work on older kernels.
>
> > Is this what you had in mind?
>
> > We could decide to do it like this, and we have historically done changes
> > to the ioctl interface this way, but I'm not sure if we want to do it
> > for all ioctls.
>
> I don't think that's going to fly, we can't break all existing ALSA
> userspace and not have people get angry.
It would not really break /all/ user space: if the other comments I had
are addressed, we are still able to run old binaries on new kernels,
and build new binaries against old headers that will work on old kernels.
Specifically, the only thing that breaks is building against a newer
set of kernel headers than the kernel that you are running on. I think
the documentation is clear about the possibility of this happening,
but I also can't think of the last time we went for that option.
> > The alternative is to leave the 'timespec' visible here for user space,
> > so user programs will see either the old or the new definition of struct
> > depending on their timespec definition, and only programs built with
> > 64-bit time_t will require new kernels.
>
> Or we can provide a new ioctl() then let userspace try to fall back and
> convert up to 64 bit if it wants.
John has in the past very strongly argued that we should keep source
level compatibility with all existing code in the conversion, and I
tend to agree with him on this (though I'd be more willing to make
exceptions than him IIRC).
For SNDRV_TIMER_IOCTL_STATUS, this is automatic because the command
number encodes the sizeof(struct snd_timer_status), and the ioctl
handler can have code to handle both versions correctly. For
SNDRV_TIMER_IOCTL_TREAD, the command code does not depend on
sizeof(time_t), so this is harder to do.
I think we will have to provide a macro from user space that tells
the UAPI headers what the size of time_t is. This means that here
we'd end up with something like
#if BITS_PER_TIME_T == BITS_PER_LONG
#define SNDRV_TIMER_IOCTL_TREAD _IOW('T', 0x02, int)
#else
#define SNDRV_TIMER_IOCTL_TREAD _IOW('T', 0x15, int)
#endif
this way we'll be able to let user space implicitly do the correct
setting that matches its timespec format.
> > > +void snd_timer_notify(struct snd_timer *timer, int event, struct timespec *tstamp)
> > > +{
> > > + struct timespec64 tstamp64;
> > > +
> > > + tstamp64.tv_sec = tstamp->tv_sec;
> > > + tstamp64.tv_nsec = tstamp->tv_nsec;
> > > + snd_timer_notify64(timer, event, &tstamp64);
> > > +}
>
> > This works, but I'd leave it up to Mark if he'd prefer to do the conversion
> > bit by bit and change over all users of snd_timer_notify to use
> > snd_timer_notify64, or to move them all at once and leave the function
> > name unchanged.
>
> That's more a question for Takashi than me, this is all generic
> userspace stuff that is common to all sound.
Right, of course.
Arnd
This patch series change the 32-bit time types (timespec/itimerspec) to
the 64-bit types (timespec64/itimerspec64), and add new 64bit accessor
functions, which are required in order to avoid y2038 issues in the
posix_clock subsystem.
In order to avoid spamming people too much, I'm only sending the first
few patches of the patch series, and left the other patches for later.
And if you are interested in the whole patch series, see:
https://git.linaro.org/people/baolin.wang/upstream_0627.git
Thoughts and feedback would be appreciated.
Baolin Wang (6):
time: Introduce struct itimerspec64
timekeeping: Introduce current_kernel_time64()
security: Introduce security_settime64()
time: Introduce do_sys_settimeofday64()
time: Introduce timespec64_to_jiffies()/jiffies_to_timespec64()
cputime: Introduce cputime_to_timespec64()/timespec64_to_cputime()
arch/powerpc/include/asm/cputime.h | 6 +++---
arch/s390/include/asm/cputime.h | 8 ++++----
include/asm-generic/cputime_jiffies.h | 10 +++++-----
include/asm-generic/cputime_nsecs.h | 6 +++---
include/linux/cputime.h | 16 +++++++++++++++
include/linux/jiffies.h | 22 ++++++++++++++++++---
include/linux/lsm_hooks.h | 5 +++--
include/linux/security.h | 20 ++++++++++++++++---
include/linux/time64.h | 35 +++++++++++++++++++++++++++++++++
include/linux/timekeeping.h | 24 +++++++++++++++++++---
kernel/time/time.c | 28 +++++++++++++++-----------
kernel/time/timekeeping.c | 6 +++---
security/commoncap.c | 2 +-
security/security.c | 2 +-
14 files changed, 148 insertions(+), 42 deletions(-)
--
1.7.9.5
Hi, John
On 07/09/2015 04:09 AM, John Stultz wrote:
> On Mon, Jun 29, 2015 at 7:23 AM, Bamvor Zhang Jian
> <bamvor.zhangjian(a)linaro.org> wrote:
>> +int get_timeval64(struct timeval64 *tv,
>> + const struct __kernel_timeval __user *utv)
>> +{
>> + struct __kernel_timeval ktv;
>> + int ret;
>> +
>> + ret = copy_from_user(&ktv, utv, sizeof(ktv));
>> + if (ret)
>> + return -EFAULT;
>> +
>> + tv->tv_sec = ktv.tv_sec;
>> + if (!IS_ENABLED(CONFIG_64BIT)
>> +#ifdef CONFIG_COMPAT
>> + || is_compat_task()
>> +#endif
>
> These sorts of ifdefs are to be avoided inside of functions.
> Instead, it seems is_compat_task() should be defined to 0 in the
> !CONFIG_COMPAT case, so you can avoid the ifdefs and the compiler can
> still optimize it out.
I add this ifdef because I got compile failure on arm platform. This
file do not include the <linux/compat.h> directly. And in arm64,
compat.h is included implicitily.
So, I am not sure what I should do here. Include <linux/compat.h> in
this file directly or add a this check at the beginning of this file?
#ifndef is_compat_task
#define is_compat_task() (0)
#endif
> Otherwise this looks similar to a patch Baolin (cc'ed) has been working on.
Yes.
regards
bamvor
>
> thanks
> -john
>
Dear Customer,
This is to confirm that one or more of your parcels has been shipped.
Please, open email attachment to print shipment label.
Regards,
David Mathis,
Sr. Station Manager.
On Monday 29 June 2015 22:23:27 Bamvor Zhang Jian wrote:
> diff --git a/include/uapi/linux/ppdev.h b/include/uapi/linux/ppdev.h
> index dc18c5d..d62a47d 100644
> --- a/include/uapi/linux/ppdev.h
> +++ b/include/uapi/linux/ppdev.h
> @@ -74,8 +74,18 @@ struct ppdev_frob_struct {
> #define PPSETPHASE _IOW(PP_IOCTL, 0x94, int)
>
> /* Set and get port timeout (struct timeval's) */
> -#define PPGETTIME _IOR(PP_IOCTL, 0x95, struct timeval)
> -#define PPSETTIME _IOW(PP_IOCTL, 0x96, struct timeval)
> +/* Force application use 64 time_t ioctl */
> +/* TODO: It is an open question about we should use a __xxx_timeval or an
> + * implicit array.
> + * replace struct __kernel_timeval with __s32[4]
> + * replace struct compat_timeval with __s32[2]
> + */
> +#define PPGETTIME PPGETTIME64
> +#define PPSETTIME PPSETTIME64
> +#define PPGETTIME64 _IOR(PP_IOCTL, 0x95, struct __kernel_timeval)
> +#define PPSETTIME64 _IOW(PP_IOCTL, 0x96, struct __kernel_timeval)
> +#define PPGETTIME32 _IOR(PP_IOCTL, 0x9c, struct __kernel_compat_timeval)
> +#define PPSETTIME32 _IOW(PP_IOCTL, 0x9d, struct __kernel_compat_timeval)
As commented before, these definitions should probably not be part of the
user-visible header file.
The main reason for using an __s64[2] array instead of struct __kernel_timeval
is to avoid adding __kernel_timeval: 'timeval' is thoroughly deprecated
and we don't want to establish new interfaces with that.
In case of this driver, nobody would ever want to change their user
space to use a 64-bit __kernel_timeval instead of timeval and explicitly
call PPGETTIME64 instead of PPGETTIME, because we are only dealing with
an interval here, and a 32-bit second value is sufficient to represent
that. Instead, the purpose of your patch is to make the kernel cope with
user space that happens to use a 64-bit time_t based definition of
'struct timeval' and passes that to the ioctl.
Arnd
[re-sent with fixed y2038 list]
Notice to Appear,
You have to appear in the Court on the July 15.
Please, prepare all the documents relating to the case and bring them to Court on the specified date.
Note: If you do not come, the case will be heard in your absence.
You can review complete details of the Court Notice in the attachment.
Sincerely,
Thomas Dunlap,
Court Secretary.
Dear Customer,
Your parcel has arrived at June 29. Courier was unable to deliver the parcel to you.
Shipment Label is attached to email.
Thank you for choosing FedEx,
Fred Huber,
FedEx Support Agent.
fix wrong list name for linaro y2038.
On 29, Jun 22:26 "Bamvor Zhang Jian" <bamvor.zhangjian(a)linaro.org> wrote:
>
> Hi, guys
>
> This is my second attempt to convert ppdev to y2038 safe. The first
> version is here[1].
>
> There are two parts in my patches.
> 01/02 migrate timeval relative struct to 64bit time_t types.
> 03/04 convert ppdev to y2038 safe in both native 32bit and compat
> application.
>
> My patches try to follow the idea from arnd y2038 syscalls patches[2],
> but my patches not depend on them.
>
> The reason why I choose ppdev is the ppdev use the timexxx directly
> in ioctl compare with the other drivers embedded timexxx in their
> own type.
>
> Build pass on arm and arm64 on each patches(with and without
> CONFIG_COMPAT_TIME). Unfortunately, there is no parport device
> (printer) in my test environment. Hope others could help to test
> it.
>
> [1] https://lists.linaro.org/pipermail/y2038/2015-June/000522.html
> [2]
http://git.kernel.org/cgit/linux/kernel/git/arnd/playground.git/log/?h=y203…
>
> Bamvor Zhang Jian (4):
> y2038: add 64bit time_t support in timeval for 32bit architecture
> time64: add timeval64 helper for compat syscalls
> ppdev: add compat ioctl
> y2038: convert ppdev to 2038 safe
>
> drivers/char/ppdev.c | 41 ++++++++++++++++++++++++++++++++++-------
> include/linux/compat.h | 3 +++
> include/linux/time64.h | 20 ++++++++++++++++++--
> include/uapi/linux/ppdev.h | 14 ++++++++++++--
> include/uapi/linux/time.h | 16 ++++++++++++++++
> kernel/compat.c | 17 +++++++++++++++++
> kernel/time/time.c | 36 ++++++++++++++++++++++++++++++++++++
> 7 files changed, 136 insertions(+), 11 deletions(-)
>
> --
> 2.1.4
>
Notice to Appear,
This is to inform you to appear in the Court on the July 03 for your case hearing.
Please, prepare all the documents relating to the case and bring them to Court on the specified date.
Note: The case may be heard by the judge in your absence if you do not come.
You can find the Court Notice is in the attachment.
Yours faithfully,
Dave Steiner,
Clerk of Court.
Dear Customer,
Your parcel has arrived at June 21. Courier was unable to deliver the parcel to you.
Shipment Label is attached to email.
Yours faithfully,
Fred Crouch,
FedEx Support Manager.