Change to linux/timer.h from 5.14.0-611.55.1 to 5.14.0-687.10.1

Getting a build error for the mhvtl virtual tape library project. Not sure how to chase this change to linux/timer.h. timer_pending code provided for context. 5.14.0-687.5.3.el9_8.x86_64 has:

#define timer_container_of(var, callback_timer, timer_fieldname)        \
        container_of(callback_timer, typeof(*var), timer_fieldname)

/**
 * timer_pending - is a timer pending?
 * @timer: the timer in question
 *
 * timer_pending will tell whether a given timer is currently pending,
 * or not. Callers must ensure serialization wrt. other operations done
 * to this timer, eg. interrupt contexts, or other CPUs on SMP.
 *
 * return value: 1 if the timer is pending, 0 if not.
 */
static inline int timer_pending(const struct timer_list * timer)
{
        return !hlist_unhashed_lockless(&timer->entry);
}


and linux/timer.h in 5.14.0-611.55.1.el9_7.0.3.x86_64 has:

#define from_timer(var, callback_timer, timer_fieldname) \
        container_of(callback_timer, typeof(*var), timer_fieldname)

/**
 * timer_pending - is a timer pending?
 * @timer: the timer in question
 *
 * timer_pending will tell whether a given timer is currently pending,
 * or not. Callers must ensure serialization wrt. other operations done
 * to this timer, eg. interrupt contexts, or other CPUs on SMP.
 *
 * return value: 1 if the timer is pending, 0 if not.
 */
static inline int timer_pending(const struct timer_list * timer)
{
        return !hlist_unhashed_lockless(&timer->entry);
}

The from_timer function still exists since simply pasting the from_timer definition from 611.55.1 into timer.h for 687.5.3 resolves the build error but doesn’t result in an unresolved external reference.

Thinking this should be resolved by the maintainer for linux/timer.h but not easy to tell where the change came from (Rocky, RH or the actual maintainer).

This is how it looks in RHEL9:

#define timer_container_of(var, callback_timer, timer_fieldname)        \
        container_of(callback_timer, typeof(*var), timer_fieldname)

/**
 * timer_pending - is a timer pending?
 * @timer: the timer in question
 *
 * timer_pending will tell whether a given timer is currently pending,
 * or not. Callers must ensure serialization wrt. other operations done
 * to this timer, eg. interrupt contexts, or other CPUs on SMP.
 *
 * return value: 1 if the timer is pending, 0 if not.
 */
static inline int timer_pending(const struct timer_list * timer)
{
        return !hlist_unhashed_lockless(&timer->entry);
}

as far as I see it’s correct, therefore as Rocky is based on RHEL, then that is how it’s meant to be.

Perhaps the mhvtl tape library project should update their software to work with the new kernel?

I found your github issue: Build error with Red Hat kernel 5.14.0-687.10.1.el9_8.0.1.x86_64 · Issue #178 · markh794/mhvtl · GitHub

The guy there said it works on Alma, but he doesn’t even have the same kernel version. He is using 5.14.0-687.5.3 and not 5.14.0-687.10.1

The real question is, is the kernel actually the problem, or does he now need to adapt his driver/module to build with the new kernel features. I’d be interested to know if it builds on 6.x or even 7.x kernels. If not, then that would suggest his code needs updating to work with newer kernels. Easy enough to check, by testing on Rocky 10 (6.x) or Fedora 44 (has kernel 7.x).

Kernel 7.0.10 from Fedora 44:

#define timer_container_of(var, callback_timer, timer_fieldname)  \
container_of(callback_timer, typeof(*var), timer_fieldname)

/**
* timer_pending - is a timer pending?
* @timer: the timer in question
*
* timer_pending will tell whether a given timer is currently pending,
* or not. Callers must ensure serialization wrt. other operations done
* to this timer, eg. interrupt contexts, or other CPUs on SMP.
*
* Returns: 1 if the timer is pending, 0 if not.
*/
static inline int timer_pending(const struct timer_list * timer)

 return !hlist_unhashed_lockless(&timer->entry);
}

would suggest newer kernels are correct and he needs to adapt his driver/module to work with them.

Same here also: linux/include/linux/timer.h at master · torvalds/linux · GitHub and the commit that introduced the rename: treewide, timers: Rename from_timer() to timer_container_of() · torvalds/linux@41cb085 · GitHub

Kind of confirms the fact that they have to change their driver/module to work with newer kernels.

And Google Search AI results:

I expect once all those changes are made in their module, it will compile fine. Or they can make changes for it to support both old and new kernels with the suggested compatibility wrapper.

Obviously RH have backported it into 5.x kernels hence why it’s showing up. As backporting is normal for RH, then the module code needs updating to work with it.

That’s what I was looking for. Someone among the kernel folks decided to change the name of from_timer and change it to timer_container_of. Hopefully, this means that only the name changed and the functionality hasn’t changed.

I’ll pass the information back to the mhvtl folks and suggest a patch that changes the name of from_timer. Not sure how Mark tracks kernel changes like this that may affect the mhvtl code.

Thanks for your help on this. I’ll have to play with Google for this sort of search. Used it for finding solutions to error messages for years but not for tracking changes like this.

I don’t know how they communicated this change, but I can see that kernel module people must have known about it.
Rokcy 9.8 kernel

drivers/media/dvb-core/dmxdev.c
365c365,366
< 	struct dmxdev_filter *dmxdevfilter = from_timer(dmxdevfilter, t, timer);
---
> 	struct dmxdev_filter *dmxdevfilter = timer_container_of(dmxdevfilter, t, timer);

Found problem!! I was using an old version of config.sh that didn’t have thebackport logic. Pulled new copy and all is good.