From patchwork Thu Sep 15 14:22:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: haoxin X-Patchwork-Id: 12977446 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 6C6E2ECAAA1 for ; Thu, 15 Sep 2022 14:22:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 35A546B007B; Thu, 15 Sep 2022 10:22:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2DFC18D0002; Thu, 15 Sep 2022 10:22:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1A8838D0001; Thu, 15 Sep 2022 10:22:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id E27D16B007D for ; Thu, 15 Sep 2022 10:22:46 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id BB78E12057A for ; Thu, 15 Sep 2022 14:22:46 +0000 (UTC) X-FDA: 79914535932.13.AA455DA Received: from out30-133.freemail.mail.aliyun.com (out30-133.freemail.mail.aliyun.com [115.124.30.133]) by imf31.hostedemail.com (Postfix) with ESMTP id A69CD200C2 for ; Thu, 15 Sep 2022 14:22:44 +0000 (UTC) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R201e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046060;MF=xhao@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0VPtLfjQ_1663251759; Received: from localhost.localdomain(mailfrom:xhao@linux.alibaba.com fp:SMTPD_---0VPtLfjQ_1663251759) by smtp.aliyun-inc.com; Thu, 15 Sep 2022 22:22: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 V1 1/2] mm/damon/sysfs: avoid call damon_target_has_pid() repeatedly Date: Thu, 15 Sep 2022 22:22:36 +0800 Message-Id: <20220915142237.92529-1-xhao@linux.alibaba.com> X-Mailer: git-send-email 2.31.0 MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663251766; a=rsa-sha256; cv=none; b=1+xRMVDfW8zliQi3d7poZjygYaVvxteurqb0UtwuAvcsZLcciQ68BteybJQQG0/mjUjTJI 7HHLU3MrlFT7WEfEw9A6+O9ZXoBnio8j7ZlBzWlJzKaa4ie9N/RMuHIeB0niT7HUWBffno DWL+OO+I38I5t1h3nBoriEeIFbcVr48= ARC-Authentication-Results: i=1; imf31.hostedemail.com; dkim=none; spf=pass (imf31.hostedemail.com: domain of xhao@linux.alibaba.com designates 115.124.30.133 as permitted sender) smtp.mailfrom=xhao@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663251766; 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=YGX0qqHINZSvQn/Aynq7haqpeyNmGTocKK3IOmDyAVE=; b=QlBmyWw34ME4eMfdWmkO/Mj3HmPRynwCkQAkZsMT5DSvMZwccmI2qkT/t/v4MhfXFPsXE1 TAplYWUVNgs1pUVELt7GqT4WmRQsBVyFtLXs+cTDyOzfZz+0MYbvjbR7dQvWCmSL1Z28W1 NnQ4UxXZIOo+8rViaW6Hm1UCetbsgBw= Authentication-Results: imf31.hostedemail.com; dkim=none; spf=pass (imf31.hostedemail.com: domain of xhao@linux.alibaba.com designates 115.124.30.133 as permitted sender) smtp.mailfrom=xhao@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: mp8pm49jmjhm63r3wws6o9mxqxqcaq96 X-Rspamd-Queue-Id: A69CD200C2 X-HE-Tag: 1663251764-445820 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: In damon_sysfs_destroy_targets(), we call damon_target_has_pid() to check whether the 'ctx' include a valid pid, but there no need to call damon_target_has_pid() to check repeatedly, just need call it once. Signed-off-by: Xin Hao Reviewed-by: SeongJae Park --- mm/damon/sysfs.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) -- 2.31.0 diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c index 1fa0023f136e..966ea7892ccf 100644 --- a/mm/damon/sysfs.c +++ b/mm/damon/sysfs.c @@ -2143,9 +2143,13 @@ 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; damon_for_each_target_safe(t, next, ctx) { - if (damon_target_has_pid(ctx)) + if (has_pid) put_pid(t->pid); damon_destroy_target(t); } From patchwork Thu Sep 15 14:22:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: haoxin X-Patchwork-Id: 12977445 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 BFAAFC6FA89 for ; Thu, 15 Sep 2022 14:22:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D43646B0078; Thu, 15 Sep 2022 10:22:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CCA666B007B; Thu, 15 Sep 2022 10:22:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B92758D0001; Thu, 15 Sep 2022 10:22:46 -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 A67FB6B0078 for ; Thu, 15 Sep 2022 10:22:46 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 7ABEBAA9C3 for ; Thu, 15 Sep 2022 14:22:46 +0000 (UTC) X-FDA: 79914535932.15.9893B79 Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) by imf11.hostedemail.com (Postfix) with ESMTP id B2129400A0 for ; Thu, 15 Sep 2022 14:22:44 +0000 (UTC) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R441e4;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_---0VPtLfkE_1663251760; Received: from localhost.localdomain(mailfrom:xhao@linux.alibaba.com fp:SMTPD_---0VPtLfkE_1663251760) by smtp.aliyun-inc.com; Thu, 15 Sep 2022 22:22:41 +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 V1 2/2] mm/damon/core: remove duplicate check about THP Date: Thu, 15 Sep 2022 22:22:37 +0800 Message-Id: <20220915142237.92529-2-xhao@linux.alibaba.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20220915142237.92529-1-xhao@linux.alibaba.com> References: <20220915142237.92529-1-xhao@linux.alibaba.com> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663251766; 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; bh=DbCpd0oRSZq3hOZrgbrh0K5Ecbd41nlcDZ2Us9cP08g=; b=MRaTae4g3h2OqlVLMmKDF2Rwx9attVkBBYiqo81Ay4BuOzzaGTgXVYbruIvR51bvWvzIh4 DWEdIHGq9ehtOoycy7BD3u0JVgPqCt9aEOLngGsxjLY57FeLLdWmicsXMJrOfEPcselzXv B8+yGPPQlKOS9scSBlwZh4i9mJgyJPU= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf11.hostedemail.com: domain of xhao@linux.alibaba.com designates 115.124.30.132 as permitted sender) smtp.mailfrom=xhao@linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663251766; a=rsa-sha256; cv=none; b=Cn8jROqnYIM1i3F0CI5pb9ZZxVBNi/GICuoDuyBgCFoeZFrIDUvxIctZaqTHHEUzC1Qf+X h2rp5U8Tc936L2PqBZsRACQ4Gk5rWzmwoil3xChBkvcAo3qaXRl6oNWNJl+Ysgc1ICeSBG 1GTj3xk5mHwVrLLG7bvfwWM1VYughes= Authentication-Results: imf11.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf11.hostedemail.com: domain of xhao@linux.alibaba.com designates 115.124.30.132 as permitted sender) smtp.mailfrom=xhao@linux.alibaba.com X-Stat-Signature: qb16ticj7iq9uzht94qau18rtmukm66t X-Rspamd-Queue-Id: B2129400A0 X-Rspamd-Server: rspam12 X-Rspam-User: X-HE-Tag: 1663251764-187558 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: In damon_young_pmd_entry(), it calls pmd_trans_huge() to check whether the OS supports THP, if CONFIG_TRANSPARENT_HUGEPAGE is not included, the pmd_trans_huge() will return 0. Signed-off-by: Xin Hao Reported-by: kernel test robot Reported-by: kernel test robot --- mm/damon/vaddr.c | 2 -- 1 file changed, 2 deletions(-) -- 2.31.0 diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c index 58bf1bbad530..21daaa5503fb 100644 --- a/mm/damon/vaddr.c +++ b/mm/damon/vaddr.c @@ -434,7 +434,6 @@ static int damon_young_pmd_entry(pmd_t *pmd, unsigned long addr, struct page *page; struct damon_young_walk_private *priv = walk->private; -#ifdef CONFIG_TRANSPARENT_HUGEPAGE if (pmd_trans_huge(*pmd)) { ptl = pmd_lock(walk->mm, pmd); if (!pmd_present(*pmd)) { @@ -462,7 +461,6 @@ static int damon_young_pmd_entry(pmd_t *pmd, unsigned long addr, } regular_page: -#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ if (pmd_none(*pmd) || unlikely(pmd_bad(*pmd))) return -EINVAL;