반응형

출처 : google "가상 메모리 관리 (AIX Virtual Memory Management) 검색 결과의 Doc 문서.


가상 메모리 관리 (AIX Virtual Memory Management)


Virtual Address Space

Virtual address space
란 프로세스가 참조하는 어드레스 범위이며, AIX에서는 16개의 Segment와 각 segment 256MB로 구성된다. 따라서 최대 4GB virtual address space를 가지고 있다. Kernel의 경우 virtual address space를 모두 사용할 수 있지만, Process의 경우에는 제한된 공간만 참조할 수 있다.

Demand Paging

Data
는 참조되는 순간에만 실제 Page(Real Memory 최소 관린 단위)에 복사되며, Mapping은 사용자가 인식할 수 없는 순간에 수행된다.

Data
:
    A page from the page space.
    A page from a file on disk.

AIX
에서는 kernel 또한 페이징을 사용하며, 페이징되지 않는 영역을 'pinned'라고 한다. 하지만, 대부분의 Kernel 영역은 페이징 영역을 사용하고 있다. Pager daemon은 실제 Page(Real Memory 최소 관린 단위) pool로 유지하기 위해, 사용 가능한 page 개수가 high-water mark 이하이면 low-water mark에 도달할 때 까지 가장 오래된 pager를 삭제하게 된다(LRU 알고리즘).

Memory Management Definitions

  • Page - 고정된 Memory의 최소단위(Size : 4096 bytes for AIX)
  • Paging Space - Inactive 상태인 메모리 페이지를 유지하기 위해 memory manager에 의해 사용되는 disk 공간
  • Real Memory - 시스템 내부에 장착된 실제 메모리
  • Virtual Memory - system memory manager에 의해 프로그램 및 프로세스에 주어진 메모리
  • Address Space - 메모리를 접근하는 프로그램에서 활용하는 address set

Virtual Memory

Virtual Memory 개념을 도입함으로써, 연속적인 address space를 가지는 사용자 프로그램이 대용량 메모리를 사용할 수 있으며 시스템의 physical memory 크기보다 큰 공간도 할당할 수 있다.


  • Virtual Memory Mapping
    H/W에 의해 이루어지며, 보통 실 메모리와 paging space에 펼쳐진다.
  • H/W & S/W에 의해 관리되는 최소 단위는 1Page 이며, Page Fault 발생시 Virtual Memory Manager virtual memory address를 사용하는 프로그램 및 프로세스에 page fault 발생한 내용을 보내기 위해 작업을 시작한다.

Hardware Address Translation

32bit virtual address

  • Segment register : 가장 앞 단의 4 bit( segment ID를 포함 )
  • Virtual page index : segment register이후의 16bit( segment page )
  • Byte offset : 마지막 12 bit( page offset )

2^4 = 16 ( 가장 앞 단위 4bit 16개의 segment register중 하나를 선택한다. )
2^28 = 256 MB(
segment 256 MB로 구성: virtual page index + byte offset )
2^12 = 4K(
page 단위는 4K )
16 segment * 256 MB/segment = 4 GB
2^32 = 4GB( 32 bit virtual address space )


    T=0 - Always 0 for memory space
    Ks - Supervisor-state protection key
    Kp - User-state protection key
    N - No-execute protection

64-bit Segment Table




Memory Segments

1.     각각의 Segment page 단위로 분리된다.

o    Segment는 프로세스간에 공유될 수 있다.

o    추가의 virtual page Segment mapping 될 수 있다.

o    이미 사용중인 segment는 프로세스로 지정될 수 도 있고 분리될 수 도 있다.

o    신규 segment는 프로세스에 의해 할당되거나 제거된다.

 

2.     Virtual address segment register로 구성된다.

3.     Segment type

o    Working: 프로그램 실행동안 stack/data 영역으로 사용되는 temporary memory

o    Persistent: Local file system을 위해 file data를 저장하는 memory

o    Client: NFS or CD-ROM과 같이 client file system를 위해 사용되는 memory

o    Log: Journalling 작업동안 file system이 쓰고 읽는데 사용되는 memory

o    Mapping: Application이 동일한 memory segment에 여러 object를 배치하도록 mmap() interface를 지원하기 위해 사용

 

4.     Virtual Page는 실제 memory page 또는 disk drive와 같은 이차 저장매체와 연관되어 있다.

5.     Memory Segment 종류

o    Kernel

o    User Text

o    Shared Library Text

o    Shared Data

o    Process Private

o    Shared Library Data

Segment Register Map in 32-bit User Mode

Segment
-----------------------------------------------------
 0x0         Kernel Segment (only parts visible)
 0x1         User Text
 0x2         User Data, Initial User Thread Stack
 0x3         Available for User (shmat, mmap)
 0x4-0xb     Available for User (shmat, mmap)
 0xc         Available for User (shmat, mmap)
 0xd         System Shared Library Text Segment
 0xe         Available for User (shmat, mmap)
 0xf         Pre-Process Shared Library Data Segment

Large Address Space Model in 32-bit

AIX
에서는 user data 영역으로 256MB 이상을 지원하며, 이 경우 maxdata binder option을 지정하여야 한다. 또한 Large user data 프로그램은 segment 3에서 malloc를 수행하여, 최대 8개의 segments(1020*1024*256*8, 2GB) 사용할 수 있다. 하지만 이 경우에도 여전히 segment 1 user text User Stack segment 2 256MB로 제한되며, segment 11 12 large address space model에 의해 사용할 수 없다.

Large Address Model Compile Option

