Rev 83 | Rev 96 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 83 | Rev 84 | ||
|---|---|---|---|
| Line 532... | Line 532... | ||
| 532 | processor. Maintaining TLB consistency on multiprocessor configurations |
532 | processor. Maintaining TLB consistency on multiprocessor configurations |
| 533 | is not as trivial as it might look from the first glance.</para> |
533 | is not as trivial as it might look from the first glance.</para> |
| 534 | 534 | ||
| 535 | <para>The remote TLB invalidation is called TLB shootdown. HelenOS uses |
535 | <para>The remote TLB invalidation is called TLB shootdown. HelenOS uses |
| 536 | a simplified variant of the algorithm described in <xref |
536 | a simplified variant of the algorithm described in <xref |
| 537 | linkend="Black89" />. </para> |
537 | linkend="Black89" />.</para> |
| 538 | 538 | ||
| 539 | <para>TLB shootdown is performed in three phases.</para> |
539 | <para>TLB shootdown is performed in three phases.</para> |
| 540 | 540 | ||
| 541 | <formalpara> |
541 | <formalpara> |
| 542 | <title>Phase 1.</title> |
542 | <title>Phase 1.</title> |
| Line 570... | Line 570... | ||
| 570 | TLB according to messages found in its TLB shootdown message queue. In |
570 | TLB according to messages found in its TLB shootdown message queue. In |
| 571 | the end, each processor sets its TLB flag and resumes its previous |
571 | the end, each processor sets its TLB flag and resumes its previous |
| 572 | operation.</para> |
572 | operation.</para> |
| 573 | </formalpara> |
573 | </formalpara> |
| 574 | </section> |
574 | </section> |
| - | 575 | </section> |
|
| - | 576 | ||
| - | 577 | <section> |
|
| - | 578 | <title>Address spaces</title> |
|
| - | 579 | ||
| - | 580 | <para>last bits about address spaces</para> |
|
| 575 | 581 | ||
| 576 | <section> |
582 | <section> |
| - | 583 | <indexterm> |
|
| - | 584 | <primary>address space</primary> |
|
| - | 585 | ||
| - | 586 | <secondary>- ASID</secondary> |
|
| - | 587 | </indexterm> |
|
| - | 588 | ||
| 577 | <title>Address spaces</title> |
589 | <title>Address Space ID (ASID)</title> |
| 578 | 590 | ||
| 579 | <section> |
- | |
| 580 | <indexterm> |
- | |
| 581 | <primary>address space</primary> |
591 | <para>Modern processor architectures optimize TLB utilization by |
| 582 | - | ||
| 583 | <secondary>- area</secondary> |
592 | associating TLB entries with address spaces through assigning |
| 584 | </indexterm> |
- | |
| 585 | - | ||
| 586 | <title>Address space areas</title> |
593 | identification numbers to them. In HelenOS, the term ASID, originally |
| 587 | - | ||
| 588 | <para>Each address space consists of mutually disjunctive continuous |
594 | taken from the mips32 terminology, is used to refer to the address space |
| 589 | address space areas. Address space area is precisely defined by its |
595 | identification number. The advantage of having ASIDs is that TLB does |
| 590 | base address and the number of frames/pages is contains.</para> |
596 | not have to be invalidated on thread context switch as long as ASIDs are |
| 591 | - | ||
| 592 | <para>Address space area , that define behaviour and permissions on |
597 | unique. Unfotunatelly, architectures supported by HelenOS use all |
| 593 | the particular area. <itemizedlist> |
598 | different widths of ASID numbers<footnote> |
| 594 | <listitem><emphasis>AS_AREA_READ</emphasis> flag indicates reading |
599 | <para>amd64 and ia32 don't use similar abstraction at all, mips32 |
| 595 | permission.</listitem> |
- | |
| 596 | - | ||
| 597 | <listitem><emphasis>AS_AREA_WRITE</emphasis> flag indicates |
600 | has 8-bit ASIDs and ia64 can have ASIDs between 18 to 24 bits |
| 598 | writing permission.</listitem> |
601 | wide.</para> |
| 599 | - | ||
| 600 | <listitem><emphasis>AS_AREA_EXEC</emphasis> flag indicates code |
602 | </footnote> out of which none is sufficient. The amd64 and ia32 |
| 601 | execution permission. Some architectures do not support execution |
603 | architectures cannot make use of ASIDs as their TLB doesn't recognize |
| 602 | persmission restriction. In this case this flag has no |
604 | such an abstraction. Other architectures have support for ASIDs, but for |
| 603 | effect.</listitem> |
605 | instance ppc32 doesn't make use of them in the current version of |
| 604 | - | ||
| 605 | <listitem><emphasis>AS_AREA_DEVICE</emphasis> marks area as mapped |
606 | HelenOS. The rest of the architectures does use ASIDs. However, even on |
| 606 | to the device memory.</listitem> |
607 | the ia64 architecture, the minimal supported width of ASID<footnote> |
| 607 | </itemizedlist></para> |
608 | <para>RID in ia64 terminology.</para> |
| 608 | - | ||
| 609 | <para>Kernel provides possibility tasks create/expand/shrink/share its |
609 | </footnote> is insufficient to provide a unique integer identifier to |
| 610 | address space via the set of syscalls.</para> |
610 | all address spaces that might hypothetically coexist in the running |
| - | 611 | system. The situation on mips32 is even worse: the architecture has only |
|
| 611 | </section> |
612 | 256 unique identifiers.</para> |
| 612 | 613 | ||
| 613 | <section> |
- | |
| 614 | <indexterm> |
614 | <indexterm> |
| 615 | <primary>address space</primary> |
615 | <primary>address space</primary> |
| 616 | 616 | ||
| 617 | <secondary>- ASID</secondary> |
617 | <secondary>- ASID stealing</secondary> |
| 618 | </indexterm> |
618 | </indexterm> |
| 619 | 619 | ||
| 620 | <title>Address Space ID (ASID)</title> |
620 | <para>To mitigate the shortage of ASIDs, HelenOS uses the following |
| 621 | - | ||
| 622 | <para>Every task in the operating system has it's own view of the |
621 | strategy. When the system initializes, a FIFO queue<footnote> |
| 623 | virtual memory. When performing context switch between different |
622 | <para>Note that architecture-specific measures are taken to avoid |
| 624 | tasks, the kernel must switch the address space mapping as well. As |
623 | too large FIFO queue. For instance, seven consecutive ia64 RIDs are |
| 625 | modern processors perform very aggressive caching of virtual mappings, |
624 | grouped to form one HelenOS ASID.</para> |
| 626 | flushing the complete TLB on every context switch would be very |
625 | </footnote> is created and filled with all available ASIDs. Moreover, |
| 627 | inefficient. To avoid such performance penalty, some architectures |
626 | every address space remembers the number of processors on which it is |
| 628 | introduce an address space identifier, which allows storing several |
627 | active. Address spaces that have a valid ASID and that are not active on |
| 629 | different mappings inside TLB.</para> |
- | |
| 630 | - | ||
| 631 | <para>HelenOS kernel can take advantage of this hardware support by |
628 | any processor are appended to the list of inactive address spaces with |
| 632 | having an ASID abstraction. I.e. on ia64 kernel ASID is derived from |
629 | valid ASID. When an address space needs to be assigned a valid ASID, it |
| 633 | RID (region identifier) and on the mips32 kernel ASID is actually the |
630 | first checks the FIFO queue. If it contains at least one ASID, the ASID |
| 634 | hardware identifier. As expected, this ASID information record is the |
631 | is allocated. If the queue is empty, an ASID is simply stolen from the |
| 635 | part of <emphasis>as_t</emphasis> structure.</para> |
632 | first address space in the list. In that case, the address space that |
| 636 | - | ||
| 637 | <para>Due to the hardware limitations, hardware ASID has limited |
633 | loses the ASID in favor of another address space, is removed from the |
| 638 | length from 8 bits on ia64 to 24 bits on mips32, which makes it |
634 | list. After the new ASID is purged from all TLBs, it can be used by the |
| 639 | impossible to use it as unique address space identifier for all tasks |
635 | address space. Note that this approach works due to the fact that the |
| 640 | running in the system. In such situations special ASID stealing |
636 | number of ASIDs is greater than the maximal number of processors |
| 641 | algoritm is used, which takes ASID from inactive task and assigns it |
637 | supported by HelenOS and that there can be only one active address space |
| 642 | to the active task.</para> |
- | |
| 643 | - | ||
| 644 | <indexterm> |
- | |
| 645 | <primary>address space</primary> |
- | |
| 646 | - | ||
| 647 | <secondary>- ASID stealing</secondary> |
638 | per processor. In other words, when the FIFO queue is empty, there must |
| 648 | </indexterm> |
- | |
| 649 | - | ||
| 650 | <para> |
- | |
| 651 | <classname>ASID stealing algoritm here.</classname> |
639 | be address spaces that are not active on any processor.</para> |
| 652 | </para> |
- | |
| 653 | </section> |
- | |
| 654 | </section> |
640 | </section> |
| 655 | </section> |
641 | </section> |
| 656 | </chapter> |
642 | </chapter> |
| 657 | 643 | ||