public inbox for [email protected]
 help / color / mirror / Atom feed
From: John David Anglin <[email protected]>
To: Helge Deller <[email protected]>, Jens Axboe <[email protected]>,
	[email protected]
Cc: linux-parisc <[email protected]>
Subject: Re: io_uring failure on parisc (32-bit userspace and 64-bit kernel)
Date: Mon, 13 Feb 2023 17:50:16 -0500	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

On 2023-02-13 5:05 p.m., Helge Deller wrote:
> On 2/13/23 22:05, Jens Axboe wrote:
>> On 2/13/23 1:59?PM, Helge Deller wrote:
>>>> Yep sounds like it. What's the caching architecture of parisc?
>>>
>>> parisc is Virtually Indexed, Physically Tagged (VIPT).
>>
>> That's what I assumed, so virtual aliasing is what we're dealing with
>> here.
>>
>>> Thanks for the patch!
>>> Sadly it doesn't fix the problem, as the kernel still sees
>>> ctx->rings->sq.tail as being 0.
>>> Interestingly it worked once (not reproduceable) directly after bootup,
>>> which indicates that we at least look at the right address from kernel side.
>>>
>>> So, still needs more debugging/testing.
>>
>> It's not like this is untested stuff, so yeah it'll generally be
>> correct, it just seems that parisc is a bit odd in that the virtual
>> aliasing occurs between the kernel and userspace addresses too. At least
>> that's what it seems like.
>
> True.
>
>> But I wonder if what needs flushing is the user side, not the kernel
>> side? Either that, or my patch is not flushing the right thing on the
>> kernel side.
>>
>> Is it possible to flush it from the userspace side? Presumable that's
>> what we'd need on the sqe side, and then the kernel side for the cqe
>> filling. So probably the patch is half-way correct :-)
>
> I hacked up in __io_uring_flush_sq() in liburing/src/queue.c this code
> (which I hope is correct):
>                 if (!(ring->flags & IORING_SETUP_SQPOLL))
>                         IO_URING_WRITE_ONCE(*sq->ktail, tail);
>                 else
>                         io_uring_smp_store_release(sq->ktail, tail);
>         } /* ADDED: */
>         { int i;  unsigned long p = (unsigned long)sq->ktail & ~(4096-1);
>           fprintf(stderr, "FLUSH CACHE OF PAGE %lx\n", p);
>           for (i=0; i < 4096; i += 8)
>                 asm volatile("fdc 0(%0)" : : "r" (p+i));
>         }
>
> The kernel sometimes sees the tail value now (it fails afterwards, but that's ok for now).
> But I'm not sure yet if this is really the effect of the fdc (flush data cache instruction),
> or pure luck because the aliasing of the userspace address and kernel address matches in
> a sucessful run.
If the user and kernel aliases are not equivalent, the kernel must also flush the page to
invalidate any lines that may be present in the cache before trying to access the data in the page.
> For me it seems as it's the aliasing which makes it work sometimes.
>
> In this regard I wonder why we don't provide the cacheflush syscall on parisc....
The kernel knows the cache stride and can optimize the flush.  But it needs to handle non access TLB
faults on userspace.  Userspace can also do flushes.

Dave

-- 
John David Anglin  [email protected]


  reply	other threads:[~2023-02-13 22:52 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-12  9:47 io_uring failure on parisc (32-bit userspace and 64-bit kernel) Helge Deller
2023-02-12 13:16 ` Jens Axboe
2023-02-12 13:28   ` Helge Deller
2023-02-12 13:35     ` Jens Axboe
2023-02-12 14:00       ` Jens Axboe
2023-02-12 14:03       ` Helge Deller
2023-02-12 19:35         ` Helge Deller
2023-02-12 19:42           ` Jens Axboe
2023-02-12 20:01             ` Helge Deller
2023-02-12 21:48               ` Jens Axboe
2023-02-12 22:20                 ` Helge Deller
2023-02-12 22:31                   ` Helge Deller
2023-02-13 16:15                     ` Jens Axboe
2023-02-13 20:59                       ` Helge Deller
2023-02-13 21:05                         ` Jens Axboe
2023-02-13 22:05                           ` Helge Deller
2023-02-13 22:50                             ` John David Anglin [this message]
2023-02-14 23:09                               ` io_uring failure on parisc with VIPT caches Helge Deller
2023-02-14 23:29                                 ` Jens Axboe
2023-02-15  2:12                                   ` John David Anglin
2023-02-15 15:16                                     ` Jens Axboe
2023-02-15 15:52                                       ` Helge Deller
2023-02-15 15:56                                         ` Jens Axboe
2023-02-15 16:02                                           ` Helge Deller
2023-02-15 16:04                                             ` Jens Axboe
2023-02-15 21:40                                               ` Helge Deller
2023-02-15 23:04                                                 ` Jens Axboe
2023-02-15 16:38                                           ` John David Anglin
2023-02-15 17:01                                             ` Jens Axboe
2023-02-15 19:00                                               ` Jens Axboe
2023-02-15 19:16                                                 ` Jens Axboe
2023-02-15 20:27                                                   ` John David Anglin
2023-02-15 20:37                                                     ` Jens Axboe
2023-02-15 21:06                                                       ` John David Anglin
2023-02-15 21:38                                                         ` Jens Axboe
2023-02-15 21:39                                                         ` John David Anglin
2023-02-15 22:10                                                           ` John David Anglin
2023-02-15 23:02                                                             ` Jens Axboe
2023-02-15 23:43                                                               ` John David Anglin
2023-02-16  2:40                                                               ` John David Anglin
2023-02-16  2:50                                                                 ` Jens Axboe
2023-02-16  8:24                                                                   ` Helge Deller
2023-02-16 15:22                                                                     ` Jens Axboe
2023-02-16 20:35                                                                     ` John David Anglin
2023-02-15 23:03                                                           ` Jens Axboe
2023-02-15 19:20                                                 ` John David Anglin
2023-02-15 19:24                                                   ` Jens Axboe
2023-02-15 16:18                                         ` John David Anglin

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 \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /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