From patchwork Wed Jan 8 23:31:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Pache X-Patchwork-Id: 13931716 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 480E0E77188 for ; Wed, 8 Jan 2025 23:34:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D3B306B0099; Wed, 8 Jan 2025 18:34:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CEB526B009A; Wed, 8 Jan 2025 18:34:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BB2B66B009B; Wed, 8 Jan 2025 18:34:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 9CE266B0099 for ; Wed, 8 Jan 2025 18:34:03 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 18FECC154A for ; Wed, 8 Jan 2025 23:34:03 +0000 (UTC) X-FDA: 82985889966.20.B393F73 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf01.hostedemail.com (Postfix) with ESMTP id 7DF4640003 for ; Wed, 8 Jan 2025 23:34:00 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Df9aCDGQ; spf=pass (imf01.hostedemail.com: domain of npache@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=npache@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736379241; 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=S133XG+svDEeb2oKFkZulclk4jILVy1/1EYUYGlZ8FE=; b=ehrcbFaNfVJxqlU/6v+ZaHnvicI6rrM5nz+CcYbTckXW1XzhtCGfYo7jD8+1vR2+7dyRee yWRYZ7d80ycAIyG9SatMwvpvdrlfNMBDm1ePk9ug1Gr8rYGVcbrK7gguM7VIFtlVBigQ7s xUifSKHst34MRohhQrCem6xViLzDe6Y= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736379241; a=rsa-sha256; cv=none; b=tO3FknClCplvv2RsQ+TqjPGM4JFWA3tzPVLmZSN9HxuPzr+/WXkoOZ/2xFH7czqibxCTy0 vnjhRbonx/m6MUhc7x2RPWMCdipnNVwCAH3WFgjuP3c1zS2lp3jHFZ0jAbJd4l7kvcYRuY 2sm5pUOwKn4TaqtNUt3Pe31uVbSrAo8= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Df9aCDGQ; spf=pass (imf01.hostedemail.com: domain of npache@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=npache@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736379239; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=S133XG+svDEeb2oKFkZulclk4jILVy1/1EYUYGlZ8FE=; b=Df9aCDGQf1OfDaKnMfs2Bx4nLBSs3xzkedzjODE334xgkEJNrgy1Chkv/P0vKIPGfNE79w smWJ8JprRwEahLBiua/kLnVteUWeDuLxNK++Nuw+o9smLxIk4h8j5ZFpjp9yUSFmxwPRBm xsuSKFah+LxVjD3nkIK15ElVFy1E7tQ= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-418-1PB79giaOF6GmKQgm3tLVg-1; Wed, 08 Jan 2025 18:33:52 -0500 X-MC-Unique: 1PB79giaOF6GmKQgm3tLVg-1 X-Mimecast-MFC-AGG-ID: 1PB79giaOF6GmKQgm3tLVg Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 376AE19560A1; Wed, 8 Jan 2025 23:33:48 +0000 (UTC) Received: from h1.redhat.com (unknown [10.22.80.41]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E4AE419560AE; Wed, 8 Jan 2025 23:33:38 +0000 (UTC) From: Nico Pache To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: ryan.roberts@arm.com, anshuman.khandual@arm.com, catalin.marinas@arm.com, cl@gentwo.org, vbabka@suse.cz, mhocko@suse.com, apopple@nvidia.com, dave.hansen@linux.intel.com, will@kernel.org, baohua@kernel.org, jack@suse.cz, srivatsa@csail.mit.edu, haowenchao22@gmail.com, hughd@google.com, aneesh.kumar@kernel.org, yang@os.amperecomputing.com, peterx@redhat.com, ioworker0@gmail.com, wangkefeng.wang@huawei.com, ziy@nvidia.com, jglisse@google.com, surenb@google.com, vishal.moola@gmail.com, zokeefe@google.com, zhengqi.arch@bytedance.com, jhubbard@nvidia.com, 21cnbao@gmail.com, willy@infradead.org, kirill.shutemov@linux.intel.com, david@redhat.com, aarcange@redhat.com, raquini@redhat.com, dev.jain@arm.com, sunnanyong@huawei.com, usamaarif642@gmail.com, audra@redhat.com, akpm@linux-foundation.org Subject: [RFC 06/11] khugepaged: generalize alloc_charge_folio for mTHP support Date: Wed, 8 Jan 2025 16:31:22 -0700 Message-ID: <20250108233128.14484-7-npache@redhat.com> In-Reply-To: <20250108233128.14484-1-npache@redhat.com> References: <20250108233128.14484-1-npache@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Rspamd-Queue-Id: 7DF4640003 X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: p4mct5jimcs5eo3c8ujz74bu69aeetio X-HE-Tag: 1736379240-400299 X-HE-Meta: U2FsdGVkX1/42iyqdLyxvSEBCHbHy4i90wl2rQBlN/m6PleIm9gja5Yfpg09eKPR9LfAF03/Sh78Dz4jar1ZWBcZ6sSXmotaFWtj6ph+j2BD/Z+iWOQ97m3oOgD2sBY6b7EPSQyq8RnZg105b3ruTtoPI8SeHfZlmb+B9P4hKLH0raeZ5VqoWoZi2WImdZQBmGjGwg2Z4o7tScA+ybz8iwp6YfeJhfV7J79kwVTWWN8p++ItMsTzC+z2/0hnXROJnRZz/x+NXQobs6zFvShZFPmH5x/oFgjNhIuSM061MtdxC1V0Ao5hrjbvxOtDe18Df3wWd9V0SCvoDCW4EKqonGRqyMTGnYXhSepmjHtpm1srMdfcJolvT05Fi760gc0K04go6J4qIrvwMAcQdJSfZOKxQHw7KARbytdBdFr5Nz37WjEiTpRhuuyk6RAYvkitXfG1BZz0D1IW+7k+boisRM0o5GRIGoWk0F8Ks49LvtuLey7zFOBS+wQXBSGkFSWPyUYf8hgvM2r4wes2cI4p8iBmElwlF3r+WetFCJrxJWvIXBEgK49NHnJeTYQKmRj2QfscG566+SwLsPX3mXFFFOGMU+YdhXPD8jIZrTT4dz3D7bpf6XvZAxJB1kGYU9JHiEHaRbd2bjZnNlLSz2osoROFo5oYSEVbOjXnuf4tedrc4KduGIQoP90wA3137RkLUvfOerHUaGPr/9HvnVO4C8t0G9IqgOYSHgGVeXi+DCBRV4BC8KRM0GWF/cb9+lOdUyol8kCYI7dDKoOemSkwHl5NS9afA7B+B9SI9dgWwNi9ia0Z7uU+vG7kWp2m3kRuXcEqHe9MCkKEOryl+Vkbljc5HMz5ZekjO3eatGqB2NLv/9cLfqFPxLjnxgTkTPNhWoqTUkvugtJS09AcCHGANQIZBYCbcElQ+QY80VHyndF/r5rlodqvMBf9Fr0UUiyW5GIUF9garfnyUaqL4sT nJxsmKIN LY+VG9vqJGkWSvmJhutHYf09WA4yN7jIib82PUyfoIIHp6Extbv5Z9QEBpCrc5peC19T2FIf9Qxc9VukUJO63NwnIwmFdQ/pFhJGLMSSimf2CJvkCosR1T1IWTTP+Ijm3ft0yLVXbIsESVPYfftui8ioc3iCl1U0f6CH/RI+1BuJ/h6zzD2kLO/Ng1MNOGZJIopbFESFuBUwu7mU8z0cV+yyWmTNoM7UgUxtP0rmuAGsoH5m4QyxdmHott/Pe6/xC66Lv/piXHV6pJ6ssleqFEGbDV1huNu+ubEskVR624uVNAKUojdgYM3fiA6vYkXWUBwtkTFfvpUsNdNipmoqM5d7YwgXPoiqNIcHc40TBI1mW5Rw6UWqO7XA7iEy23ysdpllTUrzMKAi7Lgu5/SqnCJt+hGtFnDWRE1z647oMxM0l+9qaiNoMsh9hyXrvw69RwFrr 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: alloc_charge_folio allocates the new folio for the khugepaged collapse. Generalize the order of the folio allocations to support future mTHP collapsing. No functional changes in this patch. Signed-off-by: Nico Pache --- mm/khugepaged.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index e2e6ca9265ab..6daf3a943a1a 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -1070,14 +1070,14 @@ static int __collapse_huge_page_swapin(struct mm_struct *mm, } static int alloc_charge_folio(struct folio **foliop, struct mm_struct *mm, - struct collapse_control *cc) + struct collapse_control *cc, int order) { gfp_t gfp = (cc->is_khugepaged ? alloc_hugepage_khugepaged_gfpmask() : GFP_TRANSHUGE); int node = khugepaged_find_target_node(cc); struct folio *folio; - folio = __folio_alloc(gfp, HPAGE_PMD_ORDER, node, &cc->alloc_nmask); + folio = __folio_alloc(gfp, order, node, &cc->alloc_nmask); if (!folio) { *foliop = NULL; count_vm_event(THP_COLLAPSE_ALLOC_FAILED); @@ -1121,7 +1121,7 @@ static int collapse_huge_page(struct mm_struct *mm, unsigned long address, */ mmap_read_unlock(mm); - result = alloc_charge_folio(&folio, mm, cc); + result = alloc_charge_folio(&folio, mm, cc, HPAGE_PMD_ORDER); if (result != SCAN_SUCCEED) goto out_nolock; @@ -1834,7 +1834,7 @@ 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_folio(&new_folio, mm, cc); + result = alloc_charge_folio(&new_folio, mm, cc, HPAGE_PMD_ORDER); if (result != SCAN_SUCCEED) goto out;