Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp6090131ybp; Tue, 8 Oct 2019 12:53:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqymV3lyeTW2KAz9OFxujTIEBzRR69+/+gWKqsU0S/p1eN7QgZG6nG8VYpQxpQpNVYOIxUQy X-Received: by 2002:a50:ab83:: with SMTP id u3mr35351475edc.228.1570564394324; Tue, 08 Oct 2019 12:53:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570564394; cv=none; d=google.com; s=arc-20160816; b=UFcTSXwPylSJ2JhpKLeMI7CzI/Dc0vgVZHPUa8Fp3G/7ImSv+a5G8b92RNLC+M3zbu yds5Z3JF1bV3LWBGyyOUKnR94QJZ+hp95FW4YxJXeokLvltbYytVxWmrdC+iG1PTxW1S 7SUlwTjlr95J0k6lwz9l9FCB30L7t3B3e1e9DV1mzNukrrTpYaDWjquMrr++z+09MoNJ 4JBfv46CbvbrttEuPNasv5hA6ZJ87myTBdzG/8vWc1UrOmf/IHxX0Qy6MqlrbFJ0O5Zm a7IL0jRKAk58jZ45wJip8208GhfJJVXmFuRUX4C3S/jLjLWkDpBe3HsZghrR0+mBMyps Splg== 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:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=DPyrP+iIDTwWoeGDUt4sBLAYIp1Czbzev9noeowE5ls=; b=ryc8QYP5u0M33+rjr14DKSMKj01OO+R3CrIKH9xSyflGg3eIjkyZA4cJ8xih1n1wTc F3W2qGAhKryWJcTCwwlqGH8kJfAQiTXox2q6jKEazRaO07dNnSzQrYDePQ+XgLnOOcBV ucgMPz2sTtRqeab5b5UkEHY6ZIuolmKO8i5m2st75jBhvn+dO6vYuHX3Q62Wi3/JchWB R5iuk3kQNdBVFKfMJqWd6SsMDJQfEaWEozcZ6C9wNSqAvxJfhA95FI6WaLXOrFqjljz5 htednqaRiXkvcdp1iB7uGdMIS0yiSlDknLCGgZcmL7ywvX7/s4bs4euTJdSB+esPjWPo NFyw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h23si19801edh.248.2019.10.08.12.52.50; Tue, 08 Oct 2019 12:53:14 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730101AbfJHTu0 (ORCPT + 99 others); Tue, 8 Oct 2019 15:50:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:42322 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729385AbfJHTuZ (ORCPT ); Tue, 8 Oct 2019 15:50:25 -0400 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7BEC321835; Tue, 8 Oct 2019 19:50:24 +0000 (UTC) Date: Tue, 8 Oct 2019 15:50:22 -0400 From: Steven Rostedt To: Joe Lawrence Cc: Miroslav Benes , mingo@redhat.com, jpoimboe@redhat.com, jikos@kernel.org, pmladek@suse.com, linux-kernel@vger.kernel.org, live-patching@vger.kernel.org Subject: Re: [PATCH 0/3] ftrace: Introduce PERMANENT ftrace_ops flag Message-ID: <20191008155022.61db3108@gandalf.local.home> In-Reply-To: <20191008193534.GA16675@redhat.com> References: <20191007081714.20259-1-mbenes@suse.cz> <20191008193534.GA16675@redhat.com> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 8 Oct 2019 15:35:34 -0400 Joe Lawrence wrote: > > I wonder if the opposite would be more intuitive: when ftrace_enabled is > not set, don't allow livepatches to register ftrace filters and > likewise, don't allow ftrace_enabled to be unset if any livepatches are > already registered. I guess you could make an argument either way, but > just offering another option. Perhaps livepatches should follow similar > behavior of other ftrace clients (like perf probes?) I believe I suggested the "PERMANENT" flag, but disabling ftrace_enable may be another approach. Might be much easier to maintain. > > As for the approach in this patchset, is it consistent that livepatches > loaded after setting ftrace_enabled to 0 will successfully load, but not > execute their new code... but then when ftrace_enabled is toggled, the > new livepatch code remains on? > > For example: > > 1 - Turn ftrace_enabled off and load the /proc/cmdline livepatch test > case, note that it reports a success patching transition, but > doesn't run new its code: > > % dmesg -C > % sysctl kernel.ftrace_enabled=0 > kernel.ftrace_enabled = 0 > % insmod lib/livepatch/test_klp_livepatch.ko > % echo $? > 0 > % dmesg > [ 450.579980] livepatch: enabling patch 'test_klp_livepatch' > [ 450.581243] livepatch: 'test_klp_livepatch': starting patching transition > [ 451.942971] livepatch: 'test_klp_livepatch': patching complete > % cat /proc/cmdline > BOOT_IMAGE=(hd0,msdos1)/boot/vmlinuz-5.4.0-rc2+ root=UUID=c42bb089-b5c1-4e17-82bd-132f55bee54c ro console=ttyS0 console=ttyS0,115200n8 no_timer_check net.ifnames=0 crashkernel=auto > > 2 - Turn ftrace_enabled on and see that the livepatch now works: > > % sysctl kernel.ftrace_enabled=1 > kernel.ftrace_enabled = 1 > % cat /proc/cmdline > test_klp_livepatch: this has been live patched > > 3 - Turn ftrace_enabled off and see that it's still enabled: > > % sysctl kernel.ftrace_enabled=0 > kernel.ftrace_enabled = 0 > % cat /proc/cmdline > test_klp_livepatch: this has been live patched > > Steps 2 and 3 match the behavior described by the patchset, but I was > particularly wondering what you thought about step 1. > > IMHO, I would expect step 1 to fully enable the livepatch, or at the > very least, not report a patch transition (though that may confuse > userspace tools waiting for that report). > I think I like your idea better. To prevent ftrace_enable from being disabled if a "permanent" option is set. Then we only need to have a permanent flag for the ftrace_ops, that will disable the ftrace_enable from being cleared. We can also prevent the ftrace_ops from being loaded if ftrace_enable is not set and the ftrace_ops has the PERMANENT flag set. -- Steve