Libre RISC-V Mailing list Archives (accessible via public-inbox)
 help / color / Atom feed
From: Luke Kenneth Casson Leighton <lkcl@lkcl.net>
To: Libre-RISCV General Development <libre-riscv-dev@lists.libre-riscv.org>
Subject: Re: [libre-riscv-dev] Advanced Topics on RISCV
Date: Tue, 24 Mar 2020 12:06:28 +0000
Message-ID: <CAPweEDzo=6eDRU8YhBf14JwqOn=S5vijy1+3w6T8wygXoxX2hQ@mail.gmail.com> (raw)
In-Reply-To: <0F80A1BC-0241-49FE-B374-B4F1D8F3F5BD@gatech.edu>

On Tue, Mar 24, 2020 at 11:52 AM Immanuel, Yehowshua U
<yimmanuel3@gatech.edu> wrote:

> I’ve read through the Spike page and a good portion of the simpleV page.

it's ultimately quite simple in concept: the details are where it gets hairy

> My two goals at the moment are:
> 1. Understand how RISCV handles multiple processes and does page walking

ok so SV will not help you there: it doesn't have anything to do with PTW (etc.)

multiple processes are handled by context-swapping.  register and CSR
state are "saved", the new process selected, and its state "swapped
in" to registers and CSRs.  the last thing that's swapped over is: the
Program Counter.

PTW - you'll need to do quite a bit of research into virtual memory,
TLBs, etc. first.

> 2. Understand how multicore RISCV would work

you'll need to look up "Weak Memory Model" (as opposed to "Total Store
Order").  then look up AMO (atomic memory operations).

> I’m hoping to play with FreeRTOS soon so I can run through its codebase for setting up page tables.

that's a good idea.

> Also, do you know if spike tests the special instructions like exception instructions? Also, what RISCV instructions would a kernel use to set up the pagetables?
>
> Lastly, do you know any good resources for intro to multicore systems? RISCV doesn’t seem to have any multicore specific instructions.

correct.  it has LR/SC semantics on atomic operations, and it is
entirely up to the *operating system* - the kernel - to use these in
an effective way in order to guarantee that memory corruption between
processes does not occur.

*that is all there is to it*.

> My current questions would include things like:
>
> 1. How can the kernel assign tasks to a certain core? If you have a process with multiple threads, it would make sense to spread out the threads among available processors instead of concentrating them on a single core. How might this work with respect to RISCV?

just like it would on any multi-core operating system which was
running on an SMP-capable hardware.  there's absolutely no difference
here.


> 2. Does the hardware ensure cache coherency -

nnnope.  that's what a "Weak Memory Model" is.

> that is - externally - software sees one big cache all though I imagine each core would have a local cache that would have to communicate with other caches?

nnope.

that's why LR/SC atomic semantics exist.  look up AMO.  these are then
used to do kernel-level spin-locks, mutexes etc. all of which are a
hard requirement for sorting out memory clashes.

from my (brief) look at several RISC-V SMP implementations, the
takeaway that i got was: most implementations actually put the AMO ALU
*actually in the L2 cache* (!) - one *single* AMO ALU - accessible
*ONLY* over an exclusive bus such that ONLY one core may use it at any
given time.

thus, atomicity of the Atomic Memory Operations - crucial to - are
done by way of resource contention / starvation, rather than "actual
atomic but parallel memory operation detection and clash avoidance".

given that AMOs are not very common, they basically get away with this
approach.  however for massively-parallel SMP systems (64 cores or
greater) this approach would begin to result in significant contention
and slow-down of certain tasks.

l.

_______________________________________________
libre-riscv-dev mailing list
libre-riscv-dev@lists.libre-riscv.org
http://lists.libre-riscv.org/mailman/listinfo/libre-riscv-dev

  reply index

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-24 11:51 Immanuel, Yehowshua U
2020-03-24 12:06 ` Luke Kenneth Casson Leighton [this message]
2020-03-24 12:58   ` Immanuel, Yehowshua U
2020-03-24 12:23 ` Jean-Paul Chaput
2020-03-24 13:00   ` Immanuel, Yehowshua U
2020-03-24 13:08     ` Jean-Paul Chaput

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='CAPweEDzo=6eDRU8YhBf14JwqOn=S5vijy1+3w6T8wygXoxX2hQ@mail.gmail.com' \
    --to=lkcl@lkcl.net \
    --cc=libre-riscv-dev@lists.libre-riscv.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

Libre RISC-V Mailing list Archives (accessible via public-inbox)

Archives are clonable: git clone --mirror https://inbox.libre-soc.org/libre-riscv-dev

Example config snippet for mirrors


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git