From patchwork Fri Sep 16 13:35:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: haoxin X-Patchwork-Id: 12978525 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 F2D59ECAAD8 for ; Fri, 16 Sep 2022 13:35:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D2ACE8D0002; Fri, 16 Sep 2022 09:35:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CD9DB8D0001; Fri, 16 Sep 2022 09:35:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BC9D78D0002; Fri, 16 Sep 2022 09:35:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id AE99D8D0001 for ; Fri, 16 Sep 2022 09:35:47 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 724301A0E75 for ; Fri, 16 Sep 2022 13:35:47 +0000 (UTC) X-FDA: 79918046334.29.4EC1967 Received: from out30-54.freemail.mail.aliyun.com (out30-54.freemail.mail.aliyun.com [115.124.30.54]) by imf28.hostedemail.com (Postfix) with ESMTP id 71918C00D3 for ; Fri, 16 Sep 2022 13:35:45 +0000 (UTC) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R121e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046059;MF=xhao@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0VPxa0sf_1663335339; Received: from localhost.localdomain(mailfrom:xhao@linux.alibaba.com fp:SMTPD_---0VPxa0sf_1663335339) by smtp.aliyun-inc.com; Fri, 16 Sep 2022 21:35:40 +0800 From: Xin Hao To: sj@kernel.org Cc: akpm@linux-foundation.org, damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, xhao@linux.alibaba.com Subject: [PATCH] mm/damon/sysfs: more simplified code calls damon_target_has_pid() Date: Fri, 16 Sep 2022 21:35:35 +0800 Message-Id: <20220916133535.7428-1-xhao@linux.alibaba.com> X-Mailer: git-send-email 2.31.0 MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663335347; 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:references; bh=uuWg6snk6z3ed1JQ7xtaGZNl+609mjPDtXu04xfVUkQ=; b=SobWeDcf6wVSOZRRWsuQh7ReUsY5MCq9E3Xc15QEJGAiWx2VxmxU3+es+99EQUOpt5bD4h EMayCh8egYpE1xDYsAi/Yi+ilz9MMJNsxhCBZXAAfUufIApcDLHfzJONZkGkwgXK4NWcE9 O840rL/WC9/M4Wj0NSxU1PYQN8xyZbA= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf28.hostedemail.com: domain of xhao@linux.alibaba.com designates 115.124.30.54 as permitted sender) smtp.mailfrom=xhao@linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663335347; a=rsa-sha256; cv=none; b=xpOcz0LoQTdocWN1DNKzTn8ImVQYEg/trmeJbO6FhV9vyJ1Xx4Y8VwGSYL7XJbkLsO6k4a hAZzTP5LYl/O31x+m2SfFIM6a4D5qg1feijuV9qvoQ25eii9CpFq31If1+QexjEKL99nC8 j3vFxdOgCEQYBNjg3ZbOUyWWX0JtCgA= X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 71918C00D3 X-Rspam-User: X-Stat-Signature: sbcs9b5gk5g9yi65rxpbnhdhnogreim4 Authentication-Results: imf28.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf28.hostedemail.com: domain of xhao@linux.alibaba.com designates 115.124.30.54 as permitted sender) smtp.mailfrom=xhao@linux.alibaba.com X-HE-Tag: 1663335345-919112 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: This patch further simplifies the damon_target_has_pid() call and makes the damon_sysfs_destroy_targets() look cleaner. Fixes: 49fb890735ab (mm/damon/sysfs: avoid call damon_target_has_pid() repeatedly) Signed-off-by: Xin Hao Suggested-by: SeongJae Park Reviewed-by: SeongJae Park --- mm/damon/sysfs.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c index dc8dd56d6589..7692c706bcc5 100644 --- a/mm/damon/sysfs.c +++ b/mm/damon/sysfs.c @@ -2132,10 +2132,7 @@ static int damon_sysfs_set_attrs(struct damon_ctx *ctx, static void damon_sysfs_destroy_targets(struct damon_ctx *ctx) { struct damon_target *t, *next; - bool has_pid = false; - - if (damon_target_has_pid(ctx)) - has_pid = true; + bool has_pid = damon_target_has_pid(ctx); damon_for_each_target_safe(t, next, ctx) { if (has_pid)