virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Jason Wang <jasowang@redhat.com>
Cc: axboe@kernel.dk, brauner@kernel.org, mst@redhat.com,
	linux@leemhuis.info, linux-kernel@vger.kernel.org,
	ebiederm@xmission.com, stefanha@redhat.com,
	nicolas.dichtel@6wind.com,
	virtualization@lists.linux-foundation.org,
	torvalds@linux-foundation.org
Subject: Re: [PATCH 3/3] fork, vhost: Use CLONE_THREAD to fix freezer/ps regression
Date: Fri, 2 Jun 2023 19:58:47 +0200	[thread overview]
Message-ID: <20230602175846.GC555@redhat.com> (raw)
In-Reply-To: <CACGkMEss2LkUiUKaEkhBWwFDBBz31T3N94a0=zSD1d+Fhb1zyQ@mail.gmail.com>

On 06/02, Jason Wang wrote:
>
> On Thu, Jun 1, 2023 at 3:43 PM Oleg Nesterov <oleg@redhat.com> wrote:
> >
> > and the final rewrite:
> >
> >         if (work->node) {
> >                 work_next = work->node->next;
> >                 if (true)
> >                         clear_bit(&work->flags);
> >         }
> >
> > so again, I do not see the load-store control dependency.
>
> This kind of optimization is suspicious. Especially considering it's
> the control expression of the loop but not a condition.

It is not about optimization,

> Looking at the assembly (x86):
>
>    0xffffffff81d46c5b <+75>:    callq  0xffffffff81689ac0 <llist_reverse_order>
>    0xffffffff81d46c60 <+80>:    mov    %rax,%r15
>    0xffffffff81d46c63 <+83>:    test   %rax,%rax
>    0xffffffff81d46c66 <+86>:    je     0xffffffff81d46c3a <vhost_worker+42>
>    0xffffffff81d46c68 <+88>:    mov    %r15,%rdi
>    0xffffffff81d46c6b <+91>:    mov    (%r15),%r15
>    0xffffffff81d46c6e <+94>:    lock andb $0xfd,0x10(%rdi)
>    0xffffffff81d46c73 <+99>:    movl   $0x0,0x18(%rbx)
>    0xffffffff81d46c7a <+106>:   mov    0x8(%rdi),%rax
>    0xffffffff81d46c7e <+110>:   callq  0xffffffff821b39a0
> <__x86_indirect_thunk_array>
>    0xffffffff81d46c83 <+115>:   callq  0xffffffff821b4d10 <__SCT__cond_resched>
> ...
>
> I can see:
>
> 1) The code read node->next (+91) before clear_bit (+94)

The code does. but what about CPU ?

> 2) And the it uses a lock prefix to guarantee the execution order

As I said from the very beginning, this code is fine on x86 because
atomic ops are fully serialised on x86.

OK. we can't convince each other. I'll try to write another email when
I have time,

If this code is correct, then my understanding of memory barriers is even
worse than I think. I wouldn't be surprised, but I'd like to understand
what I have missed.

Oleg.

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

  reply	other threads:[~2023-06-02 17:59 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-22  2:51 [PATCH 0/3] vhost: Fix freezer/ps regressions Mike Christie
2023-05-22  2:51 ` [PATCH 1/3] signal: Don't always put SIGKILL in shared_pending Mike Christie
2023-05-23 15:30   ` Eric W. Biederman
2023-05-22  2:51 ` [PATCH 2/3] signal: Don't exit for PF_USER_WORKER tasks Mike Christie
2023-05-22  2:51 ` [PATCH 3/3] fork, vhost: Use CLONE_THREAD to fix freezer/ps regression Mike Christie
2023-05-22 12:30   ` Oleg Nesterov
2023-05-22 17:00     ` Mike Christie
2023-05-22 17:47       ` Oleg Nesterov
2023-05-23 12:15         ` Oleg Nesterov
2023-05-23 15:57           ` Eric W. Biederman
2023-05-24 14:10             ` Oleg Nesterov
2023-05-24 14:44               ` Eric W. Biederman
2023-05-25 11:55                 ` Oleg Nesterov
2023-05-25 15:30                   ` Eric W. Biederman
2023-05-25 16:20                     ` Linus Torvalds
2023-05-27  9:49                       ` Eric W. Biederman
2023-05-27 16:12                         ` Linus Torvalds
2023-05-28  1:17                           ` Eric W. Biederman
2023-05-28  1:21                             ` Linus Torvalds
2023-05-29 11:19                             ` Oleg Nesterov
2023-05-29 16:09                               ` michael.christie
2023-05-29 17:46                                 ` Oleg Nesterov
2023-05-29 17:54                                   ` Oleg Nesterov
2023-05-29 19:03                                     ` Mike Christie
2023-05-29 19:35                                   ` Mike Christie
2023-05-29 19:46                                     ` michael.christie
2023-05-30  2:48                                       ` Eric W. Biederman
2023-05-30  2:38                                 ` Eric W. Biederman
2023-05-30 15:34                                   ` Mike Christie
2023-05-31  3:30                                   ` Mike Christie
2023-05-29 16:11                               ` michael.christie
     [not found]                               ` <20230530-autor-faxnummer-01e0a31c0fb8@brauner>
2023-05-30 17:55                                 ` Oleg Nesterov
2023-05-30 15:01                         ` Eric W. Biederman
2023-05-31  5:22             ` Jason Wang
2023-05-24  0:02           ` Mike Christie
2023-05-25 16:15           ` Mike Christie
2023-05-28  1:41             ` Eric W. Biederman
2023-05-28 19:29               ` Mike Christie
2023-05-31  5:22           ` Jason Wang
2023-05-31  7:25             ` Oleg Nesterov
2023-05-31  8:17               ` Jason Wang
2023-05-31  9:14                 ` Oleg Nesterov
2023-06-01  2:44                   ` Jason Wang
2023-06-01  7:43                     ` Oleg Nesterov
2023-06-02  5:03                       ` Jason Wang
2023-06-02 17:58                         ` Oleg Nesterov [this message]
2023-06-02 20:07                           ` Linus Torvalds
2023-06-05 14:20                             ` Oleg Nesterov
2023-05-22 19:40   ` Michael S. Tsirkin
2023-05-23 15:39     ` Eric W. Biederman
2023-05-23 15:48     ` Mike Christie

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=20230602175846.GC555@redhat.com \
    --to=oleg@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=brauner@kernel.org \
    --cc=ebiederm@xmission.com \
    --cc=jasowang@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@leemhuis.info \
    --cc=mst@redhat.com \
    --cc=nicolas.dichtel@6wind.com \
    --cc=stefanha@redhat.com \
    --cc=torvalds@linux-foundation.org \
    --cc=virtualization@lists.linux-foundation.org \
    /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).