Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp656398iob; Fri, 13 May 2022 09:34:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx12UWAxGfsfd4FplDJSFkS58YtGnc7ut5L4Fu3MmS0ie3g+jnEpfn3ZQcv0wxt1J60VU59 X-Received: by 2002:a17:907:7e83:b0:6f9:1fc:ebf3 with SMTP id qb3-20020a1709077e8300b006f901fcebf3mr5140000ejc.403.1652459672950; Fri, 13 May 2022 09:34:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652459672; cv=none; d=google.com; s=arc-20160816; b=Y2eJMtgXjIJ6W5EjxR9xBgQsX9UfjkfwyQUoOU23b1kDByylbHw0snez420fEqwhII j5WPxIrd8ZOFn68YBSy/Sm+A6FaMIn6NLHvmOzpzkDrlRucFdkRSRhIzaoX7eFm73yOA 7Kn5blJp7BVHCJWK7jb+Wbmr5XjZZPSy23iE8i0NSefej7uPZNSf1AYFo+8glRlN0hfw TbWHsiuIzukFcd9G8IS0PgjfHn4N3fz8peB+Bc5OS64HRRlYDhf63IritCVBVA/wtYD7 cptoNOL9wgW7sAyJhDNDNHkwFr+NNMF5fNSOwx5uYIGKtzFzNRXeATKGh+jTrnn/vjmk YvTA== 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; bh=v1+0rd50bZLr73rvAgjYiAO91AUSWeEQS6a0OEdlMKc=; b=VvR9tigITqERQjwUpN79tQ8Edy5GxJQJy/lA2n88OTNYjuZon6nYwEsG+jvbQybwKs Yom/NNtqxdyXC6n4Iok/UL0LVxSy/2HXnz+2XvCh0srvWykEEqB7JoM7j3NYHQnnAKck 0f6KLNyLaOdayCrgNQpH/t5QhNUXuDwz08iR3KbbVrXgnjV5qdRiFQ8GP/bjtP2ye05h t+tPsxrm6UBHlWZr7DWiYXt6hyguX6OiNvG1CiWg3zvFWCJGE6Csb3PxxaZeE19nAU01 SKl2R1h6BZjfTPFCeo29uVyLNsYUDlT9APf7mS7oc1S/evvpFclAEjbkNE7G6vmFtFV/ c8sg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j4-20020aa7c344000000b00425d815e43fsi2099268edr.400.2022.05.13.09.34.05; Fri, 13 May 2022 09:34:31 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351803AbiELIwQ (ORCPT + 99 others); Thu, 12 May 2022 04:52:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351726AbiELIvp (ORCPT ); Thu, 12 May 2022 04:51:45 -0400 Received: from outbound-smtp29.blacknight.com (outbound-smtp29.blacknight.com [81.17.249.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA0DD5DA01 for ; Thu, 12 May 2022 01:51:39 -0700 (PDT) Received: from mail.blacknight.com (pemlinmail04.blacknight.ie [81.17.254.17]) by outbound-smtp29.blacknight.com (Postfix) with ESMTPS id DFACABF1D5 for ; Thu, 12 May 2022 09:51:37 +0100 (IST) Received: (qmail 16579 invoked from network); 12 May 2022 08:51:37 -0000 Received: from unknown (HELO morpheus.112glenside.lan) (mgorman@techsingularity.net@[84.203.198.246]) by 81.17.254.9 with ESMTPA; 12 May 2022 08:51:37 -0000 From: Mel Gorman To: Andrew Morton Cc: Nicolas Saenz Julienne , Marcelo Tosatti , Vlastimil Babka , Michal Hocko , LKML , Linux-MM , Mel Gorman Subject: [PATCH 4/6] mm/page_alloc: Remove unnecessary page == NULL check in rmqueue Date: Thu, 12 May 2022 09:50:41 +0100 Message-Id: <20220512085043.5234-5-mgorman@techsingularity.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220512085043.5234-1-mgorman@techsingularity.net> References: <20220512085043.5234-1-mgorman@techsingularity.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 The VM_BUG_ON check for a valid page can be avoided with a simple change in the flow. The ZONE_BOOSTED_WATERMARK is unlikely in general and even more unlikely if the page allocation failed so mark the branch unlikely. Signed-off-by: Mel Gorman Tested-by: Minchan Kim Acked-by: Minchan Kim --- mm/page_alloc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 1c4c54503a5d..b543333dce8f 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3765,17 +3765,18 @@ struct page *rmqueue(struct zone *preferred_zone, page = rmqueue_buddy(preferred_zone, zone, order, alloc_flags, migratetype); - if (unlikely(!page)) - return NULL; out: /* Separate test+clear to avoid unnecessary atomics */ - if (test_bit(ZONE_BOOSTED_WATERMARK, &zone->flags)) { + if (unlikely(test_bit(ZONE_BOOSTED_WATERMARK, &zone->flags))) { clear_bit(ZONE_BOOSTED_WATERMARK, &zone->flags); wakeup_kswapd(zone, 0, 0, zone_idx(zone)); } - VM_BUG_ON_PAGE(page && bad_range(zone, page), page); + if (unlikely(!page)) + return NULL; + + VM_BUG_ON_PAGE(bad_range(zone, page), page); return page; } -- 2.34.1