简体   繁体   中英

how to add new fields to struct page in linux kernel

I would like to add a new field to struct page. This is for measuring the page usage statistics . However, the kernel fail to boot up once I add a new field. I feel that there are some compiler attributes that need to be set in order to modify the page struct. However , I could not find any documentation that describes this. Any pointers on this would be greatly appreciated. Thanks

I add an unsigned long into page struct in kernel 3.13 for ubuntu and 3.9 for Android 5.1.1. My experience is that you may want to put new field at the end of the page struct. I think it is because the relative offset is used somewhere. Very late answer. I wish it helps someone.

Looks like a bad idea to me.

struct page is very basic, and used (abused?) by different components in different ways for different pages. You'll need to understand a lot about this (more than I do) in order to successfully change it.

A safer way would be to allocate another array, also indexed by the page number, and use it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM