linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bernd Schubert <bschubert@ddn.com>
To: Andrei Vagin <avagin@google.com>
Cc: "avagin@gmail.com" <avagin@gmail.com>,
	"brauner@kernel.org" <brauner@kernel.org>,
	"dietmar.eggemann@arm.com" <dietmar.eggemann@arm.com>,
	"juri.lelli@redhat.com" <juri.lelli@redhat.com>,
	"keescook@chromium.org" <keescook@chromium.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"luto@amacapital.net" <luto@amacapital.net>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"peterz@infradead.org" <peterz@infradead.org>,
	"posk@google.com" <posk@google.com>,
	"tycho@tycho.pizza" <tycho@tycho.pizza>,
	"vincent.guittot@linaro.org" <vincent.guittot@linaro.org>,
	"wad@chromium.org" <wad@chromium.org>,
	"yu.c.chen@intel.com" <yu.c.chen@intel.com>
Subject: Re: [PATCH 3/6] sched: add a few helpers to wake up tasks on the current cpu
Date: Wed, 26 Apr 2023 20:57:37 +0000	[thread overview]
Message-ID: <e7184ce2-06f6-5f45-1044-f0a8e8ad44c7@ddn.com> (raw)
In-Reply-To: <1e5cb834-2769-abc6-12bb-6184cfdd3536@ddn.com>

On 4/26/23 21:35, Bernd Schubert wrote:
> On 4/26/23 20:52, Andrei Vagin wrote:
>> On Wed, Apr 26, 2023 at 7:43 AM Bernd Schubert <bschubert@ddn.com> wrote:
>>>
>>>> Add complete_on_current_cpu, wake_up_poll_on_current_cpu helpers to 
>>>> wake
>>>> up tasks on the current CPU.
>>>
>>>> These two helpers are useful when the task needs to make a 
>>>> synchronous context
>>>> switch to another task. In this context, synchronous means it wakes 
>>>> up the
>>>> target task and falls asleep right after that.
>>>
>>>> One example of such workloads is seccomp user notifies. This 
>>>> mechanism allows
>>>> the  supervisor process handles system calls on behalf of a target 
>>>> process.
>>>> While the supervisor is handling an intercepted system call, the 
>>>> target process
>>>> will be blocked in the kernel, waiting for a response to come back.
>>>
>>>> On-CPU context switches are much faster than regular ones.
>>>
>>>> Signed-off-by: Andrei Vagin <avagin@google.com>
>>>
>>> Avoiding cpu switches is very desirable for fuse, I'm working on fuse 
>>> over uring
>>> with per core queues. In my current branch and running a single 
>>> threaded bonnie++
>>> I get about 9000 creates/s when I bind the process to a core, about 
>>> 7000 creates/s
>>> when I set SCHED_IDLE for the ring threads and back to 9000 with 
>>> SCHED_IDLE and
>>> disabling cpu migration in fs/fuse/dev.c request_wait_answer() before 
>>> going into
>>> the waitq and enabling it back after waking up.
>>>
>>> I had reported this a few weeks back
>>> https://lore.kernel.org/lkml/d0ed1dbd-1b7e-bf98-65c0-7f61dd1a3228@ddn.com/
>>> and had been pointed to your and Prateeks patch series. I'm now going
>>> through these series. Interesting part is that a few weeks I didn't need
>>> SCHED_IDLE, just disabling/enabling migration before/after waking up was
>>> enough.
>>>
>>> [...]
>>>
>>>> EXPORT_SYMBOL(swake_up_one);
>>>> diff --git a/kernel/sched/wait.c b/kernel/sched/wait.c
>>>> index 133b74730738..47803a0b8d5d 100644
>>>> --- a/kernel/sched/wait.c
>>>> +++ b/kernel/sched/wait.c
>>>> @@ -161,6 +161,11 @@ int __wake_up(struct wait_queue_head *wq_head, 
>>>> unsigned int mode,
>>>>   }
>>>>   EXPORT_SYMBOL(__wake_up);
>>>
>>>> +void __wake_up_on_current_cpu(struct wait_queue_head *wq_head, 
>>>> unsigned int mode, void *key)
>>>> +{
>>>> +     __wake_up_common_lock(wq_head, mode, 1, WF_CURRENT_CPU, key);
>>>> +}
>>>
>>> I'm about to test this instead of migrate_disable/migrate_enable, but 
>>> the symbol needs
>>> to be exported - any objection to do that right from the beginning in 
>>> your patch?
>>
>> I think EXPORT_SYMBOL_GPL should not trigger any objections and it
>> covers your case, doesn't it?
> 
> Ah yes, sure, _GPL is fine. I have applied 2/6 and 3/6 in my branch and 
> then have
> 
> wait.h
> #define wake_up_interruptible_sync(x)    __wake_up_sync((x), 
> TASK_INTERRUPTIBLE)

