Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp44263ybf; Wed, 26 Feb 2020 08:32:04 -0800 (PST) X-Google-Smtp-Source: APXvYqyXFw2LlPWECVaB3IOlqJKo9KpEl70Bzd5HzwPgsPGKxrF2fyoOLBV9ZHZsj4+m8zYUTE2w X-Received: by 2002:a9d:1284:: with SMTP id g4mr3550543otg.47.1582734724110; Wed, 26 Feb 2020 08:32:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582734724; cv=none; d=google.com; s=arc-20160816; b=1DQnuVb9bn5hVSqaL5rpy8X6YXLPAm0bb/Z6MlimHDXZOTUOES+taNhvHbrQD1dpuN iA8xuUw2RCsnzPsMkO47hnPSLi6KPQ3DHzK3DiSa/nvgnDB7TVyQveJYwZiVTdIZ66yk WZf4TJkoDKukO6f7BFl+CndfV0G2GA/va4QPlvUev/Dcbzn7HAlbHBbktQhtcNNMiaQh h+fVInx7FhRIp93cQcrl0dZqfa4C7oSoomH/lPFmoXZuNV7oVfwhNTmUWb5L2DNj2iYI AYX+qglWtSkHFBjLq72Yd637E+c0dtbIpxO8LjkhQgkhkcp3NfmKJTnWNaOg40RITkJD 2E9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=YsK7RC3jNyUUCAI8YO0dZwG1LLhNnYXoQcGVITBKQgY=; b=luSIm9TRkJBVezZW7Hk/vZxiZ01JZ4ojaPlT3LKJkSMXxoJDyQNobOi2yNvtT/e72Z OW6GYPt6dKrDn/2azPGCgBhvymgmdRdr1ywFQI7qgpvBK79V6eTDqTJmX2WivUQWuhk2 804lnY/9fgv823h98j7uW3IP5Fnjt7kqmH/qgJP+6kFG04GOKMXul7st/bd8/vaQ0Zol FzQl1GHDH1c+E5ywKzh9xmQqH63fvSWIIh3ojxhSi7SbjeCMOmgpsc/sxU+m842bhFl+ 5y71jF3zYKsgoBdNEsTniWJqzIXCTNRgb9By4FfPsRL3Yxthj44M+TVLvEH7i4qtsJrw pqrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FqjUlrOV; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r6si28716otq.95.2020.02.26.08.31.52; Wed, 26 Feb 2020 08:32:04 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FqjUlrOV; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727833AbgBZQbg (ORCPT + 99 others); Wed, 26 Feb 2020 11:31:36 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:35647 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726905AbgBZQbg (ORCPT ); Wed, 26 Feb 2020 11:31:36 -0500 Received: by mail-lj1-f194.google.com with SMTP id q8so3830224ljb.2 for ; Wed, 26 Feb 2020 08:31:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=YsK7RC3jNyUUCAI8YO0dZwG1LLhNnYXoQcGVITBKQgY=; b=FqjUlrOV8kswPqn7o8fKaz4tyZlXfb7BTWpJani82vjG7UqF6G+efcPzvAeQe4zEsV bGwdnsP5NukTjOJUrgVOa8huSecOxD/WvjSVeN0HOfLfHkU+WAszYS44z0hZUvwvVCFu Ljg+COePTAEsA05Ictyg/e7HEPgmoU0uOADLJO+I7AEETdBdZ9yA/woOmk7nDbB0ECs+ IoqIhHimkBQbEvN/1jZNgvri3qT5+y3ii26QaACMzVUidNPxUko1zu7mdbzdSlmGfmyu mvm23TnDjbFfB856j7Ik5jmEjsJWV6C+Nx17PEgNrJCWrxuNFZ+LDnm2NlpLW69zxVyJ WgKA== 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:content-transfer-encoding; bh=YsK7RC3jNyUUCAI8YO0dZwG1LLhNnYXoQcGVITBKQgY=; b=CXR/mQRwdNXaSDpmGWCH/mEF5P5SwOBQ+p6S0+0Eyn1nGIqZTh8qTTOcBQugeZ702x ek827Gi9UvPDM8gOELzH7u+JPaw0dzyQArMh8Kp5zM6u1D4AzO15FGvRd0tsxzPzDcFF x3TkGNKS+hAQupXpw2mzpIi0xeu+xzoo6gdqLI0f1qYh+U+lw2XCdJ+5kZdQrnuTtIrb 40i9YtbHYmpIVPzqm6bKoY8tDmV1o9CmnmFqGBNvRM1HzyfdRe3UwAzpGK6M6rjmq27s pM4SYmDMxALSruQLs5374FyWnj9Q/gLSrvm7q6BH+/OUNMnrK3lbmtO1idmWYkcenhnW eOQw== X-Gm-Message-State: APjAAAVyelXvQckRPuKfbqJLK+O7qVy9Cf85EeBOaUavmwMwkTzGMUpT OZ63oaYn6J4oGayrBt0DZx9IwMs/qtFGC6F9zNk= X-Received: by 2002:a2e:9d89:: with SMTP id c9mr3601778ljj.212.1582734694451; Wed, 26 Feb 2020 08:31:34 -0800 (PST) MIME-Version: 1.0 References: <20200226135027.34538-1-lrizzo@google.com> <87ftexz93y.fsf@toke.dk> In-Reply-To: <87ftexz93y.fsf@toke.dk> From: Alexei Starovoitov Date: Wed, 26 Feb 2020 08:31:23 -0800 Message-ID: Subject: Re: [PATCH v3 0/2] kstats: kernel metric collector To: =?UTF-8?B?VG9rZSBIw7hpbGFuZC1Kw7hyZ2Vuc2Vu?= Cc: Luigi Rizzo , LKML , Masami Hiramatsu , Andrew Morton , Greg Kroah-Hartman , "Naveen N . Rao" , ardb@kernel.org, rizzo@iet.unipi.it, Paolo Abeni , giuseppe.lettieri@unipi.it, Jesper Dangaard Brouer , Ingo Molnar , Arnaldo Carvalho de Melo , Steven Rostedt , Peter Zijlstra Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 26, 2020 at 7:03 AM Toke H=C3=B8iland-J=C3=B8rgensen wrote: > > > The tracepoint/kprobe/kretprobe solution is much more expensive -- > > from my measurements, the hooks that invoke the various handlers take > > ~250ns with hot cache, 1500+ns with cold cache, and tracing an empty > > function this way reports 90ns with hot cache, 500ns with cold cache. > > I think it would be good if you could include an equivalent BPF-based > implementation of your instrumentation example so people can (a) see the > difference for themselves and get a better idea of how the approaches > differ in a concrete case and (b) quantify the difference in performance > between the two implementations. +1 kprobe/kretprobe are expensive. That was the reason we switched to bpf fentry/fexit based on bpf trampoline= . The overhead is close to zero. Currently it's used to collect stats for bpf programs themselves, but the framework is there to collect these stats for any kernel function. Please see: https://lore.kernel.org/bpf/20200213210115.1455809-1-songliubraving@fb.com/= T/#mae90f23e545f03bde837239e159909f4e4a1acaa One of the ideas that came up during discussion is to teach 'perf stat' to do the same. So the kernel has all the facilities to instrument itself. Only user space work left.