Received: by 10.192.165.148 with SMTP id m20csp2069929imm; Thu, 26 Apr 2018 05:57:51 -0700 (PDT) X-Google-Smtp-Source: AIpwx48OzHR50SOJkEqpO8nRnqZSfMmXZIuFtOMkXRrwQ+P8XyFvb+G7vEpBzkGp+N7ij2ufVrHG X-Received: by 2002:a17:902:22a:: with SMTP id 39-v6mr34164835plc.128.1524747471494; Thu, 26 Apr 2018 05:57:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524747471; cv=none; d=google.com; s=arc-20160816; b=c9crj6znfyJVpRqrlcCrbfEUW+O3KBbcDTYefgX4ZmpTTZh7lF3p1/0uiQMU3wVE/x HJTZhXOvULE93LXDbN35CSCkexT7FiwRw9wnXldEBea5E8i1f0buQJ9fARMXxXE9gnBs IzadICJnpmqzIYOogSgBuUkRAfer7fPhlLoz5E8FPZ9KUUbA6HQd8mXWKNkZ4USn54Ed cCpawnGKYoOHrXMgy2PwcgsvwUf1nYA5oOhtCxAT1tNPzChbb3IAiJckNtd2E5vG17Eu 5a78322XnSIxYRu7nlrWjsa/LpIamMVLXMM8KAzLYXppk532Y7xIi1jXBaxZhtuj57Gi +QAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :dlp-reaction:dlp-version:dlp-product:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:arc-authentication-results; bh=TaWPMOQTh9JtugNkW6vw/f+Em0pN+tKsMzBm2yfrNnc=; b=JPLsDYPC0kofkGdDyin1i+QenU0sMHoq+gWIwSIfSxxTeeVBkxHfNMR3umocXd5Fhx zcxifWnLysH26x1eqfCjdTbo8ZBbPIL0kyDymL4+I2ZMG+53XwxCuCaA6yYXu792WqLg F0MtHCxiFf9BaTxxFOp4j5FLWC9Qws1hvYRDGG16xrqmBO/Uio7ww0pJPacaEnXI/Rr4 4MNtJZUz3S026uyeTb5ZXgyO6LoOZ6uDulsxOg/raIzagZEKuEMh13P/k/+XiwHCw1qS OE8u1e+SO0mbKD2uHYRSyyVLFoh+E3J6fiKQ0rRKORBtwdlz/cGDs4hueAXgYtiBZnLB GTLQ== 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 8-v6si18668109plc.342.2018.04.26.05.57.36; Thu, 26 Apr 2018 05:57:51 -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 S1755861AbeDZM43 convert rfc822-to-8bit (ORCPT + 99 others); Thu, 26 Apr 2018 08:56:29 -0400 Received: from mga07.intel.com ([134.134.136.100]:65273 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754516AbeDZM41 (ORCPT ); Thu, 26 Apr 2018 08:56:27 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Apr 2018 05:56:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,330,1520924400"; d="scan'208";a="46228076" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga003.jf.intel.com with ESMTP; 26 Apr 2018 05:56:25 -0700 Received: from fmsmsx156.amr.corp.intel.com (10.18.116.74) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 26 Apr 2018 05:56:14 -0700 Received: from crsmsx103.amr.corp.intel.com (172.18.63.31) by fmsmsx156.amr.corp.intel.com (10.18.116.74) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 26 Apr 2018 05:56:14 -0700 Received: from crsmsx101.amr.corp.intel.com ([169.254.1.16]) by CRSMSX103.amr.corp.intel.com ([169.254.4.11]) with mapi id 14.03.0319.002; Thu, 26 Apr 2018 06:56:11 -0600 From: "Wan, Kaike" To: Thomas Gleixner , Frederic Weisbecker CC: "Marciniszyn, Mike" , "Dalessandro, Dennis" , "Weiny, Ira" , "Fleck, John" , "linux-kernel@vger.kernel.org" , "linux-rdma@vger.kernel.org" , Peter Zijlstra , Anna-Maria Gleixner , Frederic Weisbecker , Ingo Molnar Subject: RE: [PATCH] tick/sched: Do not mess with an enqueued hrtimer Thread-Topic: [PATCH] tick/sched: Do not mess with an enqueued hrtimer Thread-Index: AQHT3AGYnFIKYp+V/Uy/KvwnCpnvbqQTAznA Date: Thu, 26 Apr 2018 12:56:11 +0000 Message-ID: <3F128C9216C9B84BB6ED23EF16290AFB634CACE9@CRSMSX101.amr.corp.intel.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMTgxZTJjYzItMDMyMS00YzdhLTk3MzMtMjRkMTliYzYyOWM1IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJYWWxEMVwvSDVtc1prcEZRczhjVGlUYVlcL2lDV2g0VVkzTVVaN2FlOHhpeVNpczBHZG5hTURaSHhyaXRyWFVEREcifQ== x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.200.100 dlp-reaction: no-action x-originating-ip: [172.18.205.10] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > From: linux-rdma-owner@vger.kernel.org [mailto:linux-rdma- > owner@vger.kernel.org] On Behalf Of Thomas Gleixner > Sent: Tuesday, April 24, 2018 3:22 PM > To: Frederic Weisbecker > Cc: Wan, Kaike ; Marciniszyn, Mike > ; Dalessandro, Dennis > ; Weiny, Ira ; Fleck, > John ; linux-kernel@vger.kernel.org; linux- > rdma@vger.kernel.org; Peter Zijlstra ; Anna-Maria > Gleixner ; Frederic Weisbecker > ; Ingo Molnar > Subject: [PATCH] tick/sched: Do not mess with an enqueued hrtimer > > Kaike reported that in tests rdma hrtimers occasionaly stopped working. He > did great debugging, which provided enough context to decode the problem. > > CPU 3 CPU 2 > > idle > start sched_timer expires = 712171000000 queue->next = sched_timer > start rdmavt timer. expires = > 712172915662 > lock(baseof(CPU3)) > tick_nohz_stop_tick() > tick = 716767000000 timerqueue_add(tmr) > > hrtimer_set_expires(sched_timer, tick); > sched_timer->expires = 716767000000 <---- FAIL > if (tmr->expires < queue->next- > >expires) > hrtimer_start(sched_timer) queue->next = tmr; > lock(baseof(CPU3)) > unlock(baseof(CPU3)) > timerqueue_remove() > timerqueue_add() > > ts->sched_timer is queued and queue->next is pointing to it, but then > ts->sched_timer.expires is modified. > > This not only corrupts the ordering of the timerqueue RB tree, it also makes > CPU2 see the new expiry time of timerqueue->next->expires when checking > whether timerqueue->next needs to be updated. So CPU2 sees that the > rdma timer is earlier than timerqueue->next and sets the rdma timer as new > next. > > Depending on whether it had also seen the new time at RB tree enqueue, it > might have queued the rdma timer at the wrong place and then after > removing the sched_timer the RB tree is completely hosed. > > The problem was introduced with a commit which tried to solve > inconsistency between the hrtimer in the tick_sched data and the underlying > hardware clockevent. It split out hrtimer_set_expires() to store the new tick > time in both the NOHZ and the NOHZ + HIGHRES case, but missed the fact > that in the NOHZ + HIGHRES case the hrtimer might still be queued. > > Use hrtimer_start(timer, tick...) for the NOHZ + HIGHRES case which sets > timer->expires after canceling the timer and move the > timer->hrtimer_set_expires() > invocation into the NOHZ only code path which is not affected as it merily > uses the hrtimer as next event storage so code pathes can be shared with > the NOHZ + HIGHRES case. > > Fixes: d4af6d933ccf ("nohz: Fix spurious warning when hrtimer and > clockevent get out of sync") > Reported-by: "Wan Kaike" > Signed-off-by: Thomas Gleixner > Cc: "Marciniszyn Mike" > Cc: Anna-Maria Gleixner > Cc: linux-rdma@vger.kernel.org > Cc: "Dalessandro Dennis" > Cc: "Fleck John" > Cc: Peter Zijlstra > Cc: Frederic Weisbecker > Cc: "Weiny Ira" > Cc: "linux-rdma@vger.kernel.org" > Cc: stable@vger.kernel.org > Link: > https://lkml.kernel.org/r/alpine.DEB.2.21.1804241637390.1679@nanos.tec.lin > utronix.de > > --- > kernel/time/tick-sched.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > --- a/kernel/time/tick-sched.c > +++ b/kernel/time/tick-sched.c > @@ -804,12 +804,12 @@ static void tick_nohz_stop_tick(struct t > return; > } > > - hrtimer_set_expires(&ts->sched_timer, tick); > - > - if (ts->nohz_mode == NOHZ_MODE_HIGHRES) > - hrtimer_start_expires(&ts->sched_timer, > HRTIMER_MODE_ABS_PINNED); > - else > + if (ts->nohz_mode == NOHZ_MODE_HIGHRES) { > + hrtimer_start(&ts->sched_timer, tick, > HRTIMER_MODE_ABS_PINNED); > + } else { > + hrtimer_set_expires(&ts->sched_timer, tick); > tick_program_event(tick, 1); > + } > } > > static void tick_nohz_retain_tick(struct tick_sched *ts) > -- > To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the > body of a message to majordomo@vger.kernel.org More majordomo info at > http://vger.kernel.org/majordomo-info.html Tested-by: Kaike Wan