Sorry, no, that was the part that is actually not working, I'm actually 
using __wake_up_on_current_cpu(&req->waitq, TASK_NORMAL, NULL) in 
fuse_request_end().

> 
> and and using that in fuse_request_end() - works fine and no migration 
> on wake up.
> Though, I still need SCHED_IDLE for the uring thread to avoid a later 
> migration,
> will open a separate thread for that.
> 
> 
> Thanks,
> Bernd
> 
> 


  reply	other threads:[~2023-04-26 20:57 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-08  7:31 [PATCH 0/6 v5 RESEND] seccomp: add the synchronous mode for seccomp_unotify Andrei Vagin
2023-03-08  7:31 ` [PATCH 1/6] seccomp: don't use semaphore and wait_queue together Andrei Vagin
2023-03-08  7:31 ` [PATCH 2/6] sched: add WF_CURRENT_CPU and externise ttwu Andrei Vagin
2023-04-08  3:20   ` Chen Yu
2023-04-10  4:56     ` Andrei Vagin
2023-04-10 17:27       ` Andy Lutomirski
2023-04-12 19:38         ` Andrei Vagin
2023-04-10 18:16       ` Chen Yu
2023-04-11  1:50         ` Chen Yu
2023-04-17 19:24         ` Andrei Vagin
2023-03-08  7:31 ` [PATCH 3/6] sched: add a few helpers to wake up tasks on the current cpu Andrei Vagin
2023-04-26 14:43   ` Bernd Schubert
2023-04-26 18:52   ` Andrei Vagin
2023-04-26 19:35     ` Bernd Schubert
2023-04-26 20:57       ` Bernd Schubert [this message]
2023-03-08  7:31 ` [PATCH 4/6] seccomp: add the synchronous mode for seccomp_unotify Andrei Vagin
2023-04-06  3:42   ` Andy Lutomirski
2023-04-10  6:59     ` Andrei Vagin
2023-04-10 20:53       ` Andy Lutomirski
2023-03-08  7:32 ` [PATCH 5/6] selftest/seccomp: add a new test for the sync mode of seccomp_user_notify Andrei Vagin
2023-03-08  7:32 ` [PATCH 6/6] perf/benchmark: add a new benchmark for seccom_unotify Andrei Vagin
2023-09-08 17:35   ` [PATCH] perf/benchmark: Fix ifdef in header file uapi/asm/unistd_32.h Vijayendra Suman
2023-09-08 17:38     ` Andrei Vagin
2023-09-08 18:18     ` Tycho Andersen
2023-10-17  8:24   ` [PATCH 6/6] perf/benchmark: add a new benchmark for seccom_unotify Jiri Slaby
2023-03-21 18:19 ` [PATCH 0/6 v5 RESEND] seccomp: add the synchronous mode for seccomp_unotify Andrei Vagin
2023-03-27 10:27 ` Peter Zijlstra
2023-04-03 18:32   ` Andrei Vagin
2023-04-06  3:19     ` Kees Cook
2023-06-28 18:44       ` Andrei Vagin
2023-06-28 23:32         ` Kees Cook
  -- strict thread matches above, loose matches on Subject: below --
2023-02-02  3:04 [PATCH 0/6 v5] " Andrei Vagin
2023-02-02  3:04 ` [PATCH 3/6] sched: add a few helpers to wake up tasks on the current cpu Andrei Vagin
2023-02-15 20:15   ` Andrei Vagin
2023-01-24 23:41 [PATCH 0/6 v4] seccomp: add the synchronous mode for seccomp_unotify Andrei Vagin
2023-01-24 23:41 ` [PATCH 3/6] sched: add a few helpers to wake up tasks on the current cpu Andrei Vagin

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=e7184ce2-06f6-5f45-1044-f0a8e8ad44c7@ddn.com \
    --to=bschubert@ddn.com \
    --cc=avagin@gmail.com \
    --cc=avagin@google.com \
    --cc=brauner@kernel.org \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=posk@google.com \
    --cc=tycho@tycho.pizza \
    --cc=vincent.guittot@linaro.org \
    --cc=wad@chromium.org \
    --cc=yu.c.chen@intel.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).