From patchwork Thu Jan 12 08:30:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 42297 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp3761203wrt; Thu, 12 Jan 2023 00:23:26 -0800 (PST) X-Google-Smtp-Source: AMrXdXt3LVV2yQ/Rkjcx1OT+iRG0KuwchGsj2rUASQfHiDg2GuGSj4nZvuH3XxUNUbyivisle4td X-Received: by 2002:a17:906:edd6:b0:84d:138a:316 with SMTP id sb22-20020a170906edd600b0084d138a0316mr21499296ejb.36.1673511806698; Thu, 12 Jan 2023 00:23:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673511806; cv=none; d=google.com; s=arc-20160816; b=YxRN2ehodSd2ELxNvRPetmwx7xfMNmyFhHQwrohigI4gHh4aN70X0rimC1ofIE/48X /K2J7swBhOpsAew3+rDSavq9I+2qlxsKT+GiicRj0aaorxhUe6SxcOG7ku+2eKEGetTE QxkZQTm/CRD5BPFnTE1Pk387ZVmHHORp5vCO4QPwvBCGoTCo8AtEILrEu9F5BsJ5KL9P baQsNb84+xrLkHAf8FgbBXS1IgxIfjbcq9IJVLnGZ3JGjpGaJepX2TBc34yAE/VoClI0 aZNlJO0qknCbQrY0xcf2/XtUo1Of1xsf4CfMbA1TTSZjVBR3wlbGADhPHVUlO8x93XER iodg== 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=f410hYM6HfpdiyxHhhDFQuD0DaLql9Gj21P5cfv/VWA=; b=UFVsfliL2Q0dpf0RzY0PAdhNwkd5Fwna9d8T3EePvKjlSgLB3+1QgS04sMfu/cR3w6 dPfTth6lhns6mFfZClDbkwKXUFJ6xfslgC1bI5wkYTbSkfP4CApBPd74i9mHRLixbOZ1 5rhKEN8I51ByiC/EAAHCP0CjPe+ZFZuL/JLY6lvA7jK241fhKjInPekUd0uasXWa8zVo GF1A2Ba51uwf7cMwbn0p7S+pv9WEw69Thg3AHvcM/0l+I/RoaEth8DAnREksU7kpy28A o+GL0HIG+XG+OYZrmrEXon8ZDr9SPy32X9BVMeFteDjpgacMzW4u1sYY5uRGYjRwxkFn GuEw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sd40-20020a1709076e2800b007815e9c5b80si19163921ejc.617.2023.01.12.00.23.03; Thu, 12 Jan 2023 00:23:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239678AbjALIR7 (ORCPT + 99 others); Thu, 12 Jan 2023 03:17:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239481AbjALIRx (ORCPT ); Thu, 12 Jan 2023 03:17:53 -0500 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 467B935902 for ; Thu, 12 Jan 2023 00:17:35 -0800 (PST) Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4Nsy3m238PzJq98; Thu, 12 Jan 2023 16:13:24 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 12 Jan 2023 16:17:32 +0800 From: Kefeng Wang To: , , CC: , Kefeng Wang Subject: [PATCH -next 2/7] mm: memory: convert do_anonymous_page() to use a folio Date: Thu, 12 Jan 2023 16:30:01 +0800 Message-ID: <20230112083006.163393-3-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230112083006.163393-1-wangkefeng.wang@huawei.com> References: <20230112083006.163393-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754804316229484351?= X-GMAIL-MSGID: =?utf-8?q?1754804316229484351?= Convert do_anonymous_page() to use a folio and replace related functions to folio functions. Signed-off-by: Kefeng Wang --- mm/memory.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 56b571c83a0e..1cfdb0fd8d79 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4002,6 +4002,7 @@ static vm_fault_t do_anonymous_page(struct vm_fault *vmf) { struct vm_area_struct *vma = vmf->vma; struct page *page; + struct folio *folio; vm_fault_t ret = 0; pte_t entry; @@ -4055,16 +4056,17 @@ static vm_fault_t do_anonymous_page(struct vm_fault *vmf) if (!page) goto oom; - if (mem_cgroup_charge(page_folio(page), vma->vm_mm, GFP_KERNEL)) + folio = page_folio(page); + if (mem_cgroup_charge(folio, vma->vm_mm, GFP_KERNEL)) goto oom_free_page; - cgroup_throttle_swaprate(page, GFP_KERNEL); + folio_throttle_swaprate(folio, GFP_KERNEL); /* - * The memory barrier inside __SetPageUptodate makes sure that + * The memory barrier inside __folio_mark_uptodate makes sure that * preceding stores to the page contents become visible before * the set_pte_at() write. */ - __SetPageUptodate(page); + __folio_mark_uptodate(folio); entry = mk_pte(page, vma->vm_page_prot); entry = pte_sw_mkyoung(entry); @@ -4085,13 +4087,13 @@ static vm_fault_t do_anonymous_page(struct vm_fault *vmf) /* Deliver the page fault to userland, check inside PT lock */ if (userfaultfd_missing(vma)) { pte_unmap_unlock(vmf->pte, vmf->ptl); - put_page(page); + folio_put(folio); return handle_userfault(vmf, VM_UFFD_MISSING); } inc_mm_counter(vma->vm_mm, MM_ANONPAGES); page_add_new_anon_rmap(page, vma, vmf->address); - lru_cache_add_inactive_or_unevictable(page, vma); + folio_add_lru_vma(folio, vma); setpte: set_pte_at(vma->vm_mm, vmf->address, vmf->pte, entry); @@ -4101,10 +4103,10 @@ static vm_fault_t do_anonymous_page(struct vm_fault *vmf) pte_unmap_unlock(vmf->pte, vmf->ptl); return ret; release: - put_page(page); + folio_put(folio); goto unlock; oom_free_page: - put_page(page); + folio_put(folio); oom: return VM_FAULT_OOM; }