From patchwork Wed Apr 3 17:18:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13616537 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 3057DCD128A for ; Wed, 3 Apr 2024 17:18:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4905C6B009C; Wed, 3 Apr 2024 13:18:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 43E446B009D; Wed, 3 Apr 2024 13:18:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2E0DF6B009E; Wed, 3 Apr 2024 13:18:47 -0400 (EDT) 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 11C4F6B009C for ; Wed, 3 Apr 2024 13:18:47 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 4473E160BC5 for ; Wed, 3 Apr 2024 17:18:42 +0000 (UTC) X-FDA: 81968880084.25.EE853CC Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf15.hostedemail.com (Postfix) with ESMTP id A49F1A000D for ; Wed, 3 Apr 2024 17:18:40 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=CpIP3BOg; dmarc=none; spf=none (imf15.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712164720; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=P8+6TjAMcEOrqM2Z3/eY5WjRMgJRuZlDrWpfRv4AbQg=; b=25rVL8HPx7YRE7fx8POz/i3ABpddHr2BzG+xsLR8i+F5CRo10bszZiKPtOGmtIbkOt74+E ct+lKg3TO8RHkC1HSypmHRo4MoaMdMP+VR5Zu4JV66kxKGTkX0Q4sSj/459Eo9aN7TXYMj C99bJLCzaivdMKzQYjSftugMQz7QNUg= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=CpIP3BOg; dmarc=none; spf=none (imf15.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712164720; a=rsa-sha256; cv=none; b=xXcjLdhOvykPbCsMQwqeC2bVG4g1fYmUr6jjEUHomo38FeORJwZU2IkDxYu2rtzZyWGGly qqzG2c+XO7BPPO9aQEsp/hbrdHEdG7NeWBPS2Yp+R5hiVs/sdlEEK8xjWYFi1ZAoHE6doO 3FK6eNCRtL6XCKOW3exmUPSrxFRH3YE= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=P8+6TjAMcEOrqM2Z3/eY5WjRMgJRuZlDrWpfRv4AbQg=; b=CpIP3BOghWHuA78aesPeRz66Vn 3sD3cRDZpIS292UgoGRAZ0Jji+y+WP+cJzC3WJUybsTnkGJIkqQihkxd1wjXFRKTe2WLFXFkO8+Dm T/AouZHmhJKqdJOOEFSb6nta1CvUt/eO4z6t6a7NDNNbFyVSUg+LFP3OCPLtqZmEMUy/8OH075NmD bKRL2odk3gUhN2vYxo6P4HnBj1vfOSZS0OB+B1egQcG6bpiFbhzKFc1kHTXCdBJojlcwz2AXL6f6m xwnKbhA5Hv9kM2KmOdYihlyBrvNcYKFucJAukt/IUeaByCYBs6+FO77T8tUDq74xI43QuYMh1O08K dK5xduEQ==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs4Fz-0000000648g-1VOO; Wed, 03 Apr 2024 17:18:39 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH 2/7] khugepaged: Convert alloc_charge_hpage to alloc_charge_folio Date: Wed, 3 Apr 2024 18:18:31 +0100 Message-ID: <20240403171838.1445826-3-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240403171838.1445826-1-willy@infradead.org> References: <20240403171838.1445826-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: A49F1A000D X-Stat-Signature: k5tpw6y1z36fh3468f5fkqgdb963rzo5 X-Rspam-User: X-HE-Tag: 1712164720-470881 X-HE-Meta: U2FsdGVkX18AreXOkx+QaFdbltUrmtVky3IrEyD1SOMnCGa1k3jzsFCB6th5JviFp6O87xUwmpjdmLUojMZvkYneCyHBPnkE9pDGpwSKvkqR3ivuc7qTZsZSYdt7HMCHHETkVwhhwbnkIWOBOrBJfKqu4nVxb2HhDAFh0eV3SQ7oFozvrninKU+R3cohRBEgI+vYL1ZYY0CxlvwtZGWS+OQVayIYsNd2XZUyHL49dU++byiuzP7kmdBC3KZb6ZTAyO6RFz6KpNDLzsQIpQ458GbMt3yKzzDur4HAD6g9e+FhQh3GW40ecYPmasOTqer+w+EkUYN53XE3mI5knA2HmBxGtfNKPFOts9vhmoewmsnquJIxublt2WfRviD94Gx6QMa9v24iB2VmWcdEZYSMOSnO8oQon9pfOij7vC5jxQhorAXYasH7tlJkrRx0YYJPgsNt01qeWmalqWzyO7AKJi8C1Epo+gcftwvMFY5t63ul4IWfcvms2s76/O7k+s6j//Ooix2l9wWiaDlsXWUUS88p3Gfs57sUpoCDJNfgaJgApfaPzDS0BzczPi46S+lgo6HSuvGDePfaVL4Tbx0udbHLzh2j6e3CFrx6pK3UkwxDQmJtu2CQDd1KF+DOBmw2NyNh3drjt/KMnALXTCqXASafNEuEcpEH5ZOjS3ydxnXRscih29oRR8guPxPdCAB8IhVgrA4GgI8hdmgAYvDmSYSWO6CghrxaOgJe2VSSc2aHpq2bXP9BCsj2/CiAGpi4qCAoCNLx2RlLMcj3DPYM35guFedA/xzyHXAtFQqQp9PgTBD3JkXiAZPTPmS/1kASoFz7CYKV+dOfIb7gb0ULTTKx6PAZGLE47G9azEMb5VYM1rOXo/U+j+RPA/TTE84mQhTsbkCmQ4lrYDlUzEEtmB1BpeClxY8JRPFdr3QHk38dZl2I0DVXUfWy910z7Wn3dsKBWqzjBBMPE5/q0QY GqhYX/52 UtY8EtErf99ZQX908gvJpebSRQa/wQ30fVlJEsXTQ0DM7nZ+ErptIqxtJ7/BJE63tFoP8+ZTmLMvEymU0t+nNbmXAz3yMz4vYXPrtuW/CM9ysyWVQBlzYIFs5hJmZpNcWQfX9kcy0NJuECuyEMIrHRWpmOrSPsWkjGHQ69s7L8J/fgRlsZbxBtlSfi4o91pbUHO1SejueJPC7/KtA2dzaVrRvEA3tPmCwhDbh 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: Both callers want to deal with a folio, so return a folio from this function. Signed-off-by: Matthew Wilcox (Oracle) --- mm/khugepaged.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index ad16dd8b26a8..2f1dacd65d12 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -1045,7 +1045,7 @@ static int __collapse_huge_page_swapin(struct mm_struct *mm, return result; } -static int alloc_charge_hpage(struct page **hpage, struct mm_struct *mm, +static int alloc_charge_folio(struct folio **foliop, struct mm_struct *mm, struct collapse_control *cc) { gfp_t gfp = (cc->is_khugepaged ? alloc_hugepage_khugepaged_gfpmask() : @@ -1055,7 +1055,7 @@ static int alloc_charge_hpage(struct page **hpage, struct mm_struct *mm, folio = __folio_alloc(gfp, HPAGE_PMD_ORDER, node, &cc->alloc_nmask); if (!folio) { - *hpage = NULL; + *foliop = NULL; count_vm_event(THP_COLLAPSE_ALLOC_FAILED); return SCAN_ALLOC_HUGE_PAGE_FAIL; } @@ -1063,13 +1063,13 @@ static int alloc_charge_hpage(struct page **hpage, struct mm_struct *mm, count_vm_event(THP_COLLAPSE_ALLOC); if (unlikely(mem_cgroup_charge(folio, mm, gfp))) { folio_put(folio); - *hpage = NULL; + *foliop = NULL; return SCAN_CGROUP_CHARGE_FAIL; } count_memcg_folio_events(folio, THP_COLLAPSE_ALLOC, 1); - *hpage = folio_page(folio, 0); + *foliop = folio; return SCAN_SUCCEED; } @@ -1098,7 +1098,8 @@ static int collapse_huge_page(struct mm_struct *mm, unsigned long address, */ mmap_read_unlock(mm); - result = alloc_charge_hpage(&hpage, mm, cc); + result = alloc_charge_folio(&folio, mm, cc); + hpage = &folio->page; if (result != SCAN_SUCCEED) goto out_nolock; @@ -1204,7 +1205,6 @@ static int collapse_huge_page(struct mm_struct *mm, unsigned long address, if (unlikely(result != SCAN_SUCCEED)) goto out_up_write; - folio = page_folio(hpage); /* * The smp_wmb() inside __folio_mark_uptodate() ensures the * copy_huge_page writes become visible before the set_pmd_at() @@ -1789,7 +1789,7 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr, struct page *hpage; struct page *page; struct page *tmp; - struct folio *folio; + struct folio *folio, *new_folio; pgoff_t index = 0, end = start + HPAGE_PMD_NR; LIST_HEAD(pagelist); XA_STATE_ORDER(xas, &mapping->i_pages, start, HPAGE_PMD_ORDER); @@ -1800,7 +1800,8 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr, VM_BUG_ON(!IS_ENABLED(CONFIG_READ_ONLY_THP_FOR_FS) && !is_shmem); VM_BUG_ON(start & (HPAGE_PMD_NR - 1)); - result = alloc_charge_hpage(&hpage, mm, cc); + result = alloc_charge_folio(&new_folio, mm, cc); + hpage = &new_folio->page; if (result != SCAN_SUCCEED) goto out;