Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp1055191ybx; Thu, 7 Nov 2019 06:38:19 -0800 (PST) X-Google-Smtp-Source: APXvYqx/oRT+2vRcT6d5sWouwEUmhRp17t3QVHtzstIb+9RZ0QbvXTpRJ6H38ZICR8wcbCMTd/RP X-Received: by 2002:a50:85cd:: with SMTP id q13mr4070060edh.152.1573137499492; Thu, 07 Nov 2019 06:38:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573137499; cv=none; d=google.com; s=arc-20160816; b=Tw4n1xVI1PuxTkxIBq7VUZJUbpKUh/U6AZKuJycyqJk8KhEpNpwBBOy21Lxfu1/QU2 C/VU3Jgvw/ScoAMBHfFNg464DlvN9Fk0iTOIwvZvfuQG21lc9M/0QJCv55j96me5vPc8 XvP5i7lkjV4Mc2QCpEaeg9oQQqzIn8npgpTk1TXg3DCA74FgLV6Yojgi9pd+WN7LOCRI EDw+pnNQO9BX5SPA4aMxM94XPurJzND9Mb6/k6y9gxIe/5rxLZWvCoJrwYJEUr3mF1xW yIiqaUPgE/ZLo2Sbm1x6Iz2Y1e+2V+umquA/+bSd9EMhLwTzHvWLiSW8RcP2n0KEK0QW zzBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=QaD5eQ4gFbpejyb6YJvb3WH3OcRtu6il1VXY6qgIJB4=; b=HJP4W2oX26KXz3ilrIZw4P2uA+keHAvJ1q9MvPYrIP+3MQWD5QAOUtHM8slgLaJGBt ZL87wQAi20l1IV1CokwEzHodkXI1j7Dv1MhU/N9ax1ZfpbZcC+49DJNLn8s4iiGt779y MTx/JUIc2of34ZMVOMqLAnL38SJ3b/NRUaxUjdRt2L7/hFrN1S7SL1vYdSXYlMllVvpv qCveTLJNKqD1Mrr6lr/rQnH1ItTDs0GdULfFEcJSpubob1Me3EYSDcUQkqpWfgY2IG8g 6zxOPnjR1NarvfhSTRlEoYfYlD1pywTaf1PBcPi6bKSjfOygHjw+LJ6qE0Ms74ZsDOVw SrNw== 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 q10si1550310eje.222.2019.11.07.06.37.55; Thu, 07 Nov 2019 06:38:19 -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 S2388428AbfKGOhJ (ORCPT + 99 others); Thu, 7 Nov 2019 09:37:09 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:48024 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726033AbfKGOhJ (ORCPT ); Thu, 7 Nov 2019 09:37:09 -0500 Received: from [5.158.153.52] (helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1iSiuI-0007ss-9x; Thu, 07 Nov 2019 15:37:06 +0100 Date: Thu, 7 Nov 2019 15:37:05 +0100 (CET) From: Thomas Gleixner To: Peter Zijlstra cc: Jan Stancek , linux-kernel@vger.kernel.org, ltp@lists.linux.it, viro@zeniv.linux.org.uk, kstewart@linuxfoundation.org, gregkh@linuxfoundation.org, rfontana@redhat.com Subject: Re: [PATCH] kernel: use ktime_get_real_ts64() to calculate acct.ac_btime In-Reply-To: <20191107125559.GI4131@hirez.programming.kicks-ass.net> Message-ID: References: <20191107123224.GA6315@hirez.programming.kicks-ass.net> <20191107125559.GI4131@hirez.programming.kicks-ass.net> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 7 Nov 2019, Peter Zijlstra wrote: > On Thu, Nov 07, 2019 at 01:40:47PM +0100, Thomas Gleixner wrote: > > On Thu, 7 Nov 2019, Peter Zijlstra wrote: > > > > + mono = ktime_get_ns(); > > > + real = ktime_get_real_ns(); > > > + /* > > > + * Compute btime by subtracting the elapsed time from the current > > > + * CLOCK_REALTIME. > > > + * > > > + * XXX totally buggered, because it changes results across > > > + * adjtime() calls and suspend/resume. > > > + */ > > > + delta = mono - tsk->start_time; // elapsed in ns > > > + btime = real - delta; // real ns - elapsed ns > > > + do_div(btime, NSEC_PER_SEC); // truncated to seconds > > > + stats->ac_btime = btime; > > > > That has pretty much the same problem as just storing the CLOCK_REALTIME > > start time at fork and additionally it is wreckaged vs. suspend resume. > > It's wrecked in general. It also jumps around for any REALTIME > adjustment. > > > So a CLOCK_REALTIME time stamp at fork would at least be correct > > vs. suspend resume. > > But still wrecked vs REALTIME jumps, as in, when DST flips the clock > back an hour, your timestamp is in the future. > > Any which way around the whole thing is buggered. The only real fix is > not using REALTIME anything. Which is why I'm loath to add that REALTIME > timestamp at fork(), it just encourages more use. Fair enough. You have a sane alternative though: CLOCK_TAI Thanks, tglx