From patchwork Mon Jul 4 13:21:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12905356 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 8A2BBC433EF for ; Mon, 4 Jul 2022 13:22:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9C58B6B0072; Mon, 4 Jul 2022 09:22:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7809B6B007B; Mon, 4 Jul 2022 09:22:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 50CEC6B0073; Mon, 4 Jul 2022 09:22:16 -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 2E56B6B0075 for ; Mon, 4 Jul 2022 09:22:16 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id EB07533E0B for ; Mon, 4 Jul 2022 13:22:15 +0000 (UTC) X-FDA: 79649481030.16.E7F2E17 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf14.hostedemail.com (Postfix) with ESMTP id DDA5E10009D for ; Mon, 4 Jul 2022 13:22:14 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Lc5wW4fm5zTgWm; Mon, 4 Jul 2022 21:18:35 +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; Mon, 4 Jul 2022 21:22:09 +0800 From: Miaohe Lin To: CC: , , , , , , Subject: [PATCH v3 01/16] mm/huge_memory: use flush_pmd_tlb_range in move_huge_pmd Date: Mon, 4 Jul 2022 21:21:46 +0800 Message-ID: <20220704132201.14611-2-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220704132201.14611-1-linmiaohe@huawei.com> References: <20220704132201.14611-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; imf14.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf14.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656940935; a=rsa-sha256; cv=none; b=5tiA4uHNcjqEWI+9RjWRbvEFyvC8Vu4AFQlWudRASbo/d2CZriKNEjCIMZsBPc8L57M2bX 9eZtbWi+YFrPEYr5K+kw4qp1FpR2h1pFEFzgqhIQhwQw/SG8sfkq3yadMSD0CspDoqIkb1 107LJdeZCHakPFBZxRsQIvZqo9yQ7yU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656940935; 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=judNtQ8xVDqB1Asw8FTXBYESomphxFHgbdHU1fY9EyQ=; b=5ui+bW8TTnns0RgT1yCCinUf4TdF+uw+VWhhLc0yO7aWxtoQGEpasVFKrnyIGs9ygnuHPk mEwc5d1S2xfRJQ1B/odR+LiB3DyIG2wdHSDBkDPjj2hyDMRl7rniE4dNzgffxpQ5luPQD4 7sY9073om3IDLfzpcuF6uDecxfd3i6c= Authentication-Results: imf14.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf14.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: x8ejesqr54gqxtx9bg3w5hpj3wpofgwm X-Rspamd-Queue-Id: DDA5E10009D X-HE-Tag: 1656940934-981123 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 0243105d0cc6..f4e581eefb67 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1850,7 +1850,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 Mon Jul 4 13:21:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12905355 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 B5B64C43334 for ; Mon, 4 Jul 2022 13:22:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 72D6D6B0075; Mon, 4 Jul 2022 09:22:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 61D396B0074; Mon, 4 Jul 2022 09:22:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 46EE66B007B; Mon, 4 Jul 2022 09:22:16 -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 2D46B6B0074 for ; Mon, 4 Jul 2022 09:22:16 -0400 (EDT) Received: from smtpin31.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 073BD802BD for ; Mon, 4 Jul 2022 13:22:16 +0000 (UTC) X-FDA: 79649481072.31.9A6BB0E Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf20.hostedemail.com (Postfix) with ESMTP id 673E51C004C for ; Mon, 4 Jul 2022 13:22:15 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Lc5wX1FZqzTgWr; Mon, 4 Jul 2022 21:18:36 +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; Mon, 4 Jul 2022 21:22:10 +0800 From: Miaohe Lin To: CC: , , , , , , Subject: [PATCH v3 02/16] mm/huge_memory: access vm_page_prot with READ_ONCE in remove_migration_pmd Date: Mon, 4 Jul 2022 21:21:47 +0800 Message-ID: <20220704132201.14611-3-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220704132201.14611-1-linmiaohe@huawei.com> References: <20220704132201.14611-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=1656940935; 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=qxlrQq8tazFnfwy9DbvAwZNIpRhTOeKdOtlhHSc7boM=; b=7HfYLdKIVCR2dw2R8XR0KHVFFyLwG/2sVDQ465PM/sLW9QEoU8+Ke6xjjzIrdOBGaqPXZf L3iznPwFQmdBCpyC0BuvhhtaPHN5EG+FDXnTNKpIJsP+kwak0fYxw4smQTCZCbGKDZH9xZ AV1dw0j6CYTG6OAQq1gMMU1LbcGlYV0= 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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656940935; a=rsa-sha256; cv=none; b=BTMbtE6dKq4shWkuovMzh+gOupa/VlaG4Y4fcinidFBN7LuSUTml1rWWCJw+J4aECaLeha DGg1g106kbqpr22dCCRlzqPPHnLqYUp4qkyNH5ggGHNWLs/EB4Dh/dNIJzncQ/D1ILx4Lq iZ4yFTDy3ALS2X11xUqDWGwo8aymLxw= 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-Rspamd-Queue-Id: 673E51C004C X-Stat-Signature: jhn1iuwukj4cpq4chhj99ddroymj4bd5 X-Rspam-User: X-HE-Tag: 1656940935-478756 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 f4e581eefb67..a010f9ba15ce 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -3309,7 +3309,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 Mon Jul 4 13:21:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12905357 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 59D16C43334 for ; Mon, 4 Jul 2022 13:22:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E5E616B007B; Mon, 4 Jul 2022 09:22:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E3EE56B0074; Mon, 4 Jul 2022 09:22:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D22406B007B; Mon, 4 Jul 2022 09:22:16 -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 BB3AB6B0073 for ; Mon, 4 Jul 2022 09:22:16 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 8F2C8609F0 for ; Mon, 4 Jul 2022 13:22:16 +0000 (UTC) X-FDA: 79649481072.09.9338CA6 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf18.hostedemail.com (Postfix) with ESMTP id 8276E1C0002 for ; Mon, 4 Jul 2022 13:22:15 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Lc5xw0Rr4zhZ1F; Mon, 4 Jul 2022 21:19:48 +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; Mon, 4 Jul 2022 21:22:10 +0800 From: Miaohe Lin To: CC: , , , , , , Subject: [PATCH v3 03/16] mm/huge_memory: fix comment of __pud_trans_huge_lock Date: Mon, 4 Jul 2022 21:21:48 +0800 Message-ID: <20220704132201.14611-4-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220704132201.14611-1-linmiaohe@huawei.com> References: <20220704132201.14611-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=1656940935; 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=17WeH6O2lVSKbTQAoKCVetXnYNodlY+mgRoRKSgt14g=; b=ALG5N3ioeeVn9TRjYuxYPBXAsUSMQnF0YOuFdAfBfGx0he2tjRjO5i14nQorHjbRj6LTG/ IYyfHpWIW1SuJQdgPMERR+PX5cx+Koe5P06lTI8Q5wNBCWi7x2jD3+zaWZpgl2WbaVd+CV CE1qLJzsOXVBuXVMNi/5e7c0+qj99zo= 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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656940935; a=rsa-sha256; cv=none; b=8Yymdaa4fZ6IZAgCEKi4hdBE09jKiFSiXRwZ51yDwOnG1tzxFTEgM79Al3F8UfZdpn0pfN hPg0NWf+AYYa84D7O2JFPvCOA5bokZx82//ESIofB9jAotOosGWYgOCHYx/4Gryvva37ff ymlT11huKcNf2PNlmNkhukNg66X2xOU= 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: rspam10 X-Rspamd-Queue-Id: 8276E1C0002 X-Stat-Signature: 93kjbbstw8mj3u1zogxdegjz7otnzwz3 X-Rspam-User: X-HE-Tag: 1656940935-60131 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 a010f9ba15ce..212e092d8ad0 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2007,10 +2007,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 Mon Jul 4 13:21:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12905361 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 533F9C43334 for ; Mon, 4 Jul 2022 13:22:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 415236B0074; Mon, 4 Jul 2022 09:22:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 38B9E6B0081; Mon, 4 Jul 2022 09:22:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 18B4C6B0074; Mon, 4 Jul 2022 09:22:19 -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 F2C636B0074 for ; Mon, 4 Jul 2022 09:22:18 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id ABBFD3409B for ; Mon, 4 Jul 2022 13:22:18 +0000 (UTC) X-FDA: 79649481156.17.35DC519 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf09.hostedemail.com (Postfix) with ESMTP id 102A514004B for ; Mon, 4 Jul 2022 13:22:17 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Lc5wY35B9zTgXN; Mon, 4 Jul 2022 21:18:37 +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; Mon, 4 Jul 2022 21:22:11 +0800 From: Miaohe Lin To: CC: , , , , , , Subject: [PATCH v3 04/16] mm/huge_memory: use helper touch_pud in huge_pud_set_accessed Date: Mon, 4 Jul 2022 21:21:49 +0800 Message-ID: <20220704132201.14611-5-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220704132201.14611-1-linmiaohe@huawei.com> References: <20220704132201.14611-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.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=1656940938; 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=gUYgRvKJ8kh2fISp+kC9oO3XFw+alxACj4/dI9Ort9s=; b=6E86ojAJiAuv7xYwYn5syIqP8NoBtt8QL7c1clpCTTQO2bK2usxFebc/3TVWWn9jd0P67F Cp3vsBXQuH3CUeDiZQPGjB6MedYnZbnEORskFbh+BpsuZjWPxL8WZuhIreSyf2x6eavxFT lX1uvAo4UIJ+tqQTNELJF6B4seF7OHo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656940938; a=rsa-sha256; cv=none; b=G6K9GyBQd1yO/O7V3wROONm6/lUbNqkSa/o0ROJckfnJC/Japnpxp8Kq0i7nWglap+2Vpm e+28dTonH7TGw1pmNu0JHG/+u1ROYHf0ZSFCNKCVNQzSXUsS35HCh9DOcp1HkbSOxd81sn sH+CjgjXn4UByOOLA37l9kHRRXaZPhc= X-Stat-Signature: 41nbfh5ww38hc83knfxiqkinxxcsapjc X-Rspamd-Queue-Id: 102A514004B 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.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Rspamd-Server: rspam03 X-Rspam-User: X-HE-Tag: 1656940937-953097 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 Reviewed-by: Muchun Song --- 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 212e092d8ad0..30acb3b994cf 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1285,15 +1285,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); } @@ -1320,7 +1320,7 @@ struct page *follow_devmap_pud(struct vm_area_struct *vma, unsigned long addr, return NULL; if (flags & FOLL_TOUCH) - touch_pud(vma, addr, pud, flags); + touch_pud(vma, addr, pud, flags & FOLL_WRITE); /* * device mapped pages can only be returned if the @@ -1385,21 +1385,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 Mon Jul 4 13:21:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12905363 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 88512C433EF for ; Mon, 4 Jul 2022 13:22:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E37716B0081; Mon, 4 Jul 2022 09:22:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D96EC6B0082; Mon, 4 Jul 2022 09:22:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BA4496B0085; Mon, 4 Jul 2022 09:22:19 -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 A45316B0082 for ; Mon, 4 Jul 2022 09:22:19 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 8382D35859 for ; Mon, 4 Jul 2022 13:22:19 +0000 (UTC) X-FDA: 79649481198.20.7C9E32C Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf11.hostedemail.com (Postfix) with ESMTP id C9ED94005E for ; Mon, 4 Jul 2022 13:22:18 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Lc5wY6hkDzTgX4; Mon, 4 Jul 2022 21:18:37 +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; Mon, 4 Jul 2022 21:22:12 +0800 From: Miaohe Lin To: CC: , , , , , , Subject: [PATCH v3 05/16] mm/huge_memory: use helper touch_pmd in huge_pmd_set_accessed Date: Mon, 4 Jul 2022 21:21:50 +0800 Message-ID: <20220704132201.14611-6-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220704132201.14611-1-linmiaohe@huawei.com> References: <20220704132201.14611-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=1656940939; 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=AS2SBTSZET7G7PWl/TXlHv2d48jYbgUQXowIDNDN2MA=; b=NVk9NKIXYwqQ+Su6RhOqShvyy1UMAjDTVKPAvGSnaWHmeUYc+kfF1k4YWPFt7VteMit84U gFduzbjSqbChThgTa1JLnmY8kZvLYlThQKOELA9bS+xQpcLHlUxuGILfvNgjfMrFSQi9XL aZRyzytvtzRr9JnZP7gGfT5G0ElFD/I= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf11.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656940939; a=rsa-sha256; cv=none; b=Mh/8sc9vjfeQ4ZftD6GVSs4BPuwWAf45nNd1dh4UFHaNqwZ8Ga34n1cYNr9BpKdJJBlfU8 3UFJYjJUeAqmuqoYtev375Rwbpb6olUV1utGvfYZUoRxScTorPoQ7RoznXsKHJyP/CM4rV ojLHCuDJiL9TZjomUIkFoPCww8tBiKQ= X-Rspam-User: X-Rspamd-Queue-Id: C9ED94005E Authentication-Results: imf11.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf11.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Stat-Signature: kkasmt4on96hxe6q8witoumoy94msmmz X-Rspamd-Server: rspam08 X-HE-Tag: 1656940938-484606 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 Reviewed-by: Muchun Song --- mm/huge_memory.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 30acb3b994cf..f9b6eb3f2215 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1121,15 +1121,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); } @@ -1162,7 +1162,7 @@ struct page *follow_devmap_pmd(struct vm_area_struct *vma, unsigned long addr, return NULL; if (flags & FOLL_TOUCH) - touch_pmd(vma, addr, pmd, flags); + touch_pmd(vma, addr, pmd, flags & FOLL_WRITE); /* * device mapped pages can only be returned if the @@ -1399,21 +1399,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); @@ -1549,7 +1541,7 @@ struct page *follow_trans_huge_pmd(struct vm_area_struct *vma, return ERR_PTR(-ENOMEM); if (flags & FOLL_TOUCH) - touch_pmd(vma, addr, pmd, flags); + touch_pmd(vma, addr, pmd, flags & FOLL_WRITE); page += (addr & ~HPAGE_PMD_MASK) >> PAGE_SHIFT; VM_BUG_ON_PAGE(!PageCompound(page) && !is_zone_device_page(page), page); From patchwork Mon Jul 4 13:21:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12905359 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 BFCEBC43334 for ; Mon, 4 Jul 2022 13:22:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 61FB36B0073; Mon, 4 Jul 2022 09:22:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 55BCD6B0074; Mon, 4 Jul 2022 09:22:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3394E6B007E; Mon, 4 Jul 2022 09:22:18 -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 22E256B0073 for ; Mon, 4 Jul 2022 09:22:18 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id F0D7C1362 for ; Mon, 4 Jul 2022 13:22:17 +0000 (UTC) X-FDA: 79649481114.20.9947DC0 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf04.hostedemail.com (Postfix) with ESMTP id A19A540004 for ; Mon, 4 Jul 2022 13:22:16 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.55]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4Lc5zq0fk7zYd0r; Mon, 4 Jul 2022 21:21: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; Mon, 4 Jul 2022 21:22:12 +0800 From: Miaohe Lin To: CC: , , , , , , Subject: [PATCH v3 06/16] mm/huge_memory: rename mmun_start to haddr in remove_migration_pmd Date: Mon, 4 Jul 2022 21:21:51 +0800 Message-ID: <20220704132201.14611-7-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220704132201.14611-1-linmiaohe@huawei.com> References: <20220704132201.14611-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=1656940937; a=rsa-sha256; cv=none; b=HwGi26OUoi84LghH90mIW1Wz0AKYgwueOnEfqVLmpWOn3nG4nrUUQ+w50ohs4l6EWsJVf0 SovSPSIjvZWx+uAWJMpMnRn3SW03fPrU24+kvyv44wtfMGKmnvr+5QQB8yplpdjwe7VDyC chiqxxkIT8cWboZE3fYtRCC1K9BGrpQ= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=none; spf=pass (imf04.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=1656940937; 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=nb/kaVtf3azLZufmYbtGw7dT4P8q6msUXqZb3cE1Z90=; b=Gy3jmyWWB02YsiNqZhqrKwf3+Fk7suSAg6By5hBSducDpfgnPMKzhcG0tZdjGD8ElWC0rX +0mbQgSWVnWgj3Rbf0g7hDOQ1T34XRb8AuzOe7IRSgtLQfgxIFX0R9ZxvwF/3ziekHFDmP ske6gyGjQ51kSYG7dzcG/dIOhIMZzig= X-Stat-Signature: yhb7hygtpd8mr8rifhxpf83tuk343wmu X-Rspamd-Queue-Id: A19A540004 Authentication-Results: imf04.hostedemail.com; dkim=none; spf=pass (imf04.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-Rspamd-Server: rspam12 X-HE-Tag: 1656940936-259046 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 f9b6eb3f2215..f2856cfac900 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -3284,7 +3284,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; @@ -3307,12 +3307,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 Mon Jul 4 13:21:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12905366 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 184DFC433EF for ; Mon, 4 Jul 2022 13:22:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 81BF96B0088; Mon, 4 Jul 2022 09:22:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 77F886B0087; Mon, 4 Jul 2022 09:22:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5F6866B0088; Mon, 4 Jul 2022 09:22:21 -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 3E1A46B0087 for ; Mon, 4 Jul 2022 09:22:21 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id D3DBC20F1D for ; Mon, 4 Jul 2022 13:22:20 +0000 (UTC) X-FDA: 79649481240.04.E43A200 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf24.hostedemail.com (Postfix) with ESMTP id 5D5D8180013 for ; Mon, 4 Jul 2022 13:22:20 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Lc5xy2Fq4zhZ1C; Mon, 4 Jul 2022 21:19:50 +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; Mon, 4 Jul 2022 21:22:13 +0800 From: Miaohe Lin To: CC: , , , , , , Subject: [PATCH v3 07/16] mm/huge_memory: use helper function vma_lookup in split_huge_pages_pid Date: Mon, 4 Jul 2022 21:21:52 +0800 Message-ID: <20220704132201.14611-8-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220704132201.14611-1-linmiaohe@huawei.com> References: <20220704132201.14611-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=1656940940; a=rsa-sha256; cv=none; b=bD6akUAB1EULzO3FY7LuD98zChOMC3nXq6hnY2sU+vByx6pY8uJkoeDZEZgWBO7Q3vRN+Z 62IueNYafIjtitBZWzqeWHLZC6PVrQ8IdLMnXwFDK428JPW44ju1yy0x03u4+ABTlLgFF3 5abmkMIqsKfFhg9ccwU7o+ac8a7gh88= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf24.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=1656940940; 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=nXSyN1XUraXiislyjCiSCevwm5EI71BgJwuSPTFirQA=; b=6+b5SQSTxRuTiFLvTEt+PQylLuPE2/N/3jfIPOcAIQEN51/W7m0OP2wzmvosvNsHnju29I cn5MyBDZflreRcvEt+vpz2vg+6ZAAQ9lKWQM6fb7JtDDdZqTEMnMOhGQDOz6M58DS2OeiQ shtUZ2LcF1pNFG3PCQ/XDsQpdNZ/rqU= Authentication-Results: imf24.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf24.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 5D5D8180013 X-Rspam-User: X-Stat-Signature: gm1rr7sggm3pch4updbs9ps4yzpr8ptd X-HE-Tag: 1656940940-377820 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 Reviewed-by: Muchun Song --- 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 f2856cfac900..5f5123130b28 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -3045,10 +3045,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 Mon Jul 4 13:21:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12905358 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 0B1D3C433EF for ; Mon, 4 Jul 2022 13:22:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E83B16B007D; Mon, 4 Jul 2022 09:22:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E34646B0074; Mon, 4 Jul 2022 09:22:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D23796B007D; Mon, 4 Jul 2022 09:22:17 -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 C24116B0073 for ; Mon, 4 Jul 2022 09:22:17 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 9DB4E20F1D for ; Mon, 4 Jul 2022 13:22:17 +0000 (UTC) X-FDA: 79649481114.10.94E3657 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf02.hostedemail.com (Postfix) with ESMTP id 0520380007 for ; Mon, 4 Jul 2022 13:22:16 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Lc5wb4tZ9zTgWf; Mon, 4 Jul 2022 21:18:39 +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; Mon, 4 Jul 2022 21:22:13 +0800 From: Miaohe Lin To: CC: , , , , , , Subject: [PATCH v3 08/16] mm/huge_memory: use helper macro __ATTR_RW Date: Mon, 4 Jul 2022 21:21:53 +0800 Message-ID: <20220704132201.14611-9-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220704132201.14611-1-linmiaohe@huawei.com> References: <20220704132201.14611-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=1656940937; 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=h0X/V0UQZzOrze5BIj8/NRARUbv/n4PYKXGDWAstF68=; b=vJrk1iMY1FH3Jr/AMu15W3SPQhi5BEgAwyQ8icU9c9daRFUK/j3j+IymaE8sibCXHW+wkt kgHobw1ZpnEcFspF3aySJKiZO8zq/sYtQYWo+dC3PozOF1gVserl/vgr95CpUC82csG49p Oanwq8kg3Ls6YPaHQJHwMhevjmB5dTs= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf02.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656940937; a=rsa-sha256; cv=none; b=yDJ0aZ1FdAAPVw3iASLAGgpereBc8M/PEggfum0me9bbSD1b3Ucc1jH9lmTgbaVDId2jtF jIKQWDVW4/ufgeyzTwcLpDorkeRnM4B8usHfNslFnPEVVWOUoLRM+Pq98d47YjN/ulghst DB+TPxOcnG1TiBaB5kdoZVcyuGQp1po= X-Rspam-User: X-Rspamd-Queue-Id: 0520380007 Authentication-Results: imf02.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf02.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Stat-Signature: kj4tt1145uupnxsrobqcgy4ph3ichmmp X-Rspamd-Server: rspam08 X-HE-Tag: 1656940936-825811 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 5f5123130b28..32a45a1e98b7 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -277,8 +277,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, @@ -367,8 +367,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) @@ -382,8 +381,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 Mon Jul 4 13:21:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12905360 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 AEB70C433EF for ; Mon, 4 Jul 2022 13:22:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 191926B007E; Mon, 4 Jul 2022 09:22:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1156F6B0082; Mon, 4 Jul 2022 09:22:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ECFAD6B0080; Mon, 4 Jul 2022 09:22:18 -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 D598A6B0074 for ; Mon, 4 Jul 2022 09:22:18 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id A1D6A603A7 for ; Mon, 4 Jul 2022 13:22:18 +0000 (UTC) X-FDA: 79649481156.23.B83EECC Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf17.hostedemail.com (Postfix) with ESMTP id 7FF4140059 for ; Mon, 4 Jul 2022 13:22:17 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Lc5z52SWyzkX8n; Mon, 4 Jul 2022 21:20:49 +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; Mon, 4 Jul 2022 21:22:14 +0800 From: Miaohe Lin To: CC: , , , , , , Subject: [PATCH v3 09/16] mm/huge_memory: fix comment in zap_huge_pud Date: Mon, 4 Jul 2022 21:21:54 +0800 Message-ID: <20220704132201.14611-10-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220704132201.14611-1-linmiaohe@huawei.com> References: <20220704132201.14611-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=1656940938; 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=lRY5scizV52TaGVtH3Qy/9icfQZDxsLbwozTSHTM+rM=; b=te8r81T0u2LBbZ7315UfBwYM5/F/XxkZa1X86qYFuzf1w0CWWmsJwksqfiKIQ/86v7+nxp EmenlJxf3NEOUrDuBUcdJjvS5tIvniYRibeTGvvmyUSHEM+JRESjzsm0DaabGxEJAqboCR Cyuvkn766bOAABM9vaP2uIr5vUH4m4w= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf17.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656940938; a=rsa-sha256; cv=none; b=KEZf+Yzo+lN8GpfyA1GqdAi5gGin64pDYdh5oflpI5IwuCWvTY3Ajp3Vx7NpquqWRvao7c edlCA8nK0OBhKkgNO3Q1BGmaC0l4pFpicw2AFkOI7A6qLy+0VZDEl9/ZS823812NZ1EYQl r28xegNxNf8jQ15qVenVahVTpQLNAls= Authentication-Results: imf17.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf17.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Stat-Signature: jahfzfyug71nujmrdpmgin4o154kmhdh X-Rspamd-Queue-Id: 7FF4140059 X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1656940937-563989 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 32a45a1e98b7..8a40dc8edb7a 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2014,12 +2014,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 Mon Jul 4 13:21:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12905362 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 15131CCA479 for ; Mon, 4 Jul 2022 13:22:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9F2796B0080; Mon, 4 Jul 2022 09:22:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 978BC6B0081; Mon, 4 Jul 2022 09:22:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 818C96B0082; Mon, 4 Jul 2022 09:22:19 -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 6E0F26B0080 for ; Mon, 4 Jul 2022 09:22:19 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id EE6AB209FA for ; Mon, 4 Jul 2022 13:22:18 +0000 (UTC) X-FDA: 79649481156.03.D9FE830 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf10.hostedemail.com (Postfix) with ESMTP id 20776C0066 for ; Mon, 4 Jul 2022 13:22:17 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Lc5y01qKjz1L8jZ; Mon, 4 Jul 2022 21:19:52 +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; Mon, 4 Jul 2022 21:22:14 +0800 From: Miaohe Lin To: CC: , , , , , , Subject: [PATCH v3 10/16] mm/huge_memory: check pmd_present first in is_huge_zero_pmd Date: Mon, 4 Jul 2022 21:21:55 +0800 Message-ID: <20220704132201.14611-11-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220704132201.14611-1-linmiaohe@huawei.com> References: <20220704132201.14611-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; imf10.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf10.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=1656940938; 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=ZInuJWNvWhXZaiHbzG0InZUxpzZxVE6ZdhvgxL+++9VI9gfv7AsKMb81T4sMhKO5wQunkg JyM+58VdeuwdrAwQGPV/NcD79aOC7kkgqK04RmPTekDALu0P5PdNh0a9KHVDTt299Q6pVA PXbWrLAA2B5+4j+tN4g/E0U6L1oryiQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656940938; a=rsa-sha256; cv=none; b=Hl0F/suR8rzoMzMmK85HZ1+nTZjKedpRfbModEO9fG1/hhMLUDlUruxCSfazQU/c9FJw/q XK19OcInGybUQA/Esi0WiZcflmJJLt1Iw9LzJoj8up9Bos1pgzq5hBLjrahr1qrzu3VeKi pr4FBjyA8RYP9wuUtX0dY/KDTNe5yeE= X-Stat-Signature: 4qn4eh9pftnjjy5w8puofmnp3drzr4wu X-Rspamd-Queue-Id: 20776C0066 Authentication-Results: imf10.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf10.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Rspamd-Server: rspam03 X-Rspam-User: X-HE-Tag: 1656940937-176638 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 Mon Jul 4 13:21:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12905365 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 9A99ECCA479 for ; Mon, 4 Jul 2022 13:22:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 22AC76B0083; Mon, 4 Jul 2022 09:22:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 13E0B6B0085; Mon, 4 Jul 2022 09:22:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E5C7C6B0087; Mon, 4 Jul 2022 09:22:20 -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 CF69B6B0085 for ; Mon, 4 Jul 2022 09:22:20 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id A83622100D for ; Mon, 4 Jul 2022 13:22:20 +0000 (UTC) X-FDA: 79649481240.23.0CDFFC2 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf08.hostedemail.com (Postfix) with ESMTP id 09DDD16000A for ; Mon, 4 Jul 2022 13:22:19 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Lc5z71SYCzkX8p; Mon, 4 Jul 2022 21:20: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; Mon, 4 Jul 2022 21:22:15 +0800 From: Miaohe Lin To: CC: , , , , , , Subject: [PATCH v3 11/16] mm/huge_memory: try to free subpage in swapcache when possible Date: Mon, 4 Jul 2022 21:21:56 +0800 Message-ID: <20220704132201.14611-12-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220704132201.14611-1-linmiaohe@huawei.com> References: <20220704132201.14611-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=1656940940; a=rsa-sha256; cv=none; b=NNgzhg3nh9iPppxQYq0PIhTgtesviMF2DK9e1VxLNuJFfGyAOFQkxdfJcASx0ygPqfbcaS t4FxGsiVu2HC+7VyVj7UdlskILOz80Rih7b0krtdOaK1lD2RZ2bti9Di2raKHWNh+TcYpo 56rck79OHxsb7RdRnCD/QciAd/34y9U= 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.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=1656940940; 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=GwLmuttF18tNetPdbUrclurgxEq6eU/8FRplWHx6BPw=; b=yadOloHYnRQwA3TT4cDraRbuoyFNZLCBiWocmoG+3TxZwzIkvDmD2sCMEcy7oKN/jUjRQE g4DlLXlNseeaxvsptpfzD/AknoZNh8qqaemC+dM6RjugXk87v+Uf2GVvpKkR3uwHWl2Ury PvqYNtQhJEVGXWhHl/AVK2Uo1u6vRIw= X-Rspam-User: X-Rspamd-Server: rspam07 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.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Stat-Signature: ndk97eu8zaqt9gmdyd9rdaofzjyau44q X-Rspamd-Queue-Id: 09DDD16000A X-HE-Tag: 1656940939-531237 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 8a40dc8edb7a..6d95751ebfc9 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2643,7 +2643,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 Mon Jul 4 13:21:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12905364 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 18B73C43334 for ; Mon, 4 Jul 2022 13:22:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B77836B0082; Mon, 4 Jul 2022 09:22:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B01ED6B0083; Mon, 4 Jul 2022 09:22:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9A2CA6B0085; Mon, 4 Jul 2022 09:22:20 -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 889BA6B0082 for ; Mon, 4 Jul 2022 09:22:20 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 3EB07120221 for ; Mon, 4 Jul 2022 13:22:20 +0000 (UTC) X-FDA: 79649481240.19.826E2BB Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf03.hostedemail.com (Postfix) with ESMTP id 9B1B120008 for ; Mon, 4 Jul 2022 13:22:19 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Lc5y14zDWzhZ1R; Mon, 4 Jul 2022 21:19:53 +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; Mon, 4 Jul 2022 21:22:16 +0800 From: Miaohe Lin To: CC: , , , , , , Subject: [PATCH v3 12/16] mm/huge_memory: minor cleanup for split_huge_pages_all Date: Mon, 4 Jul 2022 21:21:57 +0800 Message-ID: <20220704132201.14611-13-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220704132201.14611-1-linmiaohe@huawei.com> References: <20220704132201.14611-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=1656940939; a=rsa-sha256; cv=none; b=ApoEDCv+c/QUMaRECsrcxqwMklubGXUhZJED1PTkIZqUycIQ/ZqARfrNHRsADx/e0adzYS 549UPzLW4d9UolgZyw6FaXc/DaCmJGd1KG4yr48hxImjEhJZRIa+jkXgnaQSi/PipzNIW0 9AER+YZBhbSy5PX+dvtCnKz4veJ11GU= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf03.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=1656940939; 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=+V6X9wcuGlNLkg/fjtYps5wW3brn/P53tXJasBIUEpI=; b=5cB6LyWonzy6DJC1Ef1CYzhrwtFLEmeZHgzDVRoPdOeOWDgCSFDrZtxEbRh8QI9Ekz4vZZ rncJA/89p2dfOGJI1nXSimFS2UI/fBxEObh+a6TyapXAyCrXBSvhtp0Su4aTK6YYcTYvec TNKwT53GoOB8CR2hXBKWGdYLsMdVVSI= Authentication-Results: imf03.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf03.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Rspam-User: X-Stat-Signature: ywyuzcpmhrsbaanpn5hem81c5ppnp585 X-Rspamd-Queue-Id: 9B1B120008 X-Rspamd-Server: rspam04 X-HE-Tag: 1656940939-595762 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 6d95751ebfc9..77be7dec1420 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2961,9 +2961,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; @@ -2979,8 +2982,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 Mon Jul 4 13:21:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12905367 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 A6AEFC43334 for ; Mon, 4 Jul 2022 13:22:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 29E516B0085; Mon, 4 Jul 2022 09:22:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 226DA6B0087; Mon, 4 Jul 2022 09:22:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1154D6B0089; Mon, 4 Jul 2022 09:22:22 -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 03D736B0085 for ; Mon, 4 Jul 2022 09:22:22 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id BDC82603B9 for ; Mon, 4 Jul 2022 13:22:21 +0000 (UTC) X-FDA: 79649481282.10.96278E4 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf31.hostedemail.com (Postfix) with ESMTP id 810092002C for ; Mon, 4 Jul 2022 13:22:20 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4Lc5zv3SylzYd0w; Mon, 4 Jul 2022 21:21:31 +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; Mon, 4 Jul 2022 21:22:17 +0800 From: Miaohe Lin To: CC: , , , , , , Subject: [PATCH v3 13/16] mm/huge_memory: fix comment of page_deferred_list Date: Mon, 4 Jul 2022 21:21:58 +0800 Message-ID: <20220704132201.14611-14-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220704132201.14611-1-linmiaohe@huawei.com> References: <20220704132201.14611-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=1656940940; a=rsa-sha256; cv=none; b=aoDEiGPRRKUo4nUcK1D84CzTs0xzsx/WMWETLyaYaMqoGheLHkO62RSWV08AI7PVGST4zS 3WvHYoIvxiAt21EeXES8JaXv7bFQk729frQ6Cy/lFQbbzphbvgka00rvrPsihKZTdaVOfE 9QdLuN0sgvKzuS62lUMgNnK79B9PtyU= ARC-Authentication-Results: i=1; imf31.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf31.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 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=1656940940; 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=7y6URO85YBfUdSXDP7Ai3euF33ccW/HQRND3SoIg1MdCtyCBtAgxnQqeYO2ka9Cr8LgWbS 3eQK/aSGqyNIHzIR63iH97diD+ck234NkFa88tOTsjv544uCusH2kS4Z033xn/qRPeEFe5 Y77QVTSFagNp8yVWGNHn2oFtawLIfv0= X-Rspam-User: X-Rspamd-Server: rspam07 Authentication-Results: imf31.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf31.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Stat-Signature: i99pmo5uk95oq9qr8fbutdo7own1hn8w X-Rspamd-Queue-Id: 810092002C X-HE-Tag: 1656940940-916213 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 Reviewed-by: Muchun Song --- 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 Mon Jul 4 13:21:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12905370 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 621A8C43334 for ; Mon, 4 Jul 2022 13:22:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0A8516B008A; Mon, 4 Jul 2022 09:22:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F20066B008C; Mon, 4 Jul 2022 09:22:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C60DA6B0092; Mon, 4 Jul 2022 09:22:26 -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 97A9F6B008A for ; Mon, 4 Jul 2022 09:22:26 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 7D03E33D1E for ; Mon, 4 Jul 2022 13:22:26 +0000 (UTC) X-FDA: 79649481492.13.7793AEA Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf18.hostedemail.com (Postfix) with ESMTP id 602D21C0050 for ; Mon, 4 Jul 2022 13:22:25 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Lc5z85BJxzkX90; Mon, 4 Jul 2022 21:20:52 +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; Mon, 4 Jul 2022 21:22:17 +0800 From: Miaohe Lin To: CC: , , , , , , Subject: [PATCH v3 14/16] mm/huge_memory: correct comment of prep_transhuge_page Date: Mon, 4 Jul 2022 21:21:59 +0800 Message-ID: <20220704132201.14611-15-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220704132201.14611-1-linmiaohe@huawei.com> References: <20220704132201.14611-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; 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=1656940946; 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=XOvY20vnH3kVXLyUNdopTKwr0oo/0GWEtMm7ZZ8rYm0=; b=0cmeiayqlV3n5+Jma7Wx2oXOboU96Rp/PfDxcnQjO29FTJxs+X6HcvfINHF+GnmM2xuOCr w1XRBQ1+1iiougSE+z67zdJjTreGlUTCxq/ckl9IX12zdKzbI21vlLO6vLQj11cnvC2U5s xszLz2iyW4waueYWQfXXvkown+oUkjA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656940946; a=rsa-sha256; cv=none; b=65dInEeLGRqxuZhuC7iwyTzhuCALCZ9SxD4i4pf/rPA5pQgLwVRzDejpxhds48Q9PQfokU ku+LPhO1MKoPWDGElYZPZqjeNuduIi9J/HMIjz7/ZOY7PexBN4bkDJagwc4NAEaj28RNLv kmb8u9HGCHT+7BkztqhVlNRSK29Z8EU= X-Stat-Signature: pkaqb5zuoeqzcsqo68y4j7npyrdxhir3 X-Rspamd-Queue-Id: 602D21C0050 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-Rspam-User: X-HE-Tag: 1656940945-100651 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 77be7dec1420..36f3fc2e7306 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -682,7 +682,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 Mon Jul 4 13:22:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12905369 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 F1B08C433EF for ; Mon, 4 Jul 2022 13:22:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 24FA76B0087; Mon, 4 Jul 2022 09:22:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 146E26B0092; Mon, 4 Jul 2022 09:22:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DBE326B008A; Mon, 4 Jul 2022 09:22:22 -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 C0C246B0089 for ; Mon, 4 Jul 2022 09:22:22 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 9AD1835775 for ; Mon, 4 Jul 2022 13:22:22 +0000 (UTC) X-FDA: 79649481324.05.CE83E95 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf26.hostedemail.com (Postfix) with ESMTP id ED371140032 for ; Mon, 4 Jul 2022 13:22:21 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Lc5wh0czfzTgXl; Mon, 4 Jul 2022 21:18:44 +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; Mon, 4 Jul 2022 21:22:18 +0800 From: Miaohe Lin To: CC: , , , , , , Subject: [PATCH v3 15/16] mm/huge_memory: comment the subtly logic in __split_huge_pmd Date: Mon, 4 Jul 2022 21:22:00 +0800 Message-ID: <20220704132201.14611-16-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220704132201.14611-1-linmiaohe@huawei.com> References: <20220704132201.14611-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=1656940942; 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=mg2R5DOQszpgVAtqyADsl5YpS5w5+LE+visBbIAgLUg=; b=Ut1Y9ugXkSPnNredvZES9GoEoCZhZRA+3WtBjI1xUUH1qUMONMpSML03vr2m/p0oAiNnpE GIMu+LNQ7O12lEZk80eRHSlqMvCbcRNBg36KRuwcbQzl5Ok7gy6e+/PNRzwCVI9ICLeHOw 31ZfBMqY3IC0zwVtQwRXrnuw9WAGVLc= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf26.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656940942; a=rsa-sha256; cv=none; b=Wg8vQlnL5OWVlEVHfyecsv1UWNhJe0D5Elkz6/eTByjqCrD4ZWQ6OZi+niU5mvv4rbHieq geJ6jLGk7Z7+CcgGO2YKe3d5x1lRYaJ4qIgYvfA0FjIv03ZmrQRLqvzYCqwVZ/H2T5UnH7 Hg+UswjoLPbCk/934Na+1Pkpx9sxITc= Authentication-Results: imf26.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf26.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-Rspamd-Queue-Id: ED371140032 X-Stat-Signature: yn8t5rpua7wtho3rwb1c36najqxgdzn9 X-Rspam-User: X-HE-Tag: 1656940941-981009 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 36f3fc2e7306..8380912b39fd 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2336,6 +2336,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 Mon Jul 4 13:22:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12905368 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 5CB22C43334 for ; Mon, 4 Jul 2022 13:22:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EF9846B0089; Mon, 4 Jul 2022 09:22:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E83476B0087; Mon, 4 Jul 2022 09:22:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D49296B008C; Mon, 4 Jul 2022 09:22:22 -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 C02036B0087 for ; Mon, 4 Jul 2022 09:22:22 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 9A7DB605BE for ; Mon, 4 Jul 2022 13:22:22 +0000 (UTC) X-FDA: 79649481324.01.3E35D00 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf08.hostedemail.com (Postfix) with ESMTP id E781B16000A for ; Mon, 4 Jul 2022 13:22:21 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Lc5wh4FV5zTgXr; Mon, 4 Jul 2022 21:18:44 +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; Mon, 4 Jul 2022 21:22:18 +0800 From: Miaohe Lin To: CC: , , , , , , Subject: [PATCH v3 16/16] mm/huge_memory: use helper macro IS_ERR_OR_NULL in split_huge_pages_pid Date: Mon, 4 Jul 2022 21:22:01 +0800 Message-ID: <20220704132201.14611-17-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220704132201.14611-1-linmiaohe@huawei.com> References: <20220704132201.14611-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=1656940942; 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=NG1liEc88B3xqhrHfMRopTb1e0ekMr/qfQ2BfpqAsKc=; b=Mxg6yTciFIdVgT75X2R6fNa9JK0zY8ia29//IQT2j60f+o0v5a7cl/C4Yq+CM0YmhJ8JhK uci02pn3lDM78z/K/uQJdfDWhaJY4dPb0lEOFyedNP+eqXGNUbyHb83LOCwxcjVrlZOPt4 WRWSt+k6haYFl2N4kcaNRbrcIcsGguE= 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.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656940942; a=rsa-sha256; cv=none; b=hz2M1Re67hGjjNKdu9UiI/vL0dNid2VO1rI1r1nFwiYnXBHQn2w+iScaTPaATncTwS+Fcp CtvnA3gCEhUZvTnjlkoV5quwnMIdFJqh/udy+Gk6SfTKFEVjX/dZaTMgggcgyzn0Jud/Nu MPxCUQhcgJmWBILcqcq7icjP/IHwDrE= X-Rspam-User: X-Rspamd-Queue-Id: E781B16000A 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.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Stat-Signature: shjieg9uhseatu7wcsgkckk3xs5c3a1f X-Rspamd-Server: rspam08 X-HE-Tag: 1656940941-354640 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 8380912b39fd..fd9d502aadc4 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -3062,9 +3062,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); - if (IS_ERR(page)) - continue; - if (!page || is_zone_device_page(page)) + if (IS_ERR_OR_NULL(page) || is_zone_device_page(page)) continue; if (!is_transparent_hugepage(page))