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 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 42AA4C2B9F4 for ; Tue, 22 Jun 2021 17:39:45 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C45B261027 for ; Tue, 22 Jun 2021 17:39:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C45B261027 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 98E146B0036; Tue, 22 Jun 2021 13:39:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 93D306B005D; Tue, 22 Jun 2021 13:39:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7B6BA6B006C; Tue, 22 Jun 2021 13:39:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0056.hostedemail.com [216.40.44.56]) by kanga.kvack.org (Postfix) with ESMTP id 46E8E6B0036 for ; Tue, 22 Jun 2021 13:39:43 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 83F4F181522BE for ; Tue, 22 Jun 2021 17:39:43 +0000 (UTC) X-FDA: 78282072246.18.2039517 Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) by imf26.hostedemail.com (Postfix) with ESMTP id 324384000393 for ; Tue, 22 Jun 2021 17:39:43 +0000 (UTC) Received: by mail-ej1-f46.google.com with SMTP id nb6so35665202ejc.10 for ; Tue, 22 Jun 2021 10:39:43 -0700 (PDT) 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=vzEV/LXUCOUKIacuVIarnUamt4RwzwK/u08u24ha27k=; b=PpM3LEXqUuUKFl8KpINDC0rXa4/PjeICtfvuGlxk11FYwbFIWPxZcNkpT0lYa7rGKw 6tYGL/BVmu2gWYq4cHRKjKTayTuEhUq/L23cYI07421fZDpI2fSfHIA1zc1VvtPyiuZz DZ/CFE7mPkJGL/1aBsS2tcIFASBQm4Al9RQdSsztQiS2xW1jNzsGcocnzznijOI5Qz32 5pvBiLFe/0w4Oi37Ct7ukjohcmcroJNMyeg6tQCjNONUDDYibK3X5RgElZJOozAzPeb0 Dgx7Gi3Rue2dcsAwX1WBVg/JpcQmHBOr0emhOYxjVWOHZpqDFPJOQCyPo9ZBKOO3BPci 6FdQ== 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=vzEV/LXUCOUKIacuVIarnUamt4RwzwK/u08u24ha27k=; b=pgU5U/l5jGWxMPCeytzjkIHW0fGgYqpFybYiBGePJ4m27UfL2kMn7hNfIOUEmgzGwT rWncfC5SxtIFcsUdMdc3lmNIjolctJsp+a9Q6DcCu0QKUEmY1cWoPF4evNXLX9xXH+0F 7N08XBDWoHCwQUMUMhiEyu5n1kUxkP8Xxq7UoDw7jyerbiysO73QVFoHcXd0fY3GoTHP N6kKVtMKD45f4C/z59spJ/MB0GtwntL/beOgT3jO3HsJrDJnFoA3NLhVeqtD7t8JmYHy TWNsSWCZbQhDiv71HjlXf1AwcsmN5WSi7U1lH3FGNre7v0cgd1V7R2KZ1aH//zMOeDgo fDkQ== X-Gm-Message-State: AOAM532U1OzjuG715GATVC+zWXUNhxb4Zi9K0TG82SlqN7k72p1PXZAW ST76blX/Fb7T9YJRFc0GbCe3vlqJFiEF2/pxmn8= X-Google-Smtp-Source: ABdhPJw4mj9cHRUGvTmOHI3mJ3iokanfJI5F3ztuD0BdhAmZvZC2ZG+rIq+eHClY24zJzA7tYLVmM5mg1YtBdruc/wg= X-Received: by 2002:a17:906:1f11:: with SMTP id w17mr5166177ejj.33.1624383581728; Tue, 22 Jun 2021 10:39:41 -0700 (PDT) MIME-Version: 1.0 References: <20210622074926.333223-1-gshan@redhat.com> <20210622074926.333223-3-gshan@redhat.com> In-Reply-To: <20210622074926.333223-3-gshan@redhat.com> From: Alexander Duyck Date: Tue, 22 Jun 2021 10:39:30 -0700 Message-ID: Subject: Re: [PATCH v2 2/3] mm/page_reporting: Allow driver to specify threshold To: Gavin Shan Cc: linux-mm , LKML , David Hildenbrand , "Michael S. Tsirkin" , Andrew Morton , Anshuman Khandual , Catalin Marinas , Will Deacon , shan.gavin@gmail.com Content-Type: text/plain; charset="UTF-8" Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=PpM3LEXq; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf26.hostedemail.com: domain of alexanderduyck@gmail.com designates 209.85.218.46 as permitted sender) smtp.mailfrom=alexanderduyck@gmail.com X-Stat-Signature: rufb1od4oeb88p3bgshg574ym43crijy X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 324384000393 X-HE-Tag: 1624383583-539451 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 Mon, Jun 21, 2021 at 10:48 PM Gavin Shan wrote: > > The page reporting threshold is currently sticky to @pageblock_order. > The page reporting can never be triggered because the freeing page > can't come up with a free area like that huge. The situation becomes > worse when the system memory becomes heavily fragmented. > > For example, the following configurations are used on ARM64 when 64KB > base page size is enabled. In this specific case, the page reporting > won't be triggered until the freeing page comes up with a 512MB free > area. That's hard to be met, especially when the system memory becomes > heavily fragmented. > > PAGE_SIZE: 64KB > HPAGE_SIZE: 512MB > pageblock_order: 13 (512MB) > MAX_ORDER: 14 > > This allows the drivers to specify the threshold when the page > reporting device is registered. The threshold falls back to > @pageblock_order if it's not specified by the driver. The existing > users (hv_balloon and virtio_balloon) don't specify the threshold > and @pageblock_order is still taken as their page reporting order. > So this shouldn't introduce functional changes. > > Signed-off-by: Gavin Shan > --- > include/linux/page_reporting.h | 3 +++ > mm/page_reporting.c | 14 ++++++++++---- > mm/page_reporting.h | 10 ++-------- > 3 files changed, 15 insertions(+), 12 deletions(-) > > diff --git a/include/linux/page_reporting.h b/include/linux/page_reporting.h > index 3b99e0ec24f2..fe648dfa3a7c 100644 > --- a/include/linux/page_reporting.h > +++ b/include/linux/page_reporting.h > @@ -18,6 +18,9 @@ struct page_reporting_dev_info { > > /* Current state of page reporting */ > atomic_t state; > + > + /* Minimal order of page reporting */ > + unsigned int order; > }; > > /* Tear-down and bring-up for page reporting devices */ > diff --git a/mm/page_reporting.c b/mm/page_reporting.c > index df9c5054e1b4..27670360bae6 100644 > --- a/mm/page_reporting.c > +++ b/mm/page_reporting.c > @@ -324,6 +324,12 @@ int page_reporting_register(struct page_reporting_dev_info *prdev) > goto err_out; > } > > + /* > + * We need to choose the minimal order of page reporting if it's > + * not specified by the driver. > + */ > + prdev->order = prdev->order ? prdev->order : pageblock_order; > + > /* initialize state and work structures */ > atomic_set(&prdev->state, PAGE_REPORTING_IDLE); > INIT_DELAYED_WORK(&prdev->work, &page_reporting_process); Rather than using prdev->order directly it might be better to have a reporting_order value you could export for use by page_reporting_notify_free. That way you avoid the overhead of having to make a function call per page freed. > diff --git a/mm/page_reporting.h b/mm/page_reporting.h > index 2c385dd4ddbd..d9f972e72649 100644 > --- a/mm/page_reporting.h > +++ b/mm/page_reporting.h > @@ -10,11 +10,9 @@ > #include > #include > > -#define PAGE_REPORTING_MIN_ORDER pageblock_order > - > #ifdef CONFIG_PAGE_REPORTING > DECLARE_STATIC_KEY_FALSE(page_reporting_enabled); > -void __page_reporting_notify(void); > +void __page_reporting_notify(unsigned int order); > > static inline bool page_reported(struct page *page) > { > @@ -37,12 +35,8 @@ static inline void page_reporting_notify_free(unsigned int order) > if (!static_branch_unlikely(&page_reporting_enabled)) > return; > > - /* Determine if we have crossed reporting threshold */ > - if (order < PAGE_REPORTING_MIN_ORDER) > - return; > - > /* This will add a few cycles, but should be called infrequently */ > - __page_reporting_notify(); > + __page_reporting_notify(order); > } > #else /* CONFIG_PAGE_REPORTING */ > #define page_reported(_page) false With us making the function call per page freed we are likely to have a much more significant impact on performance with page reporting enabled. Ideally we want to limit this impact so that we only take the cost for the conditional check on the lower order pages.