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: 71904 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp901000wrt; Sun, 19 Mar 2023 15:27:55 -0700 (PDT) X-Google-Smtp-Source: AK7set+n9ykPP+/J5guku67L0Bs+neSNqJygkVJmlm8UmSjdZfYWrtsWXKsJrzeweykWwOBimV1U X-Received: by 2002:a17:902:f314:b0:19f:1c79:8b21 with SMTP id c20-20020a170902f31400b0019f1c798b21mr12142856ple.42.1679264874785; Sun, 19 Mar 2023 15:27:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679264874; cv=none; d=google.com; s=arc-20160816; b=OlXQBGNZhik9GC1YbNgyx0ke8PMpUMwoJ5DF1ujD37a6Onw9A8NvgfSU5h1CrDFYO3 +PdN7UO+8kzVDF6hT9mv/SW2sLyJ5bEySBN6XhXtH5yi/WxlUO28JT9qN0ta+hAWxlPG JEo33dZUEwxk3PRJyRqSJCrNw00WitofrwbWnvAyTyas+s2RzsHMZx4dPD/GjXo39uvR rxtyV6L10LxsyKazuYTPmbEuKxTXs5g6h92dl5A5CyT37LJs9ui5MMZUirc03RJOvyNq g9Tfsd2Iph8kQgzpSlqhABBOTDwvXeVEMtVt1I1P24UypUIGPblU85ZFJwCB7KsbFpQo 6rtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gqHapehoVevycqqSvfloiB2KJWOM/j3t+5M1U1JWUoc=; b=gRq78pxww0mv1mChGj+s1d3wpurw01j63m5/i/O0NDvAkcAAGqKepVxi3Ah8bJUsmK PZz/DceG+lHgdLIX6HEhuK+sxZenf47/C5hhvaD3AcjJzeOECLUdBq5dtwMkhAaDSOyz J9Vgx5byi6KjnzbKToQrYMxIpgp8h7nSU/DzOaPFJUvHGtDUcw4bu3XVaVRDu8KVdpV+ lPglDWB4kJXYnoO0RVMJmFoPDg17wByLwsQZsGFGD8qj4AjwT+DHII9RuFAVqH8ZGzUV fGKQVv78gK4QzA0wtYK3FK7IBr9hY5kufov3wbqbygc2y881piTd+MFMpEXzp5qI1KF5 pZUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UBpAFCMO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b12-20020a170902d50c00b0019ce0f430bbsi9420710plg.476.2023.03.19.15.27.42; Sun, 19 Mar 2023 15:27:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UBpAFCMO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230156AbjCSWAj (ORCPT + 99 others); Sun, 19 Mar 2023 18:00:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229572AbjCSWAg (ORCPT ); Sun, 19 Mar 2023 18:00:36 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2CDB1514A; Sun, 19 Mar 2023 15:00:33 -0700 (PDT) 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 74D12611CE; 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-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760836845116425052?= X-GMAIL-MSGID: =?utf-8?q?1760836845116425052?= 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;