Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp1101588pxb; Thu, 7 Oct 2021 00:21:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJydDBpy6pW5IMm/qqLfmjIZvJ9b3cvciH04K2Af1o8ab71US3WJrixBg/h3J38R2Oq0dabd X-Received: by 2002:a50:a2a5:: with SMTP id 34mr4093918edm.207.1633591269790; Thu, 07 Oct 2021 00:21:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633591269; cv=none; d=google.com; s=arc-20160816; b=uEVuUZSKwiCYfI9aRmLUeeJ7V/e11DAmgcAdg+g34OgG18gFHjGi6SiplECywTJcDg w92CMLYUt6Nqbu0iql+HuVe9Fr0e9F8KAZUbp1fi7qe/iT0/ofw1yoPYOU/veqcMcB3i 7FuYwa7Uivj4X7QLGa2+B2VZs1SjZW8aB+efW3R0xUSH52lue+I57jtV7nISB5fLZDTL WHAWIdbc4bH42CwNbuZB+hJWhWQDdyKOEQfi5749Ft1f8iEQfPQ5p6joKdFu4Xm0FzU6 eXUNw1H1HmlZ9yp429dFOyybiBACkCHa6qUongSV6nT7R/d1MNPp8/ty8iU5MHKqJzl6 99AQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=2JHJIpAWgccBA6pQAUlpOyYTSFGIlpbAsVVUO6XyK3w=; b=lqlCyw+ecg33PJ4jiAafHvdqy/kJ+IqZZCuu+LZPpiBuOE7EOCrvpB4t4fBmm1DEcH IE/aHSEiKQEqkFdv+QjBQ1mWhePX/ZYPkNpY29BuQI+P9GMHN5SQsf7daDqYXfSd0xxq gNTVX1WmpdOc0XSuIIWmkV11K0QPFbF2dF8bY7lgqsGfDBRusBjoTT4+huKvyK1O0Vjb Fjyspl2muSy8mz8iyzkqfxLZE5EP9+qJnYpCX1PWvEv8N3o5xRPiHCq+EJzydQIWA+YN AiLAc+7GF6BTomlRNHBuwmaJpkpQOZKeHIyjsbZfXJOkD6K/e8ve2Gu0OdpZ9TBVEGBV pfnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=METMHJ4U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 8si27762159ejv.769.2021.10.07.00.20.44; Thu, 07 Oct 2021 00:21:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=METMHJ4U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240327AbhJGHVB (ORCPT + 99 others); Thu, 7 Oct 2021 03:21:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232512AbhJGHVA (ORCPT ); Thu, 7 Oct 2021 03:21:00 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CEA3C061746; Thu, 7 Oct 2021 00:19:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=2JHJIpAWgccBA6pQAUlpOyYTSFGIlpbAsVVUO6XyK3w=; b=METMHJ4Uwgejg7yLQ0FdhlSqDc 4RiF0XPAjwCu6Xr0VclcBmAeaY6XVFwAdTvn7RPokVchywNUZolBdvwzV1/nc6oYuiriVu/Ka2DeA KiWilHlTFcsK0KkivmGPGjKA1jD86Rz9LRzmphAr37VejYH87iZ+wPXnfzzRnm8yx+1b4kntO+nHM ld9gORc2HXAcPf9VdhhPNxHyDhY97n8btaLu7A1zqJjyVRb2vygP3c1O5ddEb9aa39iWt5HxDH6eg Lsa+U5UAvf30UkdOy2pYK7O8AmzwvHs+xWvuIPgCDCpTGluf/tRlT4nO38ZGmhb3SdWvq2BsA47q8 ERRrMV3Q==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mYNg9-008Qna-2g; Thu, 07 Oct 2021 07:18:57 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id 9FFC698623A; Thu, 7 Oct 2021 09:18:56 +0200 (CEST) Date: Thu, 7 Oct 2021 09:18:56 +0200 From: Peter Zijlstra To: Song Liu Cc: Marcelo Tosatti , bpf , open list , Nitesh Narayan Lal , Nicolas Saenz Julienne , Thomas Gleixner , Peter Xu , Andrii Nakryiko Subject: Re: [PATCH bpf-next] bpf: introduce helper bpf_raw_read_cpu_clock Message-ID: <20211007071856.GM174703@worktop.programming.kicks-ass.net> References: <20211006175106.GA295227@fuller.cnet> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 06, 2021 at 02:37:09PM -0700, Song Liu wrote: > On Wed, Oct 6, 2021 at 10:52 AM Marcelo Tosatti wrote: > > > > > > > > Add bpf_raw_read_cpu_clock helper, to read architecture specific > > CPU clock. In x86's case, this is the TSC. > > > > This is necessary to synchronize bpf traces from host and guest bpf-programs > > (after subtracting guest tsc-offset from guest timestamps). > > Trying to understand the use case. So in a host-guest scenario, > bpf_ktime_get_ns() > will return different values in host and guest, but rdtsc() will give > the same value. > Is this correct? No, it will not. Also, please explain if any of this stands a chance of working for anything other than x86. Or even on x86 in the face of guest migration. Also, please explain, again, what's wrong with dumping snapshots of CLOCK_MONOTONIC{,_RAW} from host and guest and correlating time that way? And also explain why BPF needs to do this differently than all the other tracers.