From patchwork Tue Mar 21 17:05:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13182964 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 52AEEC74A5B for ; Tue, 21 Mar 2023 17:05:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F050A6B007B; Tue, 21 Mar 2023 13:05:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EB58C6B0080; Tue, 21 Mar 2023 13:05:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D7CD26B0081; Tue, 21 Mar 2023 13:05:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id C88606B007B for ; Tue, 21 Mar 2023 13:05:40 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 9D4181C331B for ; Tue, 21 Mar 2023 17:05:40 +0000 (UTC) X-FDA: 80593532040.24.6C655B2 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf11.hostedemail.com (Postfix) with ESMTP id 521DE4000E for ; Tue, 21 Mar 2023 17:05:37 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="rvU/i21V"; spf=pass (imf11.hostedemail.com: domain of rppt@kernel.org designates 145.40.73.55 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=1679418338; a=rsa-sha256; cv=none; b=nyE+CXzsPuZeV2ER1nfGTCMEOdr58NBRQI7EY6rMwT+MVtsmD7eVi7Ho8ywGXl4IcVu4GL CcAAr/bBNqRWlEV1oEg/edMUPPNWQI0faGfLqqFg5p5d1trBimyg6jErZaw2BiLP89hWC6 yK0j/Ak+s1BNLz8Oe9agCDVm/SmH8lU= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="rvU/i21V"; spf=pass (imf11.hostedemail.com: domain of rppt@kernel.org designates 145.40.73.55 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=1679418338; 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=ZaNZb4LBOh1DPy2+ie42i9qTor/7U8b9/7azGZRiNxY=; b=npSBLxSGg4lcnivmr7mafrZZAbPwexZFAAY/I43w4/NJDNCWZaR9+rqCVWTuWNKJm7XFFb qfqIW0ZedNTKPkfvXWlI414VDI9s1GXIj/rEWS3hOvk/NDxRkqo8Cr3MW7QzXrHh3MCkbB 7fblIWVNvk2diW4Zr9/bXCoymrcDZAY= 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 sin.source.kernel.org (Postfix) with ESMTPS id 9B268CE1AB8; Tue, 21 Mar 2023 17:05:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C86B5C4339C; Tue, 21 Mar 2023 17:05:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679418335; bh=I9y2VS2sujmV0QDCgNwqn2cmquxP68oIIJXpFeZ8zWQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rvU/i21VgZbcmY0RKxM7OfYu+1hxrZakEd0qKlbAVLq51IJjKj6CKIcCK9ES+4LDa r0GXrHFiB4bewcM9qeWDh0R4qbZZpydLGatuQAdqquua5BUoy3cgjwnftNe2vICXgk TsJya2xDyox9It3dWIYTidriR688fhCIfmDNluEO305v19/xELXcjykEw3+9opOrh6 j4JkM1QSbBxxf6Gi4okJjw4G5rC/LNmMKcrQ21dwK7mzp5N3rfjBiQ2ovPN8tR2szf v+9rKcE3YA7RQs/YMnkyaHdIu7kUj5Hu0Zm+3dYlQEJ8RZLovqVXqCPD7NH5ImyjDd ua/+qlh76Uwxw== From: Mike Rapoport To: Andrew Morton Cc: David Hildenbrand , Doug Berger , 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 v2 02/14] mm/page_alloc: add helper for checking if check_pages_enabled Date: Tue, 21 Mar 2023 19:05:01 +0200 Message-Id: <20230321170513.2401534-3-rppt@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230321170513.2401534-1-rppt@kernel.org> References: <20230321170513.2401534-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 521DE4000E X-Rspamd-Server: rspam01 X-Stat-Signature: syj5oakjaxnym4edemh6y93d7dpe9y97 X-HE-Tag: 1679418337-710279 X-HE-Meta: U2FsdGVkX186r1MJfoOhVtkJUvV4c8k3cz3t7DUr7s9SD/uSObgD4EX6nNDcfX4zx0ZTJZTSWoZ4qx9CvQvtgwF8MInKU+g5j2KX2KohpPRjw/5afF9WNE4j0g0YUcQfqT70d3lfLlVIzpE3bD1hTLRugCXihUjoQoI5ucK0KlR/MFGtYWP3obT57mJM4CXlEgcxWOmtk9EPoxaeShhhgLPjj5Au68opakDNw7wVnmaRAlKlc8eH14w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IF7nTntCrGwu5z8uYJEj0zhh/uj2Py287r1g9lTpde1GeLVCPooll0uj5OY7jA8UOfAK0LTZEOb2O18fblMxHOgMasXoNgwowh3vGtyo= 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 Reviewed-by: Vlastimil Babka --- 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 87d760236dba..e1149d54d738 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) @@ -2366,7 +2371,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;