From patchwork Thu Dec 14 16:02:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13493224 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 E25A3C4332F for ; Thu, 14 Dec 2023 16:03:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4F24C6B05A1; Thu, 14 Dec 2023 11:03:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4A2926B05A3; Thu, 14 Dec 2023 11:03:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 36A466B05A4; Thu, 14 Dec 2023 11:03:56 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 279466B05A1 for ; Thu, 14 Dec 2023 11:03:56 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id DBB9DC0CDE for ; Thu, 14 Dec 2023 16:03:55 +0000 (UTC) X-FDA: 81565894830.01.CEE7CC9 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf09.hostedemail.com (Postfix) with ESMTP id 46935140255 for ; Thu, 14 Dec 2023 16:03:07 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf09.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1702569787; 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; bh=lnZNgvR6EEyZzyqYZW3gbAAbM+SXBGR3kU6QEfSIFsw=; b=CF5e0qNKPRK8h428KhTSrdvhFosPC5JIFln2ycXPJXfkb4+jiw5mzIEOfpcuXnb1n2l7tW Wm5riIIXjzp61Fq1gaz422LiwV7MuLpuM7L3TcL/0GMFBWwZvnqyBOV3El6ywekxIsUBbB BuSWldq/bjNQnEvUs2dCxUBik1aC01c= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf09.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702569787; a=rsa-sha256; cv=none; b=ofwec0F3BhjW2OyIWNQyLL8pXvotLNi5nt1f9OB1UftH1upHmcSRHsYR7KsQNibDaobhhl tYwi4FMtLtzpacuFbLm+1GVHyBNq1PLfCUm9gDGQsnqUvdGYQzNgVrFQNT/6dwOJds27uj wXW6TEsK3+ZklYx8p+uykrmUGTvhEVM= Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9E6D2C15; Thu, 14 Dec 2023 08:03:51 -0800 (PST) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2B66C3F5A1; Thu, 14 Dec 2023 08:03:03 -0800 (PST) From: Ryan Roberts To: Andrew Morton , Matthew Wilcox , Yin Fengwei , David Hildenbrand , Yu Zhao , Catalin Marinas , Anshuman Khandual , Yang Shi , "Huang, Ying" , Zi Yan , Luis Chamberlain , Itaru Kitayama , "Kirill A. Shutemov" , John Hubbard , David Rientjes , Vlastimil Babka , Hugh Dickins , Kefeng Wang , Barry Song <21cnbao@gmail.com>, Alistair Popple , Dan Carpenter Cc: Ryan Roberts , linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] mm: Resolve some multi-size THP review nits Date: Thu, 14 Dec 2023 16:02:51 +0000 Message-Id: <20231214160251.3574571-1-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 46935140255 X-Stat-Signature: nt5as1qjpmuqj77puy4bd3ezapz6f8f8 X-HE-Tag: 1702569787-212788 X-HE-Meta: U2FsdGVkX1+FkLMe3bUHwK3bqegApCCDxmEL+WvcAJX4i80e+WehdZxMVvb+MHiiIuRGzKLNoLSYcSec5ORJ9BKABJANcFT6o5YES6e6kpmWADYPX/g020fY0yVcXKy36Kf9Ls7D7NqWsI9aCdMSeX9AOKakn5f/gVsHS7huPIEti7BqCYs4I2fCRyJG+eSO3EL/fKw6MiWWoFrHwPEeKE3vYAfiXgQuAytxgOky0d7vdIToldJvL/q/KgetikakZVxm9tOceq3jDFhV/SwjtGDI6VuyxbLhx3EfaSJTuyR2D/nQTmWQ5SkZK6V2AM3N98aBVmOjIT1y+lkaIqIbitGHW/DiDDhKNcYoW9eyimbSQoMW7Zk6xHiDrqR0xBX/LOJAgITsHaLjwIBYZAf7+TXKeLlcwmhwVScmwjLvPwXK+qdw1sUISwk/7mHzr5+cEZcPqDr7PqqomyYqynYdnJUP7YGIuxdTKQzxxHcoKR8FORmrASIy3RZkoWlL4qUdviWCEuRK+7sfs5ia7N3DxaANS4VzUJSotR00hhrWSJdQQNQbs+DMEhOYnhev89ecU6RKXYat5IF/WBU+9oSOUalxwuZS9YdkBRvNeMhJkAswQ+w91OPBe0SfXEGSCpYYJVe7CMavbMIJy545MXav8VCFb8zPi0KrpYJR4KJYl0VnpPV45R3S22jz/hzW4KybJHMDkJ4XZEdpdi1v3KyIYr0+OF+PlOQavTzqXd+CCufGGEoxre0sScGcgOjpsd2ROrFCcT9u28tFkIASCReBOSu4vkwNGN3sKooELPE7gbba7BuYXLZuh7BmBvJQBxar/Qp6n+OJ/1knVzC1x7lkmr/v5j3gT7Mtms41DzHT1o9JXgQcSVDwWY6IUuNUnkTiaBK2a8VL1NGg0QNsQbL/hjo5oDsZh8uROFDEx/1z4RRPb8lZbMnvDo6ENQqpj56FdW+Mp5ULHKHnuv8GMkN Lf9Fi/E/ y5D0QUm114n+1nYKwgIbygzZN8f2w7tWq2TB4XesdN31kDjY+KyLOpetJAbN72oF12vsInWTxubG0UGMfv1o8bX0Tou6k175shKRwODmhsbsoJoWmgxWrIvNBDUxW1e/et6RJ7F/x3qbAWDokwZMQTnF3AI//JSDcqIqdQZijbAwUq2qsYPfbGNNsBI/hykwIOK/QO/GSSv1uZC8dTYrfC9734+05TdFWjlMC 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: Tidy code based on review feedback for final version of multi-size THP: - Comment added to explain alloc_anon_folio() error protocol - ifdefery simplified for alloc_anon_folio() Signed-off-by: Ryan Roberts --- Hi Andrew, Hopefully this is the final tweak. Could you please squash this with the "mm: thp: Support allocation of anonymous multi-size THP" patch in mm-unstable? Or if you prefer me to re-post the entire series, just let me know. Thanks, Ryan mm/memory.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) -- 2.25.1 diff --git a/mm/memory.c b/mm/memory.c index 8f0b936b90b5..3c530b639559 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4137,9 +4137,9 @@ static bool pte_range_none(pte_t *pte, int nr_pages) return true; } -#ifdef CONFIG_TRANSPARENT_HUGEPAGE static struct folio *alloc_anon_folio(struct vm_fault *vmf) { +#ifdef CONFIG_TRANSPARENT_HUGEPAGE struct vm_area_struct *vma = vmf->vma; unsigned long orders; struct folio *folio; @@ -4199,12 +4199,9 @@ static struct folio *alloc_anon_folio(struct vm_fault *vmf) } fallback: - return vma_alloc_zeroed_movable_folio(vma, vmf->address); -} -#else -#define alloc_anon_folio(vmf) \ - vma_alloc_zeroed_movable_folio((vmf)->vma, (vmf)->address) #endif + return vma_alloc_zeroed_movable_folio(vmf->vma, vmf->address); +} /* * We enter with non-exclusive mmap_lock (to exclude vma changes, @@ -4260,6 +4257,7 @@ static vm_fault_t do_anonymous_page(struct vm_fault *vmf) /* Allocate our own private page. */ if (unlikely(anon_vma_prepare(vma))) goto oom; + /* Returns NULL on OOM or ERR_PTR(-EAGAIN) if we must retry the fault */ folio = alloc_anon_folio(vmf); if (IS_ERR(folio)) return 0;