Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp661766lqh; Fri, 31 May 2024 12:18:40 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUVdPM09AbmJ4U6sWQw1FHE3RtMKmZJ+yxdMCQj63eZUHmLv2OaNgTw2Ub12epCHsHR2+hm4rSeDJNYxLmF6vDeTu1KW2BFwZyuwaJyCQ== X-Google-Smtp-Source: AGHT+IH0nydsy0ged9aZNZg2BC+rTKnw35wKGFNVQzo57x8m0S+vlrfFgApP7kr9oDGcY0wQflcE X-Received: by 2002:ac8:7f91:0:b0:43d:fca8:910d with SMTP id d75a77b69052e-43ff524ef42mr42535401cf.24.1717183120225; Fri, 31 May 2024 12:18:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717183120; cv=pass; d=google.com; s=arc-20160816; b=V9eKTQWHm7cowI0WhqjoI55AmyWFc6oeX365FuvTPBi6Fwyr1wii0vLKQ1pH7Hpp/d U/OrzS+CpDtGrNXupTyVJfurnidooGU2RiWQ7fz7NwX3m6ErOqNALOpsVWyKG65Nhhfu Al3SWYfS7BedsrixnGU3ypPxpHhk1cVAuMTv7aw7hVXYcnvL1Zl5X2byACWqyvKsyNvk SXJI5XLAiy0JMjKP0ARsZDfDxa4q6Sn94rMlD/7hlGfD4nrSENPLTHdQTXjPzHDGgDYx fUiY8Y/XmT/Mybpy+5LWE3diU7r0sjqMZ8umA1pxrjvTXyYgkHbsONGcMjJV44i0ndSP qaUg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=VLBzlF00otJAGz7fWp1w9pHDKelUe6skH+LZzm/YKTI=; fh=p67BK1ZyRrS3vAfmHcqwC8TQ9rEzE9U7BUa5RzG4SRY=; b=Hvv8vn6HXdh0UyGd79Uh/knqAS3BpR8CtleaQDFg8csomyWO0gHUyzCtQZYTa+3+Ca sILU0GxQ7ciWzY/6ciMKr0oGhr7ZYoZMNmx517SJu71Gm8JUOo86OoQwQggkePxsAlfh RaFOO/pP9rjenqR8alx1jyqeyVvu3Kc18ItSLNKz4YD7rEcVEc+Y8f7AjO170ZYGGIx0 4HyRHm/eDQIkTVGezht7StAtAjAuMpv4S+MrRNZIhROW/6hKpV4PkMBSXhFp564tb6GL 8kY7I5GD7hUYk6mrgKm8LzfzwHdaq0egKpPpP58P683fXoL1DGzgV7IuZ35u1xq+Zd/g Oxyg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=e8qqWdJp; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-197350-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-197350-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-43ff25b2df3si27513981cf.711.2024.05.31.12.18.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 12:18:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-197350-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=e8qqWdJp; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-197350-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-197350-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id F0E7A1C253CE for ; Fri, 31 May 2024 19:18:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2EFC017F4E0; Fri, 31 May 2024 19:16:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="e8qqWdJp" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 B7FA517E479 for ; Fri, 31 May 2024 19:16:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717182985; cv=none; b=KP3QEKpUfnBrEMkk/12COherSTn5YAp3dP1f8YQsABd3dJ61GifIVoChZLuFolMWJnd1WFeNqm6LV3Qk7O+3x6TJSC9JdezOukSMaSKBCoHdq9kKDCCy9TFjg+avGyslYo7nOlg5QdvrNjl+HRmjKSpf7Ntzgfv9TTfri0WWlD0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717182985; c=relaxed/simple; bh=xnPT9cCYR0XzEVJxY7VD2z3dllt5tDYentIhPbVk60I=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ahLmgsD0rDJcwpAHX6AwJ6iMfBlHGagiDIQN/xOM+WbShK2uEymHp8bucgu82CPb0gxxnoN5dsefw5FUsfqHZm3RCxObqQswBB7fCku+oe01wQqB6fvW+ZVqVYkYOTV+OqGvglaeuVR8nOs8KpChVHcvoV6TCYCekWVKJahvh34= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=e8qqWdJp; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717182982; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VLBzlF00otJAGz7fWp1w9pHDKelUe6skH+LZzm/YKTI=; b=e8qqWdJpvji8uIdRb28yry3LAa3/VErBNW31I6ioox1I4ZNOP7dJO4iLry0fg2SvK7ZfnG ZHUgn8IGKJs10sQAJEyEPtTfW//Fu0Q+bzr70uAspwLONS+s4sBW1iLQl5MA5vLw3CCPOp 6tJwU5tbpRf6ZJM3sAf/wzLUBJ+akxs= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-101-HzRcG1Q6O_ilqftIPjag6A-1; Fri, 31 May 2024 15:16:16 -0400 X-MC-Unique: HzRcG1Q6O_ilqftIPjag6A-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B5E1F85A58C; Fri, 31 May 2024 19:16:15 +0000 (UTC) Received: from redhat.com (unknown [10.22.18.140]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 57DDC40004D; Fri, 31 May 2024 19:16:15 +0000 (UTC) Date: Fri, 31 May 2024 15:16:13 -0400 From: Joe Lawrence To: Miroslav Benes Cc: zhang warden , Josh Poimboeuf , Jiri Kosina , Petr Mladek , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] livepatch: introduce klp_func called interface Message-ID: References: <20240520005826.17281-1-zhangwarden@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 On Tue, May 21, 2024 at 08:34:46AM +0200, Miroslav Benes wrote: > Hello, > > On Mon, 20 May 2024, zhang warden wrote: > > > > > > > > On May 20, 2024, at 14:46, Miroslav Benes wrote: > > > > > > Hi, > > > > > > On Mon, 20 May 2024, Wardenjohn wrote: > > > > > >> Livepatch module usually used to modify kernel functions. > > >> If the patched function have bug, it may cause serious result > > >> such as kernel crash. > > >> > > >> This is a kobject attribute of klp_func. Sysfs interface named > > >> "called" is introduced to livepatch which will be set as true > > >> if the patched function is called. > > >> > > >> /sys/kernel/livepatch////called > > >> > > >> This value "called" is quite necessary for kernel stability > > >> assurance for livepatching module of a running system. > > >> Testing process is important before a livepatch module apply to > > >> a production system. With this interface, testing process can > > >> easily find out which function is successfully called. > > >> Any testing process can make sure they have successfully cover > > >> all the patched function that changed with the help of this interface. > > > > > > Even easier is to use the existing tracing infrastructure in the kernel > > > (ftrace for example) to track the new function. You can obtain much more > > > information with that than the new attribute provides. > > > > > > Regards, > > > Miroslav > > Hi Miroslav > > > > First, in most cases, testing process is should be automated, which make > > using existing tracing infrastructure inconvenient. > > could you elaborate, please? We use ftrace exactly for this purpose and > our testing process is also more or less automated. > > > Second, livepatch is > > already use ftrace for functional replacement, I don’t think it is a > > good choice of using kernel tracing tool to trace a patched function. > > Why? > > > At last, this attribute can be thought of as a state of a livepatch > > function. It is a state, like the "patched" "transition" state of a > > klp_patch. Adding this state will not break the state consistency of > > livepatch. > > Yes, but the information you get is limited compared to what is available > now. You would obtain the information that a patched function was called > but ftrace could also give you the context and more. > > It would not hurt to add a new attribute per se but I am wondering about > the reason and its usage. Once we have it, the commit message should be > improved based on that. > I agree with Miroslav about using ftrace, or Dan in the other thread about using gcov if even more granular coverage is needed. Admittedly, I would have to go find documentation to remember how to do either, but at least I'd be using well-tested facilities designed for this exact purpose. Adding these attributes to livepatch sysfs would be expedient and probably easier for us to use, but imposes a recurring burden on us to maintain and test (where is the documentation and kselftest for this new interface?). Or, we could let the other tools handle all of that for us. Perhaps if someone already has an off-the-shelf script that is using ftrace to monitor livepatched code, it could be donated to Documentation/livepatch/? I can ask our QE folks if they have something like this. Regards, -- Joe