Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4382pxu; Wed, 6 Jan 2021 19:03:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJzbltRCrme2p2f6Gj6KXGp8l+x4YKPTIiWC0Olgs9bNAFLqG0zpUSy2g6YGEhNK6EFF9VY0 X-Received: by 2002:aa7:c444:: with SMTP id n4mr81761edr.226.1609988625942; Wed, 06 Jan 2021 19:03:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609988625; cv=none; d=google.com; s=arc-20160816; b=lWUrBgFpvkbxfCX2wAx/BfGq+7nxb2z+JXpkjcXSZahWRvM7Uw1v+z43IxQXTvZlTC oX9wH5//JbzWz+1uXII3Wa2RssH/HivykvqcVCWSEqndnIMhRmFoa70Z0UwU/WQoENvp wncDJvoAQlmk+2uj7hDq15SIgMqo3Nl1BqlHw4oSqu21gz/tCUAR6auVFwf5h/fQdkxU wbirwKQTgrUx7ibagovhIDvYlD7SK1FV8OMW9OpZ/sq/dW12H7dA1o1Mf4tAR2kdzb+Y HEQ2EwtDegWc1KamoHCku4vlxX9/RtGIi+AxidunbGYSpP1Wl5kYoK2qHzOh3y4rlmzY VJbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Y2xQZ5RMbObOSpIE8tPtSLqtuZYmrDOIDrzQfpthNtY=; b=M3pl52L7xdVWuG/0yaGTutk8NGMZPbf+KaQLnSTgwWtQ7Q4netKQex+RHtwxKg4KKU idMO+qTo3uR0Wfems24JH88p4smh8hncuonLRdL4YX+viHBotZ2YgZ4l8BIt1XdmY+ZO QSU3UWEZweWKK3fqTWt4HAoMtkdpn0r3tJQBK9cjdPA5T3/GB5VoSAKBDe7hnHvk2/1r pAqJKhXe9mgBXd46j99Dt+aw1DdUBgigPS30T+H2ST3kdHOgkRKNP82RX1vjcxLpqDYL ZF2u0jZXA/ExH6ZFlOLTPTz/F48mNVQjJnYOi2nXwi7Gcp2rOGHjK5BMACtlr4gc22Sj tQvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FREAbxHZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z102si1633642ede.307.2021.01.06.19.03.21; Wed, 06 Jan 2021 19:03:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FREAbxHZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727200AbhAGDAw (ORCPT + 99 others); Wed, 6 Jan 2021 22:00:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726326AbhAGDAv (ORCPT ); Wed, 6 Jan 2021 22:00:51 -0500 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BC89C0612EF for ; Wed, 6 Jan 2021 19:00:11 -0800 (PST) Received: by mail-lf1-x12a.google.com with SMTP id m25so11233417lfc.11 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=hDsL7ZyMWUR+RGr0hdWzVjtwqSUxfDMCjaSaJwbbE32JIuKzGV3LmJi6/yynhqnmMx aLy23wK3yHd/pBdfZLnu2+PR99YLYQMDTzApKlS2UITH9HEVySn0KymFvOkDRRx0qTaO LOIR1gQH4a9G1l6A+osFAiMVmOoRjI2ZgwnJhO54sF9ORn+6Y5x66wEBmt7Tm4iGSLpF 8DzcXT6585FzglhiI2z/wmr5jyXjRDkoK7GaZv+WmTHtae6LoZlXyLqAX60HQnTqop15 aRYbtHWmx/aV0p8BsIZhO14b6T+YWRnOoRGfXJohwa4Dkz6E5PE0fLQpBgPlfQblpF/u EtPQ== X-Gm-Message-State: AOAM53253qepRmd1qVsYsTo8wEc06eUQqLPFGP3TfNux6tjEBg07SAE0 zduZrQkBtEOO9Ci2fU6q1wzqvN1O1MoPPnFqC4o= 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" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > 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