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=-9.6 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,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 35584C4727C for ; Mon, 28 Sep 2020 20:38:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A4118208FE for ; Mon, 28 Sep 2020 20:38:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="tltR1aMU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A4118208FE 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 EF46A6B005D; Mon, 28 Sep 2020 16:38:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EA2DA6B006E; Mon, 28 Sep 2020 16:38:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DB94F6B0070; Mon, 28 Sep 2020 16:38:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0244.hostedemail.com [216.40.44.244]) by kanga.kvack.org (Postfix) with ESMTP id C54256B005D for ; Mon, 28 Sep 2020 16:38:47 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 85D35362A for ; Mon, 28 Sep 2020 20:38:47 +0000 (UTC) X-FDA: 77313633894.23.wave39_140d3c427184 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin23.hostedemail.com (Postfix) with ESMTP id 69AFA37606 for ; Mon, 28 Sep 2020 20:38:47 +0000 (UTC) X-HE-Tag: wave39_140d3c427184 X-Filterd-Recvd-Size: 7828 Received: from mail-il1-f194.google.com (mail-il1-f194.google.com [209.85.166.194]) by imf33.hostedemail.com (Postfix) with ESMTP for ; Mon, 28 Sep 2020 20:38:46 +0000 (UTC) Received: by mail-il1-f194.google.com with SMTP id m9so2643942ila.10 for ; Mon, 28 Sep 2020 13:38:46 -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=RnUzbIia0NAX7YNu6xY/oNMBx/xFLPCcfbG+81kQ5mc=; b=tltR1aMUodF5nkRM8cyDLmsi5fQHfl76MM63tnAbzplkLz2jke4mHz9iRqztBbf4Ql /e5kTXBINdPQATmHN0Z4FBWAQHIfEw4EXZZwvDs39YGN8a9VbK6MWAp9AICxG9CWb1ao JDCGZNqFhxL9QysVKyMsEk2CwMcGPGrmWKEwNvuGmQh0K9y7HV8YAm0RlTnmSiAZ6aaE nmR9Oy9AxXmKKqxqEQVU6DX8SoI32LkxfxQuUFZmhZQjqLGHNMbCUndxogM7/vRaij2t Mkei1km9STaHB548our4mbfW6rcj9zVY8AgBcW7+yRwpqxhbODOMlvLhSo4ZlGJM58l3 iu4g== 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=RnUzbIia0NAX7YNu6xY/oNMBx/xFLPCcfbG+81kQ5mc=; b=UQjH8/Y8dtIBglnlV0ijivOUpEarAlucxGjxiFVVeSuwt47G+8HCrlmobvpJ8FapDM HvXeqGL1DrfRT0YAnvRz/WYEJJ1X+XLHsP78A2RZWmzldsUaFL1l5AVo0itV2kIwfbVL kj1RGvSizzcbcfRJhXm6bg8GymeH4PXhImG6L+Jf0eHwGiMnJVjji8YtpGjkFm0JE2eF sqUWyOEKV/WXqvlJnpPxahTja3td+8gt5ML1g2kghgHu4/UXB42p0cc7kN/2H19nK9Jq zYztwH4p7g1UppPznYWZOXI08v9JA3JVw1/aaS5HN4vsliT9sh6YvaPE5eBy6ghMbGee NrLA== X-Gm-Message-State: AOAM5308jRq2mewvg9rHSClBeFYcY03KaQry4O7H93AOWCaHI+u7gIm0 JbpeTxW3zn/Of//twaRj26kIPXJGVwTm3rPS4Z8= X-Google-Smtp-Source: ABdhPJxjWOlMUtAx0Ie/fRo/uIuKgbTIfNY7SlCP+erH5Zk2azwfxXaEKbUxjnZFYoXuMDQaYHzKc8VClp8ne+ZnXf8= X-Received: by 2002:a92:9ec7:: with SMTP id s68mr150414ilk.143.1601325526429; Mon, 28 Sep 2020 13:38:46 -0700 (PDT) MIME-Version: 1.0 References: <20200928182110.7050-1-david@redhat.com> <20200928182110.7050-3-david@redhat.com> In-Reply-To: <20200928182110.7050-3-david@redhat.com> From: Pankaj Gupta Date: Mon, 28 Sep 2020 22:38:35 +0200 Message-ID: Subject: Re: [PATCH v1 2/5] mm/page_alloc: place pages to tail in __putback_isolated_page() To: David Hildenbrand Cc: LKML , Linux MM , linux-hyperv@vger.kernel.org, xen-devel@lists.xenproject.org, linux-acpi@vger.kernel.org, Andrew Morton , Alexander Duyck , Oscar Salvador , Mel Gorman , Michal Hocko , Dave Hansen , Vlastimil Babka , Wei Yang , Mike Rapoport , Scott Cheloha , Michael Ellerman 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: > __putback_isolated_page() already documents that pages will be placed to > the tail of the freelist - this is, however, not the case for > "order >= MAX_ORDER - 2" (see buddy_merge_likely()) - which should be > the case for all existing users. > > This change affects two users: > - free page reporting > - page isolation, when undoing the isolation (including memory onlining). > > This behavior is desireable for pages that haven't really been touched > lately, so exactly the two users that don't actually read/write page > content, but rather move untouched pages. > > The new behavior is especially desirable for memory onlining, where we > allow allocation of newly onlined pages via undo_isolate_page_range() > in online_pages(). Right now, we always place them to the head of the > free list, resulting in undesireable behavior: Assume we add > individual memory chunks via add_memory() and online them right away to > the NORMAL zone. We create a dependency chain of unmovable allocations > e.g., via the memmap. The memmap of the next chunk will be placed onto > previous chunks - if the last block cannot get offlined+removed, all > dependent ones cannot get offlined+removed. While this can already be > observed with individual DIMMs, it's more of an issue for virtio-mem > (and I suspect also ppc DLPAR). > > Document that this should only be used for optimizations, and no code > should realy on this for correction (if the order of freepage lists > ever changes). > > We won't care about page shuffling: memory onlining already properly > shuffles after onlining. free page reporting doesn't care about > physically contiguous ranges, and there are already cases where page > isolation will simply move (physically close) free pages to (currently) > the head of the freelists via move_freepages_block() instead of > shuffling. If this becomes ever relevant, we should shuffle the whole > zone when undoing isolation of larger ranges, and after > free_contig_range(). > > Reviewed-by: Alexander Duyck > Reviewed-by: Oscar Salvador > Cc: Andrew Morton > Cc: Alexander Duyck > Cc: Mel Gorman > Cc: Michal Hocko > Cc: Dave Hansen > Cc: Vlastimil Babka > Cc: Wei Yang > Cc: Oscar Salvador > Cc: Mike Rapoport > Cc: Scott Cheloha > Cc: Michael Ellerman > Signed-off-by: David Hildenbrand > --- > mm/page_alloc.c | 18 ++++++++++++++++-- > 1 file changed, 16 insertions(+), 2 deletions(-) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index daab90e960fe..9e3ed4a6f69a 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -89,6 +89,18 @@ typedef int __bitwise fop_t; > */ > #define FOP_SKIP_REPORT_NOTIFY ((__force fop_t)BIT(0)) > > +/* > + * Place the (possibly merged) page to the tail of the freelist. Will ignore > + * page shuffling (relevant code - e.g., memory onlining - is expected to > + * shuffle the whole zone). > + * > + * Note: No code should rely onto this flag for correctness - it's purely > + * to allow for optimizations when handing back either fresh pages > + * (memory onlining) or untouched pages (page isolation, free page > + * reporting). > + */ > +#define FOP_TO_TAIL ((__force fop_t)BIT(1)) > + > /* prevent >1 _updater_ of zone percpu pageset ->high and ->batch fields */ > static DEFINE_MUTEX(pcp_batch_high_lock); > #define MIN_PERCPU_PAGELIST_FRACTION (8) > @@ -1038,7 +1050,9 @@ static inline void __free_one_page(struct page *page, unsigned long pfn, > done_merging: > set_page_order(page, order); > > - if (is_shuffle_order(order)) > + if (fop_flags & FOP_TO_TAIL) > + to_tail = true; > + else if (is_shuffle_order(order)) > to_tail = shuffle_pick_tail(); > else > to_tail = buddy_merge_likely(pfn, buddy_pfn, page, order); > @@ -3300,7 +3314,7 @@ void __putback_isolated_page(struct page *page, unsigned int order, int mt) > > /* Return isolated page to tail of freelist. */ > __free_one_page(page, page_to_pfn(page), zone, order, mt, > - FOP_SKIP_REPORT_NOTIFY); > + FOP_SKIP_REPORT_NOTIFY | FOP_TO_TAIL); > } Reviewed-by: Pankaj Gupta