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: 72957 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp1909957wrt; Tue, 21 Mar 2023 10:29:36 -0700 (PDT) X-Google-Smtp-Source: AK7set/DScVqc79IavZaKU1ApNvtK79m7/PA/KyXjFOdGkj8nuMKfamjS/O02xyvRrDHm9M99p03 X-Received: by 2002:a17:90b:4b07:b0:23f:b172:27ee with SMTP id lx7-20020a17090b4b0700b0023fb17227eemr485984pjb.36.1679419776091; Tue, 21 Mar 2023 10:29:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679419776; cv=none; d=google.com; s=arc-20160816; b=KOLD1d9BgYvDg/MXYh0dJ1FI1SHgHk7+ysgG15yuW1gUV0/mY/uNb6qSiuwPW8X+0w mzOq94V3Abdn5PqqnRPFNdjuh7DUR5l5Tqpxmq8xDz6PtYIPOHLmD/pdBCwuTHwBU35o Hh9JU1jo8F6Sz3sA2IvMP+0mrNSz3W3ZAHNegc9e+1KpoUWNRDbJ+VBxJ2G6fu2uYNq6 KmpO4EgfqBxxDLTyOd9Lu9/bqmuraTCMo24DTh71SNb1T7AJ41Wrri+9QZXIdBDXvL34 eBCkpOR0AhYt00skreEDDzen93lE6OIZx6UP55Zq5eVoLRPxOMpiekJQklBqKBur9N1K kPHQ== 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=ZaNZb4LBOh1DPy2+ie42i9qTor/7U8b9/7azGZRiNxY=; b=Ol0NKKm2ZDMn958MKTAig+CcTYe/U7irP3fEHR7CyZmW6Ep82Q+supJS3OCG7+2Aj5 O9qvsXRW+FpZA2Cta69RsmXH4CBhkxVpwMytokWIcu+uPnrnw2r1hG4gbQPGEzUqpK6K WjYXsLn70FPb89pdxroxNoZ5s2KhxhCe5Hf9uVkczixxzxPrxnmLQ3HJtJbnMS3cXivh U/PjzcnQ+ETNbn6rXnxoRXQam8PejWlhZyIKhz9hxwx134bdr1p0DFbb2efrSD0ICoTV HWf8++8E9Pu9rWTZDMR1jtW2rinSEDxybm4QNVuyAyibehgfCencw38D+39BpyBWAeg4 /4Bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="rvU/i21V"; 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 ls7-20020a17090b350700b002307345bf7bsi20811612pjb.23.2023.03.21.10.29.20; Tue, 21 Mar 2023 10:29:36 -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="rvU/i21V"; 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 S230454AbjCURGC (ORCPT + 99 others); Tue, 21 Mar 2023 13:06:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229622AbjCURFr (ORCPT ); Tue, 21 Mar 2023 13:05:47 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8E8025E34; Tue, 21 Mar 2023 10:05:37 -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 ams.source.kernel.org (Postfix) with ESMTPS id 6BFDDB818B9; Tue, 21 Mar 2023 17:05:36 +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-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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?1760999271065841905?= X-GMAIL-MSGID: =?utf-8?q?1760999271065841905?= 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;