From patchwork Sat Nov 4 03:55:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13445386 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 45307C4167B for ; Sat, 4 Nov 2023 03:55:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9F08D8D00D4; Fri, 3 Nov 2023 23:55:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9A1638D00D2; Fri, 3 Nov 2023 23:55:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 88EA98D00D4; Fri, 3 Nov 2023 23:55:52 -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 7C53A8D00D2 for ; Fri, 3 Nov 2023 23:55:52 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 5CDA5B6488 for ; Sat, 4 Nov 2023 03:55:52 +0000 (UTC) X-FDA: 81418908144.17.92E76EF Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf23.hostedemail.com (Postfix) with ESMTP id 31A2D140006 for ; Sat, 4 Nov 2023 03:55:49 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=none; spf=pass (imf23.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@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=1699070150; 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=vvr+Gp+CIzn+T6Sky/V+P109WJdRdmjUuqGFwTBrUlc=; b=DDoW5o3JdcIEkD0BpwRTCHfvrGsu2Dd/xOS6cCbYBIipb/+MvYpU/Gyj8gT3PBAKjSZJlw nZxPKHVgLXQJK7X21PHN6HhS0uyvI7sDyrVbWuCzjB/LEC+0FuRP7tdxsZXBCNlJvEXpd0 OfIQ0J8FSxmlb4r9wAVDRMTnfeIZnzA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699070150; a=rsa-sha256; cv=none; b=NOCSlRlXgvKi6zyF1CltonXSkjIm/1VGucPkLJ58x19GiiKYnSwcoyi7JXSq+zYRq5tRQF 9HVFIszK7cYaQwIJzNZxUjfOrSKl167rHk8MonBLa1qNKRlKn5uy+iso6vchLxHL3yCMOs 6ysr8pDzjQwPdFOVbB22sL6BJGq/uXs= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=none; spf=pass (imf23.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.55]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4SMkDm4Z5TzMmQq; Sat, 4 Nov 2023 11:51:20 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Sat, 4 Nov 2023 11:55:43 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH v2 08/10] mm: memory: use a folio in insert_page_into_pte_locked() Date: Sat, 4 Nov 2023 11:55:20 +0800 Message-ID: <20231104035522.2418660-9-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231104035522.2418660-1-wangkefeng.wang@huawei.com> References: <20231104035522.2418660-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 31A2D140006 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: srdwsyifgpn7e8gytom3o6of6ciepcfj X-HE-Tag: 1699070149-777139 X-HE-Meta: U2FsdGVkX18mPRjdZPMfVvTgy1Z9zZzgnHBtlQFwSvB9Kn48BblmJzxxSErcRWP4HVR5O1BTqIV6JalgXiVtoGfcw8S909/Im4T0wcKmDaCW7TWu9TycHQ+CyqjZLzllgsDDt7jcFGEkEhgHqh0TdbODkB+DQDjHiscJb7E9ecYVxXBt6bUNRvzMS/NknGSi0d1hfvYKii1YSgUi7yZ2oJwB7Ok8mMdNDt0WjAlSMjw4AyyWwA4w8OxXyJHBRBP3UaS/u0WEHOleyt2sG1VycoSJyx/6DOWgQscPpWGX4A7Ie06h1VJ+NJ1U2j61i1i7whp3CaIwkWoGP/g7fv84ochi+rIrg8sH9ret5PVsZGUxyIMJoWsVgt6/pZa6OTykOfmMy/Nnzk6x3Hcq6c9I3uIncRSpfNEla8geO6fzZUXwbIzAKq/tY1lgLzqsLcSiin4tlNp01qUBRiqqXtNIafxbIID/hYzkWmUFyn3l/IE4Y1gnrKWJAeUK9aJnMrsRqEOgSolGOVKMfenavXWg7XiLfoEq9Mh1Zzfbcao3ZzN+0uGAIPtTVTi7pNbp1Pg7u1dmjqmm5v3zeMdx4yDKg0XG+otzuZ1kA6cTc7ULEGYwLvarZDVABqSBHlwymPeX1aIDtuxgJOwC+Ebd36iTg8Nhq10kL81KiPRYshiU9e8xUfOtTjPi7CbMM/PnYtQJI+maUI3S9SZ+sAvpNNzgAZrNaSAyXe03I7RQpHPg9HWY4qrx4crjWxKwRhjgGil3SueqCRnewn9fCJRBrBSOUExdvRZg9lmwc1O5SDw/KyfA2KH/s3hw8FE8Y72hkx10fU8rzITiTO9rh/rUSejW6RTF3HRgQ21ovRNXMsj5OXaX2iu2DE4YDLt9/wgVqDHRWIxWhiZGucAyGIdDhb9AnssVAlX5uIBk8kg/fGcjw6ybsD81UBq891baOJFGhaYhA5jTHG9JtXAGomeOWGV 0fvTAJW0 frRvSyjEJYmrPH2lpr+GD48NAwuKSkrDpvLG+sG9zWV++I/aFh71SAHPy7+/mLd7Ay7XPgPm7y5KYGYevGVPUKG4BsjWc4SW+RGZPV7/4/NqmcJly7e7jCWL3mK9XBrOyQlMdsFrj1bmDPrHNMBeBzRE/jdvO4H24LfltlLMrB4BSRCgSBFGNhpTgOoKxzkw+fIIaNzYRatCffcWVewdpMNodOw== 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: List-Subscribe: List-Unsubscribe: Use a folio in insert_page_into_pte_locked(), which is preparetion for converting mm counter functions to take a folio. Signed-off-by: Kefeng Wang --- mm/memory.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mm/memory.c b/mm/memory.c index ac247850919a..a2cf240b1975 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1850,10 +1850,13 @@ static int validate_page_before_insert(struct page *page) static int insert_page_into_pte_locked(struct vm_area_struct *vma, pte_t *pte, unsigned long addr, struct page *page, pgprot_t prot) { + struct folio *folio; + if (!pte_none(ptep_get(pte))) return -EBUSY; + folio = page_folio(page); /* Ok, finally just insert the thing.. */ - get_page(page); + folio_get(folio); inc_mm_counter(vma->vm_mm, mm_counter_file(page)); page_add_file_rmap(page, vma, false); set_pte_at(vma->vm_mm, addr, pte, mk_pte(page, prot));