Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp1180846lqt; Fri, 7 Jun 2024 10:08:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU4MkyXaS9UgMGiPcat+pgTCUE+eYrEYVw0CUa01IBZ8eLCfowDnXqLoG5QDzXrCF4o8s9xWXQgRH2236avWShTSeVmR7NNYHBFoaaOaQ== X-Google-Smtp-Source: AGHT+IEwlYGVQeY17NpQhp2aeclAilASrwtQLTezviNwPL+dPKTVdaB4adT7J9IOv+s+YqSkpk6Z X-Received: by 2002:a05:6512:746:b0:52b:79d9:b084 with SMTP id 2adb3069b0e04-52bb9fc5a5amr1928137e87.43.1717780084969; Fri, 07 Jun 2024 10:08:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717780084; cv=pass; d=google.com; s=arc-20160816; b=UbN7rjYYyQCNxmIyuKzYcv904FBJCrPFbKDZtBOG6oLVWvXXCBtrOPE5uAg5KNxsse iPbngvm3rhWOA2fgpyipax2aokFzBloGSsKbodphX/qYDr2OWtfCMT6PGaa24edfpDuX 6GFyimTDWCWfDzuAFeg2ZXxyf5iNdkASDTEITtkBa6hCeu3mJkwDBbb+zQzZdiLmrbLO 6qTlbQnyTHmUKilz9/KwhkCatthIYUYmZLk9LjHh/Z7FSTidS7GFqIXi0xqATAqqGEiI dc4Q07zJBmE+MFslu9UECNBsC22AG7X+VFPTF+9BatJg/ZMYGbGfGtwsZXu4ysJaKyjC pozw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=dSa94Bog5MlG3uJH6MJkTuhsGjRfMkSaag6mPIfW8wE=; fh=p3y/wNhDLiqjHRcqJ0+2vZI18DWDtspRnS7TjAwy4m0=; b=aEy3PoPF0mh5VOOxxJ5+jRSYMEKAS1Sj+bWDZ0if4ei0l6T5jleNsxFGMcz58CGZbJ hy2LFvJ1g/848dUzZqCtn6oP7WjnORdFM3HQ+a0GyN02XedNPcwffCcLQy8ePShnNbOp +wYmRNPlgsVCSMUUZoDFYlwW6SZupzpzachdtqF4VQuXpdK2d/NbgKvAlZn60UwvamEe ougsqm0MXUGK9mfo9oZTV0IALtYkJzqiEUeynl7lQ0DSAfK/OoHzy1LlHFnEnQHoj0Py CF8YqSSYJ1r+okn4mpMnaI277NSyVB83LKt5RaBgZafs3pHtEGmXu82aU/lTxQ/cFCwb Yj4w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VRfH1x2m; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-206520-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206520-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a6c806dbdcdsi196938266b.457.2024.06.07.10.08.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 10:08:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-206520-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VRfH1x2m; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-206520-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206520-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 9890B1F25551 for ; Fri, 7 Jun 2024 17:00:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D109619AD6E; Fri, 7 Jun 2024 17:00:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VRfH1x2m" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0104818059; Fri, 7 Jun 2024 16:59:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717779600; cv=none; b=JiKjm0NQ6z8JKbeH/N9XbD3DKlv6XyYJWwISolPTfnwrvFguxE0dk8ktfx4+ZYQqUkssExecXaHJEND6sCVuWtQ1LAYTrULcHBEFMDF4kX+1O7gsbYbGabXtzwvhQFVTc48Qg+ieIFDgCbjhdjU44QrnSrZrcBczBjXv+ZcLybg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717779600; c=relaxed/simple; bh=GBvNsXIMHdMRNwV+HaKNpklwhxJlqMuEiP54hYEuB8Y=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=FPDw69SVNByo8nc48xyqIlSfaEcss6uBn23HJK3pskYdL3XlhCdhJB3i6YHI8cbTDjvtKSzUENLce7bl4clru3XfDIf6a/rRibosNoJ1yLmK0WXv3Qji8/8vhsTLgJSHDZl4o1RMNUWNaEGU57PShHWtrPMCDbphTe31fe5vx6M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VRfH1x2m; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 87FFCC32786; Fri, 7 Jun 2024 16:59:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717779599; bh=GBvNsXIMHdMRNwV+HaKNpklwhxJlqMuEiP54hYEuB8Y=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=VRfH1x2mAxUen8RyH8MQt6alQ2N21U7F4vG8LddvHQwPG4abxZ90Gk49s72eDKLMf B+coli3INqSjbofZmQ4NZiVmLcIEyxLCnRHrExZuGFwEIBqmkKaHn6DGaghTtMtalW EnkM4W3PfsV6QMW4CH7HpLV4Hn0ppgkfvuM/oZevlwbgfyykUVX+uiRCWJ1R8hIeNP nzan6Q8F7xpiHiikXFk0lkpwQed3Z3BNfyvxt4bBVi8uWjPHUTqrF2Jf9O2h9XubY5 dUPbFydqVtoxzEuaLsUZRwuBnimeBSnsk8rfCRIa8NNNdOjIeyFldZYm0c5pJOSMdA XT3zXFRSa3ocQ== Received: by mail-lj1-f182.google.com with SMTP id 38308e7fff4ca-2e72b8931caso24304521fa.0; Fri, 07 Jun 2024 09:59:59 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCXU3qsk4bKWukmre2VyOmQ/YWPlUsnrArAJwFBhIZJlFMUAw0Nr5Kg9FKVpCSAlGVyPYgbrikprjhmq5LVzLVEtcOQAkFEcq+48dv/H0IjL5ttFFIZQ4n1zIajq95xEa9RNNgdQd/2OqPeDig== X-Gm-Message-State: AOJu0YyKnFlLEQq/rp/Co6Afb/AGGBg8PuYMnVrPw/6tSFY1X4o1g0KL MkrlgVEccd8TTTYorHiIbViZf4TqSx1IphM3uAId9VvfIVTq9SO91F0k4Re1NQciVKUSwPv+bka 8pH7QuAi8QzAj4xMd89c9Vfnwk3s= X-Received: by 2002:a2e:780b:0:b0:2ea:e9f9:6ac2 with SMTP id 38308e7fff4ca-2eae9f96be4mr11807711fa.8.1717779597931; Fri, 07 Jun 2024 09:59:57 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240520005826.17281-1-zhangwarden@gmail.com> In-Reply-To: From: Song Liu Date: Fri, 7 Jun 2024 09:59:46 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] livepatch: introduce klp_func called interface To: Miroslav Benes Cc: Petr Mladek , zhang warden , Josh Poimboeuf , Jiri Kosina , Joe Lawrence , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Miroslav, On Fri, Jun 7, 2024 at 2:07=E2=80=AFAM Miroslav Benes wrot= e: > > Hi, > > On Tue, 4 Jun 2024, Song Liu wrote: > > > On Tue, May 21, 2024 at 1:04=E2=80=AFAM Petr Mladek = wrote: > > [...] > > > > > > > > Yes, but the information you get is limited compared to what is ava= ilable > > > > now. You would obtain the information that a patched function was c= alled > > > > but ftrace could also give you the context and more. > > > > > > Another motivation to use ftrace for testing is that it does not > > > affect the performance in production. > > > > > > We should keep klp_ftrace_handler() as fast as possible so that we > > > could livepatch also performance sensitive functions. > > > > At LPC last year, we discussed about adding a counter to each > > klp_func, like: > > > > struct klp_func { > > ... > > u64 __percpu counter; > > ... > > }; > > > > With some static_key (+ sysctl), this should give us a way to estimate > > the overhead of livepatch. If we have the counter, this patch is not > > needed any more. Does this (adding the counter) sound like > > something we still want to pursue? > > It would be better than this patch but given what was mentioned in the > thread I wonder if it is possible to use ftrace even for this. See > /sys/kernel/tracing/trace_stat/function*. It already gathers the number o= f > hits. I didn't know about the trace_stat API until today. :) It somehow doesn't exist on some older kernels. (I haven't debugged it.) > Would it be sufficient for you? I guess it depends on what the intention > is. If there is no time limit, klp_func.counter might be better to provid= e > some kind of overall statistics (but I am not sure if it has any value) > and to avoid having ftrace registered on a live patched function for > infinite period of time. If the intention is to gather data for some > limited period, trace_stat sounds like much better approach to me. We don't have very urgent use for this. As we discussed, various tracing tools are sufficient in most cases. I brought this up in the context of the "called" entry: if we are really adding a new entry, let's do "counter" instead of "called". Thanks, Song