Received: by 2002:a05:7412:1703:b0:e2:908c:2ebd with SMTP id dm3csp3342553rdb; Tue, 29 Aug 2023 12:15:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEXiqgrLiKKXY+UqRXkBsY83fsjx3bPJ38U+YQrTfK1+/mHFvNgs4/USUuky/QfMQyk2ZAs X-Received: by 2002:aa7:c6ce:0:b0:525:6c74:5e58 with SMTP id b14-20020aa7c6ce000000b005256c745e58mr169603eds.23.1693336538350; Tue, 29 Aug 2023 12:15:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693336538; cv=none; d=google.com; s=arc-20160816; b=vQAcAzp/vajde88eLaK5DxlAoW2q8+nEjdNsdt1geS6LkVzaXGcINBur0BNUc2Fk8N KbsJtQIzewQ0/G8uw3jSAEp6xiE/BBTvDYAoOs9Of12joWOTkvT0SdU8IxBKqODYDSlX FR3EVGx4cxbGkp7wGgdTfh6EGdJzXHWeZLQktO0wRwqMu2cDETb+48fs7UvosYnnSyWY BCLRnpDEdmbXicYYszCHyzLSVnvGKizpGgJg55GjwQm0+e5Q/c+53ZJkkVpMpIOXdgXl 5COqMhT5qIxnI9akXReNN7mwtImWWEpNkbVx+kYhty09ILmrZl9Z2dXkli1g4Cu7uYXo EkHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=vSuzEt532ih4OnQ9X4waxbX+kratZguxADezzRvh4/o=; fh=xul8u5lbFhEjS9WSOKDxePiEh0mLhT/NsGR/umN2l24=; b=dsXlENDC/rstIUBeGCRCGYfxWMzxF/Kxg+Q1dNQxahttgIJrGuTiNebYuNsCMelWB2 7qkKp9SAtBTRn0i15IBMOEdvkp9ePgUgnFia/4pt1WmBRFqsODYfjRJ+OBHw2a2zc3T+ wcOaHD5be6HYhWmKewIM2tPJz7+sku16EWFgUShHHEcrG89bvif/MipDqNLYdVnwqS9H kVIMq//JiAdY6j3B6LZEA7i9H4f6UI4VshCgE7orbva9n/GmIb5LPq/zA7RGenLCYa+3 Le+fV3y/pMcKPu+7KXBkoTay8MAf6LSpesMJRV+UGbTzbB0GTus/2g2e55hX4bcRiGRo vBmg== 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 b6-20020aa7c6c6000000b0051df215a297si6551159eds.641.2023.08.29.12.15.01; Tue, 29 Aug 2023 12:15:38 -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 S235029AbjH2PCM (ORCPT + 99 others); Tue, 29 Aug 2023 11:02:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237196AbjH2PCC (ORCPT ); Tue, 29 Aug 2023 11:02:02 -0400 Received: from outbound-smtp51.blacknight.com (outbound-smtp51.blacknight.com [46.22.136.235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C7021B7 for ; Tue, 29 Aug 2023 08:01:57 -0700 (PDT) Received: from mail.blacknight.com (pemlinmail02.blacknight.ie [81.17.254.11]) by outbound-smtp51.blacknight.com (Postfix) with ESMTPS id 683FFFA77F for ; Tue, 29 Aug 2023 16:01:55 +0100 (IST) Received: (qmail 15764 invoked from network); 29 Aug 2023 15:01:55 -0000 Received: from unknown (HELO techsingularity.net) (mgorman@techsingularity.net@[84.203.20.191]) by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated); 29 Aug 2023 15:01:55 -0000 Date: Tue, 29 Aug 2023 16:01:53 +0100 From: Mel Gorman To: Kemeng Shi Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, baolin.wang@linux.alibaba.com, david@redhat.com, willy@infradead.org Subject: Re: [PATCH v2 4/7] mm/compaction: simplify pfn iteration in isolate_freepages_range Message-ID: <20230829150153.j4lw36s7yx5be7al@techsingularity.net> References: <20230826153617.4019189-1-shikemeng@huaweicloud.com> <20230826153617.4019189-5-shikemeng@huaweicloud.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <20230826153617.4019189-5-shikemeng@huaweicloud.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,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 On Sat, Aug 26, 2023 at 11:36:14PM +0800, Kemeng Shi wrote: > We call isolate_freepages_block in strict mode, continuous pages in > pageblock will be isolated if isolate_freepages_block successed. > Then pfn + isolated will point to start of next pageblock to scan > no matter how many pageblocks are isolated in isolate_freepages_block. > Use pfn + isolated as start of next pageblock to scan to simplify the > iteration. > > The pfn + isolated always points to start of next pageblock as: > In case isolated buddy page has order higher than pageblock: > 1. page in buddy page is aligned with it's order > 2. order of page is higher than pageblock order > Then page is aligned with pageblock order. So pfn of page and isolated > pages count are both aligned pageblock order. So pfn + isolated is > pageblock order aligned. > > In case isolated buddy page has order lower than pageblock: > Buddy page with order N contains two order N - 1 pages as following: > | order N | > |order N - 1|order N - 1| > So buddy pages with order N - 1 will never cross boudary of order N. > Similar, buddy pages with order N - 2 will never cross boudary of order > N - 1 and so on. Then any pages with order less than pageblock order > will never crosa boudary of pageblock. > > Signed-off-by: Kemeng Shi > Reviewed-by: Baolin Wang While I don't think the patch is wrong, I also don't think it meaningfully simplifies the code or optimises enough to be justified. Even though a branch is eliminated, the whole path is not cheap. -- Mel Gorman SUSE Labs