Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp2296776imm; Sat, 23 Jun 2018 14:32:06 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIuyArgTUAeE6rodUB20r+L1vd9l6Zt4hsfRhF/M3lfKhKXbZbzXkdxwDL1qZtMHOQgeF++ X-Received: by 2002:a17:902:8:: with SMTP id 8-v6mr6775335pla.287.1529789526767; Sat, 23 Jun 2018 14:32:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529789526; cv=none; d=google.com; s=arc-20160816; b=KvuPCN2uABaUfJ8h+iH5yvpRn9eC7FLW6IZ98jy6jcMl/Yi3HyRny6OB0AXfATvBs6 oOYIvymqqel79NvUR0kstutQyUlGgWQREjzsQ06XaUlhVfPNolcNB7z2KkcfvNy3Wfup b/OBQVljIkPht+gQUGBMv2sRBbY7MkPoP1bCfgf9KeDVr+/Q43VM4iBlt0sliyZcluiG Z8TXHpz0BDuPAWONlx8NPB3PMOvtLifiSDND57wycWd/ptiRQC3qyKiGIK5V2Fy/ruXY FG30+h48/HqAoIdYK+1DJPVOdy0d/D6zuG7UuGhvruuiIeMiUNday9dAeUoPBabtEXQZ mu8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=yAWnR92hGClOwVBRb+CMaBA4bPP1ueE7jmesojzIORs=; b=KDvby1fQxRNRY784415/kM7tAswb0CCvdn58mIOPvDU/TIPChfTKcZ5OuUN/ysXRKC khnj866gAWq2xZaKaKK6fV2wWXsz7WhXl2BjHhTAZQAzlKcTMyv3lm4iDPHjq1JAE2Su yOQK6q7kvuzJJO3lhaeFJTVqlmPpDIJ2MlPPKvx7azS5Bl2dC8ebr866H3/R++vN59Tr dx3HxpdUnfDr3DsCWQVVDXcAzevsHIIt5wqlnvvx+9fe6V7gzFXkM5ooXLe/GacKxhVi FlTyvQQx7rR6Adg5Z2uAsELdQnsxzu44Ri+kZ9v7UUge17zNX5/hplM24P6C0gRWn7Ao rV1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=Wnklzv1V; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q4-v6si8376196pgc.302.2018.06.23.14.31.52; Sat, 23 Jun 2018 14:32:06 -0700 (PDT) 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; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=Wnklzv1V; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751877AbeFWVaS (ORCPT + 99 others); Sat, 23 Jun 2018 17:30:18 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:59110 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751471AbeFWVaR (ORCPT ); Sat, 23 Jun 2018 17:30:17 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w5NLESNo181900; Sat, 23 Jun 2018 21:30:16 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=mime-version : references : in-reply-to : from : date : message-id : subject : to : cc : content-type; s=corp-2017-10-26; bh=yAWnR92hGClOwVBRb+CMaBA4bPP1ueE7jmesojzIORs=; b=Wnklzv1Vvb3kxfi6abgd3+X2b87e9AMQDup5XxCddOdzYRGHysM5fMGoTunBjkFK2Y11 vf6ggQxExfA57oXaZy6NqJqmNeGMozJGDaLWQqQkG/O15spj55jZsBLIha8VpyvUZ9uk lQvP1S9LERwOjMHpaYlqgA80OPx5nSyZmUQtItu6Kue1kLBzQ+Kvib6RtNXBjZoywkPI /LUx3Otp4xjqs2EIHkKNNElTNZbB5Xy9b/ru5Gkp2eZTzE8751FOkoABl/w7nWU44JFB +1Z3K1/YJdvjWd8wOL9hlSYf3p7+b786XuWH3/E/qJIzPFkfTazYrwE0BjZ/b6kazx0h 4Q== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2jsfg0rvaf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 23 Jun 2018 21:30:16 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w5NLUCEL020612 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 23 Jun 2018 21:30:12 GMT Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w5NLUCcF013397; Sat, 23 Jun 2018 21:30:12 GMT Received: from mail-oi0-f45.google.com (/209.85.218.45) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 23 Jun 2018 14:30:12 -0700 Received: by mail-oi0-f45.google.com with SMTP id l22-v6so9178907oib.4; Sat, 23 Jun 2018 14:30:12 -0700 (PDT) X-Gm-Message-State: APt69E2l41eWxkGi9FmgdSVEmnulllykRGvskB9C7nbYKmKTegRxup9g rJFaD3ES2TazCUFPGNIFgyZNVnnjUz+BgWYOklg= X-Received: by 2002:aca:db0a:: with SMTP id s10-v6mr3973390oig.339.1529789411688; Sat, 23 Jun 2018 14:30:11 -0700 (PDT) MIME-Version: 1.0 References: <20180621212518.19914-1-pasha.tatashin@oracle.com> <20180621212518.19914-10-pasha.tatashin@oracle.com> In-Reply-To: From: Pavel Tatashin Date: Sat, 23 Jun 2018 17:29:35 -0400 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v12 09/11] x86/tsc: prepare for early sched_clock To: tglx@linutronix.de Cc: Steven Sistare , Daniel Jordan , linux@armlinux.org.uk, schwidefsky@de.ibm.com, Heiko Carstens , John Stultz , sboyd@codeaurora.org, x86@kernel.org, LKML , mingo@redhat.com, hpa@zytor.com, douly.fnst@cn.fujitsu.com, peterz@infradead.org, prarit@redhat.com, feng.tang@intel.com, Petr Mladek , gnomes@lxorguk.ukuu.org.uk, linux-s390@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8933 signatures=668703 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=530 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1806230241 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > So you forgot to answer this question. I did not find a system yet, which > actually exposes this behaviour on mainline. > > Is this an artifact of your early sched clock thing? > Yes, it is. Let me explain how it happens. So, the problem is introduced in patch "sched: early boot clock" by this change: - if (unlikely(!sched_clock_running)) - return 0ull; + /* Use early clock until sched_clock_init_late() */ + if (unlikely(sched_clock_running < 2)) + return sched_clock() + __sched_clock_offset; As soon as sched_clock() starts output non-zero values, we start output time without correcting the output as it is done in sched_clock_local() where unstable TSC and backward motion are detected. But, since early in boot interrupts are disabled, we cannot really correct invalid time, and therefore must rely on sched_clock() to provide us with a contiguous and sane time. In earlier versions of this project, I was solving this problem by adjusting __sched_clock_offset every time sched_clock()'s continuity was changed by using a callback function into sched/clock.c. But, Peter was against that approach.