From patchwork Fri Mar 3 08:43:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 63785 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp292936wrd; Fri, 3 Mar 2023 00:33:19 -0800 (PST) X-Google-Smtp-Source: AK7set8NtbUM4t1wIoEFBOIPaGpvQICHabV9J7zwl6DGOBOLHH4qMZUWXYsMa/1od5wxQyYz2nFI X-Received: by 2002:a17:906:40d7:b0:871:d59d:4f54 with SMTP id a23-20020a17090640d700b00871d59d4f54mr827536ejk.27.1677832399220; Fri, 03 Mar 2023 00:33:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677832399; cv=none; d=google.com; s=arc-20160816; b=b+PF0XIzd+fcVq4V8/gBBsbOIxhbPg8JIYAzUSulBCXBIedhhrJblNwmR0CyFymuRN tb81RiieS3vNugn8gjEgRIAozotjiV8BenA0GnnXdPOe7X4j7Ejajne5C6RzG1XslFgV 9UocEBqd4IDDarRsftNYQVsT2JEqRDWroNoB7cxxq4zYmkV/N/5wQloB05Zc/wYL/nVV yWzmWDpfBweCsEbdWr00szczucRQMj5FiCsyR6zUVkH2yR1HWOVO6jAAgzx74ERH/Z6A L64tQaEBLysUou3MSNImscarJuxfPDhjrv2VBjBncNBdA6iQ3JQamnVpZzCsjXw3Mowe xuow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=y1434TH914/XkXlPb4/bO9w69xsgM/XMN6HmD7zOhzg=; b=aqPfNx2KXUgDZ+WT8BjhjZqbkIl3hfvfzowPVQzbsdn2bbm2iMA0uARmjhDc6DQrH5 GrdxoyLbMsQB05K0l6NMGNIW15AqlLq4zwrtqHQJxb/GqpoAbta+afOtJU4XlAj5/z4D WcELbaPmlXvZt7aSROQ3d/f53I5DveFw3EdkJE5g7+1VW2qboCPUYa06mj9qNGuekx1T gK87ksNOqQtPYysAudwVbnomiv/1RO9IRfMEwyDyxFmyXrpRf8LvREwCskQ7xOyRp+Oe +kmFw/Hp1WgXI3EoLgWY/wSprRXP9lFs5S9rUjQnBedH5q0MHcMTUILWR6Q//HPIh2Qj YEjw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m6-20020aa7c486000000b004acd42c5911si1984931edq.241.2023.03.03.00.32.56; Fri, 03 Mar 2023 00:33:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230085AbjCCIZD (ORCPT + 99 others); Fri, 3 Mar 2023 03:25:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229494AbjCCIZC (ORCPT ); Fri, 3 Mar 2023 03:25:02 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D89CB158A1 for ; Fri, 3 Mar 2023 00:23:32 -0800 (PST) Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4PSgsH0XMrz9tJH; Fri, 3 Mar 2023 16:20:51 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Fri, 3 Mar 2023 16:22:46 +0800 From: Kefeng Wang To: SeongJae Park , Andrew Morton CC: , , , Kefeng Wang Subject: [PATCH v2 1/3] mm/damon/paddr: minor refactor of damon_pa_pageout() Date: Fri, 3 Mar 2023 16:43:41 +0800 Message-ID: <20230303084343.171958-2-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230303084343.171958-1-wangkefeng.wang@huawei.com> References: <20230303084343.171958-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759334785500130619?= X-GMAIL-MSGID: =?utf-8?q?1759334785500130619?= Omit three lines by unified folio_put(), and make code more clear. Signed-off-by: Kefeng Wang Reviewed-by: SeongJae Park --- mm/damon/paddr.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index 6c655d9b5639..3fda00a0f786 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -239,21 +239,18 @@ static unsigned long damon_pa_pageout(struct damon_region *r, struct damos *s) if (!folio) continue; - if (damos_pa_filter_out(s, folio)) { - folio_put(folio); - continue; - } + if (damos_pa_filter_out(s, folio)) + goto put_folio; folio_clear_referenced(folio); folio_test_clear_young(folio); - if (!folio_isolate_lru(folio)) { - folio_put(folio); - continue; - } + if (!folio_isolate_lru(folio)) + goto put_folio; if (folio_test_unevictable(folio)) folio_putback_lru(folio); else list_add(&folio->lru, &folio_list); +put_folio: folio_put(folio); } applied = reclaim_pages(&folio_list); From patchwork Fri Mar 3 08:43:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 63784 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp292862wrd; Fri, 3 Mar 2023 00:33:04 -0800 (PST) X-Google-Smtp-Source: AK7set/QVLruA0ZQENWmVGGQSAURZ3szIuXWV1KpmmndsS3XA9HKwkq9Va6f/Ftnmmdv5/cb7CJc X-Received: by 2002:aa7:c90f:0:b0:4af:6a7e:9286 with SMTP id b15-20020aa7c90f000000b004af6a7e9286mr1175595edt.6.1677832384141; Fri, 03 Mar 2023 00:33:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677832384; cv=none; d=google.com; s=arc-20160816; b=PmnfXTkuWM2ihDCNf0IVvJZT5YnJvJsVqKOiXU+SN/f/Q02JI/2UQ2xRpRFjy+okVC uzBeqSbB3jz+2prxIur30BwqArkPTTBEFJCQrr1IlEIhFOrXPUFeXdvE4ikHje8rQQty l002PBI9IRn3yBk6gx6JBGt/OgcAIxZI5F098klZI0NxiuWGaU0MdUQVmzN5mAj3B/dP kht8TqyCXsh/azwbslsFNDxH8ZymYZeU6No6RD0jHV03ZHnXG6om8ssX7aQXMEKyP/Cg 3mlwH5mMn28IZ/W3f72pB3Scz+cQ2BfucJmh3R3FLzbMDQ5CxBKEH0lIQHErfABtH6Np 6WyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=F7kRQcf8rYI3p2XX72xLIeZ9I3gh+WTwueyptmTV+AM=; b=WF+4ifkHn8ahCD9YP0g416Eu0iWfE4XltYo0JTj5GJ+JtqpIjYcqFFMZ+lfQ1H6mga DofyPKh60QPJwVKP3S3s0hf2OY60Db4wnAkZGdxD6iG58v78cPOHEnWxHMfX65ARcbP9 E+CeXTs8owNpgslojhcj/r4ad9/N5IW2tpqoJYitllFSORVJuapACW2GFKQcyk147jQ0 c+ua34a9WA8ZA9km3lwweiYWWRTGdr5Wf+dsg5HbzA+vAC9Xzhng3Ydw4DtbcKCVCYaj PG81wwWwtkgMVLZIc3MoaQUqXso9Rr32habYjaYV1p8Swgo6AwW9bbAxXThJr8LchIcR pwjg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g12-20020a056402180c00b004c0e86b203bsi2097472edy.646.2023.03.03.00.32.41; Fri, 03 Mar 2023 00:33:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230105AbjCCIZK (ORCPT + 99 others); Fri, 3 Mar 2023 03:25:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229494AbjCCIZE (ORCPT ); Fri, 3 Mar 2023 03:25:04 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC87E65BC for ; Fri, 3 Mar 2023 00:23:33 -0800 (PST) Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4PSgsH2FF9z9tKK; Fri, 3 Mar 2023 16:20:51 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Fri, 3 Mar 2023 16:22:47 +0800 From: Kefeng Wang To: SeongJae Park , Andrew Morton CC: , , , Kefeng Wang Subject: [PATCH v2 2/3] mm/damon/paddr: minor refactor of damon_pa_young() Date: Fri, 3 Mar 2023 16:43:42 +0800 Message-ID: <20230303084343.171958-3-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230303084343.171958-1-wangkefeng.wang@huawei.com> References: <20230303084343.171958-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759334770100435956?= X-GMAIL-MSGID: =?utf-8?q?1759334770100435956?= Omit three lines by unified folio_put(), and make code more clear. Signed-off-by: Kefeng Wang --- mm/damon/paddr.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index 3fda00a0f786..2ef9db0189ca 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -130,24 +130,21 @@ static bool damon_pa_young(unsigned long paddr, unsigned long *folio_sz) accessed = false; else accessed = true; - folio_put(folio); goto out; } need_lock = !folio_test_anon(folio) || folio_test_ksm(folio); - if (need_lock && !folio_trylock(folio)) { - folio_put(folio); - return false; - } + if (need_lock && !folio_trylock(folio)) + goto out; rmap_walk(folio, &rwc); if (need_lock) folio_unlock(folio); - folio_put(folio); -out: *folio_sz = folio_size(folio); +out: + folio_put(folio); return accessed; } From patchwork Fri Mar 3 08:43:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 63783 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp292650wrd; Fri, 3 Mar 2023 00:32:15 -0800 (PST) X-Google-Smtp-Source: AK7set+81wto/jaZCqIshgfDxvpHaY6gb5/iF+6LcYap6oL4/jF32Mz+dy0QPRwB8pmQ+4vM0oOO X-Received: by 2002:aa7:d496:0:b0:4b3:32a9:eda0 with SMTP id b22-20020aa7d496000000b004b332a9eda0mr1187600edr.32.1677832334741; Fri, 03 Mar 2023 00:32:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677832334; cv=none; d=google.com; s=arc-20160816; b=m0NkBZDHoTjEVe1hznSv+oUMGosWwwgjiyEMh+ebscCHoVQPC4yfZSdYelYAmlKcNT yItbf03oivI4W4ztunlnFLY30ulEkv7ZV8VhSxVM7YUXZXe9csQXEFcNe9QVl/G7GMpN oY1tVV4G/TiEpa4TzRiV8oNfMzxreok2lOq98bJcHHEiwEIe9jluBYaNjEDoI8s2xDP4 AMk4LD4VhIFX2rD1T9RzSHXFRjVb3OVIg94a7R4ab6WG9vhgyFR8PjYgBdm1ToWR8wZR mRm3Cc7Uci/xGHIWUv6RMbs6PzttizACCqZ1tCFndJK+4UmBAmBXB6BqzEZNYN8bcIU/ H0dA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=nT8uAvYOgS1FhzPAq4yJd4zNvTr6g7LkLszlvw17IDM=; b=gitIbjNn21eGG9eyJ8XBGA3eg/Nlczc3R5Pw1zUeTb4GiEjowC5T4axWhNkQYNTTRL uPhc/Qymzim+mOAtB1hTvDTNbus+Hfh861s8S3rszWVqRIAlqi4nQyvZTSUqXKtKy5Sh MTPlkuYj2+PvfkIwNFp5WPQtwSaZUpOWR58ifse+LTt8ZrgprDal7UXUP9OteTnL7voS Xj+ph/Apqbg55kat+sGuasWEOiuYUMCgv7soJfey+8zOoQcq2rCTeLOkmarIt5DNcVQ1 im3AV2T+2a+MDAVpYg/AvbSf4scapPpT4sdBUgoZwRge6vSj82y/ACTqBavfQ8+sNxnH ex2g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jz13-20020a17090775ed00b008b17b558d68si1471722ejc.229.2023.03.03.00.31.52; Fri, 03 Mar 2023 00:32:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230098AbjCCIZG (ORCPT + 99 others); Fri, 3 Mar 2023 03:25:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229589AbjCCIZC (ORCPT ); Fri, 3 Mar 2023 03:25:02 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE24715C9D for ; Fri, 3 Mar 2023 00:23:32 -0800 (PST) Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4PSgsH2VDwz9tKp; Fri, 3 Mar 2023 16:20:51 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Fri, 3 Mar 2023 16:22:47 +0800 From: Kefeng Wang To: SeongJae Park , Andrew Morton CC: , , , Kefeng Wang Subject: [PATCH v2 3/3] mm/damon/paddr: minor refactor of damon_pa_mark_accessed_or_deactivate() Date: Fri, 3 Mar 2023 16:43:43 +0800 Message-ID: <20230303084343.171958-4-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230303084343.171958-1-wangkefeng.wang@huawei.com> References: <20230303084343.171958-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759334718104817037?= X-GMAIL-MSGID: =?utf-8?q?1759334718104817037?= Omit one line by unified folio_put(), and make code more clear. Signed-off-by: Kefeng Wang --- mm/damon/paddr.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index 2ef9db0189ca..6930ebf3667c 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -266,17 +266,16 @@ static inline unsigned long damon_pa_mark_accessed_or_deactivate( if (!folio) continue; - if (damos_pa_filter_out(s, folio)) { - folio_put(folio); - continue; - } + if (damos_pa_filter_out(s, folio)) + goto put_folio; if (mark_accessed) folio_mark_accessed(folio); else folio_deactivate(folio); - folio_put(folio); applied += folio_nr_pages(folio); +put_folio: + folio_put(folio); } return applied * PAGE_SIZE; }