From patchwork Wed Nov 8 16:00:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 118290 Delivered-To: patch@linaro.org Received: by 10.80.245.45 with SMTP id t42csp1969270edm; Wed, 8 Nov 2017 08:02:56 -0800 (PST) X-Google-Smtp-Source: ABhQp+SloowTjV/9DLDpKEADf+/eF8T6fCFoBqRcQ3BIWusQyyBTokA+R/ZiW5SL1hdZbRYgI6C5 X-Received: by 10.98.209.8 with SMTP id z8mr993702pfg.184.1510156975962; Wed, 08 Nov 2017 08:02:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510156975; cv=none; d=google.com; s=arc-20160816; b=aFJFjq3KvH/NVt6rjlPAyne/iJT0LdomDn3RuSRpwsxKjVJCZyn9ICxps5lX+C0I0A OkmcOH1bbA+7C084LgY/vGgx2wwng42NM8yGGePIF1XYVmlsa3Lq4dKDisT2l8bpHH5r 0UeW1VfvGwPL3DGCUYSSr8sbOvDAIcox78HZttHtOdgJomFSAKn2FOjdUvDvtFNL3tKL UHA4cx30inYnkcOfmo4vqAIKYp9C32FGo34gt0p5e+H1n+NVP1+nKEH4LSdXTd5w1O3V 56/GzwMQYuHp5COCpGihWf9ozlfj+0UeWgxCfMTEXObUlcJN3+7S/9fvCivAK74/33j2 4d6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=rY4P33hGBkYOk5csM3PGbZVTCOLIOWwWA9zWmqxCKic=; b=ouMK2Q9ED677tHr2QYh8rZE9lyiy2lJujgLuXzjqJxaZbLsE5hfIBMOA5RAple9w+f 9/aVCH82roZCsIATP8Qqp6GQpxmDAsAlecihTIqwviDACLLo+pfGfJToEQsS6xBgp9GS dzjSyJYb/IBY4/IaI9A3JXKLdI7nbOMGmnjljM2bdqsaWL+iuRmmTiiRbV5bUyecYE/t +kmxOmtAtCUaVuvKnPqRzALRe3jZXszNcwV9E9imZmbjGZiuQy5RB3TumUUPVcUEnMdb 20Gjrn01UX6M/fHTQkXbXucNDWyoDtfmDyJd7Fv5foR+dvrZzpY0SBOC6E3gkEMr63Hz 2qIg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r70si4394929pfe.279.2017.11.08.08.02.55; Wed, 08 Nov 2017 08:02:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752322AbdKHQCy (ORCPT + 24 others); Wed, 8 Nov 2017 11:02:54 -0500 Received: from mout.kundenserver.de ([212.227.126.134]:65522 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751534AbdKHQCw (ORCPT ); Wed, 8 Nov 2017 11:02:52 -0500 Received: from wuerfel.lan ([109.193.157.232]) by mrelayeu.kundenserver.de (mreue006 [212.227.15.129]) with ESMTPA (Nemesis) id 0MYHJs-1ehJVK2OTQ-00UqaV; Wed, 08 Nov 2017 17:02:34 +0100 From: Arnd Bergmann To: Kees Cook , Anton Vorontsov , Colin Cross , Tony Luck , John Stultz , Thomas Gleixner Cc: Arnd Bergmann , Stephen Boyd , Ingo Molnar , linux-kernel@vger.kernel.org Subject: [PATCH] pstore: use ktime_get_real_fast_ns() instead of __getnstimeofday() Date: Wed, 8 Nov 2017 17:00:14 +0100 Message-Id: <20171108160056.3042976-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:9xRBgbPyF2vNXRo1NE9vN85y/LftiBWmdNU+jTXDj/FjlQCeEbe lSUaGdgMaaLSDk1hewSXJSDDpNOGZQ3n68Y+w3Hl1oWU1y9QHbwdNa2N9Yvxc98g0qhInQA r8zpypfnZ5J2NycUBZACQIBlrbu1KBt/FmvxUevJEx2OH8OKZwOuYmMKoqo2V7PDj8hHcpm bk6eLZz5alrEySqo99Cug== X-UI-Out-Filterresults: notjunk:1; V01:K0:YEP9+FYesJ8=:XgykSGdaChrkJhSg4Cuzhj GwAeXF9FursGxBmlN4Qp+4sQUm7gdYNe404zxOtZwRVlvrn05HOsabd0Bp1PHvekx3S1Zh1P+ kHh4DuVxQXyLjiLEU4sIZqXkgEiaVaRZpOq6g2vAhi1u/EJatleEnEye2wC2Uvx2J9dbkN5mb qMp7JaVegEkzH5M/yb8Qm6wWd0oOTBiP666VAhQRK0sbzUZ909ZDRS49F0Vkaas9PRcpMvbiJ LF/dd8sWoVb06+xsCesgm1b7twkj0G0OiqWCJ4Q+B7VtWjbLKhI6RTVbBviHKlRyIYnIOUA1i MDBk6KYaBWNsduARucyxgMmHWJGwK36IYf183HHFethG0KHRcoJ5BaEyByTGE7BRyVaY7DZ8L Lfk9Q4YYXAbT/asQj4+S/4pw61xh7Cs/9NNRn/RefcPZCm4A+trRRdg4DTuJpktdr3+fHA8q5 wVqCVxPW8Eibm6HnfG72yPu49C/SeZTDL1NK+zqlmn1/riDCC0J1AngPW47/+ipkk9ZF3dm3D 03IDjrCAcHSDB1YwwCgadfAYtc/3CUgLDOjcPP9dS80mNDBbd7CwQWJDaQkftc+2HZY+UyNOB LXXdWXvXn5rOIA9CROWDZS3jyP89cD8TjDk1uhZm23/MJcm5mr8uxpbSru+twzuOKZ5NhIR/c MmYmF4IO8Uar1WeXknGXN0vgG2F3JeoOeM1F1htmQ7enoshiwbpMX0WgLZcWp5nmasEPD2Sy1 RpYPY9uv45WZ4sIjQNXnlUyy33M94khDTVlAAg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I noticed that __getnstimeofday() is a rather odd interface, with a number of quirks: - The caller may come from NMI context, but the implementation is not NMI safe - The calling conventions are different from any other timekeeping functions - The naming doesn't fit into the 'ktime_get_*()' scheme This addresses the above issues by using a completely different method to get the time: ktime_get_real_fast_ns() is NMI safe and doesn't print a warning when called with the timekeeping suspended, and we can easily transform the result into a timespec structure. Since ktime_get_real_fast_ns() was not exported to modules, I also add the export. The behavior for the suspended case changes, we now return the time if we can find it out rather than setting it to zero. We could still change that but this would require exporting the 'timekeeping_suspended' to modules. I'm not trying to address y2038-safety at this point, but plan to do that later with a more complex patch. Cc: Kees Cook Signed-off-by: Arnd Bergmann --- It would be helpful to get this merged into v4.15-rc1, since I have some other cleanups that depend on this. Please have a look to see if this makes sense to you. --- fs/pstore/platform.c | 5 +---- kernel/time/timekeeping.c | 1 + 2 files changed, 2 insertions(+), 4 deletions(-) -- 2.9.0 Acked-by: Kees Cook diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c index ec7199e859d2..086e491faf04 100644 --- a/fs/pstore/platform.c +++ b/fs/pstore/platform.c @@ -482,10 +482,7 @@ void pstore_record_init(struct pstore_record *record, record->psi = psinfo; /* Report zeroed timestamp if called before timekeeping has resumed. */ - if (__getnstimeofday(&record->time)) { - record->time.tv_sec = 0; - record->time.tv_nsec = 0; - } + record->time = ns_to_timespec(ktime_get_real_fast_ns()); } /* diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 353f7bd1eeb0..198afa78bf69 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -528,6 +528,7 @@ u64 ktime_get_real_fast_ns(void) { return __ktime_get_real_fast_ns(&tk_fast_mono); } +EXPORT_SYMBOL_GPL(ktime_get_real_fast_ns); /** * halt_fast_timekeeper - Prevent fast timekeeper from accessing clocksource.