From patchwork Tue Jun 28 13:28:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12898287 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 2A262C433EF for ; Tue, 28 Jun 2022 13:28:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A63248E0002; Tue, 28 Jun 2022 09:28:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9EB2C6B0072; Tue, 28 Jun 2022 09:28:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 88CA88E0002; Tue, 28 Jun 2022 09:28:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 76C906B0071 for ; Tue, 28 Jun 2022 09:28:42 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 4A35A976 for ; Tue, 28 Jun 2022 13:28:42 +0000 (UTC) X-FDA: 79627724484.30.E527045 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf12.hostedemail.com (Postfix) with ESMTP id 4975440030 for ; Tue, 28 Jun 2022 13:28:41 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4LXQLs0xq0zTgDj; Tue, 28 Jun 2022 21:25:09 +0800 (CST) Received: from huawei.com (10.175.124.27) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 28 Jun 2022 21:28:38 +0800 From: Miaohe Lin To: CC: , , , , , , Subject: [PATCH v2 01/16] mm/huge_memory: use flush_pmd_tlb_range in move_huge_pmd Date: Tue, 28 Jun 2022 21:28:20 +0800 Message-ID: <20220628132835.8925-2-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220628132835.8925-1-linmiaohe@huawei.com> References: <20220628132835.8925-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656422921; a=rsa-sha256; cv=none; b=LkXpltsIj1xlmOT/BLgx3ujiQWHVOwU3Tj1orvN/LFBNefmLfNwypPY8oYeV/LfsS8/3f7 Ru2FIzLRBtzuXhyj1SiPAjkyrFWuy+SpLXXjDWvQGee4jd3qnImZgC4+DmgMFZ8vrh5NFw GhhIqVL+X4+xkRBGvUAOXstNAGwuRc4= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf12.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656422921; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GGevoIVYV9j1ZCNK+fl/kf3ePw4czSSHXG1kG7dFKaU=; b=OK5sZAtNHM0XazPVN9opZwaRdvNLVamqTgV9Hs2+7oMLTmFqM9kmjPxoZjFpgw/BPjVO8s 5D4/iEs4YZjHv9vMul15ye1CDmrHGk/p4ZwdyucmHFJIUzNHlyW1eIVJegtvu4o+uGNRmi uceXIDWf1bwbVRGVFQH32F8iVlLslDI= X-Stat-Signature: gtd4a8k1jc1re3ikmme3b4dpz311c5ro X-Rspam-User: X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 4975440030 Authentication-Results: imf12.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf12.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-HE-Tag: 1656422921-358334 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: ARCHes with special requirements for evicting THP backing TLB entries can implement flush_pmd_tlb_range. Otherwise also, it can help optimize TLB flush in THP regime. Using flush_pmd_tlb_range to take advantage of this in move_huge_pmd. Signed-off-by: Miaohe Lin Reviewed-by: Muchun Song Reviewed-by: Zach O'Keefe --- mm/huge_memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 7b7eedc6d5dd..48ebeb02f7ce 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1849,7 +1849,7 @@ bool move_huge_pmd(struct vm_area_struct *vma, unsigned long old_addr, pmd = move_soft_dirty_pmd(pmd); set_pmd_at(mm, new_addr, new_pmd, pmd); if (force_flush) - flush_tlb_range(vma, old_addr, old_addr + PMD_SIZE); + flush_pmd_tlb_range(vma, old_addr, old_addr + PMD_SIZE); if (new_ptl != old_ptl) spin_unlock(new_ptl); spin_unlock(old_ptl); From patchwork Tue Jun 28 13:28:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12898285 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 04BD7C43334 for ; Tue, 28 Jun 2022 13:28:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 86CD88E0005; Tue, 28 Jun 2022 09:28:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 72FC46B0072; Tue, 28 Jun 2022 09:28:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3AAA08E0003; Tue, 28 Jun 2022 09:28:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 238256B0071 for ; Tue, 28 Jun 2022 09:28:43 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id DD6EE120F82 for ; Tue, 28 Jun 2022 13:28:42 +0000 (UTC) X-FDA: 79627724484.02.F0802E7 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf25.hostedemail.com (Postfix) with ESMTP id 23069A0034 for ; Tue, 28 Jun 2022 13:28:41 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4LXQLs4l4CzTgHx; Tue, 28 Jun 2022 21:25:09 +0800 (CST) Received: from huawei.com (10.175.124.27) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 28 Jun 2022 21:28:38 +0800 From: Miaohe Lin To: CC: , , , , , , Subject: [PATCH v2 02/16] mm/huge_memory: access vm_page_prot with READ_ONCE in remove_migration_pmd Date: Tue, 28 Jun 2022 21:28:21 +0800 Message-ID: <20220628132835.8925-3-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220628132835.8925-1-linmiaohe@huawei.com> References: <20220628132835.8925-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656422922; a=rsa-sha256; cv=none; b=oX08G8QFO/xscHTos0BoTMPox6lstiPmsUdA36PL9VE9+uTZEXmszF7y/bMtvzhregfAdh tuYvd3aFsefTwP28YJtH/6mlXJingL+t3QM5HaxcxBhdB4KDUAOJFLdJgjP1LZb5pyhcI2 dAVDYq0fTi2jv9AZ86Z/kkV9AsTuRPg= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=none; spf=pass (imf25.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656422922; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0Foko0Ox+jARmMEuBSISurKfHekBTiG6Sn1MI5lVLRw=; b=IWx0ANWqjlhVkAoEB0JK/ZgXRvQ/RkVoKwbmK7cEs7TO/olPJxAdNFShEOPcKDAWSMn5fs n8Fxoltv6uD4vSQTfVico1ndC/qDBVkehkBwRLQYUimvEOhfNLUSaq0LA9u4cK2BHuOpCZ 17Xbzg7QoeKDcI3GsLCQq2VrKbtNZns= X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 23069A0034 X-Rspam-User: X-Stat-Signature: t7zhaasp7jynk4xdyudbdmr15ppkehmc Authentication-Results: imf25.hostedemail.com; dkim=none; spf=pass (imf25.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-HE-Tag: 1656422921-803545 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: vma->vm_page_prot is read lockless from the rmap_walk, it may be updated concurrently. Using READ_ONCE to prevent the risk of reading intermediate values. Signed-off-by: Miaohe Lin --- mm/huge_memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 48ebeb02f7ce..76dc6d003245 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -3304,7 +3304,7 @@ void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, struct page *new) entry = pmd_to_swp_entry(*pvmw->pmd); get_page(new); - pmde = pmd_mkold(mk_huge_pmd(new, vma->vm_page_prot)); + pmde = pmd_mkold(mk_huge_pmd(new, READ_ONCE(vma->vm_page_prot))); if (pmd_swp_soft_dirty(*pvmw->pmd)) pmde = pmd_mksoft_dirty(pmde); if (is_writable_migration_entry(entry)) From patchwork Tue Jun 28 13:28:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12898288 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 BB04FC43334 for ; Tue, 28 Jun 2022 13:28:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D71E46B0072; Tue, 28 Jun 2022 09:28:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CF9698E0006; Tue, 28 Jun 2022 09:28:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B4C668E0003; Tue, 28 Jun 2022 09:28:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 98AC76B0072 for ; Tue, 28 Jun 2022 09:28:44 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 67CAE20996 for ; Tue, 28 Jun 2022 13:28:44 +0000 (UTC) X-FDA: 79627724568.25.50C840A Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf18.hostedemail.com (Postfix) with ESMTP id 6AAFB1C0034 for ; Tue, 28 Jun 2022 13:28:43 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4LXQPN4Jq8zkX1b; Tue, 28 Jun 2022 21:27:20 +0800 (CST) Received: from huawei.com (10.175.124.27) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 28 Jun 2022 21:28:39 +0800 From: Miaohe Lin To: CC: , , , , , , Subject: [PATCH v2 03/16] mm/huge_memory: fix comment of __pud_trans_huge_lock Date: Tue, 28 Jun 2022 21:28:22 +0800 Message-ID: <20220628132835.8925-4-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220628132835.8925-1-linmiaohe@huawei.com> References: <20220628132835.8925-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656422924; a=rsa-sha256; cv=none; b=H3vuFqKdnFHy03ScQk8fMNKoB61oD6t9XXiU6g9rc3kdfuorrRs7gL4/UruR6fhpS54q6F XsKrM9Bls9MFx6SdH3ZGDsr1IH/F3j9CAuFiH/TOUOabYmuZ6IUfj4cZ6exj+I8L4nJmeg AA8YjFe2/mJm9R3OB3izVFK7YuI05h0= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf18.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656422924; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WfcX0yLgOPdrbHZ2HW4UXhn9HneP43bMBjZ15BWwE+4=; b=tYvr/HCEyNeLGJcyvw/fL2SI7+AegTU1WrVW7eOasPs7au+QHZFcY3NIcwBH0jIBiXQx0I KM0MsDGWvsjxAsB/eVuYFA9xpp1fT8sbiEqCQtwHpRDPQCyGzN94HsFWOd2XfS6r1VdGA8 pEaBbxkWadh/ZKI3ask0gkgoNNzhHMg= X-Rspam-User: X-Stat-Signature: euszm1fu4gb4d1zgpsfq5ey8w1r9s3ao X-Rspamd-Queue-Id: 6AAFB1C0034 Authentication-Results: imf18.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf18.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Rspamd-Server: rspam03 X-HE-Tag: 1656422923-873096 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: __pud_trans_huge_lock returns page table lock pointer if a given pud maps a thp instead of 'true' since introduced. Fix corresponding comments. Signed-off-by: Miaohe Lin Acked-by: Muchun Song --- mm/huge_memory.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 76dc6d003245..f7164ef8b6e3 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2006,10 +2006,10 @@ spinlock_t *__pmd_trans_huge_lock(pmd_t *pmd, struct vm_area_struct *vma) } /* - * Returns true if a given pud maps a thp, false otherwise. + * Returns page table lock pointer if a given pud maps a thp, NULL otherwise. * - * Note that if it returns true, this routine returns without unlocking page - * table lock. So callers must unlock it. + * Note that if it returns page table lock pointer, this routine returns without + * unlocking page table lock. So callers must unlock it. */ spinlock_t *__pud_trans_huge_lock(pud_t *pud, struct vm_area_struct *vma) { From patchwork Tue Jun 28 13:28:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12898290 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 DF803C43334 for ; Tue, 28 Jun 2022 13:28:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 18DD38E0003; Tue, 28 Jun 2022 09:28:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0D0138E0006; Tue, 28 Jun 2022 09:28:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B758E8E0003; Tue, 28 Jun 2022 09:28:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 6D91F6B0073 for ; Tue, 28 Jun 2022 09:28:45 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 4A637611B5 for ; Tue, 28 Jun 2022 13:28:45 +0000 (UTC) X-FDA: 79627724610.06.BCC5F42 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf09.hostedemail.com (Postfix) with ESMTP id EC6ED14003A for ; Tue, 28 Jun 2022 13:28:43 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4LXQQ8311tz9sqr; Tue, 28 Jun 2022 21:28:00 +0800 (CST) Received: from huawei.com (10.175.124.27) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 28 Jun 2022 21:28:39 +0800 From: Miaohe Lin To: CC: , , , , , , Subject: [PATCH v2 04/16] mm/huge_memory: use helper touch_pud in huge_pud_set_accessed Date: Tue, 28 Jun 2022 21:28:23 +0800 Message-ID: <20220628132835.8925-5-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220628132835.8925-1-linmiaohe@huawei.com> References: <20220628132835.8925-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf09.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656422924; a=rsa-sha256; cv=none; b=mCQaxePoAa3Kk6gBTtJbx+PGudfqvSjedJvbkUmtUK/H9x4oA41XR5hStDPyoiMa8ISQGS K/fOcD7q7mVyXP740Y4yDKgdgyTm8MfdnqLdpBEZ3kaUbGD4/Q7//4Ba9+qzSkHQk2RMuK ASIwIaWdP3i3GnfIAcng1gIc9fgG7fk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656422924; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=o5HiH1O7osVRwJnFwVWTRthO9yg/7gewOsnHNaFn3/k=; b=q8byYJk0r1oKi8EKt27jSjA1110T6sbZZ1eRIwvUxcs9/65c+LBJAVqjApoaqSuLVuXVVr QBfXgiGBbtKhgfRn+m9MNqQSRRuv0MB1nrvhXRfVw5A4WHKK56S4qAHoggyjvp5WVCCv7U HQrVrOTPWHb88NfJ446Vb2QFPKKVAsE= X-Stat-Signature: ywgnaosnsj15pig8aumaopy5h39efanq X-Rspamd-Server: rspam08 X-Rspam-User: X-Rspamd-Queue-Id: EC6ED14003A Authentication-Results: imf09.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf09.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-HE-Tag: 1656422923-243911 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: Use helper touch_pud to set pud accessed to simplify the code and improve the readability. No functional change intended. Signed-off-by: Miaohe Lin --- mm/huge_memory.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index f7164ef8b6e3..d55d5efa06c8 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1284,15 +1284,15 @@ int copy_huge_pmd(struct mm_struct *dst_mm, struct mm_struct *src_mm, #ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD static void touch_pud(struct vm_area_struct *vma, unsigned long addr, - pud_t *pud, int flags) + pud_t *pud, bool write) { pud_t _pud; _pud = pud_mkyoung(*pud); - if (flags & FOLL_WRITE) + if (write) _pud = pud_mkdirty(_pud); if (pudp_set_access_flags(vma, addr & HPAGE_PUD_MASK, - pud, _pud, flags & FOLL_WRITE)) + pud, _pud, write)) update_mmu_cache_pud(vma, addr, pud); } @@ -1384,21 +1384,13 @@ int copy_huge_pud(struct mm_struct *dst_mm, struct mm_struct *src_mm, void huge_pud_set_accessed(struct vm_fault *vmf, pud_t orig_pud) { - pud_t entry; - unsigned long haddr; bool write = vmf->flags & FAULT_FLAG_WRITE; vmf->ptl = pud_lock(vmf->vma->vm_mm, vmf->pud); if (unlikely(!pud_same(*vmf->pud, orig_pud))) goto unlock; - entry = pud_mkyoung(orig_pud); - if (write) - entry = pud_mkdirty(entry); - haddr = vmf->address & HPAGE_PUD_MASK; - if (pudp_set_access_flags(vmf->vma, haddr, vmf->pud, entry, write)) - update_mmu_cache_pud(vmf->vma, vmf->address, vmf->pud); - + touch_pud(vmf->vma, vmf->address, vmf->pud, write); unlock: spin_unlock(vmf->ptl); } From patchwork Tue Jun 28 13:28:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12898292 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 573A1C43334 for ; Tue, 28 Jun 2022 13:28:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D9A3E8E0008; Tue, 28 Jun 2022 09:28:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CF9DD8E0007; Tue, 28 Jun 2022 09:28:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B74368E0008; Tue, 28 Jun 2022 09:28:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 9A8548E0007 for ; Tue, 28 Jun 2022 09:28:47 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 62AE7606A9 for ; Tue, 28 Jun 2022 13:28:47 +0000 (UTC) X-FDA: 79627724694.21.4E79D73 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf20.hostedemail.com (Postfix) with ESMTP id 2F6791C0042 for ; Tue, 28 Jun 2022 13:28:45 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4LXQLv1wYpzTgJ6; Tue, 28 Jun 2022 21:25:11 +0800 (CST) Received: from huawei.com (10.175.124.27) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 28 Jun 2022 21:28:40 +0800 From: Miaohe Lin To: CC: , , , , , , Subject: [PATCH v2 05/16] mm/huge_memory: use helper touch_pmd in huge_pmd_set_accessed Date: Tue, 28 Jun 2022 21:28:24 +0800 Message-ID: <20220628132835.8925-6-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220628132835.8925-1-linmiaohe@huawei.com> References: <20220628132835.8925-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656422927; a=rsa-sha256; cv=none; b=5Sr7rzRxyZPelstdp3NKnHKTYLCdrFLDYTss/7yIuygUpTz2OHd7iH6G/yLV68Rf9qHzB4 Z8/x5T7NpXShWT85dc8bFOdPph9ScEqBVPAypzBt6KpGj/gHUe/x9bs6SHjUIJC+1mEiyw 8DUAxK2p3PvMMn6xf5SHFuoxIlcusPY= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf20.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656422927; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dOx+R3saS3YDAxS2/+TLnMOE7l0dSUBD5WAgrYqRlag=; b=eyxBKWc0nVtoiZvZ7dsCmYCD6Ht8m6sxR782xfwoHkP0ZbV8gsP3R/ksxGFjNQmtdmKeYj 5G8Aswi9t0pKsbGvvkASTI8fW7Me6/9ndHiJm/MYMqtAACuK/+s2UJdvw/rYird7uIHpSO K+B+nM5RqA6RuXI0Kj/CU94lBy9LGVY= X-Stat-Signature: ci9npnb5939mqjexas5g5r5ix75oeygt X-Rspamd-Queue-Id: 2F6791C0042 Authentication-Results: imf20.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf20.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Rspamd-Server: rspam10 X-Rspam-User: X-HE-Tag: 1656422925-839376 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: Use helper touch_pmd to set pmd accessed to simplify the code and improve the readability. No functional change intended. Signed-off-by: Miaohe Lin --- mm/huge_memory.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index d55d5efa06c8..d9fe9b034783 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1120,15 +1120,15 @@ EXPORT_SYMBOL_GPL(vmf_insert_pfn_pud_prot); #endif /* CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD */ static void touch_pmd(struct vm_area_struct *vma, unsigned long addr, - pmd_t *pmd, int flags) + pmd_t *pmd, bool write) { pmd_t _pmd; _pmd = pmd_mkyoung(*pmd); - if (flags & FOLL_WRITE) + if (write) _pmd = pmd_mkdirty(_pmd); if (pmdp_set_access_flags(vma, addr & HPAGE_PMD_MASK, - pmd, _pmd, flags & FOLL_WRITE)) + pmd, _pmd, write)) update_mmu_cache_pmd(vma, addr, pmd); } @@ -1398,21 +1398,13 @@ void huge_pud_set_accessed(struct vm_fault *vmf, pud_t orig_pud) void huge_pmd_set_accessed(struct vm_fault *vmf) { - pmd_t entry; - unsigned long haddr; bool write = vmf->flags & FAULT_FLAG_WRITE; - pmd_t orig_pmd = vmf->orig_pmd; vmf->ptl = pmd_lock(vmf->vma->vm_mm, vmf->pmd); - if (unlikely(!pmd_same(*vmf->pmd, orig_pmd))) + if (unlikely(!pmd_same(*vmf->pmd, vmf->orig_pmd))) goto unlock; - entry = pmd_mkyoung(orig_pmd); - if (write) - entry = pmd_mkdirty(entry); - haddr = vmf->address & HPAGE_PMD_MASK; - if (pmdp_set_access_flags(vmf->vma, haddr, vmf->pmd, entry, write)) - update_mmu_cache_pmd(vmf->vma, vmf->address, vmf->pmd); + touch_pmd(vmf->vma, vmf->address, vmf->pmd, write); unlock: spin_unlock(vmf->ptl); From patchwork Tue Jun 28 13:28:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12898297 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 EC05DC43334 for ; Tue, 28 Jun 2022 13:28:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B4C448E0009; Tue, 28 Jun 2022 09:28:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A3FEC8E0010; Tue, 28 Jun 2022 09:28:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5599E8E0009; Tue, 28 Jun 2022 09:28:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 02B3E8E000D for ; Tue, 28 Jun 2022 09:28:48 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id CEA7321275 for ; Tue, 28 Jun 2022 13:28:48 +0000 (UTC) X-FDA: 79627724736.05.E80112A Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf24.hostedemail.com (Postfix) with ESMTP id 0C585180037 for ; Tue, 28 Jun 2022 13:28:46 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4LXQLv5gJ6zTgJB; Tue, 28 Jun 2022 21:25:11 +0800 (CST) Received: from huawei.com (10.175.124.27) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 28 Jun 2022 21:28:40 +0800 From: Miaohe Lin To: CC: , , , , , , Subject: [PATCH v2 06/16] mm/huge_memory: rename mmun_start to haddr in remove_migration_pmd Date: Tue, 28 Jun 2022 21:28:25 +0800 Message-ID: <20220628132835.8925-7-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220628132835.8925-1-linmiaohe@huawei.com> References: <20220628132835.8925-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656422928; a=rsa-sha256; cv=none; b=Rsx5Vf7CIBiJuLpyqYiBIVb+MzMHbmU0xzTOhx1y+CfUfrYMdShT9nnt8CMTys2DNrW9GV 7JsN7qCcPzGXhqQe7aG4kup3ycFJ/XBL6DuLGNbEIsk/6/DpJlTXtteSuGnwKd+O0GaxOS skGJotQcetKCnvw4ZAOTHKTjjr/HBoo= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none; spf=pass (imf24.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656422927; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=T6FZyXgxYx8FtNlznGZwc0THV2OcvOr7RZTWjZsM5Y4=; b=PyOR0pPILQAcj+zjk1LR8kcKDDdnlkZ8NCOtgyLetuddiaWzxTSnAmdpl8Xw4B97CLq9s/ IeiSzS4oaACoPMlJK7ktJfndmEeZU6fgm43QjT6yrY84SFh6JiiU0ctBGlH3FdbSMo403O Ad7VoLBuqCG4pukIGLaH7UHL77BEpps= X-Rspam-User: Authentication-Results: imf24.hostedemail.com; dkim=none; spf=pass (imf24.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Rspamd-Server: rspam02 X-Stat-Signature: 3yg4ok5f17kofcadx8afwxqidfkw7itt X-Rspamd-Queue-Id: 0C585180037 X-HE-Tag: 1656422926-24238 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: mmun_start indicates mmu_notifier start address but there's no mmu_notifier stuff in remove_migration_pmd. This will make it hard to get the meaning of mmun_start. Rename it to haddr to avoid confusing readers and also imporve readability. Signed-off-by: Miaohe Lin Reviewed-by: Muchun Song --- mm/huge_memory.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index d9fe9b034783..8364b9b25b3a 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -3279,7 +3279,7 @@ void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, struct page *new) struct vm_area_struct *vma = pvmw->vma; struct mm_struct *mm = vma->vm_mm; unsigned long address = pvmw->address; - unsigned long mmun_start = address & HPAGE_PMD_MASK; + unsigned long haddr = address & HPAGE_PMD_MASK; pmd_t pmde; swp_entry_t entry; @@ -3302,12 +3302,12 @@ void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, struct page *new) if (!is_readable_migration_entry(entry)) rmap_flags |= RMAP_EXCLUSIVE; - page_add_anon_rmap(new, vma, mmun_start, rmap_flags); + page_add_anon_rmap(new, vma, haddr, rmap_flags); } else { page_add_file_rmap(new, vma, true); } VM_BUG_ON(pmd_write(pmde) && PageAnon(new) && !PageAnonExclusive(new)); - set_pmd_at(mm, mmun_start, pvmw->pmd, pmde); + set_pmd_at(mm, haddr, pvmw->pmd, pmde); /* No need to invalidate - it was non-present before */ update_mmu_cache_pmd(vma, address, pvmw->pmd); From patchwork Tue Jun 28 13:28:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12898289 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 6793BCCA479 for ; Tue, 28 Jun 2022 13:28:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DBAB96B0073; Tue, 28 Jun 2022 09:28:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D23506B0074; Tue, 28 Jun 2022 09:28:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A3BEC8E0006; Tue, 28 Jun 2022 09:28:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 840FF8E0003 for ; Tue, 28 Jun 2022 09:28:45 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 5BF82611D0 for ; Tue, 28 Jun 2022 13:28:45 +0000 (UTC) X-FDA: 79627724610.30.420EE60 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf11.hostedemail.com (Postfix) with ESMTP id B855240036 for ; Tue, 28 Jun 2022 13:28:44 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4LXQNq49SBzkWlH; Tue, 28 Jun 2022 21:26:51 +0800 (CST) Received: from huawei.com (10.175.124.27) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 28 Jun 2022 21:28:41 +0800 From: Miaohe Lin To: CC: , , , , , , Subject: [PATCH v2 07/16] mm/huge_memory: use helper function vma_lookup in split_huge_pages_pid Date: Tue, 28 Jun 2022 21:28:26 +0800 Message-ID: <20220628132835.8925-8-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220628132835.8925-1-linmiaohe@huawei.com> References: <20220628132835.8925-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656422925; a=rsa-sha256; cv=none; b=fasvsHzUneY/gGUvrChsHXKY9JKwyvQbFcJoRMEDGeSXBCYvgMItp3GzV97rZ4iPsuLMx5 EBDchvmap4MCCFqaAceY26XFBMofy+JK5lTxMio/MV5TuJtlGymV9tLSVaPumXdnWVUiX3 5FPFlcfa3hXskTD0G1d1tIY/qfyLx04= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=none; spf=pass (imf11.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656422925; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=T1NOaYfbRHCPaq5mr9ZnIy0oD5d+2tzmVjk4wVO2qD8=; b=WZEEtVxvoOrqvTpvmPz5YM2I+95m0nNlxXSuUoSR2j3TyLEslepbRn/+GpCS+91C+Y7GH8 4whzrqAzTaMONBr2BSmANq207xqc9ZO5yWqV2C9yHRtLf6JCV4Dz7/kSiVhtu7gwYnpLwp IasAwq3s1HLjW5uINNZ7DoK6CIjGGGc= X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: B855240036 X-Rspam-User: X-Stat-Signature: kce1uxn89zzmj7gfj84si661rbd51xmm Authentication-Results: imf11.hostedemail.com; dkim=none; spf=pass (imf11.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-HE-Tag: 1656422924-761386 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: Use helper function vma_lookup to lookup the needed vma to simplify the code. Minor readability improvement. Signed-off-by: Miaohe Lin --- mm/huge_memory.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 8364b9b25b3a..1cb51eb5a60c 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -3040,10 +3040,10 @@ static int split_huge_pages_pid(int pid, unsigned long vaddr_start, * table filled with PTE-mapped THPs, each of which is distinct. */ for (addr = vaddr_start; addr < vaddr_end; addr += PAGE_SIZE) { - struct vm_area_struct *vma = find_vma(mm, addr); + struct vm_area_struct *vma = vma_lookup(mm, addr); struct page *page; - if (!vma || addr < vma->vm_start) + if (!vma) break; /* skip special VMA and hugetlb VMA */ From patchwork Tue Jun 28 13:28:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12898298 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 44237C433EF for ; Tue, 28 Jun 2022 13:29:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ED1038E000F; Tue, 28 Jun 2022 09:28:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E5A228E000C; Tue, 28 Jun 2022 09:28:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 66C348E000F; Tue, 28 Jun 2022 09:28:49 -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 39EC38E000C for ; Tue, 28 Jun 2022 09:28:49 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 1896E7BE for ; Tue, 28 Jun 2022 13:28:49 +0000 (UTC) X-FDA: 79627724778.17.62FA188 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf09.hostedemail.com (Postfix) with ESMTP id 78DB6140037 for ; Tue, 28 Jun 2022 13:28:48 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4LXQNL5N8BzdZcX; Tue, 28 Jun 2022 21:26:26 +0800 (CST) Received: from huawei.com (10.175.124.27) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 28 Jun 2022 21:28:41 +0800 From: Miaohe Lin To: CC: , , , , , , Subject: [PATCH v2 08/16] mm/huge_memory: use helper macro __ATTR_RW Date: Tue, 28 Jun 2022 21:28:27 +0800 Message-ID: <20220628132835.8925-9-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220628132835.8925-1-linmiaohe@huawei.com> References: <20220628132835.8925-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656422928; a=rsa-sha256; cv=none; b=6XJzwaCi2QOW3267v/p2epp9P9SBaPBuwuKyC+tXlG6MBQp27LRXdn7AE47H9YiQ+uPkwF a2wjIYG2wGUBZHAKv5hwPDAFlxwh521GejoKQE2kcfIJbxFi5z6f/Ljfw+OTnpo+hgPf5T ZvDl68z0mo/s2CA8Qi5jUHyTr2hkwlY= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf09.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656422928; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rKThsZUhHJEFQgKdS11IMf5VveaH/XIRUuLSDRAZSgk=; b=JD1/S0xF5g5gqAUaTTV+XP+Sv0O02yjBiMiHk0BqEz0sru9DSOS7ARFq+21LmokXPMEVEa T3GEpb9cdMj6IwXxReN9ryc+xNyW80ErEM75T4EOji8H2UfYDKZqRGUhHcXS73OXgSLpcR qRXRHUvXgiDCsRAQhSAvSezPM3pl4lQ= X-Stat-Signature: jkhohieqqzbu48wy9z7wew7hogmfkcfm X-Rspam-User: X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 78DB6140037 Authentication-Results: imf09.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf09.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-HE-Tag: 1656422928-690439 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: Use helper macro __ATTR_RW to define use_zero_page_attr, defrag_attr and enabled_attr to make code more clear. Minor readability improvement. Signed-off-by: Miaohe Lin Reviewed-by: Muchun Song --- mm/huge_memory.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 1cb51eb5a60c..7570e7681f95 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -276,8 +276,8 @@ static ssize_t enabled_store(struct kobject *kobj, } return ret; } -static struct kobj_attribute enabled_attr = - __ATTR(enabled, 0644, enabled_show, enabled_store); + +static struct kobj_attribute enabled_attr = __ATTR_RW(enabled); ssize_t single_hugepage_flag_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf, @@ -366,8 +366,7 @@ static ssize_t defrag_store(struct kobject *kobj, return count; } -static struct kobj_attribute defrag_attr = - __ATTR(defrag, 0644, defrag_show, defrag_store); +static struct kobj_attribute defrag_attr = __ATTR_RW(defrag); static ssize_t use_zero_page_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) @@ -381,8 +380,7 @@ static ssize_t use_zero_page_store(struct kobject *kobj, return single_hugepage_flag_store(kobj, attr, buf, count, TRANSPARENT_HUGEPAGE_USE_ZERO_PAGE_FLAG); } -static struct kobj_attribute use_zero_page_attr = - __ATTR(use_zero_page, 0644, use_zero_page_show, use_zero_page_store); +static struct kobj_attribute use_zero_page_attr = __ATTR_RW(use_zero_page); static ssize_t hpage_pmd_size_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) From patchwork Tue Jun 28 13:28:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12898291 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 19D0CC433EF for ; Tue, 28 Jun 2022 13:28:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 866D18E0006; Tue, 28 Jun 2022 09:28:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7F0138E0007; Tue, 28 Jun 2022 09:28:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5CEA68E0006; Tue, 28 Jun 2022 09:28:46 -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 3E9B18E0007 for ; Tue, 28 Jun 2022 09:28:46 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 06E5A12054C for ; Tue, 28 Jun 2022 13:28:46 +0000 (UTC) X-FDA: 79627724652.09.1493B4E Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf15.hostedemail.com (Postfix) with ESMTP id 656A4A000E for ; Tue, 28 Jun 2022 13:28:45 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4LXQPR5TZ2zkWy6; Tue, 28 Jun 2022 21:27:23 +0800 (CST) Received: from huawei.com (10.175.124.27) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 28 Jun 2022 21:28:42 +0800 From: Miaohe Lin To: CC: , , , , , , Subject: [PATCH v2 09/16] mm/huge_memory: fix comment in zap_huge_pud Date: Tue, 28 Jun 2022 21:28:28 +0800 Message-ID: <20220628132835.8925-10-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220628132835.8925-1-linmiaohe@huawei.com> References: <20220628132835.8925-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656422925; a=rsa-sha256; cv=none; b=LwqOf8Y0/NPWmzjlgcJIUmlIYJqfnmDn+Tf7B9p05elljxgNHHGxExKW5amSUA76vMKeej W1uv1AtpYtJK2RMdeP9QmVnP7KjpukdFydJbuW7rW9MUUZvs+Sl2MsIOKlIs00O2uRtE8o RJdpf+ZiLZDXeUxe0uDLiVSdVgr6nkg= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=none; spf=pass (imf15.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656422925; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ii6YAGgldx2YHIsjkoj0tyH3l00Uc1wyqKPBff0VP58=; b=q8PozOW5k60VH++1B3u3E29W5JpVv+ts2lYIZoibnJXc/bGYj2kmvmJzqfJ2HKZDW3dmYz alVhgietrQwCsbF/IEizEJNk/X+DpcO3JDBjCn9rzE8hrsHiIcxbT0cTuF5EQTVE8yBvc2 HOCsDiZLLK5ObTxGn5VNi+W1fO3yEXg= X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 656A4A000E Authentication-Results: imf15.hostedemail.com; dkim=none; spf=pass (imf15.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Rspam-User: X-Stat-Signature: 3dhmj66oek1qu5hhnzrr1dkhqj4oo566 X-HE-Tag: 1656422925-851674 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: The comment about deposited pgtable is borrowed from zap_huge_pmd but there's no deposited pgtable stuff for huge pud in zap_huge_pud. Remove it to avoid confusion. Signed-off-by: Miaohe Lin --- mm/huge_memory.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 7570e7681f95..b0fc3c560245 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2013,12 +2013,7 @@ int zap_huge_pud(struct mmu_gather *tlb, struct vm_area_struct *vma, ptl = __pud_trans_huge_lock(pud, vma); if (!ptl) return 0; - /* - * For architectures like ppc64 we look at deposited pgtable - * when calling pudp_huge_get_and_clear. So do the - * pgtable_trans_huge_withdraw after finishing pudp related - * operations. - */ + pudp_huge_get_and_clear_full(tlb->mm, addr, pud, tlb->fullmm); tlb_remove_pud_tlb_entry(tlb, pud, addr); if (vma_is_special_huge(vma)) { From patchwork Tue Jun 28 13:28:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12898293 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 9BC9ECCA479 for ; Tue, 28 Jun 2022 13:28:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9EE8B8E000A; Tue, 28 Jun 2022 09:28:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 92CFC8E0009; Tue, 28 Jun 2022 09:28:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 61D178E000A; Tue, 28 Jun 2022 09:28:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 446DD8E0007 for ; Tue, 28 Jun 2022 09:28:48 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 25E2F352C7 for ; Tue, 28 Jun 2022 13:28:48 +0000 (UTC) X-FDA: 79627724736.30.6479083 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf27.hostedemail.com (Postfix) with ESMTP id 1DD3840030 for ; Tue, 28 Jun 2022 13:28:46 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.56]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4LXQNN1VVjz1L8Vy; Tue, 28 Jun 2022 21:26:28 +0800 (CST) Received: from huawei.com (10.175.124.27) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 28 Jun 2022 21:28:42 +0800 From: Miaohe Lin To: CC: , , , , , , Subject: [PATCH v2 10/16] mm/huge_memory: check pmd_present first in is_huge_zero_pmd Date: Tue, 28 Jun 2022 21:28:29 +0800 Message-ID: <20220628132835.8925-11-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220628132835.8925-1-linmiaohe@huawei.com> References: <20220628132835.8925-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656422927; a=rsa-sha256; cv=none; b=UNiWtWpATJ9FQ7YHpNzW1jqcqeMCFuaM3xVTTjsp477kv29pwolJ4Z3XryQDAmQxgnVYwy MLlSqVujckoKVVKKg3uTVU5nZojuk2MX482vf0Ux7paxHgPrpe148jwtUyd6Lnsdt5GY4m hmZHAy+FchGl0XoWuX6wCac2NqNZq80= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf27.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656422927; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ov5V1IijnivfSbRK2t3YxqwmWEWJ/UmjMAfIm/UGGqY=; b=zqNCXDZn/3PzXT+tK2C76ZP+QCJkZbR5cQAaOlCKO8u594CLJeKi+yIwQQ/d6807Gtv+cW s/mjq2sIN8Wrl75F3y++6zxtkDwyn7gXzbdWuA1rsXLAGaVTWCDdZseVwa3mEWbNOXGTZT 55UQ5ZO7ELTMC0INTmWJZCoARfdllJc= X-Stat-Signature: gk8dr8aga434c5cs7etrpo8c6z489gao X-Rspam-User: X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 1DD3840030 Authentication-Results: imf27.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf27.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-HE-Tag: 1656422926-231500 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: When pmd is non-present, pmd_pfn returns an insane value. So we should check pmd_present first to avoid acquiring such insane value and also avoid touching possible cold huge_zero_pfn cache line when pmd isn't present. Signed-off-by: Miaohe Lin Reviewed-by: Muchun Song --- include/linux/huge_mm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index ae3d8e2fd9e2..12b297f9951d 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -273,7 +273,7 @@ static inline bool is_huge_zero_page(struct page *page) static inline bool is_huge_zero_pmd(pmd_t pmd) { - return READ_ONCE(huge_zero_pfn) == pmd_pfn(pmd) && pmd_present(pmd); + return pmd_present(pmd) && READ_ONCE(huge_zero_pfn) == pmd_pfn(pmd); } static inline bool is_huge_zero_pud(pud_t pud) From patchwork Tue Jun 28 13:28:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12898294 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 EAD8EC433EF for ; Tue, 28 Jun 2022 13:28:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D56BE8E0007; Tue, 28 Jun 2022 09:28:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BEA6D8E000B; Tue, 28 Jun 2022 09:28:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 77F6D8E0007; Tue, 28 Jun 2022 09:28:48 -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 5706E8E0009 for ; Tue, 28 Jun 2022 09:28:48 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id B12DC60762 for ; Tue, 28 Jun 2022 13:28:47 +0000 (UTC) X-FDA: 79627724694.20.52190E6 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf25.hostedemail.com (Postfix) with ESMTP id 51596A003D for ; Tue, 28 Jun 2022 13:28:46 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4LXQPS5w0YzkX1h; Tue, 28 Jun 2022 21:27:24 +0800 (CST) Received: from huawei.com (10.175.124.27) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 28 Jun 2022 21:28:43 +0800 From: Miaohe Lin To: CC: , , , , , , Subject: [PATCH v2 11/16] mm/huge_memory: try to free subpage in swapcache when possible Date: Tue, 28 Jun 2022 21:28:30 +0800 Message-ID: <20220628132835.8925-12-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220628132835.8925-1-linmiaohe@huawei.com> References: <20220628132835.8925-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656422927; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=z/KWpKxhovlvl8821GirzUIvgllp109XeOztU+qtPrg=; b=R7JbcKKRXizXLGxtk9/3mxLDG5vvapaF1RK2nKTq/7JoJ/wuLsBUnziQej3o/V02JTbcXr fUxpd8p8l1LieBrUyWO1cN1x4jNMowHALqacbMwG2dhiYdqp7XDNi15mhX3C1W6oDLbJv1 gu1jtr5GLsOrib+I4WXA5FMMtr+w9VY= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=none; spf=pass (imf25.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656422927; a=rsa-sha256; cv=none; b=8mgwYDTKSXrzGzlQ9XSdihnmBxBCrgnxnvM0KvVZO6bw1h82cB7LVk/IAhuYWeyMTb7h4p UHqQOhVIBS7Y1uFmbrj0DCQfAST47D5/pXnZmH03BTWFIGMESdmcXFT2TWt2yIaoqWujlE y74hWVPR7RM3pw02+e5PgP3xlZCv01U= Authentication-Results: imf25.hostedemail.com; dkim=none; spf=pass (imf25.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Rspam-User: X-Rspamd-Server: rspam06 X-Stat-Signature: mo1hyxqkrwa7dmz8jixcsk3kdtjmbgqe X-Rspamd-Queue-Id: 51596A003D X-HE-Tag: 1656422926-544803 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: Subpages in swapcache won't be freed even if it is the last user of the page until next time reclaim. It shouldn't hurt indeed, but we could try to free these pages to save more memory for system. Signed-off-by: Miaohe Lin --- mm/huge_memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index b0fc3c560245..bded58ada414 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2638,7 +2638,7 @@ static void __split_huge_page(struct page *page, struct list_head *list, * requires taking the lru_lock so we do the put_page * of the tail pages after the split is complete. */ - put_page(subpage); + free_page_and_swap_cache(subpage); } } From patchwork Tue Jun 28 13:28:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12898296 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 B45D3CCA479 for ; Tue, 28 Jun 2022 13:28:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 782828E000B; Tue, 28 Jun 2022 09:28:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 498058E000D; Tue, 28 Jun 2022 09:28:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 24DCB8E0009; Tue, 28 Jun 2022 09:28:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id E64CB8E000C for ; Tue, 28 Jun 2022 09:28:48 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id B34F7896 for ; Tue, 28 Jun 2022 13:28:48 +0000 (UTC) X-FDA: 79627724736.13.8555245 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf21.hostedemail.com (Postfix) with ESMTP id 293991C0024 for ; Tue, 28 Jun 2022 13:28:48 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4LXQQD4qlWz9skG; Tue, 28 Jun 2022 21:28:04 +0800 (CST) Received: from huawei.com (10.175.124.27) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 28 Jun 2022 21:28:43 +0800 From: Miaohe Lin To: CC: , , , , , , Subject: [PATCH v2 12/16] mm/huge_memory: minor cleanup for split_huge_pages_all Date: Tue, 28 Jun 2022 21:28:31 +0800 Message-ID: <20220628132835.8925-13-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220628132835.8925-1-linmiaohe@huawei.com> References: <20220628132835.8925-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656422928; a=rsa-sha256; cv=none; b=bPQrCqvZChHJmZfnmuia8kcb5c/xyUG7c4SDRSciwbENK+xATz6PbqDp01b6Ayy/InV0I+ xDJLlixS4xh17TM0mOH0bu4ceNnJ4Jd9aV6yYvDkqjNWBkGmcOPkhXV5tHT+tscr/Hb20b 6Ll7YgTWy8aGyi9Td5plLrIZ0o/gFAQ= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=none; spf=pass (imf21.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656422928; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MnsL7pXT73vfl7zOZ3MxFqXXtKUWvwiDrKAN2i6LEIs=; b=d53bY+H/5hddBZMuWdlR/JkAsH8UPbz6aPqawKIN+X/I4SyCXb9a4lLCkcvVnVX6Utsd21 QHRk0y/6Pd1xM3Ae09QuNb1ABfl1GYQLu6EA444qOvLyTyW96XfsjRuq67obFgMRjktMGS M2fPda13QT/EX0XToOLZ68RPNFuiZRM= X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 293991C0024 Authentication-Results: imf21.hostedemail.com; dkim=none; spf=pass (imf21.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Rspam-User: X-Stat-Signature: ms4zdiygqtppenytas5obgoyb9i451rm X-HE-Tag: 1656422928-975400 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: There is nothing to do if a zone doesn't have any pages managed by the buddy allocator. So we should check managed_zone instead. Also if a thp is found, there's no need to traverse the subpages again. Signed-off-by: Miaohe Lin --- mm/huge_memory.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index bded58ada414..5ea932beef22 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2956,9 +2956,12 @@ static void split_huge_pages_all(void) unsigned long total = 0, split = 0; pr_debug("Split all THPs\n"); - for_each_populated_zone(zone) { + for_each_zone(zone) { + if (!managed_zone(zone)) + continue; max_zone_pfn = zone_end_pfn(zone); for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++) { + int nr_pages; if (!pfn_valid(pfn)) continue; @@ -2974,8 +2977,10 @@ static void split_huge_pages_all(void) total++; lock_page(page); + nr_pages = thp_nr_pages(page); if (!split_huge_page(page)) split++; + pfn += nr_pages - 1; unlock_page(page); next: put_page(page); From patchwork Tue Jun 28 13:28:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12898299 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 B130EC43334 for ; Tue, 28 Jun 2022 13:29:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 312728E000C; Tue, 28 Jun 2022 09:28:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 22DE48E0010; Tue, 28 Jun 2022 09:28:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D73138E000D; Tue, 28 Jun 2022 09:28:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 98D808E000C for ; Tue, 28 Jun 2022 09:28:49 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 766C1606EF for ; Tue, 28 Jun 2022 13:28:49 +0000 (UTC) X-FDA: 79627724778.19.0B909F4 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf08.hostedemail.com (Postfix) with ESMTP id C4E8E16002F for ; Tue, 28 Jun 2022 13:28:48 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4LXQNP5pndz1L8h8; Tue, 28 Jun 2022 21:26:29 +0800 (CST) Received: from huawei.com (10.175.124.27) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 28 Jun 2022 21:28:44 +0800 From: Miaohe Lin To: CC: , , , , , , Subject: [PATCH v2 13/16] mm/huge_memory: fix comment of page_deferred_list Date: Tue, 28 Jun 2022 21:28:32 +0800 Message-ID: <20220628132835.8925-14-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220628132835.8925-1-linmiaohe@huawei.com> References: <20220628132835.8925-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf08.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656422929; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sB8Nv4dJ90LSK9KQiH8MPKFX6BaimpU4TGSajNrvRNo=; b=Bnvc4CbmyBCDxTLurZ74QXFH95nuxbVAmigsP0rrNb/I6NtHKP4yERtsCpx/uF8whybofW GIg0kgVRH3dAObAaJ0UM0f/vmDvRVt7b3y7gyx2s0Vvr7bRJJh1RafGRcbnrGqdvCgs3N7 CfvzEKefof1DDTAL8PeuvWU4wXbSJaw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656422929; a=rsa-sha256; cv=none; b=sa1cisHHvAIms1NhzgkSX3eivOTpfqbyfX/D6qlBlAwMQzSqHua+IBxbwsI7ftsaeGZLua tBBkAUwuZeBBMX8RJVJv0mZ9reXvnM8d64HsYaNJjClZNyG+DHwqUuFEPi7Tp62B072Ggx 53uPKKSCw4lMUt6J4ZbVOBQuaFVtQnM= X-Stat-Signature: rd3timkih87e9wm3bcppoitjoqqxoo5c X-Rspamd-Queue-Id: C4E8E16002F X-Rspam-User: Authentication-Results: imf08.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf08.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Rspamd-Server: rspam12 X-HE-Tag: 1656422928-452015 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: The current comment is confusing because if global or memcg deferred list in the second tail page is occupied by compound_head, why we still use page[2].deferred_list here? I think it wants to say that Global or memcg deferred list in the first tail page is occupied by compound_mapcount and compound_pincount so we use the second tail page's deferred_list instead. Signed-off-by: Miaohe Lin --- include/linux/huge_mm.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index 12b297f9951d..37f2f11a6d7e 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -294,8 +294,8 @@ static inline bool thp_migration_supported(void) static inline struct list_head *page_deferred_list(struct page *page) { /* - * Global or memcg deferred list in the second tail pages is - * occupied by compound_head. + * See organization of tail pages of compound page in + * "struct page" definition. */ return &page[2].deferred_list; } From patchwork Tue Jun 28 13:28:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12898295 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 5EF6FC43334 for ; Tue, 28 Jun 2022 13:28:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4A2E68E000E; Tue, 28 Jun 2022 09:28:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 35E978E000B; Tue, 28 Jun 2022 09:28:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 058538E000E; Tue, 28 Jun 2022 09:28:48 -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 C67148E0009 for ; Tue, 28 Jun 2022 09:28:48 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 990EF120F23 for ; Tue, 28 Jun 2022 13:28:48 +0000 (UTC) X-FDA: 79627724736.19.72822A2 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf27.hostedemail.com (Postfix) with ESMTP id 17C4B40036 for ; Tue, 28 Jun 2022 13:28:47 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4LXQPV31sqzkX23; Tue, 28 Jun 2022 21:27:26 +0800 (CST) Received: from huawei.com (10.175.124.27) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 28 Jun 2022 21:28:45 +0800 From: Miaohe Lin To: CC: , , , , , , Subject: [PATCH v2 14/16] mm/huge_memory: correct comment of prep_transhuge_page Date: Tue, 28 Jun 2022 21:28:33 +0800 Message-ID: <20220628132835.8925-15-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220628132835.8925-1-linmiaohe@huawei.com> References: <20220628132835.8925-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656422928; a=rsa-sha256; cv=none; b=orbV6WJgTAVXkQI2Hz4gu+KAi9iIdVg3XznrjhSZbVgL8bU6+F5Bvj4rD1R9XtC/5wZ7Sd yucpkU3JXRVxU38B5qPqf7q24jgH574xmyDs0WPR3yxWTKa6WAvcQLKyp5n5IJ/VNZW6/7 9cVSh8hFvU5Alt9ZjDbOM+PTPHEIb60= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf27.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656422928; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qfeOE9EWUpeoWlBAfRE9JMYLZRLbzVrXzuw1c8sgU+k=; b=icYXdKBwGuHmELYaG8LJ8sxaa3Pr/+SMkQmylneCE+iU8WYYmIMIQzJWgHQvk6Gc/oFL4V dS6wiVXRm8pwmKhK6Lp3vM2mbe8/s8CtPrcfROIQQ4+XZ1CdRrlrIi/G3FdW3pO5Vgypfc C8zDWiqCvDqpwRXH11KE0I5Qc0w2hlQ= X-Rspam-User: X-Stat-Signature: az3nyjkyfecg7az9ns1izeetum3n3jzy X-Rspamd-Queue-Id: 17C4B40036 Authentication-Results: imf27.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf27.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Rspamd-Server: rspam03 X-HE-Tag: 1656422927-239885 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: We use page->mapping and page->index, instead of page->indexlru in second tail page as list_head. Correct it. Signed-off-by: Miaohe Lin Reviewed-by: Muchun Song --- mm/huge_memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 5ea932beef22..36570d800f21 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -681,7 +681,7 @@ static inline void split_queue_unlock_irqrestore(struct deferred_split *queue, void prep_transhuge_page(struct page *page) { /* - * we use page->mapping and page->indexlru in second tail page + * we use page->mapping and page->index in second tail page * as list_head: assuming THP order >= 2 */ From patchwork Tue Jun 28 13:28:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12898301 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 CDE64C43334 for ; Tue, 28 Jun 2022 13:29:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 646E08E0010; Tue, 28 Jun 2022 09:28:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 556588E000D; Tue, 28 Jun 2022 09:28:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1B18E8E0010; Tue, 28 Jun 2022 09:28:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D13B68E000D for ; Tue, 28 Jun 2022 09:28:50 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 38A2532E68 for ; Tue, 28 Jun 2022 13:28:50 +0000 (UTC) X-FDA: 79627724820.16.A7C0C51 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf13.hostedemail.com (Postfix) with ESMTP id 2C7712003C for ; Tue, 28 Jun 2022 13:28:48 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4LXQNv5sP8zkWYD; Tue, 28 Jun 2022 21:26:55 +0800 (CST) Received: from huawei.com (10.175.124.27) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 28 Jun 2022 21:28:45 +0800 From: Miaohe Lin To: CC: , , , , , , Subject: [PATCH v2 15/16] mm/huge_memory: comment the subtly logic in __split_huge_pmd Date: Tue, 28 Jun 2022 21:28:34 +0800 Message-ID: <20220628132835.8925-16-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220628132835.8925-1-linmiaohe@huawei.com> References: <20220628132835.8925-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656422929; a=rsa-sha256; cv=none; b=Qf6kyz/fpcUvNbVF3gYhPZNthG2kFwkReLhDYdqn53n0p+A06XeW3zievdd/oeKrd+nEtN bJ3tXT+OOQ6wS6qJqO7C7TFmbVb7b6LC1L+0VaqyF6ZmkTpJvsscZvTJAEJTF4bklPUHxG ap63BxrF+7GiHICPMgFScU9m3bWFOHk= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; spf=pass (imf13.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656422929; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AQfxt4l5emHrLmAWIZ5cUt9orANIm+/V1mH/gXdu2oU=; b=4Dn3HFNW724GBuGNFJoXNJYitmkkqlSr1q8KNS0Cpw4IuGqGkUVeCS2c/HBl7GwUH38ow7 RcmNEeJRPTHcPb2VSViWna367ls0mtL3cOirJru2V4fyGp4CKhpFOfLQ/HV1rK0BZgMhUt 29I+NvCjGc/jopOBKLDCVKD8bayI5Ss= X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 2C7712003C Authentication-Results: imf13.hostedemail.com; dkim=none; spf=pass (imf13.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Rspam-User: X-Stat-Signature: wyorpb464zttj1nb6co4nkkpnugdxyzn X-HE-Tag: 1656422928-129616 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: It's dangerous and wrong to call page_folio(pmd_page(*pmd)) when pmd isn't present. But the caller guarantees pmd is present when folio is set. So we should be safe here. Add comment to make it clear. Signed-off-by: Miaohe Lin --- mm/huge_memory.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 36570d800f21..1d32349a95f4 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2335,6 +2335,10 @@ void __split_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd, if (pmd_trans_huge(*pmd) || pmd_devmap(*pmd) || is_pmd_migration_entry(*pmd)) { + /* + * It's safe to call pmd_page when folio is set because it's + * guaranteed that pmd is present. + */ if (folio && folio != page_folio(pmd_page(*pmd))) goto out; __split_huge_pmd_locked(vma, pmd, range.start, freeze); From patchwork Tue Jun 28 13:28:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12898300 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 59921C433EF for ; Tue, 28 Jun 2022 13:29:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 35D258E0011; Tue, 28 Jun 2022 09:28:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 29DBF8E000D; Tue, 28 Jun 2022 09:28:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0C5ED8E0011; Tue, 28 Jun 2022 09:28:50 -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 D958F8E0010 for ; Tue, 28 Jun 2022 09:28:50 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id AF85F34940 for ; Tue, 28 Jun 2022 13:28:50 +0000 (UTC) X-FDA: 79627724820.01.69E1A8F Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf17.hostedemail.com (Postfix) with ESMTP id D4C0240031 for ; Tue, 28 Jun 2022 13:28:49 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4LXQPW3RbYzkX2G; Tue, 28 Jun 2022 21:27:27 +0800 (CST) Received: from huawei.com (10.175.124.27) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 28 Jun 2022 21:28:46 +0800 From: Miaohe Lin To: CC: , , , , , , Subject: [PATCH v2 16/16] mm/huge_memory: use helper macro IS_ERR_OR_NULL in split_huge_pages_pid Date: Tue, 28 Jun 2022 21:28:35 +0800 Message-ID: <20220628132835.8925-17-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220628132835.8925-1-linmiaohe@huawei.com> References: <20220628132835.8925-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656422930; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=v9O1zeh5Ckq8WNu7To2V4yg0JhSvSIj/fHLqw48O09w=; b=WSKMXn7GVEj6qJ8j9nBar884NYWLUfmjsa/JZr9LNuERtyYQwTbVh6KkKOjW033udakvBz BubwgFPQ/i9qCAwvSAqryi6xWPrc24Gs7BQJppwCuOxN6UFwrmVGlI6KVjGNc3GVoDi42P dElj7BESdkJyDT1MTDZvqq+hcYsvH8Q= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=none; spf=pass (imf17.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656422930; a=rsa-sha256; cv=none; b=arvXkoNiljes/WPV0+HiFrFp6Vi3Gjerrp1Pr8w5uPI1lyz3hf5AjNsK7+prfawmDmsjc8 fjKyonvJV6jfbhOO/HmatZ4PAYojKsT8pxyV1H3eTX5Sqitj5A5J2rLysDi5XcHky5RBna az4g9QLeQluJ3DO0BexG8Akg3pdszIw= Authentication-Results: imf17.hostedemail.com; dkim=none; spf=pass (imf17.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Rspam-User: X-Rspamd-Server: rspam06 X-Stat-Signature: o37kngoc6yddqqqy61fz5ed4jdmz6cgs X-Rspamd-Queue-Id: D4C0240031 X-HE-Tag: 1656422929-946322 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: Use helper macro IS_ERR_OR_NULL to check the validity of page to simplify the code. Minor readability improvement. Signed-off-by: Miaohe Lin Reviewed-by: Muchun Song --- mm/huge_memory.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 1d32349a95f4..b406fe08b2c9 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -3057,9 +3057,7 @@ static int split_huge_pages_pid(int pid, unsigned long vaddr_start, /* FOLL_DUMP to ignore special (like zero) pages */ page = follow_page(vma, addr, FOLL_GET | FOLL_DUMP | FOLL_LRU); - if (IS_ERR(page)) - continue; - if (!page) + if (IS_ERR_OR_NULL(page)) continue; if (!is_transparent_hugepage(page))