linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "wang wei" <a929244872@163.com>
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,
	 "Alexander Duyck" <alexander.duyck@gmail.com>,
	 "Andrew Morton" <akpm@linux-foundation.org>,
	linux-mm@kvack.org
Subject: Re:[PATCH net-next v7 01/15] mm: page_frag: add a test module for page_frag
Date: Tue, 18 Jun 2024 22:45:58 +0800 (CST)	[thread overview]
Message-ID: <45a90c2.baa1.1902bcfd33a.Coremail.a929244872@163.com> (raw)
In-Reply-To: <20240607123819.40694-2-linyunsheng@huawei.com>

[-- Attachment #1: Type: text/plain, Size: 2322 bytes --]




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

>+module_param(nr_test, int, 0600);




"S_IRUSR | S_IWUSR" is better than "0600".





>+MODULE_PARM_DESC(nr_test, "number of iterations to test");
>+
>+static bool test_align;
>+module_param(test_align, bool, 0600);
>+MODULE_PARM_DESC(test_align, "use align API for testing");
>+
>+static int test_alloc_len = 2048;
>+module_param(test_alloc_len, int, 0600);
>+MODULE_PARM_DESC(test_alloc_len, "alloc len for testing");
>+
>+static int test_push_cpu;
>+module_param(test_push_cpu, int, 0600);
>+MODULE_PARM_DESC(test_push_cpu, "test cpu for pushing fragment");
>+
>+static int test_pop_cpu;
>+module_param(test_pop_cpu, int, 0600);
>+MODULE_PARM_DESC(test_pop_cpu, "test cpu for popping fragment");
>+
>+static int page_frag_pop_thread(void *arg)
>+{
>+	struct objpool_head *pool = arg;
>+	int nr = nr_test;
>+
>+	pr_info("page_frag pop test thread begins on cpu %d\n",
>+		smp_processor_id());
>+
>+	while (nr > 0) {
>+		void *obj = objpool_pop(pool);
>+
>+		if (obj) {
>+			nr--;
>+			page_frag_free(obj);
>+		} else {
>+			cond_resched();
>+		}
>+	}
>+
>+	if (atomic_dec_and_test(&nthreads))
>+		complete(&wait);
>+
>+	pr_info("page_frag pop test thread exits on cpu %d\n",
>+		smp_processor_id());
>+
>+	return 0;
>+}
>+
>+static int page_frag_push_thread(void *arg)
>+{
>+	struct objpool_head *pool = arg;
>+	int nr = nr_test;
>+
>+	pr_info("page_frag push test thread begins on cpu %d\n",
>+		smp_processor_id());
>+
>+	while (nr > 0) {
>+		void *va;
>+		int ret;
>+
>+		if (test_align)
>+			va = page_frag_alloc_align(&test_frag, test_alloc_len,

>+						   GFP_KERNEL, SMP_CACHE_BYTES);




Every page fragment max size is PAGE_FRAG_CACHE_MAX_SIZE,
hence the value of test_alloc_len needs to be checked.




>+ else >+ va = page_frag_alloc(&test_frag, test_alloc_len, GFP_KERNEL); >+ >+ if (!va) >+ continue; >+ >+ ret = objpool_push(va, pool); >+ if (ret) { >+ page_frag_free(va); >+ cond_resched(); >+ } else { >+ nr--; >+ } >+ } >+ >+ pr_info("page_frag push test thread exits on cpu %d\n", >+ smp_processor_id()); >+ >+ if (atomic_dec_and_test(&nthreads)) >+ complete(&wait); >+ >+ return 0; >+}

[-- Attachment #2: Type: text/html, Size: 2947 bytes --]

  reply	other threads:[~2024-06-18 15:10 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20240607123819.40694-1-linyunsheng@huawei.com>
2024-06-07 12:38 ` [PATCH " Yunsheng Lin
2024-06-18 14:45   ` wang wei [this message]
2024-06-19 12:57     ` Yunsheng Lin
2024-06-07 12:38 ` [PATCH net-next v7 04/15] mm: move the page fragment allocator from page_alloc into its own file Yunsheng Lin
2024-06-07 12:38 ` [PATCH net-next v7 05/15] mm: page_frag: use initial zero offset for page_frag_alloc_align() Yunsheng Lin
2024-06-07 12:38 ` [PATCH net-next v7 06/15] mm: page_frag: add '_va' suffix to page_frag API Yunsheng Lin
2024-06-07 12:38 ` [PATCH net-next v7 07/15] mm: page_frag: avoid caller accessing 'page_frag_cache' directly Yunsheng Lin
2024-06-07 12:38 ` [PATCH net-next v7 08/15] mm: page_frag: reuse existing space for 'size' and 'pfmemalloc' Yunsheng Lin
2024-06-07 12:38 ` [PATCH net-next v7 09/15] mm: page_frag: some minor refactoring before adding new API Yunsheng Lin
2024-06-07 12:38 ` [PATCH net-next v7 10/15] mm: page_frag: use __alloc_pages() to replace alloc_pages_node() Yunsheng Lin
2024-06-07 12:38 ` [PATCH net-next v7 12/15] mm: page_frag: introduce prepare/probe/commit API Yunsheng Lin
2024-06-07 12:38 ` [PATCH net-next v7 14/15] mm: page_frag: update documentation for page_frag Yunsheng Lin

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=45a90c2.baa1.1902bcfd33a.Coremail.a929244872@163.com \
    --to=a929244872@163.com \
    --cc=akpm@linux-foundation.org \
    --cc=alexander.duyck@gmail.com \
    --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