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=-1.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no 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 B5F17CA9EA0 for ; Sun, 20 Oct 2019 22:13:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 80E1221928 for ; Sun, 20 Oct 2019 22:13:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1571609583; bh=Bj6TMw73TeyNuW745jBR36LTFG28G62Y2RhDJWbn4wI=; h=References:In-Reply-To:From:Date:Subject:To:Cc:List-ID:From; b=nAs+/K1mes4TzcR/Fm3WpdSQx3kTF/VtuhDWUcl4Q45HmU06SzCFYN+I4oy8oBYCu 4hwlgsS3nwthLIHh9b43qoVeRWzQ1d8/Gf52bg7XcqJLTAtjNd6t7MovPbTK5btkXi gy1Q+LVvkrwkmKyQBGfU3ydTVRQaZcgUyuCkYrTs= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726638AbfJTWNB (ORCPT ); Sun, 20 Oct 2019 18:13:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:37684 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726520AbfJTWNA (ORCPT ); Sun, 20 Oct 2019 18:13:00 -0400 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 93CB7222BD for ; Sun, 20 Oct 2019 22:12:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1571609579; bh=Bj6TMw73TeyNuW745jBR36LTFG28G62Y2RhDJWbn4wI=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=FRoTaGZXEKhnt9Rb6IoiDJVJEHLgZDccBz3pezFv9eLPf+LifiuBS7qNd37ytofN/ AOQoDeNgpg7fbN7cHZm2yJC820o7PHaB8ll9LvE+7vztA/747QyQ/dZDPqddoR2y9a HFD4JeSqLjnmkIR4vifOJ1qWdCvXZUfJxUR5GmWI= Received: by mail-wm1-f51.google.com with SMTP id q13so1082964wmj.0 for ; Sun, 20 Oct 2019 15:12:59 -0700 (PDT) X-Gm-Message-State: APjAAAU4Z4u7O8b37p/7oJMl5CYJGC19w9iX1r5ChwHMMOMnBbjOCrVQ gMAOeuGeBK3qxGwNfa+9jjhvM5nBCEQiFeGwdMv60w== X-Google-Smtp-Source: APXvYqzMQ1Ze2hicw5XWHD67VMC7zJog1FHKMEmLDyh4ecdsNSYrUq/3HwKGfn5UAcczdDu2eqPXZy7UkPB8fZDR+yU= X-Received: by 2002:a1c:a556:: with SMTP id o83mr17574912wme.0.1571609577995; Sun, 20 Oct 2019 15:12:57 -0700 (PDT) MIME-Version: 1.0 References: <1571367619-13573-1-git-send-email-chenhc@lemote.com> In-Reply-To: From: Andy Lutomirski Date: Sun, 20 Oct 2019 15:12:44 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] lib/vdso: Use __arch_use_vsyscall() to indicate fallback To: Thomas Gleixner Cc: Huacai Chen , Andy Lutomirski , Vincenzo Frascino , LKML , stable , Arnd Bergmann , Paul Burton , "open list:MIPS" , linux-arm-kernel 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 Sat, Oct 19, 2019 at 3:01 AM Thomas Gleixner wrote: > > On Sat, 19 Oct 2019, Huacai Chen wrote: > > On Fri, Oct 18, 2019 at 11:15 AM Andy Lutomirski wrote: > > > > > > On Thu, Oct 17, 2019 at 7:57 PM Huacai Chen wrote: > > > > > > > > In do_hres(), we currently use whether the return value of __arch_get_ > > > > hw_counter() is negtive to indicate fallback, but this is not a good > > > > idea. Because: > > > > > > > > 1, ARM64 returns ULL_MAX but MIPS returns 0 when clock_mode is invalid; > > > > 2, For a 64bit counter, a "negtive" value of counter is actually valid. > > > > > > s/negtive/negative > > > > > > What's the actual bug? Is it that MIPS is returning 0 but the check > > > is < 0? Sounds like MIPS should get fixed. > > My original bug is what Vincenzo said, MIPS has a boot failure if no > > valid clock_mode, and surely MIPS need to fix. However, when I try to > > fix it, I found that clock_getres() has another problem, because > > __cvdso_clock_getres_common() get vd[CS_HRES_COARSE].hrtimer_res, but > > hrtimer_res is set in update_vdso_data() which relies on > > __arch_use_vsyscall(). > > __arch_use_vsyscall() is a pointless exercise TBH. The VDSO data should be > updated unconditionally so all the trivial interfaces like time() and > getres() just work independently of the functions which depend on the > underlying clocksource. > > This functions have a fallback operation already: > > Let __arch_get_hw_counter() return U64_MAX and the syscall fallback is > invoked. > My thought was that __arch_get_hw_counter() could return last-1 to indicate failure, which would allow the two checks to be folded into one check. Or we could continue to use U64_MAX and rely on the fact that (s64)U64_MAX < 0, not worry about the cycle counter overflowing, and letting cycles < last catch it. (And we should change it to return s64 at some point regardless -- all the math is signed, so the underlying types should be too IMO.)