From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3FA60C433EF for ; Fri, 15 Jul 2022 14:13:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D20029401EC; Fri, 15 Jul 2022 10:13:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CCE6B9401E5; Fri, 15 Jul 2022 10:13:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B96509401EC; Fri, 15 Jul 2022 10:13:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id A6F259401E5 for ; Fri, 15 Jul 2022 10:13:21 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 8211860683 for ; Fri, 15 Jul 2022 14:13:21 +0000 (UTC) X-FDA: 79689526602.25.085EF0E Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) by imf10.hostedemail.com (Postfix) with ESMTP id 4D3C0C0092 for ; Fri, 15 Jul 2022 14:13:19 +0000 (UTC) Received: by mail-wm1-f42.google.com with SMTP id be14-20020a05600c1e8e00b003a04a458c54so3097417wmb.3 for ; Fri, 15 Jul 2022 07:13:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=riEJIfBpfcy57tk6eBP6zBDihsAq9M9ciWKjQSWTHns=; b=N3qh55mWYG1MkCB5nWXF2U09nYYX5u0cooSnIAkTzZPECYivn+J9EbY8MvkWYlRG4f tBIoH7tt0p+hFeC2pUWGpBDm8PQMZCj6FfsRjKUv7YPdwHiOGcj1KXm3XjPT8OlmS3hc n8CylkNMOmB/jU1JFjFhH1Lp+qr0vwwDTjYSFyApmCsOK670NxDDyR6ZBFs0w3wFuBUi pPWia79Tkl2dAqnYmtgBvXvy/TvYOLjMSlANbPpVU9j5Hrt0ULjPK1s1mIMBKKjoHn4I jLZgqrqt/1UYC3iWMgZJZiRIfun6txB8ymQrPrZa3ef8cHWVyYxdXq09Ju8lzcEmlTw5 Pfpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=riEJIfBpfcy57tk6eBP6zBDihsAq9M9ciWKjQSWTHns=; b=4grZyQ5/SBHQ+clC2miDQGf0dcGYhbcKeL36v2jl3OzyGveR8e8cA+ddGTXixYZp9l bA5DwlJGsl+4T2RLpoqj72R9Lb68/IJ0PB+lGUBWQSPl5xGoJyb4a8y2xZfBb0mKJ272 cu17khVMpIagNg60wW8EC0kMGfj9CH8i+Ux3FLHLOVofg5mqhXkYhGX8AIpTM4u52bfF LBSo/N89DO9QPjNr1cY6jphZTkDQbK2MXiqZmmAxcR2dLlqyHuGvnFv1UU6A6XXo/DHY GnM/dZTg/yXU2PNI+7Y5nsYrIMB4AlV7MuWp0ZZd6DsOGknSfIVU04xjon2nE6LitZEn g/bg== X-Gm-Message-State: AJIora8gNOsh7O88uTZlkNjMAh7cIGqfSUeGFsXK/xPFYgnaM4j3oYO3 iQ7N06eoGI0I/mrOJ3kHSmuxJg== X-Google-Smtp-Source: AGRyM1v2MFrUcnY3vJQMzm0gPXoQLK1rF1PKQ5KZzsadM6EF94IHEeXLuKtzZlBXGzCTe6LSEy8v+Q== X-Received: by 2002:a7b:c442:0:b0:3a3:bdb:e84c with SMTP id l2-20020a7bc442000000b003a30bdbe84cmr3771592wmi.101.1657894397744; Fri, 15 Jul 2022 07:13:17 -0700 (PDT) Received: from C02FT09GML7L ([2a01:4b00:8019:4b00:1b0:435a:f49:c81]) by smtp.gmail.com with ESMTPSA id r21-20020a05600c425500b003a2cf5eb900sm5175095wmm.40.2022.07.15.07.13.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jul 2022 07:13:17 -0700 (PDT) Date: Fri, 15 Jul 2022 15:13:13 +0100 From: William Lam To: Punit Agrawal Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: compaction: include compound page count for scanning in pageblock isolation Message-ID: References: <20220711202806.22296-1-william.lam@bytedance.com> <874jzin30k.fsf@stealth> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <874jzin30k.fsf@stealth> ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657894401; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=riEJIfBpfcy57tk6eBP6zBDihsAq9M9ciWKjQSWTHns=; b=bFyTk7tWh855ceOAJSevdB7e/J8r1Bvfr6M2/BCnMxFvNqRMIU/Vqozv44LOfbrrfz2KHc T0oLWjYPgwxvA/UCbFkZLPIwRBdRimhfVfO+6xAezGIegzisULVbjN5baXG/3Vw8XHxyI2 0davrFiqWwd4RlxEDTz9c7QA8kQbTeU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657894401; a=rsa-sha256; cv=none; b=J9SxrDryknQGFC1wqMuTFH+NJunCuI9Q/8LRmp8Modqf2wc/I90ZLjS0YJqDSZK8ghR7Fe YGnyER39ZCE95NzMTMLW0WTUciVNG+cK5freDR80weTTFVbUBbkdU7NlYgejHimDYDnn2w XKUbqVZpa3Mol8Pu7fOCSp+RSm1LPNs= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=N3qh55mW; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf10.hostedemail.com: domain of william.lam@bytedance.com designates 209.85.128.42 as permitted sender) smtp.mailfrom=william.lam@bytedance.com X-Stat-Signature: sppzx61dkdwzmuo3sdbe6hmh88u163fa X-Rspamd-Queue-Id: 4D3C0C0092 Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=N3qh55mW; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf10.hostedemail.com: domain of william.lam@bytedance.com designates 209.85.128.42 as permitted sender) smtp.mailfrom=william.lam@bytedance.com X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1657894399-539211 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Jul 15, 2022 at 10:23:07AM +0100, Punit Agrawal wrote: > Hi William, > > William Lam writes: > > > The number of scanned pages can be lower than the number of isolated > > pages when isolating mirgratable or free pageblock. The metric is being > > reported in trace event and also used in vmstat. > > > > This behaviour is confusing since currently the count for isolated pages > > takes account of compound page but not for the case of scanned pages. > > And given that the number of isolated pages(nr_taken) reported in > > mm_compaction_isolate_template trace event is on a single-page basis, > > the ambiguity when reporting the number of scanned pages can be removed > > by also including compound page count. > > A minor suggestion - It maybe useful to include an example trace output > to highlight the issue. > some example output from trace where it shows nr_taken can be greater than nr_scanned: Produced by kernel v5.19-rc6 kcompactd0-42 [001] ..... 1210.268022: mm_compaction_isolate_migratepages: range=(0x107ae4 ~ 0x107c00) nr_scanned=265 nr_taken=255 [...] kcompactd0-42 [001] ..... 1210.268382: mm_compaction_isolate_freepages: range=(0x215800 ~ 0x215a00) nr_scanned=13 nr_taken=128 kcompactd0-42 [001] ..... 1210.268383: mm_compaction_isolate_freepages: range=(0x215600 ~ 0x215680) nr_scanned=1 nr_taken=128 mm_compaction_isolate_migratepages does not seem to have this behaviour, but for the reason of consistency, nr_scanned should also be taken care of in that side. > > > > Signed-off-by: William Lam > > --- > > mm/compaction.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/mm/compaction.c b/mm/compaction.c > > index 1f89b969c12b..1b51cf2d32b6 100644 > > --- a/mm/compaction.c > > +++ b/mm/compaction.c > > @@ -616,6 +616,7 @@ static unsigned long isolate_freepages_block(struct compact_control *cc, > > break; > > set_page_private(page, order); > > > > + nr_scanned += isolated - 1; > > total_isolated += isolated; > > cc->nr_freepages += isolated; > > list_add_tail(&page->lru, freelist); > > @@ -1101,6 +1102,7 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn, > > isolate_success_no_list: > > cc->nr_migratepages += compound_nr(page); > > nr_isolated += compound_nr(page); > > + nr_scanned += compound_nr(page) - 1; > > > > /* > > * Avoid isolating too much unless this block is being > > @@ -1504,6 +1506,7 @@ fast_isolate_freepages(struct compact_control *cc) > > if (__isolate_free_page(page, order)) { > > set_page_private(page, order); > > nr_isolated = 1 << order; > > + nr_scanned += nr_isolated - 1; > > cc->nr_freepages += nr_isolated; > > list_add_tail(&page->lru, &cc->freepages); > > count_compact_events(COMPACTISOLATED, nr_isolated); > > Regardless of the comment above - > > Reviewed-by: Punit Agrawal