From patchwork Sun Mar 19 21:59:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13180632 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 14963C6FD1F for ; Sun, 19 Mar 2023 22:00:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A1186900006; Sun, 19 Mar 2023 18:00:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8FC33900002; Sun, 19 Mar 2023 18:00:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 79EF5900006; Sun, 19 Mar 2023 18:00:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 6B634900002 for ; Sun, 19 Mar 2023 18:00:36 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 4BAB0A0478 for ; Sun, 19 Mar 2023 22:00:36 +0000 (UTC) X-FDA: 80587017672.07.984BB26 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf02.hostedemail.com (Postfix) with ESMTP id 8F03B80019 for ; Sun, 19 Mar 2023 22:00:34 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=UBpAFCMO; spf=pass (imf02.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1679263234; 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=gqHapehoVevycqqSvfloiB2KJWOM/j3t+5M1U1JWUoc=; b=FVdJVlA4IWGfdJcHMyFwXfzSoZJ9n3rxMdmgh7HcP8Fkxm6vqxGn6HJ9ukJO5TMyodP3ok xcfhv6JoKMMY5msRCWu/Xaws6SXgUjh4C0MJ7IJXSg2SZ9+lDtDdzGH6Me6jwSWwIEr7o7 EbW6bLzhkYlzVq/tEm4MxMVRySj1qDQ= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=UBpAFCMO; spf=pass (imf02.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1679263234; a=rsa-sha256; cv=none; b=og63ojITcavYx8DYI9sfL1B4t3BWaf3k1iyiP5Jv+iCBxQRYv4usIPa6wz9PEsu4ggkmBy /g3ZNXQJCa1ozp9knVfySDBohVKFwCVQcY4FGyiwHthVjWP4k2M6uGPqzrThFFBVBekevv JT270pD3CJqHqJbEb2p8ohDVNYeRDSs= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7880A611A9; Sun, 19 Mar 2023 22:00:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5B8AC4339B; Sun, 19 Mar 2023 22:00:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679263232; bh=hdgTCF3AluRT54E9MLIUV0kdVH4EuuQ6uLe4WMnOnfE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UBpAFCMO2EPuJQ3DceQO11KrNG1Xa7ss1NwTGDl2lsm+DZvOGWjpBOdQuIwm3VlAR YiaL0FwisP5hqGIHrOB0A0C58SWIc+Kr9de4Fb2Co9kcLSMuF4+YLkruSuuiF53opk QcVgTdrUsMaauwl8da/sCVuB3R+2qsDeSEAjjOJ9poCOOx+3RZJtudqLmOr7jNrtn/ d2MLLOWir2J8tvaSn6KkJAawHeUVjENMXHRwOT0QTmY8YBGVV5EznK0U84MAzrILLh 5qR/7Lv83L7RgyzqAdFgqJFQDybFQTrUQ3ysGBg/Mu/UDsJdOJEl4YvmCEn3CKJbgf tP8fiOTbLMnLA== From: Mike Rapoport To: Andrew Morton Cc: David Hildenbrand , Matthew Wilcox , Mel Gorman , Michal Hocko , Mike Rapoport , Thomas Bogendoerfer , Vlastimil Babka , linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 03/15] mm/page_alloc: add helper for checking if check_pages_enabled Date: Sun, 19 Mar 2023 23:59:56 +0200 Message-Id: <20230319220008.2138576-4-rppt@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230319220008.2138576-1-rppt@kernel.org> References: <20230319220008.2138576-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 8F03B80019 X-Rspam-User: X-Stat-Signature: iwp3nsd3t8bndgnho1x16nstst977zc4 X-HE-Tag: 1679263234-358971 X-HE-Meta: U2FsdGVkX18+JWuaEJ+LFucr0vwWJxF3+XpIwI/TR4O9YK+NNY3Np1kkOHfLOTB0FpCeFjKnOmPwS25Hmpnw3guoeGoLWoUgmSZlZ328M6g2RZxoJjk0oXJZG0RmKPx+sFaZX5tyvtevOvhrGc/vOl0q8KabAdxdmopi464uo8Gqz2W7j9bMfOscPY7MjHL+TmSFM0j1rtmN0HUH/Jm6vdlMZR3Wlc8Kwb0mhoceQUExnog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QAWn/H3OBo0CPzcxXtnIxRQrwhWwNl8r9EmXlGp5986m0ooWsmsMA6Fy9PiLACFeolgSYzg== 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: From: "Mike Rapoport (IBM)" Instead of duplicating long static_branch_enabled(&check_pages_enabled) wrap it in a helper function is_check_pages_enabled() Signed-off-by: Mike Rapoport (IBM) Reviewed-by: David Hildenbrand --- mm/page_alloc.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 22e3da842e3f..e52f90d5d6a3 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -245,6 +245,11 @@ EXPORT_SYMBOL(init_on_free); /* perform sanity checks on struct pages being allocated or freed */ static DEFINE_STATIC_KEY_MAYBE(CONFIG_DEBUG_VM, check_pages_enabled); +static inline bool is_check_pages_enabled(void) +{ + return static_branch_unlikely(&check_pages_enabled); +} + static bool _init_on_alloc_enabled_early __read_mostly = IS_ENABLED(CONFIG_INIT_ON_ALLOC_DEFAULT_ON); static int __init early_init_on_alloc(char *buf) @@ -1443,7 +1448,7 @@ static __always_inline bool free_pages_prepare(struct page *page, for (i = 1; i < (1 << order); i++) { if (compound) bad += free_tail_pages_check(page, page + i); - if (static_branch_unlikely(&check_pages_enabled)) { + if (is_check_pages_enabled()) { if (unlikely(free_page_is_bad(page + i))) { bad++; continue; @@ -1456,7 +1461,7 @@ static __always_inline bool free_pages_prepare(struct page *page, page->mapping = NULL; if (memcg_kmem_online() && PageMemcgKmem(page)) __memcg_kmem_uncharge_page(page, order); - if (static_branch_unlikely(&check_pages_enabled)) { + if (is_check_pages_enabled()) { if (free_page_is_bad(page)) bad++; if (bad) @@ -2345,7 +2350,7 @@ static int check_new_page(struct page *page) static inline bool check_new_pages(struct page *page, unsigned int order) { - if (static_branch_unlikely(&check_pages_enabled)) { + if (is_check_pages_enabled()) { for (int i = 0; i < (1 << order); i++) { struct page *p = page + i;