All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Wen Yang <wenyang.linux@foxmail.com>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Christian Brauner <brauner@kernel.org>
Cc: Christoph Hellwig <hch@lst.de>, Dylan Yudaken <dylany@fb.com>,
	David Woodhouse <dwmw@amazon.co.uk>,
	Paolo Bonzini <pbonzini@redhat.com>, Fu Wei <wefu@redhat.com>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] eventfd: support delayed wakeup for non-semaphore eventfd to reduce cpu utilization
Date: Tue, 18 Apr 2023 20:15:03 -0600	[thread overview]
Message-ID: <7dded5a8-32c1-e994-52a0-ce32011d5e6b@kernel.dk> (raw)
In-Reply-To: <tencent_9D8583482619D25B9953FCA89E69AA92A909@qq.com>

On 4/17/23 10:32?AM, Wen Yang wrote:
> 
> ? 2023/4/17 22:38, Jens Axboe ??:
>> On 4/16/23 5:31?AM, wenyang.linux@foxmail.com wrote:
>>> From: Wen Yang <wenyang.linux@foxmail.com>
>>>
>>> For the NON SEMAPHORE eventfd, if it's counter has a nonzero value,
>>> then a read(2) returns 8 bytes containing that value, and the counter's
>>> value is reset to zero. Therefore, in the NON SEMAPHORE scenario,
>>> N event_writes vs ONE event_read is possible.
>>>
>>> However, the current implementation wakes up the read thread immediately
>>> in eventfd_write so that the cpu utilization increases unnecessarily.
>>>
>>> By adding a configurable delay after eventfd_write, these unnecessary
>>> wakeup operations are avoided, thereby reducing cpu utilization.
>> What's the real world use case of this, and what would the expected
>> delay be there? With using a delayed work item for this, there's
>> certainly a pretty wide grey zone in terms of delay where this would
>> perform considerably worse than not doing any delayed wakeups at all.
> 
> 
> Thanks for your comments.
> 
> We have found that the CPU usage of the message middleware is high in
> our environment, because sensor messages from MCU are very frequent
> and constantly reported, possibly several hundred thousand times per
> second. As a result, the message receiving thread is frequently
> awakened to process short messages.
> 
> The following is the simplified test code:
> https://github.com/w-simon/tests/blob/master/src/test.c
> 
> And the test code in this patch is further simplified.
> 
> Finally, only a configuration item has been added here, allowing users
> to make more choices.

I think you'd have a higher chance of getting this in if the delay
setting was per eventfd context, rather than a global thing.

-- 
Jens Axboe


  reply	other threads:[~2023-04-19  2:15 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-16 11:31 [PATCH] eventfd: support delayed wakeup for non-semaphore eventfd to reduce cpu utilization wenyang.linux
2023-04-17  8:22 ` Bagas Sanjaya
2023-04-17 12:44 ` kernel test robot
2023-04-17 14:38 ` Jens Axboe
2023-04-17 16:32   ` Wen Yang
2023-04-19  2:15     ` Jens Axboe [this message]
2023-04-19  9:12       ` Christian Brauner
2023-04-19 15:23         ` Wen Yang
2023-04-19 16:42         ` Jens Axboe
2023-04-20 17:44           ` Wen Yang
2023-05-04 16:01             ` Wen Yang
     [not found] <20230417000711.1100-1-hdanton@sina.com>
2023-04-18 14:12 ` Wen Yang

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=7dded5a8-32c1-e994-52a0-ce32011d5e6b@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=brauner@kernel.org \
    --cc=dwmw@amazon.co.uk \
    --cc=dylany@fb.com \
    --cc=hch@lst.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=viro@zeniv.linux.org.uk \
    --cc=wefu@redhat.com \
    --cc=wenyang.linux@foxmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.