From patchwork Wed Apr 3 17:18:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13616532 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 81F0ACD128A for ; Wed, 3 Apr 2024 17:18:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9224C6B0095; Wed, 3 Apr 2024 13:18:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8D1606B0098; Wed, 3 Apr 2024 13:18:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 799156B0099; Wed, 3 Apr 2024 13:18:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 5A1566B0098 for ; Wed, 3 Apr 2024 13:18:42 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 283B81C0286 for ; Wed, 3 Apr 2024 17:18:42 +0000 (UTC) X-FDA: 81968880084.05.188404A Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf22.hostedemail.com (Postfix) with ESMTP id 81422C000A for ; Wed, 3 Apr 2024 17:18:40 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=JLc7GpWD; dmarc=none; spf=none (imf22.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=zOpNw/+Dxq+DZUz6MBpRGqjk0sOK0iT06TETKlPifKE=; b=mGAUVAifmIa3Yxv8j6d4iCRlYJGDjRB+KhqC5z+Hs+KAfi3IjJUVULUfEYa+BO0fcyzjVc 6iolNJJzlA/obaz/bZKkH1+LyAKHGdnpVPKiNGC3klW19cONJlp0kbANC2XcNfcJkhB4k2 wXxwCr3fx+famurJhtlT/4gmVyBymNM= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=JLc7GpWD; dmarc=none; spf=none (imf22.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=5EZRfNQcGI0oyw+3DApTZJ4ooi+Qoc/cwfHmMKwS9mNrHyutL3KKdpryN5kvIpkfiBTG6B Pjzp79b6QuOodoCRY6x8TwX7XASFiB+HkEP/GZDfBgrKqYY3kR7nTIrXd1VS8ol4YLpGX+ A0k/kYLs4s4kuuCQxvkmjJ1MGqZYKIQ= 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=zOpNw/+Dxq+DZUz6MBpRGqjk0sOK0iT06TETKlPifKE=; b=JLc7GpWDlAgseemsv4Hbjpn86D 7izHZ8PJT6KjStjJVgENQgG8ZIXFBi8RnupJaX5BHlmIzsyFlMYN/+spHN3Tj0Wst48Jhf8OpVLWf YPbsStch2pg6e5cOQrABgibnPyqYkE4kK9ijasbiJd95stK8XE3gc22XW71Kyd0vThzJul4XO7wmg h6HgnWdFWTm6yhZ9fitGEIAbNnPs/yYsqQQoeZn0G41j14oKYsW5snzsaGnCJdUFW/F8UFyW4BK8L kKgfeujc+A6BhFeonfzOmP8GINcNh3mSQVWXRbgNxQPILP8JvGqf150FKIvu3Myu0TskAU0OnWROl W5av2dLQ==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs4Fz-0000000648a-10Yj; 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 1/7] khugepaged: Inline hpage_collapse_alloc_folio() Date: Wed, 3 Apr 2024 18:18:30 +0100 Message-ID: <20240403171838.1445826-2-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-Queue-Id: 81422C000A X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: sun9sx9sp7zgygeaps9zqyrpixgndxec X-HE-Tag: 1712164720-616422 X-HE-Meta: U2FsdGVkX19+FPOo7F1SBG0pUyGa5ZoPkExMYF6uIHhp0Amn+9Xi+kIYJx2bxdduTkl7myuGo39jTKq+Dxrqlhc6Tvm7TyHrJ+dWc7qDJ7TPUJqi5cW5Sme4kDwhPN7wQaKeSwV4enc+GKHmQXr/jndnlOjuMrNuC9pgHjejTUZhvoHusoJ+G5sth73YaDE8zjj2Zl3axBPK1ewRN9BU5Afx8bu78uGCw3IYiDw2cVp2LKb/q/Q1klPImej+NzGn/5eOREwAaiXZh487Mi6iSDIaGRynXLnd6t2YoWunznxep3fpxdvtAOE1QOjuVINZssedBce3Kj2Ro/EjgQScEddBD+ApUF8DyB6zRoyLTzNXOOmitvUITjQXkv4zHk35y8dVNsSvyG/tHEN3+VlAxrYaAMkbhX+Fvxc78Sg2HRzcj6botGKtrl5ZkoyCne7MGCRqm179I6R69ZmH7hjAhFbforLrIVsfUMBVsLrsydkAcWhuFNjryUCV8IoRA1xlUow5zUa00QOk0IfJPychguXaMwLYkrKw2Q5ZBGA6NUauoMdIdjOVUAzpNs8eGj7SzRsLXB+Z8LLhr35WaPIaZnwOAvn8dRJVkbBorP2noCI9tybCGM8yQmkoet+izbVi7nHkcUU9GVF3u7/VUZ6DYei4NsmPVEzWb6InttrscM/cWMqBGWz/cCJjC8Lk8zFrl5elZvX3NYW00BavB4rqTyy/H3b+OjEO1ZEQH6eII1Xv9Bpf56dnXvmBhzmVMPu8/TjJglkaGVYSkzBGsuyPH5EvuUqjpwV6aRO+1HNo5O+becOCwShk6hpOXIvnpADnhKJSWl3l3lPf/9c1LvdnUbmKjyDY0a5pEv23OgnijCnDE8Mj0yLoHj6pyPOlwN+gaTYzyDvL4zR8QaVVXXjYiw1zYLb7YRISJnwNpHMh1fS5cf+4tCIoSE1VYUl5csQZeT1KSlgzjNYDpE2WUHm 0chVzITv Ljo1WGny9teuzN/sUa8uPoQ4e2c5JWV3G7h09iN7e1YM0WcytTCSesL+AXpR7uZXSYhZdxkVgVUAs9VXj4Q8P0hP4JzK2N+mXV2zYZzje8p7FeI+yVCEzR0JvKfLaCIOdYxpeV50UvqhsHJdSALIyRb3yfDVDvBeSc5CNi0gk04+mUy4MxAfW59ApHDrM4qucZruXUrMSeH4qo/yEVtgOvfDCgQb0N74CDI/a 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: This function has one caller, and the combined function is simpler to read, reason about and modify. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Vishal Moola (Oracle) --- mm/khugepaged.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 38830174608f..ad16dd8b26a8 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -891,20 +891,6 @@ static int hpage_collapse_find_target_node(struct collapse_control *cc) } #endif -static bool hpage_collapse_alloc_folio(struct folio **folio, gfp_t gfp, int node, - nodemask_t *nmask) -{ - *folio = __folio_alloc(gfp, HPAGE_PMD_ORDER, node, nmask); - - if (unlikely(!*folio)) { - count_vm_event(THP_COLLAPSE_ALLOC_FAILED); - return false; - } - - count_vm_event(THP_COLLAPSE_ALLOC); - return true; -} - /* * If mmap_lock temporarily dropped, revalidate vma * before taking mmap_lock. @@ -1067,11 +1053,14 @@ 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_folio(&folio, gfp, node, &cc->alloc_nmask)) { + folio = __folio_alloc(gfp, HPAGE_PMD_ORDER, node, &cc->alloc_nmask); + if (!folio) { *hpage = NULL; + count_vm_event(THP_COLLAPSE_ALLOC_FAILED); return SCAN_ALLOC_HUGE_PAGE_FAIL; } + count_vm_event(THP_COLLAPSE_ALLOC); if (unlikely(mem_cgroup_charge(folio, mm, gfp))) { folio_put(folio); *hpage = NULL;