linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: "wuqiang.matt" <wuqiang.matt@bytedance.com>
Cc: linux-trace-kernel@vger.kernel.org, davem@davemloft.net,
	anil.s.keshavamurthy@intel.com, naveen.n.rao@linux.ibm.com,
	rostedt@goodmis.org, peterz@infradead.org,
	akpm@linux-foundation.org, sander@svanheule.net,
	ebiggers@google.com, dan.j.williams@intel.com,
	jpoimboe@kernel.org, linux-kernel@vger.kernel.org, lkp@intel.com,
	mattwu@163.com
Subject: Re: [PATCH v9 1/5] lib: objpool added: ring-array based lockless MPMC
Date: Sun, 24 Sep 2023 23:21:45 +0900	[thread overview]
Message-ID: <20230924232145.05efde741742e24f3f4fd032@kernel.org> (raw)
In-Reply-To: <20230905015255.81545-2-wuqiang.matt@bytedance.com>

Hi,

On Tue,  5 Sep 2023 09:52:51 +0800
"wuqiang.matt" <wuqiang.matt@bytedance.com> wrote:

> +/* cleanup all percpu slots of the object pool */
> +static void objpool_fini_percpu_slots(struct objpool_head *head)
> +{
> +	int i;
> +
> +	if (!head->cpu_slots)
> +		return;
> +
> +	for (i = 0; i < head->nr_cpus; i++) {
> +		if (!head->cpu_slots[i])
> +			continue;
> +		if (head->flags & OBJPOOL_FROM_VMALLOC)
> +			vfree(head->cpu_slots[i]);
> +		else
> +			kfree(head->cpu_slots[i]);

You can use kvfree() for both kmalloc object and vmalloc object.

> +	}
> +	kfree(head->cpu_slots);
> +	head->cpu_slots = NULL;
> +	head->slot_sizes = NULL;
> +}

...

> +/* drop the allocated object, rather reclaim it to objpool */
> +int objpool_drop(void *obj, struct objpool_head *head)
> +{
> +	if (!obj || !head)
> +		return -EINVAL;
> +
> +	if (refcount_dec_and_test(&head->ref)) {
> +		objpool_free(head);
> +		return 0;
> +	}
> +
> +	return -EAGAIN;
> +}
> +EXPORT_SYMBOL_GPL(objpool_drop);

To make this work correctly, you need to disable the objpool (no more
pop the object from it) and ensure the objpool is disabled.
Also, when disabling the objpool, its refcount must be set to the "active"
number of objects.

Thank you,


-- 
Masami Hiramatsu (Google) <mhiramat@kernel.org>

  parent reply	other threads:[~2023-09-24 14:21 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-05  1:52 [PATCH v9 0/5] lib,kprobes: kretprobe scalability improvement wuqiang.matt
2023-09-05  1:52 ` [PATCH v9 1/5] lib: objpool added: ring-array based lockless MPMC wuqiang.matt
2023-09-23  9:48   ` Masami Hiramatsu
2023-10-08 18:40     ` wuqiang
2023-10-09 14:19       ` Masami Hiramatsu
2023-10-12 16:16         ` wuqiang.matt
2023-09-24 14:21   ` Masami Hiramatsu [this message]
2023-09-25  9:42   ` Masami Hiramatsu
2023-10-08 19:04     ` wuqiang
2023-10-09  9:23     ` wuqiang
2023-10-09 13:51       ` Masami Hiramatsu
2023-10-12 14:02       ` Masami Hiramatsu
2023-10-12 17:36         ` wuqiang.matt
2023-10-13  1:59           ` Masami Hiramatsu
2023-10-13  3:03             ` wuqiang.matt
2023-09-05  1:52 ` [PATCH v9 2/5] lib: objpool test module added wuqiang.matt
2023-09-05  1:52 ` [PATCH v9 3/5] kprobes: kretprobe scalability improvement with objpool wuqiang.matt
2023-10-07  2:02   ` Masami Hiramatsu
2023-10-08 18:31     ` wuqiang
2023-10-08 23:20       ` Masami Hiramatsu
2023-09-05  1:52 ` [PATCH v9 4/5] kprobes: freelist.h removed wuqiang.matt
2023-09-05  1:52 ` [PATCH v9 5/5] MAINTAINERS: objpool added wuqiang.matt
2023-09-23  8:57 ` [PATCH v9 0/5] lib,kprobes: kretprobe scalability improvement Masami Hiramatsu
2023-10-08 18:33   ` wuqiang
2023-10-08 23:17     ` Masami Hiramatsu

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=20230924232145.05efde741742e24f3f4fd032@kernel.org \
    --to=mhiramat@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=anil.s.keshavamurthy@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=davem@davemloft.net \
    --cc=ebiggers@google.com \
    --cc=jpoimboe@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=mattwu@163.com \
    --cc=naveen.n.rao@linux.ibm.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=sander@svanheule.net \
    --cc=wuqiang.matt@bytedance.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).