From: Dan Williams <dan.j.williams@intel.com>
To: Alexander Duyck <alexander.duyck@gmail.com>
Cc: nitesh@redhat.com, KVM list <kvm@vger.kernel.org>,
"Michael S. Tsirkin" <mst@redhat.com>,
David Hildenbrand <david@redhat.com>,
Dave Hansen <dave.hansen@intel.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Matthew Wilcox <willy@infradead.org>,
Michal Hocko <mhocko@kernel.org>, Linux MM <linux-mm@kvack.org>,
Andrew Morton <akpm@linux-foundation.org>,
virtio-dev@lists.oasis-open.org,
Oscar Salvador <osalvador@suse.de>,
yang.zhang.wz@gmail.com, Pankaj Gupta <pagupta@redhat.com>,
Rik van Riel <riel@surriel.com>,
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
lcapitulino@redhat.com, "Wang, Wei W" <wei.w.wang@intel.com>,
Andrea Arcangeli <aarcange@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Alexander Duyck <alexander.h.duyck@linux.intel.com>
Subject: Re: [PATCH v5 1/6] mm: Adjust shuffle code to allow for future coalescing
Date: Mon, 12 Aug 2019 15:24:09 -0700 [thread overview]
Message-ID: <CAPcyv4jEvPL3qQffDsJxKxkCJLo19FN=gd4+LtZ1FnARCr5wBw@mail.gmail.com> (raw)
In-Reply-To: <20190812213324.22097.30886.stgit@localhost.localdomain>
On Mon, Aug 12, 2019 at 2:33 PM Alexander Duyck
<alexander.duyck@gmail.com> wrote:
>
> From: Alexander Duyck <alexander.h.duyck@linux.intel.com>
>
> This patch is meant to move the head/tail adding logic out of the shuffle
s/This patch is meant to move/Move/
> 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
Is the overhead benefit observable? I would expect the overhead of
get_random_u64() dominates.
> and can consolidate all of the list addition bits in one spot.
This sounds the better argument.
[..]
> diff --git a/mm/shuffle.h b/mm/shuffle.h
> index 777a257a0d2f..add763cc0995 100644
> --- a/mm/shuffle.h
> +++ b/mm/shuffle.h
> @@ -3,6 +3,7 @@
> #ifndef _MM_SHUFFLE_H
> #define _MM_SHUFFLE_H
> #include <linux/jump_label.h>
> +#include <linux/random.h>
>
> /*
> * SHUFFLE_ENABLE is called from the command line enabling path, or by
> @@ -43,6 +44,32 @@ static inline bool is_shuffle_order(int order)
> return false;
> return order >= SHUFFLE_ORDER;
> }
> +
> +static inline bool shuffle_add_to_tail(void)
> +{
> + static u64 rand;
> + static u8 rand_bits;
> + u64 rand_old;
> +
> + /*
> + * The lack of locking is deliberate. If 2 threads race to
> + * update the rand state it just adds to the entropy.
> + */
> + if (rand_bits-- == 0) {
> + rand_bits = 64;
> + rand = get_random_u64();
> + }
> +
> + /*
> + * Test highest order bit while shifting our random value. This
> + * should result in us testing for the carry flag following the
> + * shift.
> + */
> + rand_old = rand;
> + rand <<= 1;
> +
> + return rand < rand_old;
> +}
This function seems too involved to be a static inline and I believe
each compilation unit that might call this routine gets it's own copy
of 'rand' and 'rand_bits' when the original expectation is that they
are global. How about leave this bit to mm/shuffle.c and rename it
coin_flip(), or something more generic, since it does not
'add_to_tail'? The 'add_to_tail' action is something the caller
decides.
next prev parent reply other threads:[~2019-08-12 22:24 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-12 21:33 [PATCH v5 0/6] mm / virtio: Provide support for unused page reporting Alexander Duyck
2019-08-12 21:33 ` [PATCH v5 1/6] mm: Adjust shuffle code to allow for future coalescing Alexander Duyck
2019-08-12 22:24 ` Dan Williams [this message]
2019-08-12 22:49 ` Alexander Duyck
2019-08-12 21:33 ` [PATCH v5 2/6] mm: Move set/get_pcppage_migratetype to mmzone.h Alexander Duyck
2019-08-12 21:33 ` [PATCH v5 3/6] mm: Use zone and order instead of free area in free_list manipulators Alexander Duyck
2019-08-12 22:39 ` Dan Williams
2019-08-12 21:33 ` [PATCH v5 4/6] mm: Introduce Reported pages Alexander Duyck
2019-08-13 8:07 ` David Hildenbrand
2019-08-13 17:35 ` Alexander Duyck
2019-08-14 12:57 ` David Hildenbrand
2019-08-13 8:34 ` kbuild test robot
2019-08-13 8:39 ` kbuild test robot
2019-08-12 21:33 ` [PATCH v5 5/6] virtio-balloon: Pull page poisoning config out of free page hinting Alexander Duyck
2019-08-12 21:33 ` [PATCH v5 6/6] virtio-balloon: Add support for providing unused page reports to host Alexander Duyck
2019-09-03 7:32 ` Michael S. Tsirkin
2019-09-03 14:13 ` Alexander Duyck
2019-09-04 10:44 ` Michael S. Tsirkin
2019-09-04 14:23 ` Alexander Duyck
2019-08-12 21:34 ` [PATCH v5 QEMU 1/3] virtio-ballon: Implement support for page poison tracking feature Alexander Duyck
2019-08-12 21:34 ` [PATCH v5 QEMU 2/3] virtio-balloon: Add bit to notify guest of unused page reporting Alexander Duyck
2019-08-12 21:34 ` [PATCH v5 QEMU 3/3] virtio-balloon: Provide a interface for " Alexander Duyck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAPcyv4jEvPL3qQffDsJxKxkCJLo19FN=gd4+LtZ1FnARCr5wBw@mail.gmail.com' \
--to=dan.j.williams@intel.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=alexander.duyck@gmail.com \
--cc=alexander.h.duyck@linux.intel.com \
--cc=dave.hansen@intel.com \
--cc=david@redhat.com \
--cc=konrad.wilk@oracle.com \
--cc=kvm@vger.kernel.org \
--cc=lcapitulino@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=mst@redhat.com \
--cc=nitesh@redhat.com \
--cc=osalvador@suse.de \
--cc=pagupta@redhat.com \
--cc=pbonzini@redhat.com \
--cc=riel@surriel.com \
--cc=virtio-dev@lists.oasis-open.org \
--cc=wei.w.wang@intel.com \
--cc=willy@infradead.org \
--cc=yang.zhang.wz@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).