From patchwork Wed Jun 22 17:06:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12891176 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 592E1C433EF for ; Wed, 22 Jun 2022 17:07:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9EC996B00D0; Wed, 22 Jun 2022 13:06:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8CDFB6B00D1; Wed, 22 Jun 2022 13:06:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4A0468E00D2; Wed, 22 Jun 2022 13:06:53 -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 E15536B00D0 for ; Wed, 22 Jun 2022 13:06:52 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id C2D9621384 for ; Wed, 22 Jun 2022 17:06:52 +0000 (UTC) X-FDA: 79606501464.05.208C499 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf23.hostedemail.com (Postfix) with ESMTP id 32BE61400BF for ; Wed, 22 Jun 2022 17:06:50 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4LSqT33KVJzSh9t; Thu, 23 Jun 2022 01:03:03 +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; Thu, 23 Jun 2022 01:06:27 +0800 From: Miaohe Lin To: CC: , , , , , Subject: [PATCH 01/16] mm/huge_memory: use flush_pmd_tlb_range in move_huge_pmd Date: Thu, 23 Jun 2022 01:06:12 +0800 Message-ID: <20220622170627.19786-2-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220622170627.19786-1-linmiaohe@huawei.com> References: <20220622170627.19786-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) 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=1655917610; 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=oF8fb7gM6FeM9ws84vEw0nCHFHhgGDmcLSk5G+hHuBk=; b=m0aEVRWNpDEdwMipendD7+sUUS/Y59CwQFYgNh0f4bfIsywAjUXqL0+hyL6n1nyYY8H+qK tiOCFIhRmw/9ZxrtJ130mPYwecfCe0lOCJSRVoV4mDMtW5BaE/OgR49RqpGSHh+XgHgiZk LiSNnWslzxHuy6N60KvxiBP/sKyUQ6g= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655917610; a=rsa-sha256; cv=none; b=Q/2COWRkQqNm/taTf8bcrszkJ272muclYqZIWE0EdnFqni/5bmuiYNpyHU+AB/p7zbRbLd GzzayBJM53RFERpPEBzM09hAQ1xqFQ/JOOKinWNvQ7AQeTjw8j7YfjNUx2QP1zM+16aIXo HpJ8S38M1CuWkc6S9e7OrdIP3k7/Is0= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf23.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Stat-Signature: 5cnu49m535th4p8zq9h9dbkou8rs64m4 X-Rspamd-Queue-Id: 32BE61400BF Authentication-Results: imf23.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf23.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Rspamd-Server: rspam02 X-Rspam-User: X-HE-Tag: 1655917610-192644 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 af0751a79c19..fd6da053a13e 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1746,7 +1746,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 Wed Jun 22 17:06:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12891183 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 8023DC43334 for ; Wed, 22 Jun 2022 17:07:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 603FD8E00D1; Wed, 22 Jun 2022 13:06:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 541058E00D8; Wed, 22 Jun 2022 13:06:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2D36A8E00D9; Wed, 22 Jun 2022 13:06:55 -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 119408E00D7 for ; Wed, 22 Jun 2022 13:06:55 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id EB510355B3 for ; Wed, 22 Jun 2022 17:06:54 +0000 (UTC) X-FDA: 79606501548.03.90C0E1D Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf30.hostedemail.com (Postfix) with ESMTP id 654F7800B2 for ; Wed, 22 Jun 2022 17:06:54 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4LSqT36mZDzSh9m; Thu, 23 Jun 2022 01:03:03 +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; Thu, 23 Jun 2022 01:06:28 +0800 From: Miaohe Lin To: CC: , , , , , Subject: [PATCH 02/16] mm/huge_memory: access vm_page_prot with READ_ONCE in remove_migration_pmd Date: Thu, 23 Jun 2022 01:06:13 +0800 Message-ID: <20220622170627.19786-3-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220622170627.19786-1-linmiaohe@huawei.com> References: <20220622170627.19786-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655917614; a=rsa-sha256; cv=none; b=mR6BBgFmiu8rTi6EL1vjhLfHcrm4frIR1gtVfmN4es8kYP5MuEKJidM/fg7iLmDOI+0PWT 8cpYOqpr+oP6VtonVTbQu+zGB1aLihJxcBPBzLtusmYvcFYIQ07xbY6XKUJsSLSBtj33rq bef0Gx7tj20bsNnoNiamn8S32Uo9JOo= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=none; spf=pass (imf30.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=1655917614; 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=2Xbl29GIhuxqCtpYlDQLHpFA7Fv96sx7/11+jwKcu40=; b=8lOI0pQy3ORSi63wtBWd3OeE3iELaHmMlWuFqgKURrW3F8hi17LdgreIfrH4O9og/WS2gh EbOLTaLe5GxmGpxlPetReszXYJ7iMWPempmFExYkP9VQZC3gF7/Jsmp0xEov8bjkcbRtzS yERpayaxDUfXD86xlyrRw2HHsn5Op3U= X-Stat-Signature: 1b45xi7dgq465z4rb99oku7m7onih9c7 X-Rspamd-Server: rspam06 Authentication-Results: imf30.hostedemail.com; dkim=none; spf=pass (imf30.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-Rspamd-Queue-Id: 654F7800B2 X-HE-Tag: 1655917614-659361 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 fd6da053a13e..83fb6c3442ff 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -3202,7 +3202,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 Wed Jun 22 17:06:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12891168 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 4F93FC433EF for ; Wed, 22 Jun 2022 17:06:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BDBDE6B00CB; Wed, 22 Jun 2022 13:06:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B62836B00CE; Wed, 22 Jun 2022 13:06:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9F8286B00CD; Wed, 22 Jun 2022 13:06:51 -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 8EB4A6B00CB for ; Wed, 22 Jun 2022 13:06:51 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 5DAC471C for ; Wed, 22 Jun 2022 17:06:51 +0000 (UTC) X-FDA: 79606501422.18.B4F95F7 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf14.hostedemail.com (Postfix) with ESMTP id ADC46100086 for ; Wed, 22 Jun 2022 17:06:48 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4LSqVY0PsfzhYfV; Thu, 23 Jun 2022 01:04:21 +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; Thu, 23 Jun 2022 01:06:28 +0800 From: Miaohe Lin To: CC: , , , , , Subject: [PATCH 03/16] mm/huge_memory: fix comment of __pud_trans_huge_lock Date: Thu, 23 Jun 2022 01:06:14 +0800 Message-ID: <20220622170627.19786-4-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220622170627.19786-1-linmiaohe@huawei.com> References: <20220622170627.19786-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655917609; a=rsa-sha256; cv=none; b=dkoREgplbEVJaWPAfadGwo96E4MLSDXfthwdvEeFnVE96RZckilo7vI4QEobBDYoWedQ/y LdoKhJ2rlbGutZRFiq2Da0WqvDFF2O3RitZUfuNCw5QQjSK86dfRWvdgmyMX80uI6LrKok 4stZQ2z2mULgidPkYuWiUfM0DQzLRdQ= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=none; spf=pass (imf14.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=1655917609; 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=4T0BOGbjX0YOuzWQpx9fYBhCncXi+3oKiyRRGZEpyqc=; b=xBiTVl7nFwfsnSBsI4vHq5GKfHqFiiTElinasTMFu6FdeafnaV28T1j7RgprpSPTOnneUx i1+ay5yPQG3gCc8cY4DFVitlpCRox8x0hB19dlAhFPc4p45grNWM5MBJ2XxgQM9dwH1k3Y tKvQS0HFIqyvbvy+ehPgXFemd3LxFyY= X-Stat-Signature: gx7tcswzcaom4999bfd89z5utnuk7t7n X-Rspamd-Server: rspam06 Authentication-Results: imf14.hostedemail.com; dkim=none; spf=pass (imf14.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-Queue-Id: ADC46100086 X-HE-Tag: 1655917608-923950 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 83fb6c3442ff..a26580da8011 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1903,10 +1903,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 pointe, 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 Wed Jun 22 17:06:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12891172 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 5E3A1C43334 for ; Wed, 22 Jun 2022 17:06:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 05C5C8E00C9; Wed, 22 Jun 2022 13:06:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ED13D6B00D2; Wed, 22 Jun 2022 13:06:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BCF268E00D1; Wed, 22 Jun 2022 13:06:52 -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 8AEDA6B00D0 for ; Wed, 22 Jun 2022 13:06:52 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 65CA280344 for ; Wed, 22 Jun 2022 17:06:52 +0000 (UTC) X-FDA: 79606501464.13.C3675C1 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf05.hostedemail.com (Postfix) with ESMTP id C19821000A1 for ; Wed, 22 Jun 2022 17:06:49 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4LSqT46cSZzSgrr; Thu, 23 Jun 2022 01:03: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; Thu, 23 Jun 2022 01:06:29 +0800 From: Miaohe Lin To: CC: , , , , , Subject: [PATCH 04/16] mm/huge_memory: use helper touch_pud in huge_pud_set_accessed Date: Thu, 23 Jun 2022 01:06:15 +0800 Message-ID: <20220622170627.19786-5-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220622170627.19786-1-linmiaohe@huawei.com> References: <20220622170627.19786-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) 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=1655917610; 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=TVeSdvFGF6ZenxAzQdu4IqHqbWNp4ZpI0IpmlkCrI9Q=; b=K3Zr6g+qzTdRpKjTBpd59ZjQ6raGTex7Q8O5dOvf06PC4/BBCBtZkfCwtQkCrlF3nLKimi Bsc88QSVgZBjG+wK8kR8uBvdVANBK7/pnYMW7WqBChKFZM9c7N0CSI6+t3AqcJNwKS7+VW qgabLCiYQR/bmvk6DsQlLhbyQX9X0KM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655917610; a=rsa-sha256; cv=none; b=sU6NvHmfG5sxlTmq/72S43sdeTniBE61YWsTIFngbcFJButDDMYI+Z4bna37ARqQlVhUkM B3ha8Ib2C7Ei4TODXDv/3zvoBLe0ZbGox65CayewLaECY1rnrE4zAVlWVzRZPq53ruMWc4 zvpTVAzKyJBucwUZ+ifsyR+ydiY6yH4= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf05.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Stat-Signature: r7si548mtqb33m1fuqqo9spcsh6asncq X-Rspamd-Queue-Id: C19821000A1 Authentication-Results: imf05.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf05.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Rspamd-Server: rspam02 X-Rspam-User: X-HE-Tag: 1655917609-296791 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 | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index a26580da8011..a0c0e4bf9c1e 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1281,21 +1281,15 @@ 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; + int flags = 0; 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); - + if (vmf->flags & FAULT_FLAG_WRITE) + flags = FOLL_WRITE; + touch_pud(vmf->vma, vmf->address, vmf->pud, flags); unlock: spin_unlock(vmf->ptl); } From patchwork Wed Jun 22 17:06:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12891177 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 A0D2BC43334 for ; Wed, 22 Jun 2022 17:07:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 010D98E00D2; Wed, 22 Jun 2022 13:06:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E8D988E00D1; Wed, 22 Jun 2022 13:06:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D07098E00D2; Wed, 22 Jun 2022 13:06:53 -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 AB1998E00D1 for ; Wed, 22 Jun 2022 13:06:53 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 72E332142C for ; Wed, 22 Jun 2022 17:06:53 +0000 (UTC) X-FDA: 79606501506.03.5E872F9 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf09.hostedemail.com (Postfix) with ESMTP id 31A171400C7 for ; Wed, 22 Jun 2022 17:06:50 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4LSqVZ3FCpz1KC4m; Thu, 23 Jun 2022 01:04:22 +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; Thu, 23 Jun 2022 01:06:29 +0800 From: Miaohe Lin To: CC: , , , , , Subject: [PATCH 05/16] mm/huge_memory: use helper touch_pmd in huge_pmd_set_accessed Date: Thu, 23 Jun 2022 01:06:16 +0800 Message-ID: <20220622170627.19786-6-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220622170627.19786-1-linmiaohe@huawei.com> References: <20220622170627.19786-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655917612; a=rsa-sha256; cv=none; b=Q7PHeOMTyHZ+oSGlC5qP3xux8Y62Vm8ucEclzLwNZy/hNJbKbbIShjzmC9XkMs4f53TKS3 DTdh1VhDDi+6Xjpni12kAcaY38rNUlNo6rAab+HBeiViqcn6TWr7FfkNcaY+5FYhWTPWp3 iFQ4XSUEWVtLlFKwE1++oyGeskOGSMg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655917612; 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=174fjyX0Hja8nW9P18Ui4XCy2P1Rk/MUkl0TOYVnsI0=; b=FXt3C5/lOL7+zdpEh5UjP6GQ41lqKJOJIpjYyqTMq9y/fggAdX7dMrq+fenWdO5TUUpzHv jNlPe69sF9r+ZFSstE7843Q5NdWew7Jjjd+vMY2tb2nq+xeqj6c+6gVfTHMzvvdtZGAjl6 2n6LSDzLKG+pWBle7XFIQ11NyO+wqT0= 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.255 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Rspam-User: X-Rspamd-Queue-Id: 31A171400C7 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.255 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Stat-Signature: o7b9zu5suxdozbdtkoqszhqa9ion56ra X-Rspamd-Server: rspam09 X-HE-Tag: 1655917610-359947 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 | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index a0c0e4bf9c1e..c6302fe6704b 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1297,21 +1297,15 @@ 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; + int flags = 0; 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); + if (vmf->flags & FAULT_FLAG_WRITE) + flags = FOLL_WRITE; + touch_pmd(vmf->vma, vmf->address, vmf->pmd, flags); unlock: spin_unlock(vmf->ptl); From patchwork Wed Jun 22 17:06:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12891178 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 0B3C0CCA47D for ; Wed, 22 Jun 2022 17:07:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 67AB98E00D3; Wed, 22 Jun 2022 13:06:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5DB358E00D6; Wed, 22 Jun 2022 13:06:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3B84A8E00D1; Wed, 22 Jun 2022 13:06:54 -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 1E7708E00D4 for ; Wed, 22 Jun 2022 13:06:54 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id F396F8118B for ; Wed, 22 Jun 2022 17:06:53 +0000 (UTC) X-FDA: 79606501506.18.55A4E27 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf03.hostedemail.com (Postfix) with ESMTP id 4FD09200BC for ; Wed, 22 Jun 2022 17:06:49 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4LSqT56RpXzSh9p; Thu, 23 Jun 2022 01:03:05 +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; Thu, 23 Jun 2022 01:06:29 +0800 From: Miaohe Lin To: CC: , , , , , Subject: [PATCH 06/16] mm/huge_memory: rename mmun_start to haddr in remove_migration_pmd Date: Thu, 23 Jun 2022 01:06:17 +0800 Message-ID: <20220622170627.19786-7-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220622170627.19786-1-linmiaohe@huawei.com> References: <20220622170627.19786-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=none; spf=pass (imf03.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=1655917609; 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=7bIR2qGLf+mJcBWA5k0JnsvnnUkjOl0vjhHA19cmbig=; b=OIBrCTbajThVtcR7xDFp9o2vqaJI2DBk1ngTPr+zDz6ixAj2LJEm+SPeOLlC+IfNwyj44U kOM2o4I48HYl+Bga31YJz2HC2JkXab8TGrSyNgrKFvK6NllAUXc4WDgbYjp79MVOOI9mCs v7pCUrZgHDR8URE42HTTZown80zwV10= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655917609; a=rsa-sha256; cv=none; b=WGysvZpZ0teGqHPGLZ/uRh2w7Pta9MSgZtPKsYh7rdD6+4btoBcvcSpyAsIXBafQc42Uu2 1gPonGF6MnhLRIuyUxZ9PobsH7lQCnl3URERf37sINAokuGMm1TzQ535YDumt1Bwa8ZT2t bZlnJcugHlIngA3/kh5L3PGKxKKrfH0= X-Stat-Signature: nydg6ac8s6udx5djyh8g73kxw6fz4zo9 X-Rspam-User: X-Rspamd-Server: rspam07 Authentication-Results: imf03.hostedemail.com; dkim=none; spf=pass (imf03.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-Queue-Id: 4FD09200BC X-HE-Tag: 1655917609-607533 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 c6302fe6704b..fb5c484dfa39 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -3181,7 +3181,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; @@ -3204,12 +3204,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 Wed Jun 22 17:06:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12891173 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 82CC9CCA481 for ; Wed, 22 Jun 2022 17:06:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 323408E00D0; Wed, 22 Jun 2022 13:06:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 254F38E00CF; Wed, 22 Jun 2022 13:06:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C6B0F6B00CF; Wed, 22 Jun 2022 13:06:52 -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 A73F48E00CF for ; Wed, 22 Jun 2022 13:06:52 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 82915120FA5 for ; Wed, 22 Jun 2022 17:06:52 +0000 (UTC) X-FDA: 79606501464.23.62A85F4 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf19.hostedemail.com (Postfix) with ESMTP id E92BC1A00BB for ; Wed, 22 Jun 2022 17:06:51 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4LSqW52NY4zkWLh; Thu, 23 Jun 2022 01:04: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; Thu, 23 Jun 2022 01:06:30 +0800 From: Miaohe Lin To: CC: , , , , , Subject: [PATCH 07/16] mm/huge_memory: minor cleanup for split_huge_pages_pid Date: Thu, 23 Jun 2022 01:06:18 +0800 Message-ID: <20220622170627.19786-8-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220622170627.19786-1-linmiaohe@huawei.com> References: <20220622170627.19786-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655917612; a=rsa-sha256; cv=none; b=dKXFFgolwjjB9nnPQVqe6quxTSHIHQ6EnTR3SedHaUHgE6PlV2JY8XbuZoM9Pe46krDOKh GCA+DpyudE7RNwIeMDc7e6dFW3Fxn6EO+da1jSNi4/BOy1V/OKAIKkAPn9VaCpHew80H5W 1gcuRqOD6boN+U9fcfXotIDsuJFKZiE= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=none; spf=pass (imf19.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=1655917612; 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=as46R5QMFDhvQrqbVwO9M/hzoAQUCElMhEjQNdf2tpk=; b=qInZ1r94Hs9FLUTIwFAie32LChRDgoKjdYhP2Hi+Pq/l8hhH7WzH9fJqCfuJv3IUkHp7b1 G7xmJcbLAgpx55TF6Q5+oIw3gmIrQxYY9DcbwgdoY6UT3xfQlbXFYgSGOaT/BwpgUPVk7q mpd+1UZNdyu9iP+kSHAVgjCsVf+Af5A= X-Rspamd-Queue-Id: E92BC1A00BB X-Rspam-User: Authentication-Results: imf19.hostedemail.com; dkim=none; spf=pass (imf19.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: rspam08 X-Stat-Signature: p15c6eyn761om9nqg7na6zo3b5c9zdb7 X-HE-Tag: 1655917611-684382 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 and use help macro IS_ERR_OR_NULL to check the validity of page to simplify the code. Minor readability improvement. Signed-off-by: Miaohe Lin --- mm/huge_memory.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index fb5c484dfa39..7cfa003b1789 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2942,10 +2942,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 */ @@ -2957,9 +2957,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)) From patchwork Wed Jun 22 17:06:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12891171 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 83EF8CCA481 for ; Wed, 22 Jun 2022 17:06:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D0A1B6B00CE; Wed, 22 Jun 2022 13:06:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CE0788E00CF; Wed, 22 Jun 2022 13:06:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B0C4E8E00D0; Wed, 22 Jun 2022 13:06:52 -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 799A76B00CF for ; Wed, 22 Jun 2022 13:06:52 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 5560E35545 for ; Wed, 22 Jun 2022 17:06:52 +0000 (UTC) X-FDA: 79606501464.01.6393F53 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf13.hostedemail.com (Postfix) with ESMTP id 8B4C52002E for ; Wed, 22 Jun 2022 17:06:49 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4LSqWf3RNkzkWdH; Thu, 23 Jun 2022 01:05:18 +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; Thu, 23 Jun 2022 01:06:30 +0800 From: Miaohe Lin To: CC: , , , , , Subject: [PATCH 08/16] mm/huge_memory: use helper macro __ATTR_RW Date: Thu, 23 Jun 2022 01:06:19 +0800 Message-ID: <20220622170627.19786-9-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220622170627.19786-1-linmiaohe@huawei.com> References: <20220622170627.19786-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655917609; a=rsa-sha256; cv=none; b=FjmNAJNDVVSEIcR/i0kQOE0BMLSuf7LREQUZ+qF0TvOxMlcSuuzPcuhZjXg52BVG50IMyt s+vzhmK8mm+eiKrSvjL5PaN716uVgNmsvXGlTBW4gfIECIN0RjnsUgYBMRLUvzcIL/y+DD diFhaQR1WOFcbbLgAFHQbqS5TBz1us4= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf13.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=1655917609; 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=hPUX9Bq8a4whXwu7GKQhlUA6u4LpqfBMx0BTcDOlgKQ=; b=nHNi3GkOhxUmczsBaLw/hu3yozSWKQ5vSWv41hNBWKc1kMw+HlbyCu7TqzdOxjHj8BaVY6 VYIF2pZydu/YP70CyNoKa0J+PBmzgVX931WbrD1VYZoJdfHB3MGHKj1zoLz77ZVOs5hKqN EhFvnBNPkWYpQ6kxssc59MR6JK01upw= X-Rspamd-Queue-Id: 8B4C52002E X-Rspam-User: Authentication-Results: imf13.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf13.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-Stat-Signature: i9x6dz65x3ue1z6t8gerafk4g1axxq4u X-HE-Tag: 1655917609-952391 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 7cfa003b1789..b42c8fa51e46 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -273,8 +273,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, @@ -363,8 +363,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) @@ -378,8 +377,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 Wed Jun 22 17:06: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: 12891181 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 0CCB8C43334 for ; Wed, 22 Jun 2022 17:07:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0431F8E00D6; Wed, 22 Jun 2022 13:06:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B7F298E00D8; Wed, 22 Jun 2022 13:06:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 760FD8E00D7; Wed, 22 Jun 2022 13:06:54 -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 540698E00D5 for ; Wed, 22 Jun 2022 13:06:54 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 1B7FC120410 for ; Wed, 22 Jun 2022 17:06:54 +0000 (UTC) X-FDA: 79606501548.16.0397F28 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf25.hostedemail.com (Postfix) with ESMTP id ED479A00AC for ; Wed, 22 Jun 2022 17:06:48 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4LSqVc34nyz1KC7g; Thu, 23 Jun 2022 01:04: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; Thu, 23 Jun 2022 01:06:31 +0800 From: Miaohe Lin To: CC: , , , , , Subject: [PATCH 09/16] mm/huge_memory: fix comment in zap_huge_pud Date: Thu, 23 Jun 2022 01:06:20 +0800 Message-ID: <20220622170627.19786-10-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220622170627.19786-1-linmiaohe@huawei.com> References: <20220622170627.19786-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) 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=1655917610; 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=CIOMoqeYcv8TX91p5iT/XNazOHEZTMTgLz2JpZ3FcY8=; b=2os+k29PPJLX8H3BL8QAwK4kTvzPtibMctLiOnrD0ubr1hz+B4S0Y90XOYHEawvy0pxmnh f42VkR7tcK0swhXEoISw2pyN1SieqRGKJx3QnTDeanw1S0sycTq4zsxy8DEZa+CaQc8lGV xNRjh2GeOhauIIvjXL6rKgf2Y7fewuA= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=none; spf=pass (imf25.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.255 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=1655917610; a=rsa-sha256; cv=none; b=EhRD77esWSGGWfTnPN7c9tkXV4Rg/NYXUK/deqQhN9QsD6fxvaT/rkbgpg4BYnw+ltLI0O i9RE+SdZdTZik0RaDUwKM4k0lxZwdtNjDZoNfWexOz4QOaVmHEr5vUf1v7NJvYMrIwbSWR YxUycaiTKGM1iHu6iq1GsfecrTB5HCY= X-Rspamd-Queue-Id: ED479A00AC Authentication-Results: imf25.hostedemail.com; dkim=none; spf=pass (imf25.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Rspam-User: X-Stat-Signature: cacgmj4cihnpqmoenz63j44qiostqbjy X-Rspamd-Server: rspam04 X-HE-Tag: 1655917608-660175 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 b42c8fa51e46..fd12fa930937 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1914,12 +1914,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 Wed Jun 22 17:06: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: 12891182 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 37BEDC433EF for ; Wed, 22 Jun 2022 17:07:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 367A58E00D7; Wed, 22 Jun 2022 13:06:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F086E8E00D1; Wed, 22 Jun 2022 13:06:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D522E8E00D7; Wed, 22 Jun 2022 13:06:54 -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 B2D968E00D1 for ; Wed, 22 Jun 2022 13:06:54 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 872E13561C for ; Wed, 22 Jun 2022 17:06:54 +0000 (UTC) X-FDA: 79606501548.11.F893618 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf05.hostedemail.com (Postfix) with ESMTP id E8CE2100028 for ; Wed, 22 Jun 2022 17:06:50 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4LSqVc69q5z1KC7l; Thu, 23 Jun 2022 01:04: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; Thu, 23 Jun 2022 01:06:31 +0800 From: Miaohe Lin To: CC: , , , , , Subject: [PATCH 10/16] mm/huge_memory: check pmd_present first in is_huge_zero_pmd Date: Thu, 23 Jun 2022 01:06:21 +0800 Message-ID: <20220622170627.19786-11-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220622170627.19786-1-linmiaohe@huawei.com> References: <20220622170627.19786-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; spf=pass (imf05.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.255 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=1655917611; 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=hbj21bdAHUOl7J2ZRs+7KEibVpPsfNhXgbPCP0m5NSw=; b=WhYTE01gYG8KOu/zKFsxKW0znQhv6jUUZoTcBC63NWd74yrDV0oFXO2oS9yn91WHVoofob /2WeR/7X/SG9TtnnQp0or+LBw3gNF9Tqi53Udso6wsiXQsFgdhh1/rz2O+9qA5Zta5MS/0 ux+NyQsLd/FiEj7BQD1LkHSaLXIZY28= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655917611; a=rsa-sha256; cv=none; b=fG347q5pxiHThyk+tlwChTCoCI/IVIS4xV3KjiGJHRlpcvpkia+cJnt3sCFb4AGwFgfAxw 52BzH0qQfd/e+64DvNZly+PAIfPvlr6KqMjVODjBmW4HEENC75H7No6Im6B4lvVsg8e6/V ByNniA+aMafeI86jz7MAaQsKbKORjtk= X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: E8CE2100028 X-Rspam-User: Authentication-Results: imf05.hostedemail.com; dkim=none; spf=pass (imf05.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Stat-Signature: sdf1ucui47pq174p1n4y9uqp54i89r79 X-HE-Tag: 1655917610-723865 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 Wed Jun 22 17:06: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: 12891175 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 0B665CCA481 for ; Wed, 22 Jun 2022 17:07:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7D40A6B00CF; Wed, 22 Jun 2022 13:06:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 71A0A8E00D3; Wed, 22 Jun 2022 13:06:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 31BE76B00CF; Wed, 22 Jun 2022 13:06:53 -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 E70506B00D4 for ; Wed, 22 Jun 2022 13:06:52 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id B8C416140E for ; Wed, 22 Jun 2022 17:06:52 +0000 (UTC) X-FDA: 79606501464.16.1AD9F39 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf11.hostedemail.com (Postfix) with ESMTP id 0F17E400B4 for ; Wed, 22 Jun 2022 17:06:49 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.53]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4LSqXR1nM0zDrGg; Thu, 23 Jun 2022 01:05:59 +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; Thu, 23 Jun 2022 01:06:32 +0800 From: Miaohe Lin To: CC: , , , , , Subject: [PATCH 11/16] mm/huge_memory: try to free subpage in swapcache when possible Date: Thu, 23 Jun 2022 01:06:22 +0800 Message-ID: <20220622170627.19786-12-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220622170627.19786-1-linmiaohe@huawei.com> References: <20220622170627.19786-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=none; spf=pass (imf11.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=1655917610; 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=BYGhDF/tmNqTlx2C88YLNUW3r/aPC526LMz+sx+oJw0=; b=yB+FVp2I6BErannczM7V3hSOwYqDItOwED9c53x5inwO8K/cArhohlfQJEE4qH1ZhF+rxO t671rv1t6api4+etm41h7YEOX0XNXJdOazmuIvNRFTNR1a+wiGKfh2LNEcYw6YV3vNJrXe tTSanX49mANilD1uPX7iMefL421SrJc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655917610; a=rsa-sha256; cv=none; b=R++5Svz8KsMsw0C9BN7Ns7LW9Uaoupg+kEMWeGVvvjT5SftAfIHsS8qSHg+WqNFu8ZTe1f 3ha74KSH5l7SIPgEuQKYxwwMi9IqTnA2kGuSEiQ6NO4ZXuJrSaMT+MpV/PMFJdKiF27eQu alMr9XmoPJ9ZB7HXaSo8LWmnu6Aagao= X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 0F17E400B4 X-Rspam-User: Authentication-Results: imf11.hostedemail.com; dkim=none; spf=pass (imf11.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-Stat-Signature: xuezf6gp5hegjrkg9qhfpkufxmh6izba X-HE-Tag: 1655917609-253190 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 fd12fa930937..506e7a682780 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2539,7 +2539,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 Wed Jun 22 17:06: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: 12891180 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 A7E55C433EF for ; Wed, 22 Jun 2022 17:07:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C75958E00D5; Wed, 22 Jun 2022 13:06:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 996D38E00D6; Wed, 22 Jun 2022 13:06:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 677F38E00D1; Wed, 22 Jun 2022 13:06:54 -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 443378E00D3 for ; Wed, 22 Jun 2022 13:06:54 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 228848118C for ; Wed, 22 Jun 2022 17:06:54 +0000 (UTC) X-FDA: 79606501548.06.5E728B3 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf18.hostedemail.com (Postfix) with ESMTP id 7E11A1C0016 for ; Wed, 22 Jun 2022 17:06:49 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4LSqT85tK4zShBY; Thu, 23 Jun 2022 01:03:08 +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; Thu, 23 Jun 2022 01:06:32 +0800 From: Miaohe Lin To: CC: , , , , , Subject: [PATCH 12/16] mm/huge_memory: minor cleanup for split_huge_pages_all Date: Thu, 23 Jun 2022 01:06:23 +0800 Message-ID: <20220622170627.19786-13-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220622170627.19786-1-linmiaohe@huawei.com> References: <20220622170627.19786-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655917609; a=rsa-sha256; cv=none; b=aOR1k2WChoYMxrTCfoB7mpqEpH/kx8oFkoBZk4Y0FemiA31FYuBMz7BIxhxiGvLlAVXeSj hEitStlG6Er8FdJu5LjpzexbOJlox4ZZzkGC9MI9v5Fqu5Jury/iTLEpQKMPUZXpHiDm8D 35QkSvr9sV2E8y0XsdPIR3MR48qEeDE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655917609; 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=RIOt7QIGP4ypomvGQ3TBO5jZwJNbtWFYEHxfhbxcgeo=; b=8YGHiKAiSTegpztz9wOoHZwjutZWcq6SGc/U4Kzp+ANiaM1q16oL71RUpjU7ySSGqgVPAz 3ZATZKdWgOcdiOjJqasSk+Mwr15cSnOwvXB4h/Mza0SdQmVPcmC2jKY67UEmuwJsGWzM2J eaQq6iT4flLE/RBJc/IOD0gv/NQn7ho= 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.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Rspam-User: X-Rspamd-Queue-Id: 7E11A1C0016 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.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Stat-Signature: iyinbbe1j45668zh9pi8hehowkke5eya X-Rspamd-Server: rspam09 X-HE-Tag: 1655917609-83647 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 506e7a682780..0030b4f67cd9 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2858,9 +2858,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; @@ -2876,8 +2879,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 Wed Jun 22 17:06: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: 12891174 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 CA79CC433EF for ; Wed, 22 Jun 2022 17:07:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5AC288E00CF; Wed, 22 Jun 2022 13:06:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 454578E00D1; Wed, 22 Jun 2022 13:06:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EB3136B00D6; Wed, 22 Jun 2022 13:06:52 -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 A67608E00C9 for ; Wed, 22 Jun 2022 13:06:52 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id E5403204D3 for ; Wed, 22 Jun 2022 17:06:50 +0000 (UTC) X-FDA: 79606501380.02.C08C610 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf23.hostedemail.com (Postfix) with ESMTP id 343091400B4 for ; Wed, 22 Jun 2022 17:06:49 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4LSqVd6XLFzhYds; Thu, 23 Jun 2022 01:04:25 +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; Thu, 23 Jun 2022 01:06:33 +0800 From: Miaohe Lin To: CC: , , , , , Subject: [PATCH 13/16] mm/huge_memory: add helper __get_deferred_split_queue Date: Thu, 23 Jun 2022 01:06:24 +0800 Message-ID: <20220622170627.19786-14-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220622170627.19786-1-linmiaohe@huawei.com> References: <20220622170627.19786-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655917609; a=rsa-sha256; cv=none; b=mAFJeqBQ8lXYRD9z+B5ArsMpYnoyT0jDsj/jF90joY07Wojn8pw0c8izxTKaOTd17p9mLD HRbgWpnz2ytvygmuhkRRP4hDgHTHXeQFEt35dsJnJm4/iU7MCxomfRo1sEm4ZmOSQXVA17 LlIaHN0e+CQiE5PAtj0LG5+BK18OTMs= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=none; spf=pass (imf23.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=1655917609; 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=WV+C+ZhSlalt/ScQz1oP6rV/W+OqiyyCTiyJ7nlsCng=; b=AJXbJwv6/zLZRa07jt/xcqH3xQVyTew2KiwqDdMufJ2w9iC2bhcan6xxdm4UgzwQXtVHLu I4sT9gpQr2701vS32Yp8Q54zQAMmaslqnpcP0mk9Nc26EeKGRmSj1Sd+x1gaTleloxL/EE EQZrB25P5MwDb8XXNYKGIBklbWaDch8= X-Stat-Signature: qepjqzkgctu6itg3f8tiqx4fi9af7whh X-Rspamd-Server: rspam06 Authentication-Results: imf23.hostedemail.com; dkim=none; spf=pass (imf23.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-Queue-Id: 343091400B4 X-HE-Tag: 1655917609-246281 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: Add helper __get_deferred_split_queue to remove the duplicated codes of getting ds_queue. No functional change intended. Signed-off-by: Miaohe Lin --- mm/huge_memory.c | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 0030b4f67cd9..de8155ff584c 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -555,25 +555,23 @@ pmd_t maybe_pmd_mkwrite(pmd_t pmd, struct vm_area_struct *vma) return pmd; } -#ifdef CONFIG_MEMCG -static inline struct deferred_split *get_deferred_split_queue(struct page *page) +static inline struct deferred_split *__get_deferred_split_queue(struct pglist_data *pgdat, + struct mem_cgroup *memcg) { - struct mem_cgroup *memcg = page_memcg(compound_head(page)); - struct pglist_data *pgdat = NODE_DATA(page_to_nid(page)); - +#ifdef CONFIG_MEMCG if (memcg) return &memcg->deferred_split_queue; - else - return &pgdat->deferred_split_queue; +#endif + return &pgdat->deferred_split_queue; } -#else + static inline struct deferred_split *get_deferred_split_queue(struct page *page) { + struct mem_cgroup *memcg = page_memcg(compound_head(page)); struct pglist_data *pgdat = NODE_DATA(page_to_nid(page)); - return &pgdat->deferred_split_queue; + return __get_deferred_split_queue(pgdat, memcg); } -#endif void prep_transhuge_page(struct page *page) { @@ -2774,31 +2772,22 @@ void deferred_split_huge_page(struct page *page) static unsigned long deferred_split_count(struct shrinker *shrink, struct shrink_control *sc) { - struct pglist_data *pgdata = NODE_DATA(sc->nid); - struct deferred_split *ds_queue = &pgdata->deferred_split_queue; + struct deferred_split *ds_queue; -#ifdef CONFIG_MEMCG - if (sc->memcg) - ds_queue = &sc->memcg->deferred_split_queue; -#endif + ds_queue = __get_deferred_split_queue(NODE_DATA(sc->nid), sc->memcg); return READ_ONCE(ds_queue->split_queue_len); } static unsigned long deferred_split_scan(struct shrinker *shrink, struct shrink_control *sc) { - struct pglist_data *pgdata = NODE_DATA(sc->nid); - struct deferred_split *ds_queue = &pgdata->deferred_split_queue; + struct deferred_split *ds_queue; unsigned long flags; LIST_HEAD(list), *pos, *next; struct page *page; int split = 0; -#ifdef CONFIG_MEMCG - if (sc->memcg) - ds_queue = &sc->memcg->deferred_split_queue; -#endif - + ds_queue = __get_deferred_split_queue(NODE_DATA(sc->nid), sc->memcg); spin_lock_irqsave(&ds_queue->split_queue_lock, flags); /* Take pin on all head pages to avoid freeing them under us */ list_for_each_safe(pos, next, &ds_queue->split_queue) { From patchwork Wed Jun 22 17:06: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: 12891179 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 4830EC43334 for ; Wed, 22 Jun 2022 17:07:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9139E8E00D4; Wed, 22 Jun 2022 13:06:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 84BB98E00D5; Wed, 22 Jun 2022 13:06:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 42D408E00D4; Wed, 22 Jun 2022 13:06:54 -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 097688E00D3 for ; Wed, 22 Jun 2022 13:06:54 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id DC62F61412 for ; Wed, 22 Jun 2022 17:06:53 +0000 (UTC) X-FDA: 79606501506.03.C492301 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf21.hostedemail.com (Postfix) with ESMTP id 3EAD51C00BF for ; Wed, 22 Jun 2022 17:06:50 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4LSqVf5hGkz1KC7p; Thu, 23 Jun 2022 01:04: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; Thu, 23 Jun 2022 01:06:33 +0800 From: Miaohe Lin To: CC: , , , , , Subject: [PATCH 14/16] mm/huge_memory: fix comment of page_deferred_list Date: Thu, 23 Jun 2022 01:06:25 +0800 Message-ID: <20220622170627.19786-15-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220622170627.19786-1-linmiaohe@huawei.com> References: <20220622170627.19786-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf21.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=1655917610; 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=khev0xV1QgkFIg6EntN8L6u1WaRQxrWemSzINrKX0ik=; b=XJcinunvl2zyUGyOK4o1MI1qMGSgstrR+KKwzfIJE73hImBFTfXwriCSx30e2qRFSMn+DJ m2YnPPKQ3ron1QIA0YOypOKx4m/hBwZ9TifDY++AQLURi/x+cXKuINHm/KWzg+GqGNaF0N GZlSeOWONZ+nMa6AAkeVlVvzwK4wwmQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655917610; a=rsa-sha256; cv=none; b=i2uoRbY+F+exyXhiMDPs0vCOajeDs7h31O4CCw9by0XCGzcT9otcWi3wyd/WlOhGUf63dx Z11bf6Gj6lC3+vgPvaP51q5s6bOiyeNtrGwSCeWqbaQqbmd0KiAncClxbwVMRukomZjCyz osl9gisn2jrzdEArJ0ytkmal/rawD+U= X-Rspam-User: Authentication-Results: imf21.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf21.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Stat-Signature: gtxctr6okyiar8bmc44gctb8hzzb6jbf X-Rspamd-Queue-Id: 3EAD51C00BF X-Rspamd-Server: rspam12 X-HE-Tag: 1655917610-839577 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..2e8062b3417a 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. + * Global or memcg deferred list in the first tail page is + * occupied by compound_mapcount and compound_pincount. */ return &page[2].deferred_list; } From patchwork Wed Jun 22 17:06: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: 12891184 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 D0CB7CCA481 for ; Wed, 22 Jun 2022 17:07:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7642C8E00D9; Wed, 22 Jun 2022 13:06:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 713028E00D8; Wed, 22 Jun 2022 13:06:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 564E48E00D9; Wed, 22 Jun 2022 13:06:59 -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 3C5198E00D8 for ; Wed, 22 Jun 2022 13:06:59 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 1D983354BB for ; Wed, 22 Jun 2022 17:06:59 +0000 (UTC) X-FDA: 79606501758.25.6F377FE Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf15.hostedemail.com (Postfix) with ESMTP id C1451A00A7 for ; Wed, 22 Jun 2022 17:06:57 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4LSqTB1y7BzShBf; Thu, 23 Jun 2022 01:03:10 +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; Thu, 23 Jun 2022 01:06:34 +0800 From: Miaohe Lin To: CC: , , , , , Subject: [PATCH 15/16] mm/huge_memory: correct comment of prep_transhuge_page Date: Thu, 23 Jun 2022 01:06:26 +0800 Message-ID: <20220622170627.19786-16-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220622170627.19786-1-linmiaohe@huawei.com> References: <20220622170627.19786-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655917618; a=rsa-sha256; cv=none; b=7rga9m0nRRMku1TV4Em2FUXBsMzRgUSL19tuQP1xQN+a+5GetwbS0T3U+YOjMVhZnBBgOm /bMHzDMDtbKHaWbhu0A6hrIVjVH1WNQl/lFOQPW06/eCNfa65xLkYdverRRP16Jki32vrR LSEPYqY+yMfcpK4CfKWzOS9XPc5iJn4= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=none; spf=pass (imf15.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=1655917618; 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=A2hrabp9qAjagRhWYPYfjwynFtoy3tAsz8spAaraMPY=; b=BdhX2xl+fQPbDNXpCxeiBGeAbxp0naZMhvSezDxOike4N4boi28icSPEBlasKSuxY4d/M9 WVE06efSvS81r69t3vhTApr7CUpecJC2iEEaZxHXk2sPk+da8RgZHy3UKvubhHqCXTjVh/ XacKqE0yhyvHY7bynKDlfOsfGJXr+Kc= Authentication-Results: imf15.hostedemail.com; dkim=none; spf=pass (imf15.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: rspam05 X-Rspamd-Queue-Id: C1451A00A7 X-Stat-Signature: oytm1huwa1e84fzmt6w7nzf91m1aiwja X-Rspam-User: X-HE-Tag: 1655917617-209996 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 de8155ff584c..8bd937cc1f74 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -576,7 +576,7 @@ static inline struct deferred_split *get_deferred_split_queue(struct page *page) 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 Wed Jun 22 17:06: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: 12891169 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 29BF5CCA47D for ; Wed, 22 Jun 2022 17:06:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 05D2E6B00CC; Wed, 22 Jun 2022 13:06:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F28656B00CD; Wed, 22 Jun 2022 13:06:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CDE768E00C9; Wed, 22 Jun 2022 13:06:51 -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 B03AA6B00CC for ; Wed, 22 Jun 2022 13:06:51 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 7056D20589 for ; Wed, 22 Jun 2022 17:06:51 +0000 (UTC) X-FDA: 79606501422.11.AA78E51 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf18.hostedemail.com (Postfix) with ESMTP id A8E991C0096 for ; Wed, 22 Jun 2022 17:06:48 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4LSqWk2dxzzkWhM; Thu, 23 Jun 2022 01:05:22 +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; Thu, 23 Jun 2022 01:06:34 +0800 From: Miaohe Lin To: CC: , , , , , Subject: [PATCH 16/16] mm/huge_memory: comment the subtle logic in __split_huge_pmd Date: Thu, 23 Jun 2022 01:06:27 +0800 Message-ID: <20220622170627.19786-17-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220622170627.19786-1-linmiaohe@huawei.com> References: <20220622170627.19786-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; spf=pass (imf18.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=1655917609; 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=MXKxAKOOK4Q84o2hJ8b0bTNW9kwJDI1+cDgfu++r/Bk=; b=EWsJswosB5x639iXjpJyzTe2VFBRxVTQcmHVuAdKvc5LRCWmDZn80NPodGQT73RE5ME8b8 F+uVZ3vCMvyCqneJjonjdu9gxxCFp8q3mgEVHbjv+YE7++l7C/wi8nMu65TYeFX81hN7xU DRH+tYdIDnr5THjYEfrg7G31VQgvW38= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655917609; a=rsa-sha256; cv=none; b=YX1Frgjrke5YdKRqkXLN57XocsuqdD6y5A+cB3l+CogP3x4eRUNXTA1S/Med1X2aqECPHw zu2T1VYCtafeWAvGtnSn6cqUZONgFWf11sCsjnUnvgmhzIMhPvMBdXNTzmOHqgrOdXInng fPNN0YjCqmkPHqFU+BYgzAOto+4swUc= X-Stat-Signature: gibaukzd831oxm4o4fmdpqk5uk55m6sr X-Rspam-User: X-Rspamd-Server: rspam07 Authentication-Results: imf18.hostedemail.com; dkim=none; spf=pass (imf18.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-Rspamd-Queue-Id: A8E991C0096 X-HE-Tag: 1655917608-687030 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 8bd937cc1f74..b98b97592bd3 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2234,6 +2234,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);