lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e7184ce2-06f6-5f45-1044-f0a8e8ad44c7@ddn.com>
Date:   Wed, 26 Apr 2023 20:57:37 +0000
From:   Bernd Schubert <bschubert@....com>
To:     Andrei Vagin <avagin@...gle.com>
CC:     "avagin@...il.com" <avagin@...il.com>,
        "brauner@...nel.org" <brauner@...nel.org>,
        "dietmar.eggemann@....com" <dietmar.eggemann@....com>,
        "juri.lelli@...hat.com" <juri.lelli@...hat.com>,
        "keescook@...omium.org" <keescook@...omium.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "luto@...capital.net" <luto@...capital.net>,
        "mingo@...hat.com" <mingo@...hat.com>,
        "peterz@...radead.org" <peterz@...radead.org>,
        "posk@...gle.com" <posk@...gle.com>,
        "tycho@...ho.pizza" <tycho@...ho.pizza>,
        "vincent.guittot@...aro.org" <vincent.guittot@...aro.org>,
        "wad@...omium.org" <wad@...omium.org>,
        "yu.c.chen@...el.com" <yu.c.chen@...el.com>
Subject: Re: [PATCH 3/6] sched: add a few helpers to wake up tasks on the
 current cpu

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@....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@...gle.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
> 
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