From patchwork Tue Jun 26 00:52:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 139893 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4611738lji; Mon, 25 Jun 2018 17:52:12 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJuGZB3zU/OXRLLq+awbtt69Xc70B+naA4UEnLrAeXop1Q7EixqLcSxSPCAumx9TMaRPYEi X-Received: by 2002:a62:84e:: with SMTP id c75-v6mr15166691pfd.35.1529974331964; Mon, 25 Jun 2018 17:52:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529974331; cv=none; d=google.com; s=arc-20160816; b=S7kktbyXjDSJX99ADEGEAUGjoN1s3P5SdfALAxUNCyGJYnSr6Cfs3jo4zOONN2QRoF W8GxnWM1lTYe3amVjEX+78wMLkNw+BAsaAecA1vdyMxMuUA62Y+OeD/VIm+IXjOSKpRd 13V2xVO2oe5+zawpJiRsEitZjyk8YxC2G1ido+fM/UsekXCHcFEGtSRCHTDJHC9Idm8E fCHXgbyADdI6ikneQqlTon/bWXAY/h7OeC2wTvProeusauZimw2RqAnqEyaBZB0KdHht /mUPy54jpdiCOY1gpo4C29nL7ar9A6Idy6F5SZdYsF1IVn7UndIm5uHsve9KKvG5T/kT bOpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:references:in-reply-to:date :subject:cc:to:from:arc-authentication-results; bh=n2/ReWhDpOg8v9fyF2dkrFdL0ol5p2qsKrdcgpgK8QA=; b=YC1VPGztF/p05vNAHvH+MV2i8GYsLGzTcah1tzTpDJbhm2U9PJBcbhnQKkqccRE0Ii uTe4ZZ71dEM61uxcGeS8+dE0Xs+uzAKG//SYicR33EfX81iWQtFKdchnilVe2ct7eNI9 7VcszECstoMKjCLRxyPhvKsE4H4cWYME8YBnPIucmH2MX7iP5XoR/HyWyFGEjRy+yoJh Zqo3riEx5FHHUh4icuqss3iKa0F13HVUeFAFRsz1sb/KtxOdBET/6nilQE0h+r5ahK8U 5Iae1HwzQGShWQxMrfBAKMKbVd/1uu1QrtPsK4byRfPPD7K5DDP6p1Qjj3+xyJx0HRWO qfow== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o10-v6si336367pll.158.2018.06.25.17.52.11; Mon, 25 Jun 2018 17:52:11 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935201AbeFZAwI (ORCPT + 31 others); Mon, 25 Jun 2018 20:52:08 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:45856 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934823AbeFZAuc (ORCPT ); Mon, 25 Jun 2018 20:50:32 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w5Q0n1Ae085049 for ; Mon, 25 Jun 2018 20:50:31 -0400 Received: from e15.ny.us.ibm.com (e15.ny.us.ibm.com [129.33.205.205]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ju96uc3a9-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 25 Jun 2018 20:50:31 -0400 Received: from localhost by e15.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 25 Jun 2018 20:50:30 -0400 Received: from b01cxnp22036.gho.pok.ibm.com (9.57.198.26) by e15.ny.us.ibm.com (146.89.104.202) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 25 Jun 2018 20:50:25 -0400 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w5Q0oOfn1769822 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 26 Jun 2018 00:50:24 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 56BB0B2076; Mon, 25 Jun 2018 20:50:19 -0400 (EDT) Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 33CFEB206E; Mon, 25 Jun 2018 20:50:19 -0400 (EDT) Received: from paulmck-ThinkPad-W541 (unknown [9.70.82.159]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP; Mon, 25 Jun 2018 20:50:19 -0400 (EDT) Received: by paulmck-ThinkPad-W541 (Postfix, from userid 1000) id 73A8B16CA09E; Mon, 25 Jun 2018 17:52:29 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: mingo@kernel.org, jiangshanlai@gmail.com, dipankar@in.ibm.com, akpm@linux-foundation.org, mathieu.desnoyers@efficios.com, josh@joshtriplett.org, tglx@linutronix.de, peterz@infradead.org, rostedt@goodmis.org, dhowells@redhat.com, edumazet@google.com, fweisbec@gmail.com, oleg@redhat.com, joel@joelfernandes.org, Arnd Bergmann , "Paul E . McKenney" Subject: [PATCH tip/core/rcu 11/13] rcutorture: Use monotonic timestamp for stall detection Date: Mon, 25 Jun 2018 17:52:25 -0700 X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180626005205.GA28179@linux.vnet.ibm.com> References: <20180626005205.GA28179@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18062600-0068-0000-0000-0000030E2E15 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009255; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01052342; UDB=6.00539473; IPR=6.00830268; MB=3.00021856; MTD=3.00000008; XFM=3.00000015; UTC=2018-06-26 00:50:29 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18062600-0069-0000-0000-000044CF2F7B Message-Id: <20180626005227.30660-11-paulmck@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-06-25_11:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=963 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1806260008 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnd Bergmann 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 --- kernel/rcu/rcutorture.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index 36b9b8266213..049b3735dba8 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -1622,7 +1622,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) @@ -1631,7 +1631,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();