Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp7398306ybp; Wed, 16 Oct 2019 08:06:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqyxbcH/WLrkqC/5+j3BbFduWmHQRI8xEzcs8sqbmaeGTN7IHiodHAyq/bAs7bOV3LVIhot5 X-Received: by 2002:a1c:cc18:: with SMTP id h24mr4004253wmb.40.1571238386359; Wed, 16 Oct 2019 08:06:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571238386; cv=none; d=google.com; s=arc-20160816; b=k9aw/ktFYvwyX/ioEX5mKRKGkYY1gn/tqXKL2EGd8/J8/gMUs+UsQsUgmS9VRxBVLZ tOjVbx4gzF9gD4E1495iN/6P5F6QFum1nZC623VMGGfFW+qspspszx8741kg6CZ+p1/l X1S00zutnP2pywSzro+Bn4n1G5qMGEgWhtLrx3i2fYW14OaotX6Kf3J/GhyLErJkaPvj NcGCQEmv2PS0goEWrVMgBpHL7Y5DAFbMlxs2+bJbSi5RCbDieAGWocZI60GcQNPxvHQ4 syxDT8UXztZoFkZTVnrqgWppT2gjKAYOioKzwQImwypUW12pZ34lqiK+fAM1wcgSgqkm ULkg== 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:date:subject:cc:to:from; bh=C+Q3I6PzR+vb3SHzkS26llbBjYgZfi0h6zQMZLmXbYA=; b=IHYgKJbz7nJvgavYxdkmFo6wCttnEI+xJMHww2Dc7hJ0YfMwQdW944ej3E9cYO+3hY CXh0xHtTRR8WNe4VkaYY661rqDAvWC7AtN2rS13d8B0+Yo7fxJS3+BjWYiNmP2A27UDP rpGEFcta5obl8WgCd0fhKQ44n3T0Ogp7iYkXXLvc2Nnv+NE6ML3rXGQlikp5R+NImlws blnYeo7gZwCLMhs5cPV2u4j65hckm0Oys9ZZvtdX2PTX/26HWGH+yIK6y4qW5zuEPJSF AF9lA+wHorp3A/KfWCXkkp6i1/DI3PqOn5HFOnv2AIgES1YFJv7rKVrEggMA5KR3dp7v /s6A== 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 b34si19674307edb.439.2019.10.16.08.06.01; Wed, 16 Oct 2019 08:06:26 -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 S2392788AbfJPLdY (ORCPT + 99 others); Wed, 16 Oct 2019 07:33:24 -0400 Received: from mx2.suse.de ([195.135.220.15]:35626 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728838AbfJPLdW (ORCPT ); Wed, 16 Oct 2019 07:33:22 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 64620B1B1; Wed, 16 Oct 2019 11:33:19 +0000 (UTC) From: Miroslav Benes To: rostedt@goodmis.org, mingo@redhat.com, jpoimboe@redhat.com, jikos@kernel.org, pmladek@suse.com, joe.lawrence@redhat.com Cc: linux-kernel@vger.kernel.org, live-patching@vger.kernel.org, shuah@kernel.org, kamalesh@linux.vnet.ibm.com, linux-kselftest@vger.kernel.org, Miroslav Benes Subject: [PATCH v3 2/3] selftests/livepatch: Make dynamic debug setup and restore generic Date: Wed, 16 Oct 2019 13:33:14 +0200 Message-Id: <20191016113316.13415-3-mbenes@suse.cz> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191016113316.13415-1-mbenes@suse.cz> References: <20191016113316.13415-1-mbenes@suse.cz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joe Lawrence Livepatch selftests currently save the current dynamic debug config and tweak it for the selftests. The config is restored at the end. Make the infrastructure generic, so that more variables can be saved and restored. Signed-off-by: Joe Lawrence Signed-off-by: Miroslav Benes --- .../testing/selftests/livepatch/functions.sh | 22 +++++++++++-------- .../selftests/livepatch/test-callbacks.sh | 2 +- .../selftests/livepatch/test-livepatch.sh | 2 +- .../selftests/livepatch/test-shadow-vars.sh | 2 +- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/tools/testing/selftests/livepatch/functions.sh b/tools/testing/selftests/livepatch/functions.sh index 79b0affd21fb..b7e5a67ae434 100644 --- a/tools/testing/selftests/livepatch/functions.sh +++ b/tools/testing/selftests/livepatch/functions.sh @@ -29,29 +29,33 @@ function die() { exit 1 } -function push_dynamic_debug() { - DYNAMIC_DEBUG=$(grep '^kernel/livepatch' /sys/kernel/debug/dynamic_debug/control | \ - awk -F'[: ]' '{print "file " $1 " line " $2 " " $4}') +function push_config() { + DYNAMIC_DEBUG=$(grep '^kernel/livepatch' /sys/kernel/debug/dynamic_debug/control | \ + awk -F'[: ]' '{print "file " $1 " line " $2 " " $4}') } -function pop_dynamic_debug() { +function pop_config() { if [[ -n "$DYNAMIC_DEBUG" ]]; then echo -n "$DYNAMIC_DEBUG" > /sys/kernel/debug/dynamic_debug/control fi } -# set_dynamic_debug() - save the current dynamic debug config and tweak -# it for the self-tests. Set a script exit trap -# that restores the original config. function set_dynamic_debug() { - push_dynamic_debug - trap pop_dynamic_debug EXIT INT TERM HUP cat <<-EOF > /sys/kernel/debug/dynamic_debug/control file kernel/livepatch/* +p func klp_try_switch_task -p EOF } +# setup_config - save the current config and set a script exit trap that +# restores the original config. Setup the dynamic debug +# for verbose livepatching output. +function setup_config() { + push_config + set_dynamic_debug + trap pop_config EXIT INT TERM HUP +} + # loop_until(cmd) - loop a command until it is successful or $MAX_RETRIES, # sleep $RETRY_INTERVAL between attempts # cmd - command and its arguments to run diff --git a/tools/testing/selftests/livepatch/test-callbacks.sh b/tools/testing/selftests/livepatch/test-callbacks.sh index e97a9dcb73c7..a35289b13c9c 100755 --- a/tools/testing/selftests/livepatch/test-callbacks.sh +++ b/tools/testing/selftests/livepatch/test-callbacks.sh @@ -9,7 +9,7 @@ MOD_LIVEPATCH2=test_klp_callbacks_demo2 MOD_TARGET=test_klp_callbacks_mod MOD_TARGET_BUSY=test_klp_callbacks_busy -set_dynamic_debug +setup_config # TEST: target module before livepatch diff --git a/tools/testing/selftests/livepatch/test-livepatch.sh b/tools/testing/selftests/livepatch/test-livepatch.sh index f05268aea859..493e3df415a1 100755 --- a/tools/testing/selftests/livepatch/test-livepatch.sh +++ b/tools/testing/selftests/livepatch/test-livepatch.sh @@ -7,7 +7,7 @@ MOD_LIVEPATCH=test_klp_livepatch MOD_REPLACE=test_klp_atomic_replace -set_dynamic_debug +setup_config # TEST: basic function patching diff --git a/tools/testing/selftests/livepatch/test-shadow-vars.sh b/tools/testing/selftests/livepatch/test-shadow-vars.sh index 04a37831e204..1aae73299114 100755 --- a/tools/testing/selftests/livepatch/test-shadow-vars.sh +++ b/tools/testing/selftests/livepatch/test-shadow-vars.sh @@ -6,7 +6,7 @@ MOD_TEST=test_klp_shadow_vars -set_dynamic_debug +setup_config # TEST: basic shadow variable API -- 2.23.0