From patchwork Fri Sep 9 20:28:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12972159 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D304BECAAA1 for ; Fri, 9 Sep 2022 20:29:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D57618D0002; Fri, 9 Sep 2022 16:29:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D05B18D0005; Fri, 9 Sep 2022 16:29:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BA6A98D0002; Fri, 9 Sep 2022 16:29:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id A6D138D0005 for ; Fri, 9 Sep 2022 16:29:08 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 7C2A41404C2 for ; Fri, 9 Sep 2022 20:29:08 +0000 (UTC) X-FDA: 79893686376.06.CF999D8 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf21.hostedemail.com (Postfix) with ESMTP id DB5851C008C for ; Fri, 9 Sep 2022 20:29:07 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 573D8B82656; Fri, 9 Sep 2022 20:29:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6B0CDC433D7; Fri, 9 Sep 2022 20:29:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662755345; bh=hZYNe4incADQflac8QuxFEY25e1dLUMw1HCGMf1nJPw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HVd46DjfyD5K6T5dIhqM++JmCaEKjX2kucCKjE5XWfr29DaoDkrwaAQaQKKt+eUtY bq//B5BzvLiLtyLZGF5vHQgZiExTcIhRv58oQgZC2yRQs1OcumuX42jf1i5z8+QRUt ekSTZdZnTDrgbjkROJ/FB2TMCCcltd7gnqK30X4xrW5tgUu3wJAMaIBCpPGgutdulR SnJUHsMB2E42d/TEFyxDks146Swk7bfDgYxvTZs5WUvkZTLce3SMWVaVBCKy2IovSn xL+4MKKQrzpSFuWuSgWC3DQXNxKUOgLwQRLQVKB8T8PCwnK2g1KwrrYZxrX5PDYsxX 4TZR0hmKuiW7Q== From: SeongJae Park To: Andrew Morton Cc: Shuah Khan , linux-kernel@vger.kernel.org, damon@lists.linux.dev, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, SeongJae Park Subject: [PATCH 1/7] selftest/damon: add a test for duplicate context dirs creation Date: Fri, 9 Sep 2022 20:28:55 +0000 Message-Id: <20220909202901.57977-2-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220909202901.57977-1-sj@kernel.org> References: <20220909202901.57977-1-sj@kernel.org> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662755348; a=rsa-sha256; cv=none; b=QxUgHe9te2iQJHinTe916rzztpsjMRK9w3rkMfIg2CIqDAFblTD6NobDFADWvOTsias141 AzeP8Xj5B1TxNw6chSpvtZZb9PEaHkdRCJ6+tHKPLFglZ6JZ2Fakqzbka/y9juk57INMAo ZmrgIw+gxzoD/5HRlXX+NgilXKGv2uo= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=HVd46Djf; spf=pass (imf21.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662755348; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=DfuierM8GuMai/NRfsu23h5rJ7+Qgmg5FCbC6IHXuUg=; b=Eu9RVSKxcTkZi9V67UE2Tqaul8hkXfuJu0GiFqdDGmdiqSO3aLw5IAAtNjuo0nlU0RCzvo QHX22flzw4QwyNBfX82EmvYwkYdtVub6F/poKKZxkuMPlb0Eq2XUKaBWHsOKqeExncO+R6 L+IGJD3XkXoydmSc1HHL2MlFv+aKIFk= Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=HVd46Djf; spf=pass (imf21.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Rspam-User: X-Stat-Signature: y7y7k9b1ty6mprmxrp84cemdr5hwti5n X-Rspamd-Queue-Id: DB5851C008C X-Rspamd-Server: rspam01 X-HE-Tag: 1662755347-5644 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000067, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Commit d26f60703606 ("mm/damon/dbgfs: avoid duplicate context directory creation") fixes a bug which could result in memory leak and DAMON disablement. This commit adds a selftest for verifying the fix and avoid regression. Signed-off-by: SeongJae Park --- tools/testing/selftests/damon/Makefile | 1 + .../debugfs_duplicate_context_creation.sh | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 tools/testing/selftests/damon/debugfs_duplicate_context_creation.sh diff --git a/tools/testing/selftests/damon/Makefile b/tools/testing/selftests/damon/Makefile index 0470c5f3e690..a1fa2eff8192 100644 --- a/tools/testing/selftests/damon/Makefile +++ b/tools/testing/selftests/damon/Makefile @@ -6,6 +6,7 @@ TEST_GEN_FILES += huge_count_read_write TEST_FILES = _chk_dependency.sh _debugfs_common.sh TEST_PROGS = debugfs_attrs.sh debugfs_schemes.sh debugfs_target_ids.sh TEST_PROGS += debugfs_empty_targets.sh debugfs_huge_count_read_write.sh +TEST_PROGS += debugfs_duplicate_context_creation.sh TEST_PROGS += sysfs.sh include ../lib.mk diff --git a/tools/testing/selftests/damon/debugfs_duplicate_context_creation.sh b/tools/testing/selftests/damon/debugfs_duplicate_context_creation.sh new file mode 100644 index 000000000000..4a76e37ef16b --- /dev/null +++ b/tools/testing/selftests/damon/debugfs_duplicate_context_creation.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +source _debugfs_common.sh + +# Test duplicated context creation +# ================================ + +if ! echo foo > "$DBGFS/mk_contexts" +then + echo "context creation failed" + exit 1 +fi + +if echo foo > "$DBGFS/mk_contexts" +then + echo "duplicate context creation success" + exit 1 +fi + +if ! echo foo > "$DBGFS/rm_contexts" +then + echo "context deletion failed" + exit 1 +fi + +exit 0