From patchwork Mon Oct 16 20:05:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13424039 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 B9AB3CDB482 for ; Mon, 16 Oct 2023 20:07:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0C28F8000A; Mon, 16 Oct 2023 16:07:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F405480008; Mon, 16 Oct 2023 16:07:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CF5648000A; Mon, 16 Oct 2023 16:07:02 -0400 (EDT) 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 B1A0080008 for ; Mon, 16 Oct 2023 16:07:02 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 7EB47A0B91 for ; Mon, 16 Oct 2023 20:07:02 +0000 (UTC) X-FDA: 81352408284.18.DE4194F Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) by imf08.hostedemail.com (Postfix) with ESMTP id 84CA616001B for ; Mon, 16 Oct 2023 20:07:00 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=fcv3WcUc; spf=pass (imf08.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.45 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1697486820; 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=mwAjlmpq6KKWWorM+tiqR60ij8VY2bcU8cxZ+UqJifo=; b=5MGEaqLpirZjisDYn4UFowIUI9QUSUKO/vPphC0ezDPW4jDdCLeEiGDF6Yfzk4cpYX0XPF S96YoJ7Uhye1yUlWBqsXf+UcLeAwNlmjW85+hrbqLWgV2giwrCGLNuo6vVU8ZDkUhBRFFS 7grLx+Pk7A9NdWwELo/0aeWva/JsMEM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1697486820; a=rsa-sha256; cv=none; b=kc94+PW8yASqsAeQ5PeqHvShEVgLssdLZQ7kQk+TeYABTbFNJQAk9mNl9Ax5QCK53abaqA Hv7VS4qxX8P1lsDgeXNiEIHMsQu5xrBbzUmJ46mksNTIAKdMr8/J6L4J5L88BeDbBLkYq5 zC4qwgvqFEPwayFWfHCeZ8kuaaHwd0g= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=fcv3WcUc; spf=pass (imf08.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.45 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pj1-f45.google.com with SMTP id 98e67ed59e1d1-27cfb8bc7eeso3940650a91.0 for ; Mon, 16 Oct 2023 13:07:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697486819; x=1698091619; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mwAjlmpq6KKWWorM+tiqR60ij8VY2bcU8cxZ+UqJifo=; b=fcv3WcUchj6wKCkns0jYmJJhwp4t0oNNCWQB1pSbPsDpmgPxKSNdgiG0IfQLSuYWgG SX7r6cSgaZx/Ibog0hPasX/e7LE+jxCxia1E4S6Ivq1YpnoYYDfYaIsnoYroLukHL8+q oKV3OpPcHIEn2TqVCVVg9rISJjrNg2v9IHM2u6YnB+inJzKySOx0XIx7Z/L9sznFUaZ+ Q3cVY8dRmbNEn087RzavLMWiJxDRs7m14nV7nsz4dpMaEiqcQNLOChP9fklzFaFdjIvP SkYSByBNIx5NetXAQ9mByerYKW0Mql0/qnBBHyjIoxp0G2Ep2WsjsOl6vfFdHMV1kwYS IbVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697486819; x=1698091619; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mwAjlmpq6KKWWorM+tiqR60ij8VY2bcU8cxZ+UqJifo=; b=vXOSpniWSdV69AsrUBUizXE0jMk3UOQpfYOWyOiPiwP8qhfgNDq9j4eGg5spPxipSC xMa2enbkCwA18vqAY+p1g9sb77kX9AaoBBLciKNL++mYMTpyW8m3fUKShQDvZY0NXsm0 dwHyBv/2UI/dgpeAwhS1b00l/rkZX9NnA8uWAlEX4rWWt3Vf5XQ3idYPscSzVn8CZ1zn xjfbF2vVPAD75FN26pGWK435ABQJt1NrwTvNmz5c/KZpJWKtZgRXQ0Ca0A2suS6ELQ6x 9xHxTRODjmAXFUKHqxhqSIcaFwLFNvn0acHwC4Zqt7nkv+HaD2ONe/nbscJQa/luhWX5 uofg== X-Gm-Message-State: AOJu0YwXElz9/lReWTZBtTUvlpnnm4pVrmF5gy08PZLY7wOwB/ag9vU4 4wxehPhqrHTb7LaBMDDz5anheEzumFQ= X-Google-Smtp-Source: AGHT+IG2u33OIftxV+vG+uCRE0PArlnIRhFf/JTq4llkJ/7L4qH2959ZYqq3PoHzeqWuyBIqSdin2A== X-Received: by 2002:a17:90b:245:b0:27d:4259:b7ef with SMTP id fz5-20020a17090b024500b0027d4259b7efmr190516pjb.23.1697486819203; Mon, 16 Oct 2023 13:06:59 -0700 (PDT) Received: from fedora.. (c-73-170-51-167.hsd1.ca.comcast.net. [73.170.51.167]) by smtp.googlemail.com with ESMTPSA id t16-20020a17090b019000b002772faee740sm5162367pjs.5.2023.10.16.13.06.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 13:06:58 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org, shy828301@gmail.com, "Vishal Moola (Oracle)" Subject: [PATCH 4/5] mm/khugepaged: Convert alloc_charge_hpage() to use folios Date: Mon, 16 Oct 2023 13:05:09 -0700 Message-Id: <20231016200510.7387-5-vishal.moola@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231016200510.7387-1-vishal.moola@gmail.com> References: <20231016200510.7387-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 84CA616001B X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: f16u7udy6d7etm7iu8n4pqz619fijipd X-HE-Tag: 1697486820-825180 X-HE-Meta: U2FsdGVkX1+BxnKRsRUnVvJhjqGC3+WQDBmUZ+Zfg7etVVVOtUQMVdEo/uRu+NHbrwuWqay0Uco+24NxU2fOXePd6WUvpkQzSAZYq2mixxIrly9FbC6nGGdOkWVV4RjpR+JXdbxb5M7vHlu0nHhK4Jm/OSxTUYxJCezzZNkZs3vZiBpVSOOVIxVo71xzOVehPvHGZeok//pfyjiS0CfLMrn/OpWvdZ4upUAWRVz4/7/n4eh7LAAPZOcc/7c+1Fd4FF/+h+rM4SGn63bEoz+QP+Ncsr48wSzDUxeBo2++m3WZW6HFfRSJSy1smhVLqhXAb3qEYLPD6f5sATA8BknCSlQIF9Gqcc1E/ysW7K2Rvi/Y9Sffdi+oOaAJf0MJCzyB2+JtrbWYyc5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+2A6lcfzCjDGK4HdbcW3mF/ojzqCb3VOIijXll9fHFwSQAO3EmE7fagGukc6hYk+R8j3vzZg8pUk+iYiMANOIhxOeQwaqYoj+6AfEx8wSNM+nCmnsWA3/Sm+hI+8wcPw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000021, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Also convert hpage_collapse_alloc_page() to hpage_collapse_alloc_folio(). This removes 1 call to compound_head() and helps convert khugepaged to use folios throughout. Signed-off-by: Vishal Moola (Oracle) --- mm/khugepaged.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index fa21a53ce0c0..70bba8ddea13 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -886,16 +886,16 @@ static int hpage_collapse_find_target_node(struct collapse_control *cc) } #endif -static bool hpage_collapse_alloc_page(struct page **hpage, gfp_t gfp, int node, +static bool hpage_collapse_alloc_folio(struct folio **folio, gfp_t gfp, int node, nodemask_t *nmask) { - *hpage = __alloc_pages(gfp, HPAGE_PMD_ORDER, node, nmask); - if (unlikely(!*hpage)) { + *folio = __folio_alloc(gfp, HPAGE_PMD_ORDER, node, nmask); + + if (unlikely(!*folio)) { count_vm_event(THP_COLLAPSE_ALLOC_FAILED); return false; } - folio_prep_large_rmappable((struct folio *)*hpage); count_vm_event(THP_COLLAPSE_ALLOC); return true; } @@ -1062,15 +1062,16 @@ static int alloc_charge_hpage(struct page **hpage, struct mm_struct *mm, int node = hpage_collapse_find_target_node(cc); struct folio *folio; - if (!hpage_collapse_alloc_page(hpage, gfp, node, &cc->alloc_nmask)) + if (!hpage_collapse_alloc_folio(&folio, gfp, node, &cc->alloc_nmask)) return SCAN_ALLOC_HUGE_PAGE_FAIL; - folio = page_folio(*hpage); if (unlikely(mem_cgroup_charge(folio, mm, gfp))) { folio_put(folio); *hpage = NULL; return SCAN_CGROUP_CHARGE_FAIL; } + + *hpage = folio_page(folio, 0); count_memcg_page_event(*hpage, THP_COLLAPSE_ALLOC); return SCAN_SUCCEED;