Re: [PATCH v2 28/39] timekeeping: Fix a circular include dependency
From: Nick Desaulniers <hidden>
Date: 2023-10-27 15:28:24
Also in:
cgroups, linux-doc, linux-fsdevel, linux-iommu
On Thu, Oct 26, 2023 at 11:35 PM Arnd Bergmann [off-list ref] wrote:
On Fri, Oct 27, 2023, at 01:54, Kent Overstreet wrote:quoted
On Fri, Oct 27, 2023 at 01:05:48AM +0200, Thomas Gleixner wrote:quoted
On Thu, Oct 26 2023 at 18:33, Suren Baghdasaryan wrote:quoted
On Wed, Oct 25, 2023 at 5:33 PM Thomas Gleixner [off-list ref] wrote:quoted
quoted
This avoids a circular header dependency in an upcoming patch by only making hrtimer.h depend on percpu-defs.hWhat's the actual dependency problem?Sorry for the delay. When we instrument per-cpu allocations in [1] we need to include sched.h in percpu.h to be able to use alloc_tag_save(). sched.hIncluding sched.h in percpu.h is fundamentally wrong as sched.h is the initial place of all header recursions. There is a reason why a lot of funtionalitiy has been split out of sched.h into seperate headers over time in order to avoid that.Yeah, it's definitely unfortunate. The issue here is that alloc_tag_save() needs task_struct - we have to pull that in for alloc_tag_save() to be inline, which we really want. What if we moved task_struct to its own dedicated header? That might be good to do anyways...Yes, I agree that is the best way to handle it. I've prototyped a more thorough header cleanup with good results (much improved build speed) in the past, and most of the work to get there is to seperate out structures like task_struct, mm_struct, net_device, etc into headers that only depend on the embedded structure definitions without needing all the inline functions associated with them.
This is something I'll add to our automation todos which I plan to talk about at plumbers; I feel like it should be possible to write a script that given a header and identifier can split whatever declaration out into a new header, update the old header, then add the necessary includes for the newly created header to each dependent (optional). -- Thanks, ~Nick Desaulniers