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=-7.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no 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 2D1C5C433E0 for ; Thu, 7 Jan 2021 03:00:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C117823101 for ; Thu, 7 Jan 2021 03:00:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C117823101 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 201C98D0118; Wed, 6 Jan 2021 22:00:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1B2468D0090; Wed, 6 Jan 2021 22:00:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0F0498D0118; Wed, 6 Jan 2021 22:00:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0223.hostedemail.com [216.40.44.223]) by kanga.kvack.org (Postfix) with ESMTP id ECC5C8D0090 for ; Wed, 6 Jan 2021 22:00:11 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id A70698248076 for ; Thu, 7 Jan 2021 03:00:11 +0000 (UTC) X-FDA: 77677475022.22.drum25_44163d3274e6 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin22.hostedemail.com (Postfix) with ESMTP id 8A9CA18038E60 for ; Thu, 7 Jan 2021 03:00:11 +0000 (UTC) X-HE-Tag: drum25_44163d3274e6 X-Filterd-Recvd-Size: 6302 Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) by imf36.hostedemail.com (Postfix) with ESMTP for ; Thu, 7 Jan 2021 03:00:11 +0000 (UTC) Received: by mail-lf1-f42.google.com with SMTP id o17so11356182lfg.4 for ; Wed, 06 Jan 2021 19:00:10 -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=Y2xQZ5RMbObOSpIE8tPtSLqtuZYmrDOIDrzQfpthNtY=; b=FREAbxHZ+FdRctVna5bB4km0wAZI1guozJraW+Ss/19NakfFF5WZZtgcJ9yPXDFugO BpmhRoQiQhslNDXDDiq93//SMZ7ohrQb1rtT4tY+75q5KB6lZOdXtILfBWWQCBaoXlPJ 8LONDz0qABe3Fig5IqXutrZr3xx9wZnt+L5i0+37k/m/2Vs0J7IQ8zQ4uCHleW6ngBIR zA/MmbgGo2srFlLyIsSJARCqTFRSnOox0oX3Q2Ujh4pg0/TVN3e45dS7DUDZGNTC5+CV NQcW7j2vsR3GGN+X1PJDCIKLoju5XbpXh85F2ukI3YOWq8SJP6NSAKl20ISjJrFLb6eS lXaQ== 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=Y2xQZ5RMbObOSpIE8tPtSLqtuZYmrDOIDrzQfpthNtY=; b=a3hgV1BDC1YCeOZFP6n0EGYVUa900fsndmXGAA7wtSTdOP1FY8MD2q2boqHZFbOOJ3 TYMvonCQp7LFNvWqYuYZ/xvCynZ9vPg3OuHmHH1kd8dPAUZ1MJvFbJWIlfLJCDLHVBnq 7iff5rx2ZesNKMJB7WxFG1+belCIUz1dtii2cl7mDDwI31iTB05/vS+CbP5wvxDx2Pe/ OkAH/B+RRfmi7i9TjdIRhPdp2+z2B36FQg0PVx5+Zad11ZKU/ljQy4mTgHjgN1m+JEPz x8zieconBuRrhbLfrhaf4MfjiQj/T8fJGmmduQvzu9nKxCyKxFaXh4xnkyktS2CR28DW urgw== X-Gm-Message-State: AOAM5314X9EdO+Tg1afiwMvHod/ktsbg17RQDlVXdzkxblXRsIQIleVv yKcMP/s7o9mA6Y1YaWPJEKx6v55zFaGTme4lUFw= X-Google-Smtp-Source: ABdhPJz0u4kaTNiRDi7EHBiRqoyK82SxCRX5Gw1c7Qs4zLA5ZsrkL4MCqQqXfao/3cfYwAfoncEI9LH4LDSRvFr/3nM= X-Received: by 2002:a05:651c:22b:: with SMTP id z11mr3104479ljn.38.1609988409068; Wed, 06 Jan 2021 19:00:09 -0800 (PST) MIME-Version: 1.0 References: <20210106034715.GA1138@open-light-1.localdomain> In-Reply-To: From: Liang Li Date: Thu, 7 Jan 2021 10:59:55 +0800 Message-ID: Subject: Re: [PATCH 1/6] mm: Add batch size for free page reporting To: Alexander Duyck Cc: 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 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: > 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. The reason for adding a batch is mainly for page prezero, I just want to make it configurable to control the 'cache pollution', for that case, the reporting thread should not be woken up too frequently. > > --- > > 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. you are right, will change. > > /* 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. You are right again. Thanks Liang