From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3BE0EC282D7 for ; Wed, 30 Jan 2019 22:55:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DCF7D218D2 for ; Wed, 30 Jan 2019 22:55:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548888939; bh=oMrJKF17pErY8vdizP0pGkB+pQKVNwzV5MKv/m9vv2U=; h=References:In-Reply-To:From:Date:Subject:To:Cc:List-ID:From; b=l1oyuB7mxffp3xwTJaRkM1SUKchVP7UVVkpsJXOkEwzkRw/ptPeXV9Pq/BHsVpJYx ZwyhN3VqfRZc4XqZJ5dvheUnRTrxQs7Su3Jing2ZhLYHp+oOgz0V/ptbOsdPOp3Ub3 ZPqWaO2fQxD7J984L8PTOOLzctW9KqmSbQDmpQYA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731941AbfA3Wze (ORCPT ); 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-Google-Smtp-Source: ALg8bN5WmlZghK92UzFWWO/bpgaQE+0vzBzrN5Lq8REMLjdrp+ANVFp49w+PVDNz/myAVI16mzVYyEsNcw/EoGNppFM= 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-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@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!