From patchwork Wed Mar 8 08:33:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 66067 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp204747wrd; Wed, 8 Mar 2023 00:18:07 -0800 (PST) X-Google-Smtp-Source: AK7set9JaZsUiYuG10b9jMfo0dbffeAHvF/K2XIbzUWCJYxbWswCeaT9Ml8XyPHhY6GzZHhZZTRh X-Received: by 2002:a05:6a20:4b09:b0:b0:c30:1de with SMTP id fp9-20020a056a204b0900b000b00c3001demr12330118pzb.61.1678263487633; Wed, 08 Mar 2023 00:18:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678263487; cv=none; d=google.com; s=arc-20160816; b=n7tpiQIWUXrtd54NjNVaz885RgCRxKczlJlA7OFoH2oPySxvuNM+bIqHypPE/9SOGT w0BbCjJgjfuDu19ffrWJXbDrInPgl9dqH2Y+FbI6k327rfcDAPUXzP60N3wqQQlXkhIU I5ak14g4V2tVsENX+wec2Um8eTG9A4mbYkCBY3L9rRnTX8K/Z9d1oLvKSRmvLhvCbBfM /YNX75/gh/p1zQzUPrp2teWxpT2Dqzp2up2mFZOJxe6TCXkTU/1MXBv43xkky0V/1SwY pKABGUl1VNDmoLj8GdW7xeqoNInj7RCc/Dsn9r3BrDVVrlPxIrjxGmy4Gu72bWms66cP BU9A== 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=+Layu/iSxbaCwl2EtiPPzTOBELCa4Jr3rf2UxbUwrao=; b=f7jfB3UUbsmyHviFmbHQRw8Q0JnE5wJQrGuY6ejYvmODweESSIXZwP2tPzPF3kxap4 YtBBoN1Xhn8wPXDZlzkQbrnKVAx5D5wFO6qg2h1fcIuiZondZSxP+M/Vk+4DHtxzYFEj bWdmk3LTjbniXrtQA1bgDxpm7b5QNSboo7qSGF61pnuw8RBwb5DI32K9RdvKla2KkrPi FZlaHAmIecb1LhbWIgrldUBLxQ7ZgcFGvq0n6rABH/IpYgw3OQpC7M3pUVgMLUG19Ez3 0A67JUbPbUrgOAhgHz9w/gR/rYEgidB90hv+bGMmPQDvktTnxPP8TDv60U7KDSKY/tKO rydg== 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 j62-20020a638041000000b0050780e28ce1si764275pgd.701.2023.03.08.00.17.54; Wed, 08 Mar 2023 00:18:07 -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 S230051AbjCHINM (ORCPT + 99 others); Wed, 8 Mar 2023 03:13:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230031AbjCHIM4 (ORCPT ); Wed, 8 Mar 2023 03:12:56 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0E41A0B12 for ; Wed, 8 Mar 2023 00:12:48 -0800 (PST) Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4PWlPF3z9pzKqMt; Wed, 8 Mar 2023 16:10:41 +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; Wed, 8 Mar 2023 16:12:29 +0800 From: Kefeng Wang To: SeongJae Park , Andrew Morton CC: , , , Kefeng Wang Subject: [PATCH v3 1/3] mm/damon/paddr: minor refactor of damon_pa_pageout() Date: Wed, 8 Mar 2023 16:33:09 +0800 Message-ID: <20230308083311.120951-2-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230308083311.120951-1-wangkefeng.wang@huawei.com> References: <20230308083311.120951-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) 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?1759786815174909344?= X-GMAIL-MSGID: =?utf-8?q?1759786815174909344?= Omit three lines by unified folio_put(), and make code more clear. Reviewed-by: SeongJae Park Signed-off-by: Kefeng Wang --- 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 dd9c33fbe805..0db724aec5cb 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -238,21 +238,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 Wed Mar 8 08:33:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 66071 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp205681wrd; Wed, 8 Mar 2023 00:21:01 -0800 (PST) X-Google-Smtp-Source: AK7set9agAael6OeoIwzM2EHWH/gExyFYLjQbbu7tHZGTWX7d6E4S4a54kyMlZqQAmhriR97BVxu X-Received: by 2002:a17:902:c94c:b0:19b:33c0:4091 with SMTP id i12-20020a170902c94c00b0019b33c04091mr22858280pla.52.1678263661203; Wed, 08 Mar 2023 00:21:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678263661; cv=none; d=google.com; s=arc-20160816; b=o7Ms+8+DB3GDTdXfHwjJUFDzfiNth8Etn6kZ/N1IOxQN7l7tcIG/zKFLvYlkg0pmjD JMNuAA+HdtXG8BKDC64PZviFWlrIlYwLF5L83pla3l+Sjf4C+lacguF0oZD8a/OG+FI9 mOUeIETFkCCdZJ/6XFRB90IqtqhNz6IwrHvEgUcENN+fdGAHJnjrmV78oTuYi6PIO5d8 huMG45YSj/JY5S2XVQqFypFfJrC2pZCvNwi1vE9p7pYRQH/K2Q/3Ymz4hyOl2sGAXVpR 5Fb5VSNV+UbN5xU/lQ9xmRALCZ1XThlycMaHFXkHBVgK1S7R5IVxYvLB9kuzJmSRuAYP VIsg== 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=rxxvt2ZY/2w1vBgoz+ZTt/7u5whq/ogITHKZHoaklEA=; b=YKQmWXj36qkM0y8oUMZ9uFOv6kM43+TzDQtn0LtCG9fUff/W5D9I76+zY8K5PHddpp hikBCeA8JRo7TZt9+I9/HMkZd0r9PVeBnQipuiEDBJY2EKGb794uf+MoZCBBz74/YI1u 4ePp9XKeXKgMT1t40Ld89KXOrI+VwlXKTsdZWtrm7ZmgLOYgeGASBDo8LObksK/mToGy Ks6+Zz2qqyf2pYZ32d16z6jg0iDMM+7uDWy1mg44gYwGRNCYx8yldSePyne7mqHTwzqv rx6qcS5AJ4ViV1Us/y8GAr1ecDuqNSFv2dd43hwR80dks1PYCTvI5HeaO1xgJRBKoVnp mAEw== 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 a2-20020a1709027d8200b0019ca5ddf234si13708577plm.627.2023.03.08.00.20.48; Wed, 08 Mar 2023 00:21:01 -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 S229973AbjCHINH (ORCPT + 99 others); Wed, 8 Mar 2023 03:13:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230032AbjCHIM4 (ORCPT ); Wed, 8 Mar 2023 03:12:56 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1F5DA0B28 for ; Wed, 8 Mar 2023 00:12:48 -0800 (PST) Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4PWlPG1NkyzKqJm; Wed, 8 Mar 2023 16:10:42 +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; Wed, 8 Mar 2023 16:12:29 +0800 From: Kefeng Wang To: SeongJae Park , Andrew Morton CC: , , , Kefeng Wang Subject: [PATCH v3 2/3] mm/damon/paddr: minor refactor of damon_pa_mark_accessed_or_deactivate() Date: Wed, 8 Mar 2023 16:33:10 +0800 Message-ID: <20230308083311.120951-3-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230308083311.120951-1-wangkefeng.wang@huawei.com> References: <20230308083311.120951-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) 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?1759786996980439438?= X-GMAIL-MSGID: =?utf-8?q?1759786996980439438?= Omit one line by unified folio_put(), and make code more clear. Signed-off-by: Kefeng Wang --- mm/damon/paddr.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index 0db724aec5cb..b22f6fbb5816 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -268,16 +268,15 @@ 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); applied += folio_nr_pages(folio); +put_folio: folio_put(folio); } return applied * PAGE_SIZE; From patchwork Wed Mar 8 08:33:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 66080 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp207468wrd; Wed, 8 Mar 2023 00:26:51 -0800 (PST) X-Google-Smtp-Source: AK7set8ccFh0TZiHMNcEgC3/iYkq+m7TwxxUbdxQ2JNlDznCC6g9tgOqAZOK//QQYU0htVLmka0d X-Received: by 2002:a05:6402:31fb:b0:4ac:c3c0:24d7 with SMTP id dy27-20020a05640231fb00b004acc3c024d7mr17369905edb.42.1678264011521; Wed, 08 Mar 2023 00:26:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678264011; cv=none; d=google.com; s=arc-20160816; b=tF2OXAkP37r4//KPLovtzADPPlrTdE+oEb7juoqfau7Cf5N2zpDG0V1BA4khunMf8P imLe6DYvxJovg8j5ruXovxvcVmobS9yGDrU/EJmW2Gw00+WKd/iSCK2ihQ0JnYBDRufi g09cdx3kXT4TpfYxYp8rBbR3jerwzlJDCv9B6hG1FVcZmxqpKdZgn9HbXr8anuuu6Sm8 q67/zP4qhgaSYhteNEfgqLk1sQEmzkY+Pn5GhfY2jROPWZi87QH0hLu38IsySfQuD9MT 2XFR3hZ40WrGOHvQvHMnWX34hw9cSQVBlFHKbvEL9TaU7bSHlXv+AMRec73VJZEUFSgX 5jIA== 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=nACr05IkdnlTlwIhOKVQZNYjS9RH1sfG5PN/oA2Vl8M=; b=BO8s2z+0RSs3+mgkTxR3AW4Ekn13RSqA9AoeLrP1JTeikJDB3rTV7CCnWDhbVHd0GW BXweynNgO5S1IoaxdkdQw5APsMRtEd97xqCnSUbxFKwrAx1l7gsuRUBjT/9likMyn3E3 cq5yg3K9wNeFTUonf3aF7WLtW5qShXbKBWJHATbAVCLlzRRSeAAT92CrSV79GUL5httP XHt6UqRRAhjJiEp8+28JQHA6b/se5syoAZR/Sa+IlkmHgfXopA6W5Tx+h5ngWc1RB2YQ O15ssePgjL6Skm/vaz5+YV0Fy/ijA2WRDAslW09vuiGeQYcr8FYdOGF20Je7LKJR2hvB G5rQ== 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 l3-20020a056402124300b004acddcb7501si272792edw.116.2023.03.08.00.26.27; Wed, 08 Mar 2023 00:26:51 -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 S230061AbjCHINQ (ORCPT + 99 others); Wed, 8 Mar 2023 03:13:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230033AbjCHIM4 (ORCPT ); Wed, 8 Mar 2023 03:12:56 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A4E4A18BB for ; Wed, 8 Mar 2023 00:12:49 -0800 (PST) Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4PWlPG1fzPzKqMs; Wed, 8 Mar 2023 16:10:42 +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; Wed, 8 Mar 2023 16:12:29 +0800 From: Kefeng Wang To: SeongJae Park , Andrew Morton CC: , , , Kefeng Wang Subject: [PATCH v3 3/3] mm/damon/paddr: fix missing folio_sz update in damon_pa_young() Date: Wed, 8 Mar 2023 16:33:11 +0800 Message-ID: <20230308083311.120951-4-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230308083311.120951-1-wangkefeng.wang@huawei.com> References: <20230308083311.120951-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) 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?1759787364023327447?= X-GMAIL-MSGID: =?utf-8?q?1759787364023327447?= The *folio_sz in damon_pa_young() will be used(as last_folio_sz) by __damon_pa_check_access(), so it's need to be updated, fix missing branch. Signed-off-by: Kefeng Wang --- mm/damon/paddr.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index b22f6fbb5816..467b99166b43 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -134,10 +134,8 @@ static bool damon_pa_young(unsigned long paddr, unsigned long *folio_sz) } 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);