On Thu, Apr 09, 2020 at 05:47:44PM +0300, Kirill A. Shutemov wrote: > On Thu, Apr 09, 2020 at 07:32:38AM -0700, Matthew Wilcox wrote: > > On Thu, Apr 09, 2020 at 05:28:51PM +0300, Kirill A. Shutemov wrote: > > > > We have a few places that do things like > > > > > > > > mm/filemap.c: if (unlikely(compound_head(page)->mapping != mapping)) { > > > > > > Good point. > > > > > > Acked-by: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx> > > > > Darn, I hoped you'd have a better idea. I feel quite ashamed of this patch. > > I had two ideas. Both awful. > > - Rename compound_head() to __compound_head() or something and make it > return void *. Then wrap it into a macro that would cast return type to > type of the argument. It would allow to regain *some* type safety. > > - Provide two implementations and use C11 _Generic() :P > (bump GCC version requirements first) I guess a reasonable modification would be to add typechecking to the macros: typecheck(const struct page *, page) Not sure though if it threats const vs non-const as compatible. -- Kirill A. Shutemov