linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Yunsheng Lin <linyunsheng@huawei.com>
Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org
Subject: Re: [PATCH net-next v1 11/12] mm: page_frag: add a test module for page_frag
Date: Fri, 12 Apr 2024 14:50:23 +0100	[thread overview]
Message-ID: <20240412135023.GS514426@kernel.org> (raw)
In-Reply-To: <20240407130850.19625-12-linyunsheng@huawei.com>

On Sun, Apr 07, 2024 at 09:08:48PM +0800, Yunsheng Lin wrote:
> Basing on the lib/objpool.c, change it to something like a
> ptrpool, so that we can utilize that to test the correctness
> and performance of the page_frag.
> 
> The testing is done by ensuring that the fragments allocated
> from a frag_frag_cache instance is pushed into a ptrpool
> instance in a kthread binded to the first cpu, and a kthread
> binded to the current node will pop the fragmemt from the
> ptrpool and call page_frag_alloc_va() to free the fragmemt.
> 
> We may refactor out the common part between objpool and ptrpool
> if this ptrpool thing turns out to be helpful for other place.
> 
> Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>

...

> diff --git a/mm/page_frag_test.c b/mm/page_frag_test.c

...

> +/* allocate and initialize percpu slots */
> +static int objpool_init_percpu_slots(struct objpool_head *pool,
> +				     int nr_objs, gfp_t gfp)
> +{
> +	int i;
> +
> +	for (i = 0; i < pool->nr_cpus; i++) {
> +		struct objpool_slot *slot;
> +		int size;
> +
> +		/* skip the cpu node which could never be present */
> +		if (!cpu_possible(i))
> +			continue;
> +
> +		size = struct_size(slot, entries, pool->capacity);
> +
> +		/*
> +		 * here we allocate percpu-slot & objs together in a single
> +		 * allocation to make it more compact, taking advantage of
> +		 * warm caches and TLB hits. in default vmalloc is used to
> +		 * reduce the pressure of kernel slab system. as we know,
> +		 * mimimal size of vmalloc is one page since vmalloc would

nit: minimal

> +		 * always align the requested size to page size
> +		 */
> +		if (gfp & GFP_ATOMIC)
> +			slot = kmalloc_node(size, gfp, cpu_to_node(i));
> +		else
> +			slot = __vmalloc_node(size, sizeof(void *), gfp,
> +					      cpu_to_node(i),
> +					      __builtin_return_address(0));
> +		if (!slot)
> +			return -ENOMEM;
> +
> +		memset(slot, 0, size);
> +		pool->cpu_slots[i] = slot;
> +
> +		objpool_init_percpu_slot(pool, slot);
> +	}
> +
> +	return 0;
> +}

...

> +static struct objpool_head ptr_pool;
> +static int nr_objs = 512;
> +static int nr_test = 5120000;
> +static atomic_t nthreads;
> +static struct completion wait;
> +struct page_frag_cache test_frag;

nit: Is test_frag used outside of this file?
     If not, should it be static?

...


  reply	other threads:[~2024-04-12 13:52 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20240407130850.19625-1-linyunsheng@huawei.com>
2024-04-07 13:08 ` [PATCH net-next v1 01/12] mm: Move the page fragment allocator from page_alloc into its own file Yunsheng Lin
2024-04-07 17:42   ` Alexander H Duyck
2024-04-08 13:38     ` Yunsheng Lin
2024-04-07 13:08 ` [PATCH net-next v1 02/12] mm: page_frag: use initial zero offset for page_frag_alloc_align() Yunsheng Lin
2024-04-07 17:52   ` Alexander H Duyck
2024-04-08 13:39     ` Yunsheng Lin
2024-04-08 16:11       ` Alexander Duyck
2024-04-09  7:59         ` Yunsheng Lin
2024-04-07 13:08 ` [PATCH net-next v1 03/12] mm: page_frag: change page_frag_alloc_* API to accept align param Yunsheng Lin
2024-04-07 13:08 ` [PATCH net-next v1 04/12] mm: page_frag: add '_va' suffix to page_frag API Yunsheng Lin
2024-04-07 13:08 ` [PATCH net-next v1 05/12] mm: page_frag: add two inline helper for " Yunsheng Lin
2024-04-07 13:08 ` [PATCH net-next v1 06/12] mm: page_frag: reuse MSB of 'size' field for pfmemalloc Yunsheng Lin
2024-04-07 13:08 ` [PATCH net-next v1 07/12] mm: page_frag: reuse existing bit field of 'va' for pagecnt_bias Yunsheng Lin
2024-04-07 13:08 ` [PATCH net-next v1 09/12] mm: page_frag: introduce prepare/commit API for page_frag Yunsheng Lin
2024-04-07 13:08 ` [PATCH net-next v1 11/12] mm: page_frag: add a test module " Yunsheng Lin
2024-04-12 13:50   ` Simon Horman [this message]
2024-04-07 13:08 ` [PATCH net-next v1 12/12] mm: page_frag: update documentation and maintainer " Yunsheng Lin
2024-04-07 18:13   ` Alexander H Duyck
2024-04-08 13:39     ` Yunsheng Lin
2024-04-08 16:13       ` Alexander Duyck
2024-04-09  7:59         ` Yunsheng Lin
2024-04-09 13:25           ` Jakub Kicinski
2024-04-09 15:11             ` Alexander Duyck
2024-04-10 11:56               ` Yunsheng Lin
     [not found]               ` <6517b5ae-e302-4cbe-8a4c-716e604822ce@redhat.com>
2024-04-10 18:19                 ` 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=20240412135023.GS514426@kernel.org \
    --to=horms@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linyunsheng@huawei.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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