Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is the size of struct thread_info in linux-initialization-4? #306

Closed
spacewander opened this issue Dec 22, 2015 · 2 comments
Closed

Comments

@spacewander
Copy link
Contributor

In that chapter it says:

thread_info defined as:

struct thread_info {
        struct task_struct      *task;
        struct exec_domain      *exec_domain;
        __u32                   flags; 
        __u32                   status;
        __u32                   cpu;
        int                     saved_preempt_count;
        mm_segment_t            addr_limit;
        struct restart_block    restart_block;
        void __user             *sysenter_return;
        unsigned int            sig_on_uaccess_error:1;
        unsigned int            uaccess_err:1;
};

and occupies 52 bytes.

However, then it says:

The remaining thread_size will be 16 killobytes - 62 bytes = 16332 bytes.

At first I thought it as a typo. But, it seems that the size of thread_info is not less than 56 bytes whatever the size of struct restart_block is, because of memory alignment.
And its size can not be 62 bytes, again because of memory alignment. Its size should be the multiple of 8 bytes.

@hitmoon
Copy link
Contributor

hitmoon commented Jan 5, 2016

Actually in kernel 4.0.0(x86), there is no restart_block field in struct thread_info. Any way, the 62 bytes said above is not correct !

@0xAX
Copy link
Owner

0xAX commented Jan 28, 2016

Hello @spacewander and @hitmoon, you are right, there is error.

I'm using Linux kernel from master, and for me, the thread_info is 40 bytes size. It defined as:

struct thread_info {
    struct task_struct  *task;      /* main task structure */
    __u32           flags;      /* low level flags */
    __u32           status;     /* thread synchronous flags */
    __u32           cpu;        /* current CPU */
    mm_segment_t        addr_limit;
    unsigned int        sig_on_uaccess_error:1;
    unsigned int        uaccess_err:1;  /* uaccess failed */
};

Will fix it soon. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants