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=-4.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED 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 DF2A5C49ED8 for ; Tue, 10 Sep 2019 14:48:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B12DF2168B for ; Tue, 10 Sep 2019 14:48:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PzcNTtgF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732423AbfIJOsy (ORCPT ); Tue, 10 Sep 2019 10:48:54 -0400 Received: from mail-io1-f68.google.com ([209.85.166.68]:43872 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726132AbfIJOsy (ORCPT ); Tue, 10 Sep 2019 10:48:54 -0400 Received: by mail-io1-f68.google.com with SMTP id r8so13156316iol.10; Tue, 10 Sep 2019 07:48:53 -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=y51Wmq0LRgJPRQu0wESyACMKgIN3oGN4hPyCwS8B9Fw=; b=PzcNTtgFRZmzMv0K1KK0mg45o4Yljkgb90mn498QkmecMBhhZ5hVU/NDRq0XyRodXv oqt8Gfa8DdtOS8BNXSn78trtFzo/cG4x2Q3hTi0E8/87ACzQRuE0GaG6NPFNj2w7i5hz d9eH/XfpdFJ4ZsSIItHV5fPjLK39IDFhjDsIgyoeiWYb/OgukBbYhH7k63i7aX9m43JY B2q7D5PGC8y5aL/e8xurQByjUcIrfbOUk1u3uk1YXpi2aKIq2f9GOVhCzAD0nNiZ6KBc mxNmVjxT2XEjrQHY1egt7O+EREMCd1qYYvBFoCb6XuBlHZGCELCMyobbvgTykr1X77AJ JGUw== 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=y51Wmq0LRgJPRQu0wESyACMKgIN3oGN4hPyCwS8B9Fw=; b=jUjXbcwCx+FQJvXSp97hvAgMMT5MvCcmQR8TxZUPgWJkk5Ygpz0qpZJNhU3RP6xRv9 1ugbaLGR1Mnd5ZRQzgwSNTODWTsIPZ4WkQooqlvM2VKjKhCFnlnLhTl1YIIrcJzQCTRl JFBCaVf1n0bEURuCHgIyb9gGo2/ZhDpGOl2bU6dsVvhgz0E+EJIjF7SNdaf7QUgELmks fzmqRNW+jg14azlr8BKN7Lxh5JZQ5vqYedSyqB9/G7pQdNgw16MNR2f7gq1A7+ebjsFU QjmGfQEGdufyHH2IXHZKzG0EBwewGfnXVxqp1iCkdtuw6i/c/dfzEX/Q2SwGyvxoXmT7 aH6A== X-Gm-Message-State: APjAAAVwhWPDTStoyJZUXEmTAu1seJaMmiwTih5Ii94zwtC/veit2yyt NuvupbHSCU4HqJenLjPaSDFm8CxYGv+HHwJEBmY= X-Google-Smtp-Source: APXvYqwN74shiAyKliNs3JxV0dTTuWrOoxH7hX54E/H8prvfohDIALH6Vobq+JG8UlF+hibP/Y2WKvw7cp3R4NGGfXs= X-Received: by 2002:a5d:8908:: with SMTP id b8mr1353105ion.237.1568126932604; Tue, 10 Sep 2019 07:48:52 -0700 (PDT) MIME-Version: 1.0 References: <20190907172225.10910.34302.stgit@localhost.localdomain> <20190907172520.10910.83100.stgit@localhost.localdomain> <20190910122030.GV2063@dhcp22.suse.cz> In-Reply-To: <20190910122030.GV2063@dhcp22.suse.cz> From: Alexander Duyck Date: Tue, 10 Sep 2019 07:48:41 -0700 Message-ID: Subject: Re: [PATCH v9 2/8] mm: Adjust shuffle code to allow for future coalescing To: Michal Hocko Cc: virtio-dev@lists.oasis-open.org, kvm list , "Michael S. Tsirkin" , Catalin Marinas , David Hildenbrand , Dave Hansen , LKML , Matthew Wilcox , linux-mm , Andrew Morton , will@kernel.org, linux-arm-kernel@lists.infradead.org, Oscar Salvador , Yang Zhang , Pankaj Gupta , Konrad Rzeszutek Wilk , Nitesh Narayan Lal , Rik van Riel , lcapitulino@redhat.com, "Wang, Wei W" , Andrea Arcangeli , ying.huang@intel.com, Paolo Bonzini , Dan Williams , Fengguang Wu , Alexander Duyck , "Kirill A. Shutemov" Content-Type: text/plain; charset="UTF-8" Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Tue, Sep 10, 2019 at 5:20 AM Michal Hocko wrote: > > On Sat 07-09-19 10:25:20, Alexander Duyck wrote: > > From: Alexander Duyck > > > > Move the head/tail adding logic out of the shuffle code and into the > > __free_one_page function since ultimately that is where it is really > > needed anyway. By doing this we should be able to reduce the overhead > > and can consolidate all of the list addition bits in one spot. > > This changelog doesn't really explain why we want this. You are > reshuffling the code, allright, but why do we want to reshuffle? Is the > result readability a better code reuse or something else? Where > does the claimed reduced overhead coming from? > > From a quick look buddy_merge_likely looks nicer than the code splat > we have. Good. > > But then > > > Reviewed-by: Dan Williams > > Signed-off-by: Alexander Duyck > > [...] > > > - if (is_shuffle_order(order)) > > - add_to_free_area_random(page, &zone->free_area[order], > > - migratetype); > > + area = &zone->free_area[order]; > > + if (is_shuffle_order(order) ? shuffle_pick_tail() : > > + buddy_merge_likely(pfn, buddy_pfn, page, order)) > > Ouch this is just awful don't you think? Yeah. I am going to go with Kirill's suggestion and probably do something more along the lines of: bool to_tail; ... if (is_shuffle_order(order)) to_tail = shuffle_pick_tail(); else to_tail = buddy_merge_likely(pfn, buddy_pfn, page, order); if (to_tail) add_to_free_area_tail(page, area, migratetype); else add_to_free_area(page, area, migratetype);