From patchwork Mon Nov 6 15:49:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13447142 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 2D847C4167B for ; Mon, 6 Nov 2023 15:50:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C305A8E0002; Mon, 6 Nov 2023 10:50:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BE1838E0001; Mon, 6 Nov 2023 10:50:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 948A88E0002; Mon, 6 Nov 2023 10:50:14 -0500 (EST) 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 800568E0001 for ; Mon, 6 Nov 2023 10:50:14 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 0161A8068F for ; Mon, 6 Nov 2023 15:50:13 +0000 (UTC) X-FDA: 81427965948.08.313DF48 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf01.hostedemail.com (Postfix) with ESMTP id 0B81440021 for ; Mon, 6 Nov 2023 15:50:10 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf01.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1699285812; 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=8W4DGONJ14Bibgm3pNXmI4YyRAKX5ZNYD4yPVpkOEtg=; b=8rYzuJ4rVGEfUs+IO7pi3dLKtdjcIXVGLsyIkCDi6xBeBc1CksNz0fjvqKGA4cuqiUSB/u LfNzVt7idxEtWI6yAYzFeaIET5MGE+NyhRCZxjwg9rtgQWI+RQbIp9W7iC0aViDdHeZW8i tdm8prgIzcOIt2YUaV9jkUL6LIA6ME0= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf01.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699285812; a=rsa-sha256; cv=none; b=FAYW82lRcosyuUgy/lC9e8KZTMUO6Rm/ere1739VMhWZLIntbxBwNXnJnpL5MjnBdDxyeA M44+JyEXWD1yoT5tJjBS3y+PBbwc8o2RJbK5Zmj6tA4KH4+HzT+1AdnwgKPx6zNvMKEBFz Cbcoo60jPztIPAQaBHSrbdkMG3Qpscg= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4SPG0L0dT2zPntQ; Mon, 6 Nov 2023 23:45:54 +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; Mon, 6 Nov 2023 23:50:02 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 08/10] mm: memory: use a folio in insert_page_into_pte_locked() Date: Mon, 6 Nov 2023 23:49:48 +0800 Message-ID: <20231106154950.3399469-9-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231106154950.3399469-1-wangkefeng.wang@huawei.com> References: <20231106154950.3399469-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 0B81440021 X-Stat-Signature: ysjomr9beu83y5d18om3r1wrwwtqfhb9 X-Rspam-User: X-HE-Tag: 1699285810-431889 X-HE-Meta: U2FsdGVkX1/dRRS90qwr5XYn2orWQ9dyNycxgTnoLN5u8qJqbSIH5sOmVOAbFOLKXkUdFkGM8tCaxGVuBiSXxJm9aNNsuEbkw8+Vy8tMvw/He8PFldCDiEa9EGrZiEbuE7G/OjFdeGJaM/xQ022kP64kEDVxBl41Ozn2BpA/aSk+jEdrvP6NKZfCxLcjCrKDm+AAvsLnzi0iyyOKdYj+5Rh+PYud5NXbjhrC+XG0YHuE1UxT2zgK9LmNgpQlTQxmxyVOJs9RowrY6cNTOy3+Hxqh8fV5NAbW3LW/CC9BNnNwMYGpFdpcz8chOgQ+x2zv7nBfFa4oT72R7Idk8jZY7HB81SlnbC+726Y0Eudmwt8xzHi3fXQfM0uVXAmHZNDOp6seeNEj4t3QkBw22W4I3nP+QIXIpdUcXsn2UT0ZxAVKAQLN+UgiHVDh+rZePWJ5txudTkf1Wpk7dp/wUu0d7qlMKYrNwUQfa7fuCGz1eI5kIeajt6LNyaO9cYOrPDUanByzUdhi1LUuRQWW/38dZHeHCY6/y35dlclJlGHI6Ao/yEGMgA6AqMmllfTViWsy4TYJ4uJ9fMNJYyWaG2Khhjz6GX7t5KaqI7RP7ymHfHpkHpRRmCS8rpLjpWSEq6DlDIp1Ycjb/Gjl7cVH7cxMa5a79h+vEfblIHAesmRWKfsSXNAuLeyAAHUQA5fdg1msR9jQX3q9KXov8nk1acKF/vgGIUY2T1B4YDNzuiObs3ABjF1T+MF6d3QuzQ9uJPiyUI+wtOX6nNa8VNT2vB9PqN11quIJqBMlrEghWb5422FveBi7mbPloLmlqdPc9kQ8yVsED6AC048xcYvUzaEFb2sF/Z6XVcSoH8VY+U4kr0pkyVyzDB4WQ7SexUwZVhSk2FDqVOMq7vP1v2ZSCNOSFVJ3LAYK16VQ30f1X45CqN4AEdrR6YFgF51Hx455NhZeILxHz547+hZ/Ho8fndB SwjnAl9U i/SZsS4wwtdqMOJC6+vJwRwcv+sVj0jfunyfrLTYeYTW7veDfdMD6QSaRUwrkQQCvj+iYqfEEoAftTV3T5qNsnkmE8IPjEW6EuY5OYKf5+F/hfA0t8mEdHEyd+KVx+cjbAwD/YV6cuGnRlCde0EtrtO6T2YSrKyVsyJznNaAArmHcofUOLeICiOYk4VyOSJbdHya55zHNaFIj9irWmzbA1MTwdw== 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 fbed32a09fec..dd3760988e02 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1854,10 +1854,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));