From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933257AbcA1Lwi (ORCPT ); Thu, 28 Jan 2016 06:52:38 -0500 Received: from mout.kundenserver.de ([217.72.192.74]:60693 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751509AbcA1Lwe (ORCPT ); Thu, 28 Jan 2016 06:52:34 -0500 From: Arnd Bergmann To: Thomas Gleixner Cc: zengtao , LKML , Frederic Weisbecker Subject: Re: [PATCH] cputime: Fix timeval-->cputime conversion Date: Thu, 28 Jan 2016 12:52:12 +0100 Message-ID: <2202801.VajSj19nWd@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) In-Reply-To: References: <1453964546-111074-1-git-send-email-prime.zeng@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:X95renmPRkxzwH2S2uxXFMON84g1y/f6+W+ylG5tXeGXane80dE kk9DdTdPJh5fy2RgLzbjqE328k/VM94aOk51nbLeTKfDYC/jD1MHzTznrU7E/wN3p8xAaiz VT6op02FM4Z8aPbiZscgync5q5Evd/7lDroK6sp9xoUPZFbW6O3x4o7OApGYk0mliqjLmQx 99cTQEQiuPymNGdv0fAZQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:9RQApvGfgds=:D6y7Onxgbhq1Ix6DtVU8wY gJ5p3sVpbJIlspumYRv1Hol1AnFUo5gNIqoH9ekD/lqt1Sb7p/HQ2SLGpXr9b+uIujWNDvtjH +7Rrl+5EeZpszu8Bd22t7v8Xo/8Uf0E8kkoWGtSd+cpUmWBPVZLOt+QAVnzWW2I/YO2LvuR2v qtjMN1fMFBhPhpKz06Xjt+epStODRruymRFCs/+IU9ILk/oLpqqFPc/c7eeyO2MftSBHTpzev Cyp3nhhWfYhwofuXaasmmVvd91N1yE0drF6tirNuldFALsC/z/v9zmi9Mvar+kedVjNmtkzn1 rd0/Pp8rT/oHQ6+wUIc07tnIglnTvi2DlK/02lcpfnORaspoCP6CzYe8EGpLCXt9xe8ACgdg4 KJ1q8VEVu/fZN7K2n3lls6W2gGXKBIhEPepvkVKYBkfXCnOVRVh6y5DzUBr9UKWpOL9MwNMfp MMA+asns6NurhWCING9U0JjPY3eqg5dMJBx1IDEhIjUdKvjh7HKoluYLi3wyvhQvePZjrK15T GOoz7RHP7X58azBTtksLWhTKkIuH534GRqaArd+EDLkj3HA7+WQ2Eymx0iXRQJTpwKLaGL71/ wnCMyjOsMkl7an83sDohYi7jnuP6eeyDfZkwSH4TnRCbvzqR1+eo+WEDbYU9PkrRAGZcFIlN+ ce08krRAZwG296yWnoo0wVo9mTuvS3DxTO7Ew2LwIWU5If8S+PwQxw2uNxXxsHUTdEW8N38mo dDR6UQDyCJPOF3Tj Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thursday 28 January 2016 09:22:04 Thomas Gleixner wrote: > Cc'ing Arnd > > On Thu, 28 Jan 2016, zengtao wrote: > > > The structure: > > struct timeval { > > __kernel_time_t tv_sec; /* seconds */ > > __kernel_suseconds_t tv_usec; /* microseconds */ > > }; > > both __kernel_time_t and __kernel_suseconds_t are short than u64 > > when it is 32bit platform, so force u64 conversion here. > > > > Signed-off-by: zengtao > > Reviewed-by: Thomas Gleixner This seems to miss timespec_to_cputime(), which has the same problem, so only setitimer() is fixed, but not nanosleep() or timer_settime(). There should probably be some explanation in which cases this happens, my reading is that can only occur on MIPS32 and ARM32 with "Full dynticks CPU time accounting" enabled, which is required for CONFIG_NO_HZ_FULL, so we need this backported to any kernel that includes 31c1fc818715 ("ARM: Kconfig: allow full nohz CPU accounting"), i.e. v3.13 or higher, correct? Arnd > > include/asm-generic/cputime_nsecs.h | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/include/asm-generic/cputime_nsecs.h b/include/asm-generic/cputime_nsecs.h > > index 0419485..e2f7ff9 100644 > > --- a/include/asm-generic/cputime_nsecs.h > > +++ b/include/asm-generic/cputime_nsecs.h > > @@ -91,7 +91,8 @@ static inline void cputime_to_timespec(const cputime_t ct, struct timespec *val) > > */ > > static inline cputime_t timeval_to_cputime(const struct timeval *val) > > { > > - u64 ret = val->tv_sec * NSEC_PER_SEC + val->tv_usec * NSEC_PER_USEC; > > + u64 ret = (u64)val->tv_sec * NSEC_PER_SEC + > > + val->tv_usec * NSEC_PER_USEC; > > return (__force cputime_t) ret; > > } > > static inline void cputime_to_timeval(const cputime_t ct, struct timeval *val) > > -- > > 1.9.1 > > > >