Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2515126imm; Mon, 24 Sep 2018 05:46:14 -0700 (PDT) X-Google-Smtp-Source: ACcGV60CbGOHfqgbWpZSRn6VX6ogFnkU2ur4XPKLILc+lcsD8Jxew9HIuVljuDcy7IZm6MXN3fkt X-Received: by 2002:a17:902:7c8b:: with SMTP id y11-v6mr4085921pll.283.1537793174562; Mon, 24 Sep 2018 05:46:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537793174; cv=none; d=google.com; s=arc-20160816; b=oKfrreCVzAKbrj3Okr3S72b8JpxokzpEwbJMRA2pyeGiVJf7AG5R5URhOQitHeqUfo TAUIotoTdU3gcg71pkfqi8BxUHoKJnqnFAuY9wiKH7SXTydT63/phZXsbO0F2P0ja/jN /2IDcCNSmR/iTKmnhVB8TepUUPXUNBmKJv/dwYZ500Ef45YWuF5mJRDWxJ4y6SeLJc8E zAcr6IRWkyW5g0IAPG9bk0bjg+btqm//mSPLthCtO+hjn1em1zHPJrlURyqWcU3UXWNA A4bDLF9+h6niiX20CAslkGfdF+rYe4GtPTwsZXdcrF6XQsNE0kAuCCF2iG3jJbrqL/2l tkZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=59YCemOAqgVAlsNejaBNqlDcT+B6HlQL+gmMnndsZEA=; b=G1KgqVs9HVPQ6P7ZtuntQg7EXJTYnfNeYBQqOd7jdLxKhWCFLqoP3rUnrGZAUKOfMu gpJkNX7mLZ+mSd00df9lrC4YBQy1aiZr20nrhhvj6awt0LsgtxqhdakokeYVoODSqWAG rRqRejgJVTuOK8+jSzDfDc5h7PhDQYlqjGfD3WK7E+0C4Y2NmZJLXuuXBkuKS+stGjAG 2pi681VXBYsAsprTRKR2OSYKl58XY8yZVqX8doCBu9OmcEGjb7pe2ucj+rG8KSjOUauB aO0DA3HzhzZji2Da9p5j4Iprk6HFY2f5HrJaxIR4YyfqOpIKOI4JgTRPov87BEqK/2qj DvEg== 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 1-v6si10741823pls.340.2018.09.24.05.45.58; Mon, 24 Sep 2018 05:46:14 -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; 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 S2388719AbeIXSpm (ORCPT + 99 others); Mon, 24 Sep 2018 14:45:42 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:59496 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388731AbeIXSpl (ORCPT ); Mon, 24 Sep 2018 14:45:41 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 32D6B109A; Mon, 24 Sep 2018 12:43:42 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann , "Paul E. McKenney" , Sasha Levin Subject: [PATCH 4.18 204/235] rcutorture: Use monotonic timestamp for stall detection Date: Mon, 24 Sep 2018 13:53:10 +0200 Message-Id: <20180924113124.454528127@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180924113103.999624566@linuxfoundation.org> References: <20180924113103.999624566@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Arnd Bergmann [ Upstream commit 622be33fcbc93e9b672b99ed338369eb5e843ac3 ] The get_seconds() call is deprecated because it overflows on 32-bit architectures. The algorithm in rcu_torture_stall() can deal with the overflow, but another problem here is that using a CLOCK_REALTIME stamp can lead to a false-positive stall warning when a settimeofday() happens concurrently. Using ktime_get_seconds() instead avoids those issues and will never overflow. The added cast to 'unsigned long' however is necessary to make ULONG_CMP_LT() work correctly. Signed-off-by: Arnd Bergmann Signed-off-by: Paul E. McKenney Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- kernel/rcu/rcutorture.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -1446,7 +1446,7 @@ static int rcu_torture_stall(void *args) VERBOSE_TOROUT_STRING("rcu_torture_stall end holdoff"); } if (!kthread_should_stop()) { - stop_at = get_seconds() + stall_cpu; + stop_at = ktime_get_seconds() + stall_cpu; /* RCU CPU stall is expected behavior in following code. */ rcu_read_lock(); if (stall_cpu_irqsoff) @@ -1455,7 +1455,8 @@ static int rcu_torture_stall(void *args) preempt_disable(); pr_alert("rcu_torture_stall start on CPU %d.\n", smp_processor_id()); - while (ULONG_CMP_LT(get_seconds(), stop_at)) + while (ULONG_CMP_LT((unsigned long)ktime_get_seconds(), + stop_at)) continue; /* Induce RCU CPU stall warning. */ if (stall_cpu_irqsoff) local_irq_enable();