Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3496894ybg; Sun, 20 Oct 2019 15:14:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqwXUJ0ZaK+lYhaQwILYUde65PaB1jWIjd6i/Xt0hsT4+b5aZj9LeetfXMnNmQ6ADLzXXnxw X-Received: by 2002:a17:906:af5c:: with SMTP id ly28mr18765820ejb.228.1571609645427; Sun, 20 Oct 2019 15:14:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571609645; cv=none; d=google.com; s=arc-20160816; b=jyNrtA2y334WzMJlVjki2WVj4k6Zd+neyKCrQ1TW7s2whP+H+cPQQI5TM/MKfLL0y+ fZ1ztkwZcNbtmzEpD00BMulIoFoMc9FmGopTEYgAQRrjWjSEh09dRljdvL7C1QydCwB7 cvf5WTxIukMRpiCH0nTfQlgwYDFVuUTa6fUZblp2g3Y4SR1NtNBMSe8MRfYG3PC/0lDL DSVNSwyVCGE63yK+B27Z1cKTPM67cM/gt38YSNpdvCVnXT1XtfX7QnefoLpXxpRj3X+z FGHx57lPV7LeoNnFtTUWuDBjL5oy+Ouv3ul7o9Uqmm/ACad3xn5cgSz6EvIwqGeUNwXY w3vQ== 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:dkim-signature; bh=rNaUM0a4UKoSlNamxKC2CP3j9QbP2mPFbrxZe8x8jZs=; b=NGRXwc4YgvnSd8gyrnt/qpJ8KmnOH7tZUKiU7lXnTpJvxkz4rTJolCCSke0B8zF642 VGku0J6aRdVLBfmTburbNuOJOxrFzc1hNnBr2lqsw+lZEOtIpad3cUvvgKrounC3WvLc 3GS/hvaDpurCZZAPSdwSQzEqyuib5tQeJ1lAlH6xy1HFsb6jT2nc2xxudFRpeW3pcmNc R6wNmf6D3qC3+WN2h1rJTaBSB2MrXVVQo7OzPv0jvzVOonxR/ovZcoYdfIiolN7wpjbY fTGA2Go/vuMskUFsew2KQ3NzymAtwEDhr8Q5KrNWVeteVN/Xuld4qgyMoHlsw94SbWJ0 zcZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FRoTaGZX; 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=pass (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 u21si7446022ejt.345.2019.10.20.15.13.05; Sun, 20 Oct 2019 15:14:05 -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; dkim=pass header.i=@kernel.org header.s=default header.b=FRoTaGZX; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726607AbfJTWNB (ORCPT + 99 others); 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-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.)