linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: wuqiang <wuqiang.matt@bytedance.com>
To: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
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 0/5] lib,kprobes: kretprobe scalability improvement
Date: Mon, 9 Oct 2023 02:33:09 +0800	[thread overview]
Message-ID: <30892865-c92e-433e-2dba-ec6004c3d0e2@bytedance.com> (raw)
In-Reply-To: <20230923175746.da3ab516a5c17c5d1897d6d6@kernel.org>

On 2023/9/23 16:57, Masami Hiramatsu (Google) wrote:
> Hi Wuqiang,
> 
> I dug my mail box and found this. Sorry for replying late.
> 
> On Tue,  5 Sep 2023 09:52:50 +0800
> "wuqiang.matt" <wuqiang.matt@bytedance.com> wrote:
> 
>> This patch series introduces a scalable and lockless ring-array based
>> object pool and replaces the original freelist (a LIFO queue based on
>> singly linked list) to improve scalability of kretprobed routines.
>>
>> v9:
>>    1) objpool: raw_local_irq_save/restore added to prevent interruption
>>
>>       To avoid possible ABA issues, we must ensure objpool_try_add_slot
>>       and objpool_try_add_slot are uninterruptible. If these operations
>>       are blocked or interrupted in the middle, other cores could overrun
>>       the same slot's ages[] of uint32, then after resuming back, the
>>       interrupted pop() or push() could see same value of ages[], which
>>       is a typical ABA problem though the possibility is small.
>>
>>       The pair of pop()/push() costs about 8.53 cpu cycles, measured
>>       by IACA (Intel Architecture Code Analyzer). That is, on a 4Ghz
>>       core dedicated for pop() & push(), theoretically it would only
>>       need 8.53 seconds to overflow a 32bit value. Testings upon Intel
>>       i7-10700 (2.90GHz) cost 71.88 seconds to overrun a 32bit integer.
> 
> What does this mean? This sounds like "There is a timing issue if it's enough fast".

Yes, that's why local irq must be disabled. If push()/pop() is interrupted or 
preempted long enough (> 10 seconds for the extreme cases), other nodes could
overrun the same ages[] of 32-bit, then after resuming to execution the push()
or pop() would see the same value without notifying the overrun, which is a
typical ABA.

Changing ages[] to 64-bit could be a solution, but it's inappropriate for
32-bit OS and looks too heavy. With local irg disabled, push() or pop() is
uninterrupted,thus the ABA is avoided.

push() or pop() consumes only ~4 cycles to complete (most of the use cases), 
so raw_local_irq_save/restore are used instead of local_irq_save/restore to
minimize the overhead.

> Let me reivew the patch itself.
> 
> Thanks,
> 
>>
>>    2) codes improvements: thanks to Masami for the thorough inspection
>>
>> v8:
>>    1) objpool: refcount added for objpool lifecycle management
>>
>> wuqiang.matt (5):
>>    lib: objpool added: ring-array based lockless MPMC
>>    lib: objpool test module added
>>    kprobes: kretprobe scalability improvement with objpool
>>    kprobes: freelist.h removed
>>    MAINTAINERS: objpool added
>>
>>   MAINTAINERS              |   7 +
>>   include/linux/freelist.h | 129 --------
>>   include/linux/kprobes.h  |  11 +-
>>   include/linux/objpool.h  | 174 ++++++++++
>>   include/linux/rethook.h  |  16 +-
>>   kernel/kprobes.c         |  93 +++---
>>   kernel/trace/fprobe.c    |  32 +-
>>   kernel/trace/rethook.c   |  90 +++--
>>   lib/Kconfig.debug        |  11 +
>>   lib/Makefile             |   4 +-
>>   lib/objpool.c            | 338 +++++++++++++++++++
>>   lib/test_objpool.c       | 689 +++++++++++++++++++++++++++++++++++++++
>>   12 files changed, 1320 insertions(+), 274 deletions(-)
>>   delete mode 100644 include/linux/freelist.h
>>   create mode 100644 include/linux/objpool.h
>>   create mode 100644 lib/objpool.c
>>   create mode 100644 lib/test_objpool.c
>>
>> -- 
>> 2.40.1
>>
> 
> 



  reply	other threads:[~2023-10-08 18:33 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
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 [this message]
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=30892865-c92e-433e-2dba-ec6004c3d0e2@bytedance.com \
    --to=wuqiang.matt@bytedance.com \
    --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=mhiramat@kernel.org \
    --cc=naveen.n.rao@linux.ibm.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=sander@svanheule.net \
    /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).