Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6443285imu; Wed, 30 Jan 2019 15:01:56 -0800 (PST) X-Google-Smtp-Source: ALg8bN6XogPpw5HPWMXIdkDtLGxbpZuinT6B65UyFej1UVInhYjPxcHya/ncs9uWFD8WkjgABl4g X-Received: by 2002:a62:5658:: with SMTP id k85mr32105821pfb.231.1548889316709; Wed, 30 Jan 2019 15:01:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548889316; cv=none; d=google.com; s=arc-20160816; b=Vfu0tt0TmTNGROJokKOPYL4qPWb3L7YKS6ypWmu2sYyzLJcegB+uOgO3rM9UBIUKK3 nbRfoomtqoc8rOwh0r+qr2ooDm3GztnQs2SO6Ca8VoH1FIoJrg1bDoJQdp/iXcfcA7k5 aFHvCio8NFJ3QYuI1HKu4YDU7v5OUVksfAMcfCGmM8GZ11TBPY80nWXGSWf0MTr7J0wN ZcaYBe36fx3DG1CRmdU69lrNRHZijSP5J0DSpY5gCXKc61oMGS4YEfxF+B6YcJyezv1F mnpEKrIqXW+JR1w3nT6v9SIdFzZo1vAIfZ7iVmZXwLv2leCfO6zm5fv8OoY9kN6CQcMY HL2Q== 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; bh=YuA330KElE94ag75CUZF0JfLlQgGpCicSadKqqJDO2M=; b=g+cEoluHSq4OIONgF+X12VZQJukCiebrBKzKK8b0P/LIJZA+TFsYSWt6xUBTMOdjrR df0iKjIed+O8s3ifgknWq30xWt4qqDHPkO3Tt/e5KD5qfOrkE+gNsgCLVAq+P6z3Glz1 HPfOsdMumAz14Hcy27OugiZ92dqUjTSHwDftODPUlellYS9DOzGp5h2H3yjduHLQ87x+ 0oVmXHnW6ycC+QdiHhVX0CoTbRaShtrWEI74hu3foNbY4VPy9VV6NPUAMAUnNKewonK+ BGXihOVwP/atlpnrxeElqjYnOnH+HULg6JbGiAMz90vHD3TYbrVuoxdmWNZ0dolEj8j7 OLxA== 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m10si2526099plt.295.2019.01.30.15.01.39; Wed, 30 Jan 2019 15:01:56 -0800 (PST) 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732058AbfA3Wze (ORCPT + 99 others); Wed, 30 Jan 2019 17:55:34 -0500 Received: from mail-ot1-f66.google.com ([209.85.210.66]:46589 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728573AbfA3Wze (ORCPT ); Wed, 30 Jan 2019 17:55:34 -0500 Received: by mail-ot1-f66.google.com with SMTP id w25so1108701otm.13; Wed, 30 Jan 2019 14:55:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=YuA330KElE94ag75CUZF0JfLlQgGpCicSadKqqJDO2M=; b=TF3ZPtgmjYDUfIWCEAvj6lkOSKq9FTzRdP6LVjXzV4UbfN7MsJWW3x2YVVY1r5hEmH c5Q6TnymvxyYumGuZ907+vAMTOAFB0XscJtpopGaW+/PXSmizj4GiWQzPK1p99ECVnvN pE+yAzhBEJ2nM9m4zyn6izTRbMtU75JpEPEBVNgkX+/622DgoxUi8uuwxaJhyNoNe74t y2IjopX8/YRk/zwe9IyYqMsbmJsaQQmRuM6Wwq/Qn0Qmo1M7+ZMm0OpWY8kt3tBo43dc sPTqdvBeVAOAwjZbUr8fjJIuJlpFy1niB6ImNUu24Cq7BKfMSupcluy9pKVzxZ49KgGc MbgA== X-Gm-Message-State: AJcUuke7mDe7qxt3X4gWWMCbcE/eVVooiwr6PTd9+qmwN2EiXvHZ8B1b QOGN8R+kPLIT3RMoXF5qQYrcWBUqI3TlrUaUv1ufxA== X-Received: by 2002:a9d:588c:: with SMTP id x12mr24659825otg.139.1548885192162; Wed, 30 Jan 2019 13:53:12 -0800 (PST) MIME-Version: 1.0 References: <1548869162-6223-1-git-send-email-vincent.guittot@linaro.org> In-Reply-To: <1548869162-6223-1-git-send-email-vincent.guittot@linaro.org> From: "Rafael J. Wysocki" Date: Wed, 30 Jan 2019 22:53:00 +0100 Message-ID: Subject: Re: [PATCH v3] PM-runtime: fix deadlock with ktime To: Vincent Guittot Cc: Linux PM , Linux Kernel Mailing List , Linux ARM , Linux OMAP Mailing List , "Rafael J. Wysocki" , Ulf Hansson , Biju Das , Geert Uytterhoeven , Linux-Renesas Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 30, 2019 at 6:26 PM Vincent Guittot wrote: > > A deadlock has been seen when swicthing clocksources which use PM runtime. > The call path is: > change_clocksource > ... > write_seqcount_begin > ... > timekeeping_update > ... > sh_cmt_clocksource_enable > ... > rpm_resume > pm_runtime_mark_last_busy > ktime_get > do > read_seqcount_begin > while read_seqcount_retry > .... > write_seqcount_end > > Although we should be safe because we haven't yet changed the clocksource > at that time, we can't because of seqcount protection. > > Use ktime_get_mono_fast_ns() instead which is lock safe for such case > > With ktime_get_mono_fast_ns, the timestamp is not guaranteed to be > monotonic across an update and as a result can goes backward. According to > update_fast_timekeeper() description: "In the worst case, this can > result is a slightly wrong timestamp (a few nanoseconds)". For > PM runtime autosuspend, this means only that the suspend decision can > be slightly sub optimal. > > Fixes: 8234f6734c5d ("PM-runtime: Switch autosuspend over to using hrtimers") > Reported-by: Biju Das > Signed-off-by: Vincent Guittot > --- > > Hi Rafael, > > Sorry, I sent the version with the typo mistake that generated the compilation error > reported by kbuild-test-robot > > This version doesn't have the typo. OK, I've applied this one, thanks!