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 X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C372C433DB for ; Wed, 6 Jan 2021 16:59:17 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4190123120 for ; Wed, 6 Jan 2021 16:59:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4190123120 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 7F9E36B02A6; Wed, 6 Jan 2021 11:59:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7A8B06B02A8; Wed, 6 Jan 2021 11:59:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6BCDF6B02A9; Wed, 6 Jan 2021 11:59:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0018.hostedemail.com [216.40.44.18]) by kanga.kvack.org (Postfix) with ESMTP id 57D876B02A6 for ; Wed, 6 Jan 2021 11:59:16 -0500 (EST) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 23C671EF1 for ; Wed, 6 Jan 2021 16:59:16 +0000 (UTC) X-FDA: 77675960712.20.smile66_521612d274e3 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin20.hostedemail.com (Postfix) with ESMTP id 0581A180C0609 for ; Wed, 6 Jan 2021 16:59:15 +0000 (UTC) X-HE-Tag: smile66_521612d274e3 X-Filterd-Recvd-Size: 7072 Received: from mail-il1-f179.google.com (mail-il1-f179.google.com [209.85.166.179]) by imf34.hostedemail.com (Postfix) with ESMTP for ; Wed, 6 Jan 2021 16:59:15 +0000 (UTC) Received: by mail-il1-f179.google.com with SMTP id x15so3873688ilq.1 for ; Wed, 06 Jan 2021 08:59:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=3EmfUTuYnuTvPsdC4hdIk2/vIKZRsbh5sYgRQoKisdc=; b=kBn4N4cJQY1i+4o8/OjUAlYWOoo4zZhtiRIw2uz9KnHglVk+6VWWFzkj8sI7zU+85G PhR6dzXAwWuVGiDXkHkXqG9lLgitcz8TlgzkJvMxp1i4rUCgyqFXE9Ipu0kstODAcX0g mpayT3d4Uwaaw6k6mNhrite1jm4Oq9cQntsaW1Y/NDC1s0fslrfPs+8GY7jR0km7SESU HOndvPqqmkmf8ZhRmj4NZAy6zeYOCS+QTUb2iHWxdUDKZ43BTgQl8IJqXx/tpCi4BmjM 0tRgZ3kA4x4S2356P19eTh3+DsEr5Fw3USj0OCBf3WQTQIiMZNtObrhY2i+GzQtpW8Z2 w4BA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=3EmfUTuYnuTvPsdC4hdIk2/vIKZRsbh5sYgRQoKisdc=; b=uWtuKHTwtKD39dGaYUuw22bZlgerz+0PnDRrwnz3OuU3Yk+m8A6qvM9ke8skjM2rW/ TjuN70z05aEJrBxytEi0QyRr9I+hL21L3GpD6aapts1LDKiX3JE1WmKNcB0RVWZ4xEKN wYf7KnLwRQS9duxwnw8uj8Iz85bn9JsDZBwO+5Ayw+V1PlhQjrow0e1R/dGTcOnprqcG Npi901Tpi7mAJXWYb+ZrmhuCD4iwRRuLeyW+f89kFdPdBBLRMoxpjPYjp8g8cqs59IKR BJIVCt9+b4/giJjjI+p94cmlGXclfFxlCJcKXAQJBXx6QziNYsoUwvgxjdOJWhzJ64R4 7zhQ== X-Gm-Message-State: AOAM533tX9KoCPFySzGapFc4gjqBKk1ltuPOkaJXxrbMEhmXtgXfw3WW vctD36yrF0IHIdPr1QAF5Fcv2oRBPFV7+9knm5g= X-Google-Smtp-Source: ABdhPJzjwgaxVsHtTZws6cL84ADauyumJ8mJ0Jvu4/J1N8I/u89+8vWMx+nTn/GdpCCaz5MlKXGT+g3VPF3uG37FwtE= X-Received: by 2002:a92:d8cc:: with SMTP id l12mr4972019ilo.64.1609952354762; Wed, 06 Jan 2021 08:59:14 -0800 (PST) MIME-Version: 1.0 References: <20210106034715.GA1138@open-light-1.localdomain> In-Reply-To: <20210106034715.GA1138@open-light-1.localdomain> From: Alexander Duyck Date: Wed, 6 Jan 2021 08:59:03 -0800 Message-ID: Subject: Re: [PATCH 1/6] mm: Add batch size for free page reporting To: Alexander Duyck , Mel Gorman , Andrew Morton , Andrea Arcangeli , Dan Williams , "Michael S. Tsirkin" , David Hildenbrand , Jason Wang , Dave Hansen , Michal Hocko , Liang Li , Mike Kravetz , linux-mm , LKML , virtualization@lists.linux-foundation.org Cc: Liang Li Content-Type: text/plain; charset="UTF-8" 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 Tue, Jan 5, 2021 at 7:47 PM Liang Li wrote: > > Use the page order as the only threshold for page reporting > is not flexible and has some flaws. Because scan a long free > list is not cheap, it's better to wake up the page reporting > worker when there are more pages, wake it up for a sigle page > may not worth. > This patch add a batch size as another threshold to control the > waking up of reporting worker. > > Cc: Alexander Duyck > Cc: Mel Gorman > Cc: Andrea Arcangeli > Cc: Dan Williams > Cc: Dave Hansen > Cc: David Hildenbrand > Cc: Michal Hocko > Cc: Andrew Morton > Cc: Alex Williamson > Cc: Michael S. Tsirkin > Cc: Liang Li > Signed-off-by: Liang Li So you are going to need a lot more explanation for this. Page reporting already had the concept of batching as you could only scan once every 2 seconds as I recall. Thus the "PAGE_REPORTING_DELAY". The change you are making doesn't make any sense without additional context. > --- > mm/page_reporting.c | 1 + > mm/page_reporting.h | 12 ++++++++++-- > 2 files changed, 11 insertions(+), 2 deletions(-) > > diff --git a/mm/page_reporting.c b/mm/page_reporting.c > index cd8e13d41df4..694df981ddd2 100644 > --- a/mm/page_reporting.c > +++ b/mm/page_reporting.c > @@ -12,6 +12,7 @@ > > #define PAGE_REPORTING_DELAY (2 * HZ) > static struct page_reporting_dev_info __rcu *pr_dev_info __read_mostly; > +unsigned long page_report_batch_size __read_mostly = 16 * 1024 * 1024UL; > > enum { > PAGE_REPORTING_IDLE = 0, > diff --git a/mm/page_reporting.h b/mm/page_reporting.h > index 2c385dd4ddbd..b8fb3bbb345f 100644 > --- a/mm/page_reporting.h > +++ b/mm/page_reporting.h > @@ -12,6 +12,8 @@ > > #define PAGE_REPORTING_MIN_ORDER pageblock_order > > +extern unsigned long page_report_batch_size; > + > #ifdef CONFIG_PAGE_REPORTING > DECLARE_STATIC_KEY_FALSE(page_reporting_enabled); > void __page_reporting_notify(void); > @@ -33,6 +35,8 @@ static inline bool page_reported(struct page *page) > */ > static inline void page_reporting_notify_free(unsigned int order) > { > + static long batch_size; > + I'm not sure this makes a tone of sense to place the value in an inline function. It might make more sense to put this new code in __page_reporting_notify so that all callers would be referring to the same batch_size value and you don't have to bother with the export of the page_report_batch_size value. > /* Called from hot path in __free_one_page() */ > if (!static_branch_unlikely(&page_reporting_enabled)) > return; > @@ -41,8 +45,12 @@ static inline void page_reporting_notify_free(unsigned int order) > if (order < PAGE_REPORTING_MIN_ORDER) > return; > > - /* This will add a few cycles, but should be called infrequently */ > - __page_reporting_notify(); > + batch_size += (1 << order) << PAGE_SHIFT; > + if (batch_size >= page_report_batch_size) { > + batch_size = 0; I would probably run this in the opposite direction. Rather than running batch_size to zero I would look at adding a "batch_remaining" and then when it is < 0 you could then reset it back to page_report_batch_size. Doing that you only have to read one variable most of the time instead of doing a comparison against two. > + /* This add a few cycles, but should be called infrequently */ > + __page_reporting_notify(); > + } > } > #else /* CONFIG_PAGE_REPORTING */ > #define page_reported(_page) false > -- > 2.18.2 > >