Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp946833pxb; Fri, 22 Apr 2022 15:04:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/fP1CIAkBrW/1/zJGcFeMIGmy4qlyYSZV589RrWHBOMu0+mFFlluzxaMmzm7PI/04O7Y7 X-Received: by 2002:a63:78c3:0:b0:398:2d6d:c275 with SMTP id t186-20020a6378c3000000b003982d6dc275mr5629368pgc.565.1650665062077; Fri, 22 Apr 2022 15:04:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650665062; cv=none; d=google.com; s=arc-20160816; b=c11UFJDeGtEaGpKp9RDq2RsurZY0aFv7Pv8fbgL99ukhJHshxZE7I7R5RrNcCR9KTx VpiFmDKx+cLNCms7KvrsGfW8HGhnxUdIxQY3WtVOSJiN4FF+aeZz1aKTkZxJpZbORDPy bhCB0CXoDBTlXVwgfEb+E9eP0lHROygDYuShMouv2rqLkXUDwZOaA4tg+IuWDV1VwiRY Ktw//QE3L/KODs50HJyKcQZCtI5oBrp1klzUPWf9pq02vNKO5EPukouKTkP9g+0HCvEK LVQNZ2OEScaJBhxdz9ARLhCaIN5zp7VWW67W0lMhIFqaC7+YcOg8WyNOMcgV7YSfvArY lFJg== 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=weplSIyWyg+JT8G5ccdNAE8EfH8QQRj4TA+id+KKwRg=; b=pv5ugheqLaaVhfXMFiW+LvJd7RFz3qTEACiGqCZlS2QkIezEdep/MgI4HQPbIZKNZ3 YCKx0AJXVZvMc2hjWMkZ1shtW9QHzClVWt+a/gjEgi/TQ38skezx0XKXpBU9Ivu3cVQf f+oRUfmfq12grXEm5XpgGIbYZq7U41mpRaT1zw2RsHzbHwxRAA/L1AfbrPFyoAtD+oX8 iOabUdS5v3iSCzi5am+ALjRTLqXyiYz4iZJ+RgYpvhUaCiND5XfL8io4Emc7XHTQRMjH eTKis0enn9Co33DKm7I0yAboB8f8AOJ70daC11DA+Z1kEYI2NdBUMbRKURP3fgYcVuv0 9KTw== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id x7-20020a634847000000b003aa65024928si3734989pgk.224.2022.04.22.15.04.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 15:04:22 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 973F92608FA; Fri, 22 Apr 2022 13:11:24 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356891AbiDTKJ7 (ORCPT + 99 others); Wed, 20 Apr 2022 06:09:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347063AbiDTKJs (ORCPT ); Wed, 20 Apr 2022 06:09:48 -0400 Received: from outbound-smtp31.blacknight.com (outbound-smtp31.blacknight.com [81.17.249.62]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B51163ED09 for ; Wed, 20 Apr 2022 03:07:01 -0700 (PDT) Received: from mail.blacknight.com (pemlinmail04.blacknight.ie [81.17.254.17]) by outbound-smtp31.blacknight.com (Postfix) with ESMTPS id 20194C0E27 for ; Wed, 20 Apr 2022 11:00:01 +0100 (IST) Received: (qmail 12208 invoked from network); 20 Apr 2022 10:00:01 -0000 Received: from unknown (HELO morpheus.112glenside.lan) (mgorman@techsingularity.net@[84.203.198.246]) by 81.17.254.9 with ESMTPA; 20 Apr 2022 10:00:00 -0000 From: Mel Gorman To: Nicolas Saenz Julienne Cc: 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: Wed, 20 Apr 2022 10:59:04 +0100 Message-Id: <20220420095906.27349-5-mgorman@techsingularity.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420095906.27349-1-mgorman@techsingularity.net> References: <20220420095906.27349-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, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE autolearn=no 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 --- 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 4c1acf666056..dc0fdeb3795c 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