Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp321006imm; Tue, 24 Jul 2018 20:13:40 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcOICCSfZVdWvboz/BPMQ+LXVfGUzvzigcvb2BcJmpGMaBeGZFfrKdRGULX7ADUSgz6ciM4 X-Received: by 2002:a17:902:a40b:: with SMTP id p11-v6mr19471217plq.228.1532488420670; Tue, 24 Jul 2018 20:13:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532488420; cv=none; d=google.com; s=arc-20160816; b=khomhB21IOLVyPwi4qtKiE51uvWQNj+QS4TiPjTtppHcBhYZG4aVT8Exf+S5oSq2Z4 Tfp37mhgeU81JNznFvaM0euZHsAzCZriAzgBEtX1jnfRhgc7trtdGjwQ98Htr9Z2bToE Vmt/8yMaImL7GNodmXqAMIGxJFdl67pkgJak+iqlbihCR3cueVmUKLgi5YhuKUuU40m1 7Kna9LLZf2pc06ez8WsS2qY+wKoCvvmSR7S619Q60Ps+eTAyfUkJtbhfbbh2FFXWu27d cuga0wHFkmmPeBGB/K2bP7heCKWpdvnYR+4WO28UL4sWUeJg+vLPFgSOkQ51lMnKRkpU S3Uw== 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=96yVAkYhnOZEteCpzcWbFUXqGCBPdDycThJBrXOZ7Ng=; b=vSXvdGf6bYxe3qT9bmaKtuaxhjGcPJCoXdTbWgYbfHXnbItn93rw1Qkz5VZZhnm9HW LAD7qBdNIefmG5K1g5fupD3cqiFC6Jcpx2dMrzCxBi3ZIX1XM3PtW2L7Y1OiJoFPMObf B3Z0IQWb0KPp0NNJD2SILNwWW6pwCvu+buJntJPp3ntx6USA9kJfkkELZL/3/v+0Sp0J jjbZFLGBpJbEhaXy4TPoKCayx4yQrpEH9BeYcOUL0ni5BQrOgugaug7MINPdKHKteawP 4a+eD955txRGxH4JFKJEnVrmY6Yzrsn+JGN1gkPJXVJ1i/ATfJqXyJjXXWCgi71tIkdJ HQwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=bVetck8J; 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 y123-v6si13207290pfc.302.2018.07.24.20.13.23; Tue, 24 Jul 2018 20:13:40 -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-2018-07-02 header.b=bVetck8J; 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 S1727036AbeGYEWF (ORCPT + 99 others); Wed, 25 Jul 2018 00:22:05 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:45262 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726660AbeGYEWE (ORCPT ); Wed, 25 Jul 2018 00:22:04 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w6P39KFn057176; Wed, 25 Jul 2018 03:12:29 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-2018-07-02; bh=96yVAkYhnOZEteCpzcWbFUXqGCBPdDycThJBrXOZ7Ng=; b=bVetck8JVECI6C+aQYFFoJkaJp4tEWrj1etHY0KDYfTx3m29X0/gX5CW3s8awoQfPeHO iNBrkyPjfhwjkCjucfAnahfGbN5nTw56w7gPeU9g/Yk84rZtLltAOJAk8tG4sNn0RTHf Oo6ma2QQjpBWb+HrRg8f604tGBR/NdQnBTrjuSJmlUFaIODznmu9zOL4c9LQx46Iupv0 d+WVLmCI11TzoQFO1Uu/qe0kAgx7ll2RV7nIuip8KxPq74Gfc+Ip/hLk/7Poimy4OQFd pTL//an7piGBgyg2LpEuSwDSFUfzo5/Oo5IuPawe8/ptHT5/++DLo0b3CQjfbOyFXtfr DQ== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2120.oracle.com with ESMTP id 2kbvsnujjb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Jul 2018 03:12:29 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w6P3CTM8016605 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Jul 2018 03:12:29 GMT Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w6P3CSnf026290; Wed, 25 Jul 2018 03:12:29 GMT Received: from mail-oi0-f53.google.com (/209.85.218.53) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 24 Jul 2018 19:41:56 -0700 Received: by mail-oi0-f53.google.com with SMTP id w126-v6so11228265oie.7; Tue, 24 Jul 2018 19:41:56 -0700 (PDT) X-Gm-Message-State: AOUpUlFWe+Xh3x4bi+g2YvKrxqMX6qgLu7h+W78n/A2aq74v+sApEveq CS9m5GOjGwOcJ599NL/6EtLTuYloRL46QJyyzsM= X-Received: by 2002:aca:edc1:: with SMTP id l184-v6mr1396194oih.65.1532486515891; Tue, 24 Jul 2018 19:41:55 -0700 (PDT) MIME-Version: 1.0 References: <20180719205545.16512-24-pasha.tatashin@oracle.com> <20180724195215.GA22496@roeck-us.net> In-Reply-To: From: Pavel Tatashin Date: Tue, 24 Jul 2018 22:41:19 -0400 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [tip:x86/timers] sched/clock: Enable sched clock early To: Guenter Roeck , peterz@infradead.org Cc: LKML , mingo@kernel.org, tglx@linutronix.de, hpa@zytor.com, linux-tip-commits@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8964 signatures=668706 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1807250032 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Peter, The problem is in this stack start_kernel local_irq_enable late_time_init sched_clock_init generic_sched_clock_init sched_clock_register WARN_ON(!irqs_disabled()); Before this work, sched_clock_init() was called prior to enabling interrupts, but now after. So, we hit this WARN_ON() in sched_clock_register(). The question is why do we need this warning in sched_clock_register? I guess because we want to make this section of the code atomic: 195 new_epoch = read(); <- from here 196 cyc = cd.actual_read_sched_clock(); 197 ns = rd.epoch_ns + cyc_to_ns((cyc - rd.epoch_cyc) & rd.sched_clock_mask, rd.mult, rd.shift); 198 cd.actual_read_sched_clock = read; 199 200 rd.read_sched_clock = read; 201 rd.sched_clock_mask = new_mask; 202 rd.mult = new_mult; 203 rd.shift = new_shift; 204 rd.epoch_cyc = new_epoch; 205 rd.epoch_ns = ns; 206 207 update_clock_read_data(&rd); <- to here If we need it, we can surround the sched_clock_register() with local_irq_disable/local_irq_enable: diff --git a/kernel/time/sched_clock.c b/kernel/time/sched_clock.c index cbc72c2c1fca..5015b165b55b 100644 --- a/kernel/time/sched_clock.c +++ b/kernel/time/sched_clock.c @@ -243,8 +243,11 @@ void __init generic_sched_clock_init(void) * If no sched_clock() function has been provided at that point, * make it the final one one. */ - if (cd.actual_read_sched_clock == jiffy_sched_clock_read) + if (cd.actual_read_sched_clock == jiffy_sched_clock_read) { + local_irq_disable(); sched_clock_register(jiffy_sched_clock_read, BITS_PER_LONG, HZ); + local_irq_enable(); + } update_sched_clock(); Thank you, Pavel