Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp10666740rwl; Thu, 12 Jan 2023 00:34:07 -0800 (PST) X-Google-Smtp-Source: AMrXdXtuE/xiIoHRrbCAdWlXnycdcj7lGf5rSRSaDf8PmFmPY8/aG93PIL7xlla+yP+P9ndiKn5m X-Received: by 2002:a05:6402:e82:b0:48e:afc9:726 with SMTP id h2-20020a0564020e8200b0048eafc90726mr31530431eda.42.1673512446787; Thu, 12 Jan 2023 00:34:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673512446; cv=none; d=google.com; s=arc-20160816; b=SeBT9U0/ntkwJyzJCovdRmYyRp1q1fYwYvRmO1by2O3PuQMB8ggrmOqufjin+c9WGQ 11hzV3dgfOJR9kl7c+2jqKGzWclgV2Gw9hBrtalWKhODN/MqQoe7Yyf0S8CkmSFS8HBo glbnEXOenij2krK5szCGYyJdF/CwDYqrWF8KJ1ZC8wAPjDAEWrnGg3Egweok3AO22feu OnPoxlbhlU9Ip9L4w1bOWaARItrXXgiDkDEpdV2UdwE2vDUsrWjnUO8jQVPr3fs3v4uo NE2VSFLSSN9EQlfnX/cW6pbo64svICbSTXDWx+FR2J/4topFdXytgk1kFDFc3UbqtPcH XIag== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h2-20020a056402280200b0047f9f11dab3si20426933ede.25.2023.01.12.00.33.53; Thu, 12 Jan 2023 00:34:06 -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 + 52 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 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII 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 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; } -- 2.35.3