Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp896501rdf; Fri, 3 Nov 2023 20:57:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFWMpTtrMC8EQVUyuUGJxcnrvDDrbznsh97KSWHRTH6iWDVpCh0Dv3gPUAZJgqNDmYelci5 X-Received: by 2002:a05:6870:b14e:b0:1e9:e268:ab6f with SMTP id a14-20020a056870b14e00b001e9e268ab6fmr29569178oal.17.1699070219682; Fri, 03 Nov 2023 20:56:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699070219; cv=none; d=google.com; s=arc-20160816; b=jJOKCa65HE+8+WiaS6J23DUMiXFS+0hnV6ERwbObLM2KnjtX3YgsIhkVQZj5dvQJan zJ1Jj50l+7+cjPF0dT94ISoj94rUKBSAw7+Qi9v6xFW9H5xlWVEk6GE109IMNIY9RDuf Jt0fj5oHHeRlxjDgNbSZRhIO+V5RPqB40u/lqp1Z/cEApkUPHXp/EKl8LPj+s2pyLHOQ cGJDNH6mVfir/y4FCjU/G0KlBkv2oPIYSTn4+/ejcm+v6parNGD5GSVm/a8oAveJ/QQN i2F1OHy6OdzltAW004AKqztLj6+WaOppoomC5npVZeZbiRPdp6kb0ZfoDzwtVX/YZU4n T5/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=vvr+Gp+CIzn+T6Sky/V+P109WJdRdmjUuqGFwTBrUlc=; fh=kUj/5waaepfljbNx30rj2BALdV0u/mUCTaFWThlgquQ=; b=xN917w40gEjb7w/d06QF8hRZvTtyxa6dqpgsTjJETTqedelSa8WcwOVWDbDam59Phm oX8Qr4kaxATe9qQjuLBXFHMMs2QvU579nM3wF5bufjrpImYIKMOreKocX3+ed7qethBP eWeQJz0MFHhm03pzyJcU7f87PTJ9/1vJ3EEcfHB8lAAK0qWbTwgbS3+an2hEkSK/kMiY 1O0jszXVcoWxbcxz5BeaeyNuLdBPiLZxlZmgqzO8b08Ge7KMPitwuY1Z7Ykg4xpkmrAF DasENSgRIsCPUzep6hPJ7CopYndFU02a2f64a6hzmAkGXXtNZAftk/xTVP34JRF/2WlF bJkQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id c17-20020a6566d1000000b005b91a58721esi2833421pgw.316.2023.11.03.20.56.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 20:56:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 15F808208F33; Fri, 3 Nov 2023 20:56:54 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346273AbjKDD4T (ORCPT + 99 others); Fri, 3 Nov 2023 23:56:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343779AbjKDDzs (ORCPT ); Fri, 3 Nov 2023 23:55:48 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08EAFD54; Fri, 3 Nov 2023 20:55:46 -0700 (PDT) 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 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII 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-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Fri, 03 Nov 2023 20:56:54 -0700 (PDT) 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)); -- 2.27.0