기본 option으로 Compile을 하는 경우 하나의 Segment가 가질 수 있는 256MB 이상을 참조할 수 없다. 그래서 Large Address가 필요한 프로그램의 경우 아래와 같은 Option을 주어야 가능하다.

cc sample.o -bmaxdata:0x80000000 ->
필요에 따라 segment 개수를 변경할 수 있으며, 최대 8개의 segment를 지정할 수 있음.




-----------------------------------------------------------------------------------------------------------------


출처 : https://www.spec.org/mpi2007/flags/IBM-AIX.html


그렇다면 AIX 관련 컴파일 옵션 및 관련 설명을 보도록 하자.

IBM AIX: Environment Settings and Utilities

IBM AIX 5L V5.3

IBM AIX V6

Last updated: 04-Aug-2008

Sections

Selecting one of the following will take you directly to that section:


Optimization Flags

    • -bdatapsize:64K
    • -bdatapsize:64K\b
    • Specifies a non-default page size of 64K for the program data segment.

    • -bstackpsize:64K
    • -bstackpsize:64K\b
    • Specifies a non-default page size of 64K for the program stack segment.

    • -btextpsize:64K
    • -btextpsize:64K\b
    • Specifies a non-default page size of 64K for the program text segment.

    • -blpdata
    • -blpdata\b
    • Sets the bit in the file's XCOFF header indicating that this executable will request the use of large pages when they are available on the system and when the user has an appropriate privilege

    • -D__IBM_FAST_VECTOR
    • -D__IBM_FAST_VECTOR\b
    • The __IBM_FAST_VECTOR macro defines a different iterator for the std::vector template class. This iterator results in faster code, but is not compatible with code using the default iterator for a std::vector template class. All uses of std::vector for a data type must use the same iterator. Add -D__IBM_FAST_VECTOR to the compile line, or "#define __IBM_FAST_VECTOR 1" to your source code to use the faster iterator for std::vector template class. You must compile all sources with this macro.

    • -D__IBM_FAST_SET_MAP_ITERATOR
    • -D__IBM_FAST_SET_MAP_ITERATOR\b
    • The __IBM_FAST_SET_MAP_ITERATOR macro defines a different iterator for the std::vector template class. This iterator results in faster code, but is not compatible with code using the default iterator for a std::vector template class. All uses of std::vector for a data type must use the same iterator. Add -D__IBM_FAST_SET_MAP_ITERATOR to the compile line, or "#define __IBM_FAST_SET_MAP_ITERATOR 1" to your source code to use the faster iterator for std::vector template class. You must compile all sources with this macro.

    • -D_ILS_MACROS
    • -D_ILS_MACROS\b
    • Causes AIX to define "ischar()" (and friends) as macro's and not subroutines.


System and Other Tuning Information

  • drmgr -r -c cpu
  • Deconfigures one core from the active partition. Use it N times to deconfigure N cores.

  • smtctl -m on|off -w now|boot

  • Controls the enabling and disabling of processor simultaneous multi-threading mode.

  • vmo -r -o lgpg_regions=n -o lgpg_size=16777216

  • Sets the size of large pages to 16M, and set the number to use, with -r, takes effect on the next IPL.

  • bosboot -q

  • Regenerates the IPL boot to set the options specified with smtctl and vmo.

  • ulimit

  • Controls resources allowed to be used by processes. All resource are set to unlimited, of primary importance is the "stack" and "data/heap" settings for SPEC CPU2006 and MPI2007.

  • chsyscfg -m system -r prof -i name=profile,lpar_name=partition,lpar_proc_compat_mode=POWER6_enhanced

  • This command enables the POWERPC architecture optional instructions supported on POWER6.

    Usage: chsyscfg -r lpar | prof | sys | sysprof | frame
                    -m <managed system> | -e <managed frame>
                    -f <configuration file> | -i "<configuration data>"
                    [--help]
    
    Changes partitions, partition profiles, system profiles, or the attributes of a
    managed system or a managed frame.
    
        -r                        - the type of resource(s) to be changed:
                                      lpar    - partition
                                      prof    - partition profile
                                      sys     - managed system
                                      sysprof - system profile
                                      frame   - managed frame
        -m <managed system>       - the managed system's name
        -e <managed frame>        - the managed frame's name
        -f <configuration file>   - the name of the file containing the
                                    configuration data for this command.
                                    The format is:
                                      attr_name1=value,attr_name2=value,...
                                    or
                                      "attr_name1=value1,value2,...",...
        -i "<configuration data>" - the configuration data for this command.
                                    The format is:
                                      "attr_name1=value,attr_name2=value,..."
                                    or
                                      ""attr_name1=value1,value2,...",..."
        --help                    - prints this help
    
    The valid attribute names for this command are:
        -r prof     required: name, lpar_id | lpar_name
                    optional: ...
                              lpar_proc_compat_mode (default | POWER6_enhanced)
    
  • bindprocessor $$ <n>

  • The next program is to be bound to the specified processor.

    Environment variables set before the run:

  • MEMORY_AFFINITY=MCM

  • Cause the OS to alloc memory "closest" to the chip that first requests it.

  • XLFRTEOPTS=intrinthrds=1

  • Causes the Fortran runtime to only use a single thread.

  • MALLOCOPTIONS=POOL

  • Selects the OS malloc option that allocates/frees small objects very quickly.

실제 옵션들을 o 파일 컴파일 시 옵션으로 넣어서 컴파일 하니 256메가에서 프로그램이 메모리 할당에 실패했던 문제가 해소되었다.



반응형

+ Recent posts