Study 📔

운영체제 리눅스 소스를 보고 해석하는 과제

SeongJo 2020. 6. 15. 23:20
반응형

안녕하세요 상자입니다.

리눅스 소스를 보고 부분을 발췌해서 소스를 해석하는 과제가 있었습니다. (시간은 좀 많이 지났지만..)

https://github.com/torvalds/linux/blob/master/include/linux/sched.h#L622

 

torvalds/linux

Linux kernel source tree. Contribute to torvalds/linux development by creating an account on GitHub.

github.com

의 링크를 타고가서 소스를 긁어서 인터넷에서 하나하나 확인하고 번역기를 돌려가면서 글을 작성했네요...

뭔가 C로 작성된 내용이라 하나하나 보면서 접근했지만 결국은 번역기와 인터넷 정보로 찾아서 작성했네요

개인적으로 작성했던 과제여서 남기고 싶어서 글로 남깁니다... ㅋㅋㅋ 

 

632 struct task_struct {

633 #ifdef CONFIG_THREAD_INFO_IN_TASK

/* #indef의 경우 선언부 #endif는 마감부의 정도로 보면 무관하며 선언을 마감해주는 역할을 해줍니다. CONFIG_THREAD_INFO_IN_TASK 커널 옵션을 사용한 경우에는 가장 처음에 스레드 정보가 위치합니다. */

634 /*

635 * For reasons of header soup (see current_thread_info()), this

636 * must be the first element of task_struct.

637 */

/ *

* 헤더 수프의 이유로 (current_thread_info () 참조)

*task_struct의 첫 번째 요소 여야합니다.

* /

638 struct thread_info thread_info;

639 #endif

640 /* -1 unrunnable, 0 runnable, >0 stopped: */

/ * -1 실행 불가능, 0 실행 가능,> 0 중지 : * /

641 volatile long state; /*선언된 변수는 외부적인 요인으로 그 값이 언제든지 바뀔 쉬 있음을 뜻합니다. */

642

 

643 /*

644 * This begins the randomizable portion of task_struct. Only

645 * scheduling-critical items should be added above here.

646 */

/ *

* 이것은 task_struct의 무작위 부분을 시작합니다.

* 예약 필수 항목은 여기에 추가해야합니다.

* /

647 randomized_struct_fields_start

648

 

649 void *stack;

650 refcount_t usage;

651 /* Per task flags (PF_*), defined further below: */

refcount_t 사용법;

/ * 작업 플래그 당 (PF_ *), 아래에 자세히 정의되어 있습니다. * /

652 unsigned int flags;

653 unsigned int ptrace;

654

 

655 #ifdef CONFIG_SMP

656 struct llist_node wake_entry;

657 int on_cpu;

658 #ifdef CONFIG_THREAD_INFO_IN_TASK

659 /* Current CPU: */

/ * 현재 CPU : * /

660 unsigned int cpu;

661 #endif

662 unsigned int wakee_flips;

663 unsigned long wakee_flip_decay_ts;

664 struct task_struct *last_wakee;

665

 

666 /*

667 * recent_used_cpu is initially set as the last CPU used by a task

668 * that wakes affine another task. Waker/wakee relationships can

669 * push tasks around a CPU where each wakeup moves to the next one.

670 * Tracking a recently used CPU allows a quick search for a recently

671 * used CPU that may be idle.

672 */

/ *

* recent_used_cpu는 처음에 작업에서 사용한 마지막 CPU로 설정됩니다

* 다른 일을 깨우침. Waker / Wake 관계는

* 각 깨우기가 다음으로 이동하는 CPU 주위에 작업을 푸시하십시오.

* 최근에 사용한 CPU를 추적하면 최근에 빠른 검색이 가능합니다

* 유휴 상태 일 수있는 CPU를 사용했습니다.

* /

673 int recent_used_cpu;

674 int wake_cpu;

675 #endif

676 int on_rq;

677

 

678 int prio;

679 int static_prio;

680 int normal_prio;

681 unsigned int rt_priority;

682

 

683 const struct sched_class *sched_class;

684 struct sched_entity se;

685 struct sched_rt_entity rt;

686 #ifdef CONFIG_CGROUP_SCHED /* 이 기능으로 CPU 스케줄러는 작업 그룹을 인식하고 해당 작업 그룹에 대한 CPU의 대역폭 할당을 제어해줍니다*/

687 struct task_group *sched_task_group;

688 #endif

689 struct sched_dl_entity dl;

690

 

691 #ifdef CONFIG_UCLAMP_TASK /* 이 기능을 통해 스케줄러는 해당 CPU에서 예약 된 RUNNABLE 작업을 기반으로 각 CPU의 클램핑 된 사용률을 추적 할 수 있습니다. */

692 /* Clamp values requested for a scheduling entity */

/ * 스케줄링 엔티티에 요청 된 클램프 값 * /

693 struct uclamp_se uclamp_req[UCLAMP_CNT];

694 /* Effective clamp values used for a scheduling entity */

/ * 스케줄링 엔티티에 사용되는 유효 클램프 값 * /

695 struct uclamp_se uclamp[UCLAMP_CNT];

696 #endif

697

 

698 #ifdef CONFIG_PREEMPT_NOTIFIERS

699 /* List of struct preempt_notifier: */

/ * 구조체 preempt_notifier 목록 : * /

700 struct hlist_head preempt_notifiers;

701 #endif

702

 

703 #ifdef CONFIG_BLK_DEV_IO_TRACE /* 주어진 대기열에서 블록 레이어 동작을 추적할 때 필요하고 추적을 사용하면 블록 장치 큐에서 발생하는 모든 트래픽을 볼 수 있습니다.*/

704 unsigned int btrace_seq;

705 #endif

706

 

707 unsigned int policy;

708 int nr_cpus_allowed;

709 const cpumask_t *cpus_ptr;

710 cpumask_t cpus_mask;

711

 

712 #ifdef CONFIG_PREEMPT_RCU /* 수백개 또는 수천개의 CPU가있는 매우 큰 SMP 시스템 용으로 설계가 되어있지만 실시간 응답이 필요한 RCU 구현을 선택합니다. 더 작은 시스템 확장을 할 수 있는 옵션입니다.*/

713 int rcu_read_lock_nesting;

714 union rcu_special rcu_read_unlock_special;

715 struct list_head rcu_node_entry;

716 struct rcu_node *rcu_blocked_node;

717 #endif /* #ifdef CONFIG_PREEMPT_RCU */

718

 

719 #ifdef CONFIG_TASKS_RCU /* 유휴 및 사용자 모드 실행 만 대기 상태로 사용하는 작업 기반 RCU 구현이 가능합니다.*/

720 unsigned long rcu_tasks_nvcsw;

721 u8 rcu_tasks_holdout;

722 u8 rcu_tasks_idx;

723 int rcu_tasks_idle_cpu;

724 struct list_head rcu_tasks_holdout_list;

725 #endif /* #ifdef CONFIG_TASKS_RCU */

726

 

727 struct sched_info sched_info;

728

 

729 struct list_head tasks;

730 #ifdef CONFIG_SMP /*활성화 된 SMP 소프트웨어; 시작하는 동안 둘 이상의 CPU / CORE를 활성화 할 수 있습니다.*/

731 struct plist_node pushable_tasks;

732 struct rb_node pushable_dl_tasks;

733 #endif

734

 

735 struct mm_struct *mm;

736 struct mm_struct *active_mm;

737

 

738 /* Per-thread vma caching: */

/ * 스레드 당 vma 캐싱 : * /

739 struct vmacache vmacache;

740

 

741 #ifdef SPLIT_RSS_COUNTING /*

add_mm_counter요구가 동시에 액세스로부터 보호하고, 그래서 그것은 사용 스핀 락을 사용하여 보호 mm->page_table_lock 잠금 CPU동기화 하는 가장 기본적인 방법*/

742 struct task_rss_stat rss_stat;

743 #endif

744 int exit_state;

745 int exit_code;

746 int exit_signal;

747 /* The signal sent when the parent dies: */

/ * 부모가 죽을 때 보내지는 신호 : * /

748 int pdeath_signal;

749 /* JOBCTL_*, siglock protected: */

/ * JOBCTL_ *, siglock으로 보호됨 : * /

750 unsigned long jobctl;

751

 

752 /* Used for emulating ABI behavior of previous Linux versions: */

/ * 이전 Linux 버전의 ABI 동작을 에뮬레이트하는 데 사용됩니다. * /

753 unsigned int personality;

754

 

755 /* Scheduler bits, serialized by scheduler locks: */

/ * 스케줄러 잠금으로 직렬화 된 스케줄러 비트 : * /

756 unsigned sched_reset_on_fork:1;

757 unsigned sched_contributes_to_load:1;

758 unsigned sched_migrated:1;

759 unsigned sched_remote_wakeup:1;

760 #ifdef CONFIG_PSI /* 시스템에서 CPU, 메모리 및 IO 용량이 얼마나 커밋되었는지 표시하는 메트릭을 수집해주고 여기서 여기서 Y라고하면 커널은 압력 통계 파일 cpu, memory io/ proc / pressure /를 만듭니다. 이는 각 리소스의 경합으로 인해 시스템의 일부 또는 모든 작업이 지연되는 월별 공유 시간을 나타냅니다. cgroup을 지원하는 커널에서 cgroup (cgroup2 만 해당)에는 cpu.pressure, memory.pressure io.pressure 파일이 있으며,이 파일은 그룹화 된 작업에 대해서만 압력 스톨을 집계합니다. 확실하지 않으면 N로 말합니다. */

761 unsigned sched_psi_wake_requeue:1;

762 #endif

763

 

764 /* Force alignment to the next boundary: */

/ * 다음 경계로 강제 정렬 : * /

765 unsigned :0;

766

 

767 /* Unserialized, strictly 'current' */

/ * 직렬화되지 않은, 엄격하게 '현재'* /

768

 

769 /* Bit to tell LSMs we're in execve(): */

/ * execve ()에있는 LSM에게 알려주는 비트 : * /

770 unsigned in_execve:1;

771 unsigned in_iowait:1;

772 #ifndef TIF_RESTORE_SIGMASK

773 unsigned restore_sigmask:1;

774 #endif

775 #ifdef CONFIG_MEMCG // cgroup에서 작업의 메모리 사용량을 제어해줍니다.

776 unsigned in_user_fault:1;

777 #endif

778 #ifdef CONFIG_COMPAT_BRK /* 옵션은 부팅 기본값을 힙 무작위 화 비활성화로 변경하고 / proc / sys / kernel / randomize_va_space2로 설정하여 런타임시 재정의 할 수 있습니다.*/

779 unsigned brk_randomized:1;

780 #endif

781 #ifdef CONFIG_CGROUPS /*Cpusets, CFS, 메모리 제어 또는 장치 격리와 같은 프로세스 제어 서브 시스템과 함께 사용하기 위해 프로세스 세트 그룹화에 대한 지원을 추가합니다.*/

 

782 /* disallow userland-initiated cgroup migration */

/ * 사용자 영역 시작 cgroup 마이그레이션을 허용하지 않습니다 * /

783 unsigned no_cgroup_migration:1;

784 /* task is frozen/stopped (used by the cgroup freezer) */

/ * 작업이 중지 / 중지되었습니다 (cgroup 냉동고에서 사용) * /

785 unsigned frozen:1;

786 #endif

787 #ifdef CONFIG_BLK_CGROUP /*일반 블록 IO 컨트롤러 cgroup 인터페이스 이것은 다양한 IO 제어 정책에서 사용해야하는 공통 cgroup 인터페이스입니다.*/

788 unsigned use_memdelay:1;

789 #endif

790 #ifdef CONFIG_PSI /* cgroup을 지원하는 커널에서 cgroup (cgroup2 만 해당)에는 cpu.pressure, memory.pressure io.pressure 파일이 있으며,이 파일은 그룹화 된 작업에 대해서만 압력 스톨을 집계합니다.*/

791 /* Stalled due to lack of memory */

/ * 메모리 부족으로 인해 멈춤 * /

792 unsigned in_memstall:1;

793 #endif

794

 

795 unsigned long atomic_flags; /* Flags requiring atomic access. */

796

 

797 struct restart_block restart_block;

798

 

799 pid_t pid;

800 pid_t tgid;

801

 

802 #ifdef CONFIG_STACKPROTECTOR /* 이 옵션은 "스택 프로텍터"GCC 기능을 켭니다. 이 기능은 함수의 시작 부분에 반환 주소 직전의 스택에 카나리아 값을 넣고 실제로 반환하기 직전에 값의 유효성을 검사합니다. 스택 기반 버퍼 오버 플로우 (이 리턴 주소를 덮어 써야 함)는 이제 카나리아를 덮어 쓰고 감지되고 커널 패닉을 통해 공격이 중화됩니다. 함수는 스택에 8 바이트 이상의 문자 배열이있는 경우 스택 보호기 카나리아 논리를 추가합니다. 이 기능은 4.2 버전이상의 gcc 버전을 사용해야 합니다.*/

803 /* Canary value for the -fstack-protector GCC feature: */

/ * -fstack-protector GCC 기능의 카나리아 값 : * /

804 unsigned long stack_canary;

805 #endif

806 /*

807 * Pointers to the (original) parent process, youngest child, younger sibling,

808 * older sibling, respectively. (p->father can be replaced with

809 * p->real_parent->pid)

810 */

811

/ *

* 부모 프로세스, 가장 어린 자녀, 더 어린 형제 자매

* 더 오래된 형제 자매. (p-> 아버지는

* p-> real_parent-> pid)

* /

 

812 /* Real parent process: */

/ * 실제 상위 프로세스 : * /

813 struct task_struct __rcu *real_parent;

814

 

815 /* Recipient of SIGCHLD, wait4() reports: */

/ * SIGCHLD의 수신자, wait4 () 보고서 : * /

816 struct task_struct __rcu *parent;

817

real_parentparent의 차이점

우선 두 가지의 정의를 내립니다.

real_parent의 경우는 자신을 생성한 부모 프로세스의 태스크 디스크립터 주소를 저장해줍니다.

parent의 경우는 부모 프로세스의 태스크 디스크립터 주소를 담고 있습니다.

둘은 일반적인 상황에서는 자신을 생성한 부모 즉 부모의 부모가(할아버지 뻘)의 프로세스가 종료되지 않고 계속 실행중일 때는 둘의 차이점은 없지만 real_paren의 경우는 현재 태스크를 생성한 즉 현 상황에 생성된 부모 태스크의 구조체를 가르키며 parent의 경우는 현재(실시간의 조건이없는) 부모 태스크의 구조체를 가르키는 것으로 알고 있습니다.

818 /*

819 * Children/sibling form the list of natural children:

820 */

/ *

* 어린이 / 형제 : 자연 어린이 목록 :

* /

821 struct list_head children;

822 struct list_head sibling;

823 struct task_struct *group_leader;

824

childrensibling의 차이점

위와 동일하게 정의부터 우선 내린다면

children(자식)의 경우 부모 프로세스가 자식 프로세스를 생성할 때 연결 리스트에 자식 프로세스를 등록해줍니다.

sibling(형제)의 경우는 같은 부모 프로세스로 생성된 프로세스를 연결 리스트 주소를 저장해줍니다. 둘의 차의점은 같은 부모를 가지고 있는 형제(sibling)와 다른 부모를 가지고 있어도 같은 자녀로 들어갈 수 있는children이 있는데 2020-04-30현 시점에서 엄청난 화재성을 가지고 있는 부부의 세계를 예로 들겠습니다. 부부의 세계에서 이태오라는 인물과 여다경이라는 인물이 바람이 나서 재혼한 상황입니다. 재혼 전에는 지선우라는 인물의 자식인 이준영이라는 인물이 있었습니다. 이 때 이태오와 여다경 사이에 아이가 생깁니다. 재혼 전 이태오와 지선우의 아이인 이준영이 있으며 이준영과 재혼 후 생긴 아이는 서로 부모가 다릅니다. 즉 자식 프로세스는 성립이 되지만 형제 프로세스가 성립이 되지 않는 것입니다. 같은 부모를 가지고 있는 경우에만 형제 프로세스라는 개념을 성립할 수 있습니다. 만약에라도 이태오와 지선우 사이에서 다른 또 하나의 자식 프로세스가 나온다면 이 프로세스와 이준영이라는 인물의 자식 프로세스는 형제 프로세스를 성립하게 됩니다. 같은 부모사이에서 연결 리스트가 적용이 되며 둘 이상의 프로세스를 가져올 때 sibling(형제) 프로세스를 확인이 가능하며 재혼한 이태오와 여다경의 자식이 된 이준영(자식)프로세스의 경우는 이태오와 여다경 사이에 생긴 children(자식)sibling(형제)가 될 수 없는 차이점이 있습니다.

825 /*

826 * 'ptraced' is the list of tasks this task is using ptrace() on.

827 *

828 * This includes both natural children and PTRACE_ATTACH targets.

829 * 'ptrace_entry' is this task's link on the p->parent->ptraced list.

830 */

/ *

* 'ptraced'는이 작업에서 ptrace ()를 사용하는 작업 목록입니다.

*

* 여기에는 자연 하위 항목과 PTRACE_ATTACH 대상이 포함됩니다.

* 'ptrace_entry'p-> parent-> ptraced 목록에있는이 작업의 링크입니다.

* /

831 struct list_head ptraced;

832 struct list_head ptrace_entry;

833

 

834 /* PID/PID hash table linkage. */

/ * PID / PID 해시 테이블 연결. * /

835 struct pid *thread_pid;

836 struct hlist_node pid_links[PIDTYPE_MAX];

837 struct list_head thread_group;

838 struct list_head thread_node;

839

 

840 struct completion *vfork_done;

841

 

842 /* CLONE_CHILD_SETTID: */

843 int __user *set_child_tid;

844

 

845 /* CLONE_CHILD_CLEARTID: */

846 int __user *clear_child_tid;

847

 

848 u64 utime;

849 u64 stime;

850 #ifdef CONFIG_ARCH_HAS_SCALED_CPUTIME

851 u64 utimescaled;

852 u64 stimescaled;

853 #endif

854 u64 gtime;

855 struct prev_cputime prev_cputime;

856 #ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN

857 struct vtime vtime;

858 #endif

859

 

860 #ifdef CONFIG_NO_HZ_FULL /*CPU가 작업을 실행하는 경우에도 가능하면 항상 틱을 종료하십시오. 일반적으로 CPU에서 단일 작업을 실행해야합니다. 작업이 대부분 사용자 공간에서 실행되고 커널 활동이 거의없는 경우 틱리스 실행 가능성이 최대화됩니다.*/

861 atomic_t tick_dep_mask;

862 #endif

863 /* Context switch counts: */

/ * 컨텍스트 스위치 수 : * /

864 unsigned long nvcsw;

865 unsigned long nivcsw;

866

 

867 /* Monotonic time in nsecs: */

/ * 단조 시간 () : * /

868 u64 start_time;

869

 

870 /* Boot based time in nsecs: */

/ * 부팅 기반 시간 () : * /

871 u64 start_boottime;

872

 

873 /* MM fault and swap info: this can arguably be seen as either mm-specific or thread-specific: */

/ * MM 오류 및 스왑 정보 : 이는 mm 또는 스레드 특정으로 볼 수 있습니다. * /

874 unsigned long min_flt;

875 unsigned long maj_flt;

876

 

877 /* Empty if CONFIG_POSIX_CPUTIMERS=n */

/ * CONFIG_POSIX_CPUTIMERS = n 이면 비어 있음*/

878 struct posix_cputimers posix_cputimers;

879

 

880 /* Process credentials: */

/ * 프로세스 자격 증명 : * /

881

 

882 /* Tracer's credentials at attach: */

/ * 첨부시 추적 프로그램의 자격 증명 : * /

883 const struct cred __rcu *ptracer_cred;

884

 

885 /* Objective and real subjective task credentials (COW): */

/ * 객관적이고 실제 주관적인 작업 자격 증명 (COW) : * /

886 const struct cred __rcu *real_cred;

887

 

888 /* Effective (overridable) subjective task credentials (COW): */

/ * 효과적인 (재정의 가능한) 주관적인 작업 자격 증명 (COW) : * /

889 const struct cred __rcu *cred;

890

 

891 #ifdef CONFIG_KEYS /*커널에 인증 토큰 및 액세스 키를 유지하는 기능을 지원합니다.*/

892 /* Cached requested key. */

/ * 캐시 된 요청 된 키. * /

893 struct key *cached_requested_key;

894 #endif

895

 

896 /*

897 * executable name, excluding path.

898 *

899 * - normally initialized setup_new_exec()

900 * - access it with [gs]et_task_comm()

901 * - lock it with task_lock()

902 */

/ *

* 경로를 제외한 실행 파일 이름.

*

*-정상적으로 초기화 된 setup_new_exec ()

*-[gs] et_task_comm ()으로 액세스

*-task_lock ()으로 잠그십시오.

* /

903 char comm[TASK_COMM_LEN];

904

 

905 struct nameidata *nameidata;

906

 

907 #ifdef CONFIG_SYSVIPC /* 프로세스 간 통신은 프로세스 (프로그램 실행)가 정보를 동기화하고 교환 할 수 있도록하는 라이브러리 함수 및 시스템 호출 스위트입니다. */

908 struct sysv_sem sysvsem;

909 struct sysv_shm sysvshm;

910 #endif

911 #ifdef CONFIG_DETECT_HUNG_TASK /*커널이 "중지 된 작업"을 감지 할 수 있게 하려면 Y라고 말해야하며, 이 작업은 작업이 중단되지 않는 "D"상태로 무기한 중단되는 버그입니다. 중단 된 작업이 감지되면 커널은 현재 스택 추적 (인쇄해야 함)을 인쇄하지만 작업은 중단 불가능한 상태로 유지됩니다.*/

912 unsigned long last_switch_count;

913 unsigned long last_switch_time;

914 #endif

915 /* Filesystem information: */

/ * 파일 시스템 정보 : * /

916 struct fs_struct *fs;

917

 

918 /* Open file information: */

/ * 열린 파일 정보 : * /

919 struct files_struct *files;

920

 

921 /* Namespaces: */

/ * 네임 스페이스 : * /

922 struct nsproxy *nsproxy;

923

 

924 /* Signal handlers: */

/ * 신호 처리기 : * /

925 struct signal_struct *signal;

926 struct sighand_struct __rcu *sighand;

927 sigset_t blocked;

928 sigset_t real_blocked;

929 /* Restored if set_restore_sigmask() was used: */

/ * set_restore_sigmask ()가 사용 된 경우 복원 : * /

930 sigset_t saved_sigmask;

931 struct sigpending pending;

932 unsigned long sas_ss_sp;

933 size_t sas_ss_size;

934 unsigned int sas_ss_flags;

935

 

936 struct callback_head *task_works;

937

 

938 #ifdef CONFIG_AUDIT /* SELinux와 같은 다른 커널 하위 시스템과 함께 사용할 수있는 감사 인프라를 활성화합니다 (avc 메시지 출력 로깅에 필요). 시스템 호출 감사는이를 지원하는 아키텍처에 포함되어 있습니다.*/

939 #ifdef CONFIG_AUDITSYSCALL /* 독립적으로 사용하거나 SELinux와 같은 다른 커널 하위 시스템과 함께 사용할 수있는 오버 헤드가 적은 시스템 호출 감사 인프라를 활성화합니다.*/

940 struct audit_context *audit_context;

941 #endif

942 kuid_t loginuid;

943 unsigned int sessionid;

944 #endif

945 struct seccomp seccomp;

946

 

947 /* Thread group tracking: */

/ * 스레드 그룹 추적 : * /

948 u64 parent_exec_id;

949 u64 self_exec_id;

950

 

951 /* Protection against (de-)allocation: mm, files, fs, tty, keyrings, mems_allowed, mempolicy: */

/ * (할당 해제) 방지 : mm, 파일, fs, tty, 키링, mems_allowed, mempolicy : * /

952 spinlock_t alloc_lock;

953

 

954 /* Protection of the PI data structures: */

/ * PI 데이터 구조의 보호 : * /

955 raw_spinlock_t pi_lock;

956

 

957 struct wake_q_node wake_q;

958

 

959 #ifdef CONFIG_RT_MUTEXES

960 /* PI waiters blocked on a rt_mutex held by this task: */

/ * PI 대기자가이 작업에서 보유한 rt_mutex에서 차단되었습니다. * /

961 struct rb_root_cached pi_waiters;

962 /* Updated under owner's pi_lock and rq lock */

/ * 소유자의 pi_lock rq 잠금으로 업데이트 * /

963 struct task_struct *pi_top_task;

964 /* Deadlock detection and priority inheritance handling: */

/ * 교착 상태 감지 및 우선 순위 상속 처리 : * /

965 struct rt_mutex_waiter *pi_blocked_on;

966 #endif

967

 

968 #ifdef CONFIG_DEBUG_MUTEXES /* 이 기능 활성화시 뮤텍스 시맨틱 위반을 감지하고보고 할 수 있습니다. */

969 /* Mutex deadlock detection: */

/ * 뮤텍스 교착 상태 감지 : * /

970 struct mutex_waiter *blocked_on;

971 #endif

972

 

973 #ifdef CONFIG_DEBUG_ATOMIC_SLEEP /*여기서 Y/NY를 선택하면 원자 섹션 내부에서 호출되면 잠자기 할 수 있는 다양한 루틴이 시끄럽게 됩니다. 스핀 록이 개최 될 때, rcu 읽기 측 중요 섹션 내부, 선점 비활성화 섹션 내부, 인터럽트 내부 등을 의미합니다.*/

974 int non_block_count;

975 #endif

976

 

977 #ifdef CONFIG_TRACE_IRQFLAGS

978 unsigned int irq_events;

979 unsigned int hardirq_threaded;

980 unsigned long hardirq_enable_ip;

981 unsigned long hardirq_disable_ip;

982 unsigned int hardirq_enable_event;

983 unsigned int hardirq_disable_event;

984 int hardirqs_enabled;

985 int hardirq_context;

986 unsigned long softirq_disable_ip;

987 unsigned long softirq_enable_ip;

988 unsigned int softirq_disable_event;

989 unsigned int softirq_enable_event;

990 int softirqs_enabled;

991 int softirq_context;

992 int irq_config;

993 #endif

994

 

995 #ifdef CONFIG_LOCKDEP

996 # define MAX_LOCK_DEPTH 48UL

997 u64 curr_chain_key;

998 int lockdep_depth;

999 unsigned int lockdep_recursion;

1000 struct held_lock held_locks[MAX_LOCK_DEPTH];

1001 #endif

1002

 

1003 #ifdef CONFIG_UBSAN /* 정의되지 않은 동작 상태 검사기를 활성화합니다. 또한 정의되지 않은 다양한 동작 감지에도 사용이 됩니다.*/

1004 unsigned int in_ubsan;

1005 #endif

1006

 

1007 /* Journalling filesystem info: */

/ * 저널링 파일 시스템 정보 : * /

1008 void *journal_info;

1009

 

1010 /* Stacked block device info: */

/ * 스택 블록 장치 정보 : * /

1011 struct bio_list *bio_list;

1012

 

1013 #ifdef CONFIG_BLOCK /* 커널에서 블록 계층 지원을 제거하려면 옵션을 비활성화 해야 하지만 임베디드 장치에 유용 할 수 있으며 이 기능을 비활성 하면 차단 장치 파일을 사용할 수 없게 됩니다 일부 파일 시스템등 사용 불가능*/

1014 /* Stack plugging: */

/ * 스택 연결 : * /

1015 struct blk_plug *plug;

1016 #endif

1017

 

1018 /* VM state: */

/ * VM 상태 : * /

1019 struct reclaim_state *reclaim_state;

1020

 

1021 struct backing_dev_info *backing_dev_info;

1022

 

1023 struct io_context *io_context;

1024

 

1025 #ifdef CONFIG_COMPACTION /* 압축은 고차 (큰 물리적으로 인접한) 메모리 블록을 안정적으로 형성하는 유일한 메모리 관리 구성 요소입니다. */

1026 struct capture_control *capture_control;

1027 #endif

1028 /* Ptrace state: */

/ * Ptrace 상태 : * /

1029 unsigned long ptrace_message;

1030 kernel_siginfo_t *last_siginfo;

1031

 

1032 struct task_io_accounting ioac;

1033 #ifdef CONFIG_PSI /* 커널은 압력 통계 파일 cpu, memory io/ proc / pressure /를 만듭니다.*/

1034 /* Pressure stall state */

/ * 압력 스톨 상태 * /

1035 unsigned int psi_flags;

1036 #endif

1037 #ifdef CONFIG_TASK_XACCT

1038 /* Accumulated RSS usage: */

/ * 누적 RSS 사용량 : * /

1039 u64 acct_rss_mem1;

1040 /* Accumulated virtual memory usage: */

/ * 누적 가상 메모리 사용량 : * /

1041 u64 acct_vm_mem1;

1042 /* stime + utime since last update: */

/ * stime + 마지막 업데이트 이후의 utime : * /

1043 u64 acct_timexpd;

1044 #endif

1045 #ifdef CONFIG_CPUSETS /* 활성화시키면 시스템을 CPU 및 메모리 노드 세트로 동적으로 파티셔닝하고 해당 세트 내에서만 실행되도록 태스크를 지정할 수있는 CPUSET을 작성하고 관리 할 수 ​​있습니다. */

1046 /* Protected by ->alloc_lock: */

/ * 보호-> alloc_lock : * /

1047 nodemask_t mems_allowed;

1048 /* Seqence number to catch updates: */

/ * 업데이트를 잡을 Seqence 번호 : * /

1049 seqcount_t mems_allowed_seq;

1050 int cpuset_mem_spread_rotor;

1051 int cpuset_slab_spread_rotor;

1052 #endif

1053 #ifdef CONFIG_CGROUPS /* Cpusets, CFS, 메모리 제어 또는 장치 격리와 같은 프로세스 제어 서브 시스템과 함께 사용하기 위해 프로세스 세트 그룹화에 대한 지원을 추가합니다.*/

1054 /* Control Group info protected by css_set_lock: */

/ * css_set_lock으로 보호되는 제어 그룹 정보 : * /

1055 struct css_set __rcu *cgroups;

1056 /* cg_list protected by css_set_lock and tsk->alloc_lock: */

/ * css_set_lock tsk-> alloc_lock으로 보호되는 cg_list : * /

1057 struct list_head cg_list;

1058 #endif

1059 #ifdef CONFIG_X86_CPU_RESCTRL /* x86 CPU 리소스 제어 지원을 활성화합니다. CPU에 의한 시스템 리소스 사용량의 할당 및 모니터링을 지원합니다. */

1060 u32 closid;

1061 u32 rmid;

1062 #endif

1063 #ifdef CONFIG_FUTEX /*비활성화하면 "빠른 사용자 공간 뮤텍스"를 지원하지 않고 커널이 구축됩니다.*/

1064 struct robust_list_head __user *robust_list;

1065 #ifdef CONFIG_COMPAT

1066 struct compat_robust_list_head __user *compat_robust_list;

1067 #endif

1068 struct list_head pi_state_list;

1069 struct futex_pi_state *pi_state_cache;

1070 struct mutex futex_exit_mutex;

1071 unsigned int futex_state;

1072 #endif

1073 #ifdef CONFIG_PERF_EVENTS /* 소프트웨어 및 하드웨어가 제공하는 다양한 성능 이벤트에 대한 커널 지원을 활성화합니다. 소프트웨어 이벤트는 내장 또는 일반 추적 점 사용을 통해 지원됩니다. Linux 성능 이벤트 서브 시스템은 시스템 호출을 통해 사용 가능하고 tools / perf /"perf"유틸리티가 사용하는 이러한 소프트웨어 및 하드웨어 이벤트 기능의 추상화를 제공합니다. 또한 작업 및 CPU ᅟᅡᆿ운터를 제공하며, 그 위에 이벤트 기능 또한 제공해줍니다.*/

1074 struct perf_event_context *perf_event_ctxp[perf_nr_task_contexts];

1075 struct mutex perf_event_mutex;

1076 struct list_head perf_event_list;

1077 #endif

1078 #ifdef CONFIG_DEBUG_PREEMPT /* 활성화시 커널은 일반적으로 사용되는 smp_processor_id () 함수의 디버그 변형을 사용하며 커널 코드가 선점 안전하지 않은 방식으로 이를 사용하면 경고를 인쇄합니다. */

1079 unsigned long preempt_disable_ip;

1080 #endif

1081 #ifdef CONFIG_NUMA /* Non-Uniform Memory Access 커널은 CPU가 사용하는 메모리를 CPU의 로컬 메모리 컨트롤러에 할당하고 커널에 NUMA 인식을 더 추가합니다. */

1082 /* Protected by alloc_lock: */

/ * alloc_lock으로 보호 : * /

1083 struct mempolicy *mempolicy;

1084 short il_prev;

1085 short pref_node_fork;

1086 #endif

1087 #ifdef CONFIG_NUMA_BALANCING /* 이 옵션은 자동 NUMA 인식 메모리 / 작업 배치를 지원합니다. */

1088 int numa_scan_seq;

1089 unsigned int numa_scan_period;

1090 unsigned int numa_scan_period_max;

1091 int numa_preferred_nid;

1092 unsigned long numa_migrate_retry;

1093 /* Migration stamp: */

/ * 마이그레이션 스탬프 : * /

1094 u64 node_stamp;

1095 u64 last_task_numa_placement;

1096 u64 last_sum_exec_runtime;

1097 struct callback_head numa_work;

1098

 

1099 /*

1100 * This pointer is only modified for current in syscall and

1101 * pagefault context (and for tasks being destroyed), so it can be read

1102 * from any of the following contexts:

1103 * - RCU read-side critical section

1104 * - current->numa_group from everywhere

1105 * - task's runqueue locked, task not running

1106 */

/ *

*이 포인터는 syscall

* pagefault 컨텍스트 및 작업이 파괴되어 읽을 수 있습니다.

* 다음 컨텍스트 중 하나에서 :

*-RCU 읽기 측 중요 섹션

*-어디서나 현재-> numa_group

*-작업의 Runqueue가 잠겨 있고 작업이 실행되지 않습니다

* /

 

1107 struct numa_group __rcu *numa_group;

1108

 

1109 /*

1110 * numa_faults is an array split into four regions:

1111 * faults_memory, faults_cpu, faults_memory_buffer, faults_cpu_buffer

1112 * in this precise order.

1113 *

1114 * faults_memory: Exponential decaying average of faults on a per-node

1115 * basis. Scheduling placement decisions are made based on these

1116 * counts. The values remain static for the duration of a PTE scan.

1117 * faults_cpu: Track the nodes the process was running on when a NUMA

1118 * hinting fault was incurred.

1119 * faults_memory_buffer and faults_cpu_buffer: Record faults per node

1120 * during the current scan window. When the scan completes, the counts

1121 * in faults_memory and faults_cpu decay and these values are copied.

1122 */

/ *

numa_faults4 개의 영역으로 분할 된 배열입니다.

* faults_memory, faults_cpu, faults_memory_buffer, faults_cpu_buffer

*이 정확한 순서로.

*

* faults_memory : 노드 당 지수 붕괴 평균 고장

* 기초. 배치 배치 결정은 다음을 기반으로 이루어집니다.

* 카운트. PTE 스캔 기간 동안 값은 정적으로 유지됩니다.

* faults_cpu : NUMA 일 때 프로세스가 실행되고 있던 노드를 추적

* 힌트 오류가 발생했습니다.

* faults_memory_buffer faults_cpu_buffer : 노드 당 레코드 결함

* 현재 스캔 창 동안. 스캔이 완료되면 카운트

* faults_memory faults_cpu에서 소멸되며이 값이 복사됩니다.

* /

1123 unsigned long *numa_faults;

1124 unsigned long total_numa_faults;

1125

 

1126 /*

1127 * numa_faults_locality tracks if faults recorded during the last

1128 * scan window were remote/local or failed to migrate. The task scan

1129 * period is adapted based on the locality of the faults with different

1130 * weights depending on whether they were shared or private faults

1131 */

/ *

* numa_faults_locality는 마지막 동안 오류가 기록되었는지 추적

* 스캔 창이 원격 / 로컬이거나 마이그레이션에 실패했습니다. 작업 스캔

* 기간은 다른 결함의 위치에 따라 조정됩니다

* 공유 결함인지 개인 결함인지에 따라 가중치

* /

1132 unsigned long numa_faults_locality[3];

1133

 

1134 unsigned long numa_pages_migrated;

1135 #endif /* CONFIG_NUMA_BALANCING */

1136

 

1137 #ifdef CONFIG_RSEQ /* 현재 CPU 번호 값에 대한 사용자 공간 캐시를 제공하여 사용자 공간에서 현재 CPU 번호를 얻는 속도를 높이고 CPU 당 데이터에 대한 사용자 공간 작업 속도를 높이는 ABI를 제공합니다.*/

1138 struct rseq __user *rseq;

1139 u32 rseq_sig;

1140 /*

1141 * RmW on rseq_event_mask must be performed atomically

1142 * with respect to preemption.

1143 */

/ *

rseq_event_maskRmW는 원자 적으로 수행되어야합니다.

* 선점과 관련하여.

* /

1144 unsigned long rseq_event_mask;

1145 #endif

1146

 

1147 struct tlbflush_unmap_batch tlb_ubc;

1148

 

1149 union {

1150 refcount_t rcu_users;

1151 struct rcu_head rcu;

1152 };

1153

 

1154 /* Cache last used pipe for splice(): */

/ * splice ()에 마지막으로 사용한 파이프 캐시 : * /

1155 struct pipe_inode_info *splice_pipe;

1156

 

1157 struct page_frag task_frag;

1158

 

1159 #ifdef CONFIG_TASK_DELAY_ACCT /* CPU, 동기식 블록 I / O 완료 및 페이지 스왑과 같은 시스템 리소스를 기다리는 작업에서 소비 한 시간에 대한 정보를 수집합니다.*/

1160 struct task_delay_info *delays;

1161 #endif

1162

 

1163 #ifdef CONFIG_FAULT_INJECTION

1164 int make_it_fail;

1165 unsigned int fail_nth;

1166 #endif

1167 /*

1168 * When (nr_dirtied >= nr_dirtied_pause), it's time to call

1169 * balance_dirty_pages() for a dirty throttling pause:

1170 */

/ *

* (nr_dirtied> = nr_dirtied_pause) 일 때, 전화 할 시간

더티 스로틀 링 일시 정지에 대한 balance_dirty_pages () :

* /

1171 int nr_dirtied;

1172 int nr_dirtied_pause;

1173 /* Start of a write-and-pause period: */

/ * 쓰기 및 일시 중지 기간 시작 : * /

1174 unsigned long dirty_paused_when;

1175

 

1176 #ifdef CONFIG_LATENCYTOP /* LatencyTOP 도구를 사용하여 어떤 커널 작업에서 어떤 사용자 공간이 차단되는지 확인할 때 이 선언문이 들어갑니다.*/

1177 int latency_record_count;

1178 struct latency_record latency_record[LT_SAVECOUNT];

1179 #endif

1180 /*

1181 * Time slack values; these are used to round up poll() and

1182 * select() etc timeout values. These are in nanoseconds.

1183 */

/ *

* 시간 여유 값; 이들은 poll ()을 반올림하는 데 사용되며

* select () 등의 타임 아웃 값. 이것들은 나노초입니다.

* /

1184 u64 timer_slack_ns;

1185 u64 default_timer_slack_ns;

1186

 

1187 #ifdef CONFIG_KASAN /* KASAN (KernelAddressSANitizer) (런타임 메모리 디버거)을 사용하여 범위를 벗어난 액세스 및 사후 사용 가능 버그를 찾도록 설계합니다.*/

1188 unsigned int kasan_depth;

1189 #endif

1190

 

1191 #ifdef CONFIG_FUNCTION_GRAPH_TRACER /* 이 함수 선언의 목적은 함수의 지속 시간을 추적하고 반환 값과 같은 정보를 사용하여 각 스레드에 대한 호출 그래프를 그리는 것입니다*/

1192 /* Index of current stored address in ret_stack: */

/ * ret_stack에 현재 저장된 주소의 인덱스 : * /

1193 int curr_ret_stack;

1194 int curr_ret_depth;

1195

 

1196 /* Stack of return addresses for return function tracing: */

/ * 리턴 함수 추적을위한 리턴 주소 스택 : * /

1197 struct ftrace_ret_stack *ret_stack;

1198

 

1199 /* Timestamp for last schedule: */

/ * 마지막 일정의 타임 스탬프 : * /

1200 unsigned long long ftrace_timestamp;

1201

 

1202 /*

1203 * Number of functions that haven't been traced

1204 * because of depth overrun:

1205 */

/ *

* 추적되지 않은 기능의 수

* 깊이 오버런으로 인해 :

* /

1206 atomic_t trace_overrun;

1207

 

1208 /* Pause tracing: */

/ * 일시 중지 추적 : * /

1209 atomic_t tracing_graph_pause;

1210 #endif

1211

 

1212 #ifdef CONFIG_TRACING

1213 /* State flags for use by tracers: */

/ * 추적 프로그램에서 사용하기위한 상태 플래그 : * /

1214 unsigned long trace;

1215

 

1216 /* Bitmask and counter of trace recursion: */

/ * 비트 마스크 및 추적 재귀 카운터 : * /

1217 unsigned long trace_recursion;

1218 #endif /* CONFIG_TRACING */

1219

 

1220 #ifdef CONFIG_KCOV /* KCOV는 커버리지 유도 퍼지 (무작위 테스트)에 적합한 형식으로 커널 코드 커버리지 정보를 노출합니다.*/

1221 /* See kernel/kcov.c for more details. */

/ * 자세한 내용은 kernel / kcov.c를 참조하십시오. * /

1222

 

1223 /* Coverage collection mode enabled for this task (0 if disabled): */

/ *이 작업에 적용 범위 적용 모드 (사용하지 않는 경우 0) : * /

1224 unsigned int kcov_mode;

1225

 

1226 /* Size of the kcov_area: */

/ * kcov_area의 크기 : * /

1227 unsigned int kcov_size;

1228

 

1229 /* Buffer for coverage collection: */

/ * 적용 범위 수집을위한 버퍼 : * /

1230 void *kcov_area;

1231

 

1232 /* KCOV descriptor wired with this task or NULL: */

/ *이 작업과 연결된 KCOV 디스크립터 또는 NULL : * /

1233 struct kcov *kcov;

1234

 

1235 /* KCOV common handle for remote coverage collection: */

/ * 원격 적용 범위 수집을위한 KCOV 공통 핸들 : * /

1236 u64 kcov_handle;

1237

 

1238 /* KCOV sequence number: */

/ * KCOV 시퀀스 번호 : * /

1239 int kcov_sequence;

1240 #endif

1241

 

1242 #ifdef CONFIG_MEMCG /*cgroup에서 작업의 메모리 사용량을 제어합니다.*/

1243 struct mem_cgroup *memcg_in_oom;

1244 gfp_t memcg_oom_gfp_mask;

1245 int memcg_oom_order;

1246

 

1247 /* Number of pages to reclaim on returning to userland: */

/ * userland로 돌아올 때 회수 할 페이지 수 : * /

1248 unsigned int memcg_nr_pages_over_high;

1249

 

1250 /* Used by memcontrol for targeted memcg charge: */

/ * memcontrol에서 대상 memcg 청구에 사용 : * /

1251 struct mem_cgroup *active_memcg;

1252 #endif

1253

 

1254 #ifdef CONFIG_BLK_CGROUP

1255 struct request_queue *throttle_queue;

1256 #endif

1257

 

1258 #ifdef CONFIG_UPROBES /* Uprobeskprobes의 사용자 공간에 해당합니다.*/

1259 struct uprobe_task *utask;

1260 #endif

1261 #if defined(CONFIG_BCACHE) || defined(CONFIG_BCACHE_MODULE)

CONFIG_BCACHE = 블록 장치를 다른 장치의 캐시로 사용할 수 있습니다. 인덱싱에 btree를 사용하고 레이아웃은 SSD에 최적화되어 있습니다.

1262 unsigned int sequential_io;

1263 unsigned int sequential_io_avg;

1264 #endif

1265 #ifdef CONFIG_DEBUG_ATOMIC_SLEEP /*위에서 언급했습니다*/

1266 unsigned long task_state_change;

1267 #endif

1268 int pagefault_disabled;

1269 #ifdef CONFIG_MMU /*페이징 된 메모리 관리를 통해 MMU 기반 가상화 주소 공간 지원을 원하는 경우 선택해줍니다.*/

1270 struct task_struct *oom_reaper_list;

1271 #endif

1272 #ifdef CONFIG_VMAP_STACK /* 가드 페이지와 함께 가상 매핑 된 커널 스택을 사용하려면이 옵션을 활성화하십시오. 이로 인해 커널 스택 오버플로가 진단하기 어려운 손상이 아닌 즉시 잡히게됩니다.*/

1273 struct vm_struct *stack_vm_area;

1274 #endif

1275 #ifdef CONFIG_THREAD_INFO_IN_TASK

1276 /* A live task holds one reference: */

/ * 라이브 작업에는 하나의 참조가 있습니다 : * /

1277 refcount_t stack_refcount;

1278 #endif

1279 #ifdef CONFIG_LIVEPATCH /* 커널 "패치"모듈이이 옵션에서 제공하는 인터페이스를 사용하여 패치를 등록 할 때까지 런타임에 영향을 미치지 않으므로 패치 된 함수에 대한 호출이 패치 모듈에 포함 된 새로운 함수 코드로 리디렉션됩니다.*/

1280 int patch_state;

1281 #endif

1282 #ifdef CONFIG_SECURITY /* 이를 통해 커널에 구성 할 다른 보안 모듈을 선택할 수 있습니다. 이 옵션을 선택하지 않으면 기본 Linux 보안 모델이 사용됩니다. */

1283 /* Used by LSM modules for access restriction: */

/ * 액세스 제한을 위해 LSM 모듈에서 사용 : * /

1284 void *security;

1285 #endif

1286

 

1287 #ifdef CONFIG_GCC_PLUGIN_STACKLEAK /* 이 함수는 시스템 호출에서 돌아 오기 전에 커널이 커널 스택을 지우도록합니다. 이것은 스택을 초기화 된 포이즌 값으로 유지하는 효과가 있으며, 이는 민감한 스택 내용의 수명을 줄이고 초기화되지 않은 스택 변수 익스플로잇 또는 정보 노출의 가능성을 줄입니다 (이는 이전 기능과 동일한 스택 깊이에 도달하는 기능은 다루지 않습니다) 같은 시스템 콜). 이것은 초기화되지 않은 대부분의 스택 변수 공격을 차단하며, 함수 호출의 복잡성보다는 스택 사용의 깊이에 의해 성능에 영향을 미칩니다.*/

1288 unsigned long lowest_stack;

1289 unsigned long prev_lowest_stack;

1290 #endif

1291

 

1292 /*

1293 * New fields for task_struct should be added above here, so that

1294 * they are included in the randomized portion of task_struct.

1295 */

/ *

* task_struct의 새 필드가 여기 위에 추가되어야합니다.

* 이들은 task_struct의 무작위 부분에 포함됩니다.

* /

1296 randomized_struct_fields_end

1297

 

1298 /* CPU-specific state of this task: */

/ *이 작업의 CPU 별 상태 : * /

1299 struct thread_struct thread;

1300

 

1301 /*

1302 * WARNING: on x86, 'thread_struct' contains a variable-sized

1303 * structure. It *MUST* be at the end of 'task_struct'.

1304 *

1305 * Do not put anything below here!

1306 */

/ *

* 경고 : x86에서 'thread_struct'는 가변 크기를 포함합니다

* 구조. 'task_struct'의 끝에 * MUST * 있습니다.

*

* 여기에 아무것도 넣지 마십시오!

* /

1307 };

을 끝으로 프로세스 구조체에 대한 소스내용이 마무리 된 것으로 알고 있습니다.

반응형