Messages in this thread | | | Subject | Re: [RFC][PATCH 7/7] sched: Replace rq::wake_list | From | Guenter Roeck <> | Date | Fri, 5 Jun 2020 06:33:38 -0700 |
| |
On 6/5/20 1:10 AM, Peter Zijlstra wrote: > On Thu, Jun 04, 2020 at 07:18:37AM -0700, Guenter Roeck wrote: >> On Tue, May 26, 2020 at 06:11:04PM +0200, Peter Zijlstra wrote: > >>> + BUILD_BUG_ON(offsetof(struct task_struct, wake_entry_type) - offsetof(struct task_struct, wake_entry) != >>> + offsetof(struct __call_single_data, flags) - offsetof(struct __call_single_data, llist)); >>> + >> >> There is no guarantee in C that >> >> type1 a; >> type2 b; >> >> in two different data structures means that offsetof(b) - offsetof(a) >> is the same in both data structures unless attributes such as >> __attribute__((__packed__)) are used. > > Do tell more; the alignment requirements and size of the types remains > the same, this resulting in different layout is unlikely. >
I have not made the C standard. You point out yourself a possible explicit culprit: struct randomization. That by itself shows that you can not rely on two elements of different structures having the same alignment, which is pretty much exactly what I said (and may explain why observing the problem seemed to at least somewhat depend on the weather).
> I found this excellent quote on Hacker News this morning: > > "I think the attitude of compiler writers is a good reason to fix the > spec so they can't keep ratfucking developers trying to get work done." >
Qed.
Guenter
>> As result, this does and will cause a variety of build errors depending >> on the compiler version and compile flags. > > The only thing I can think of that's actually a problem is that retarded > struct randomization stuff. > > Anyway, I'll move cleaning it up a little higher on the todo list. >
| |