From patchwork Fri Apr 29 16:05:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12832416 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 66809C433F5 for ; Fri, 29 Apr 2022 16:06:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AB3146B0081; Fri, 29 Apr 2022 12:06:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A3B116B0082; Fri, 29 Apr 2022 12:06:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8DA8A6B0083; Fri, 29 Apr 2022 12:06:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.27]) by kanga.kvack.org (Postfix) with ESMTP id 78B726B0081 for ; Fri, 29 Apr 2022 12:06:20 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 4A40326079 for ; Fri, 29 Apr 2022 16:06:20 +0000 (UTC) X-FDA: 79410393720.30.02013DD Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf10.hostedemail.com (Postfix) with ESMTP id B5F4BC0069 for ; Fri, 29 Apr 2022 16:06:08 +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 dfw.source.kernel.org (Postfix) with ESMTPS id 103106229E; Fri, 29 Apr 2022 16:06:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7AC0FC385B0; Fri, 29 Apr 2022 16:06:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1651248378; bh=Hcue4UkSxQRyEUzwbaytE02Er4fLlaTR3fDdxJ0RqWc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X9FMxOBbdtErkeAclj4pzR65QPA31ltzHi4e6XJQM1s+FcZkV8NW3jZrxHT2kHkF4 lv5UHIsB+Z2ImbsF3l86/aSgp1oqfUZV43FKtLrX6hFKGqcvEbeKeazCUwW2kZ1IKK jSULCIeRy4oSW72G6pLsH8tUo0EKls6kOFv5KYp5cp0u/7ywvBllY90Xnz60L3qZnp HDDWHwiMC7WTAkIdr3X+rIv7Y0ZxKo21GeHrtCtuWW+LmijIvl7cff6mPLYYd6v8ts xDzEupUY0o8tb8JzJQ5pewg8RwoVHk3636mxTHYuJtX2PicCTnfLlLvuC4WC5W9I+o l7sWU07sJhCgg== From: sj@kernel.org To: akpm@linux-foundation.org Cc: linux-damon@amazon.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 06/14] mm/damon/sysfs: prohibit multiple physical address space monitoring targets Date: Fri, 29 Apr 2022 16:05:58 +0000 Message-Id: <20220429160606.127307-7-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220429160606.127307-1-sj@kernel.org> References: <20220429160606.127307-1-sj@kernel.org> MIME-Version: 1.0 X-Stat-Signature: ewaommqdqdq8w8ssrazjah8cucuqfse5 Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=X9FMxOBb; spf=pass (imf10.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: B5F4BC0069 X-HE-Tag: 1651248368-6123 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: SeongJae Park Having multiple targets for physical address space monitoring makes no sense. This commit prohibits such a ridiculous DAMON context setup my making the DAMON context build function to check and return an error for the case. Signed-off-by: SeongJae Park --- mm/damon/sysfs.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c index 767ab8c33e4d..988247d35862 100644 --- a/mm/damon/sysfs.c +++ b/mm/damon/sysfs.c @@ -2124,6 +2124,10 @@ static int damon_sysfs_set_targets(struct damon_ctx *ctx, { int i, err; + /* Multiple physical address space monitoring targets makes no sense */ + if (ctx->ops.id == DAMON_OPS_PADDR && sysfs_targets->nr > 1) + return -EINVAL; + for (i = 0; i < sysfs_targets->nr; i++) { struct damon_sysfs_target *sys_target = sysfs_targets->targets_arr[i];