Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp368061rwl; Tue, 11 Apr 2023 20:18:48 -0700 (PDT) X-Google-Smtp-Source: AKy350YhYaRKTVn9rc7fSokYIRLwdt+ILoqxmnhQH9dUmlxXey5xgbyloDTH1XM/YxKqkLzTSFtw X-Received: by 2002:a17:902:e549:b0:19a:f9b5:2f2f with SMTP id n9-20020a170902e54900b0019af9b52f2fmr20485880plf.55.1681269527721; Tue, 11 Apr 2023 20:18:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681269527; cv=none; d=google.com; s=arc-20160816; b=oSFYD7n/692Ev+QeevrMbBps/g9ff0uk8h00jfHnX4OpOqGmPgtHcUsMsnBB1QE4aD /qFtyXyv1c/65JH57i8S6N5JwuqfiXNxBOtvIpKqDDCV0UgPwWgJYWyDBHavn1uEtyqk mafo9JV380nKtZUkDKfaA8LCm9GEU958dHS6EHfMjEp3v+6qCKqpGUNu4mUFvsvKY8/J T7YH7vTw0mwfVomnc5ibvgcm8LgR2qf3ypd4nsuEoQzutOhTn1K3JJkzLl5CuJ/qHDif 8kZ2PxK9rg2U8meRsuiLBufoGX+FL+p5NP0Q18FCdzj/CSt2oCLTeLKh7zpIAGNRRTGU HYBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=fMwtG3kjimCSdpRTY8GTgkdQjXk+vO4Foj6iAaTFla8=; b=Zpzbt2UsDiTlsd8tdl1vAmivgniW9cRz0Ti1bIB3J018fR0jzPaC9rtj3PiQK/aAm9 I+1JRVPvrg+Dw+fNCfoBDEl2RZ29AqLMP1tC4GXLGWdGt7L4kfiA1yVDwnNGTbhaKCF9 ivto+sH+00jg1zLJDMFBb0kGQx6saJzT84+BkEABB5900JEec/x5nH7dY5a7dfhOkB9E jPkmDcYoDoYl+/DF3f0QBjkcxQu1mV30l6Qq51aQtXkz3BYu7bZXfXQkEyXQ6NTgRNYY m95/p0oWTyzW6Fv69seMju5lgzLMPPoXxZcUAvsFPqfqMBaIciVocxbfVMW8Y4WcQ0OD Y/kw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e6-20020a17090301c600b0019c14335fc0si16248143plh.70.2023.04.11.20.18.35; Tue, 11 Apr 2023 20:18:47 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229660AbjDLDPT (ORCPT + 99 others); Tue, 11 Apr 2023 23:15:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229649AbjDLDPP (ORCPT ); Tue, 11 Apr 2023 23:15:15 -0400 Received: from out30-97.freemail.mail.aliyun.com (out30-97.freemail.mail.aliyun.com [115.124.30.97]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9CB4524B for ; Tue, 11 Apr 2023 20:15:13 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R181e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045176;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0VfuWQdr_1681269309; Received: from 30.97.48.75(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0VfuWQdr_1681269309) by smtp.aliyun-inc.com; Wed, 12 Apr 2023 11:15:10 +0800 Message-ID: <80c53bfc-891d-af09-9b69-2954d7fe625e@linux.alibaba.com> Date: Wed, 12 Apr 2023 11:15:13 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: Re: [PATCH v2 1/2] mm: compaction: consider the number of scanning compound pages in isolate fail path To: Mel Gorman Cc: akpm@linux-foundation.org, osalvador@suse.de, vbabka@suse.cz, william.lam@bytedance.com, mike.kravetz@oracle.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <73d6250a90707649cc010731aedc27f946d722ed.1678962352.git.baolin.wang@linux.alibaba.com> <20230405103141.yu7p53psbvstv6kg@techsingularity.net> From: Baolin Wang In-Reply-To: <20230405103141.yu7p53psbvstv6kg@techsingularity.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL 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 4/5/2023 6:31 PM, Mel Gorman wrote: > On Thu, Mar 16, 2023 at 07:06:46PM +0800, Baolin Wang wrote: >> The commit b717d6b93b54 ("mm: compaction: include compound page count >> for scanning in pageblock isolation") had added compound page statistics >> for scanning in pageblock isolation, to make sure the number of scanned >> pages are always larger than the number of isolated pages when isolating >> mirgratable or free pageblock. >> >> However, when failed to isolate the pages when scanning the mirgratable or >> free pageblock, the isolation failure path did not consider the scanning >> statistics of the compound pages, which can show the incorrect number of >> scanned pages in tracepoints or the vmstats to make people confusing about >> the page scanning pressure in memory compaction. >> >> Thus we should take into account the number of scanning pages when failed >> to isolate the compound pages to make the statistics accurate. >> >> Signed-off-by: Baolin Wang > > Acked-by: Mel Gorman Thanks Mel. > > However, the patch highlights weakeness in the tracepoints and how > useful they are. > > Minimally, I think that the change might be misleading when comparing > tracepoints across kernel versions as it'll be necessary to check the exact > meaning of nr_scanned for a given kernel version. That's not a killer problem > as such, just a hazard if using an analysis tool comparing kernel versions. > > As an example, consider this > > if (PageCompound(page)) { > const unsigned int order = compound_order(page); > > if (likely(order < MAX_ORDER)) { > blockpfn += (1UL << order) - 1; > cursor += (1UL << order) - 1; > nr_scanned += compound_nr(page) - 1; <<< patch adds > } > goto isolate_fail; > } > > Only the head page is "scanned", the tail pages are not scanned so > accounting for them as "scanned" is not an accurate reflection of the > amount of work done. Isolation is different because the compound pages > isolated is a prediction of how much work is necessary to migrate that > page as it's obviously more work to copy 2M of data than 4K. The migrated > pages combined with isolation then can measure efficiency of isolation > vs migration although imperfectly as isolation is a span while migration > probably fails at the head page. > > The same applies when skipping buddies, the tail pages are not scanned > so skipping them is not additional work. > > Everything depends on what the tracepoint is being used for. If it's a > measure of work done, then accounting for skipped tail pages over-estimates > the amount of work. However, if the intent is to measure efficiency of > isolation vs migration then the "span" scanned is more useful. Yes, we are more concered about the efficiency of isolation vs migration. > None of this kills the patch, it only notes that the tracepoints as-is > probably cannot answer all relevant questions, most of which are only > relevant when making a modification to compaction in general. The patch > means that an unspecified pressure metric can be derived (maybe interesting > to sysadmins) but loses a metric about time spent on scanning (maybe > interesting to developers writing a patch). Of those concerns, sysadmins > are probably more common so the patch is acceptable but some care will be > need if modifying the tracepoints further if it enables one type of > analysis at the cost of another. I learned, and thanks for your excellent explaination.