* [tglx-devel:timers/posix 8/14] kernel/time/posix-timers.c:852 timer_wait_running() warn: inconsistent returns '&timer->it_lock'.
@ 2025-02-24 23:55 kernel test robot
0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2025-02-24 23:55 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Dan Carpenter
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: Thomas Gleixner <tglx@linutronix.de>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git timers/posix
head: 2f9ae35230ff61b3caa708359c745f375cf0c075
commit: 029c3a43aaca2ffc86a970704b469733b70fe88b [8/14] posix-timers: Rework timer removal
:::::: branch date: 17 hours ago
:::::: commit date: 24 hours ago
config: x86_64-randconfig-161-20250225 (https://download.01.org/0day-ci/archive/20250225/202502250737.fMTOUVfQ-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202502250737.fMTOUVfQ-lkp@intel.com/
smatch warnings:
kernel/time/posix-timers.c:852 timer_wait_running() warn: inconsistent returns '&timer->it_lock'.
vim +852 kernel/time/posix-timers.c
ec8f954a40da8c Thomas Gleixner 2019-08-02 800
0bee3b601b77db Frederic Weisbecker 2019-08-20 801 /*
7d990902664506 Thomas Gleixner 2023-04-25 802 * On PREEMPT_RT this prevents priority inversion and a potential livelock
7d990902664506 Thomas Gleixner 2023-04-25 803 * against the ksoftirqd thread in case that ksoftirqd gets preempted while
7d990902664506 Thomas Gleixner 2023-04-25 804 * executing a hrtimer callback.
7d990902664506 Thomas Gleixner 2023-04-25 805 *
7d990902664506 Thomas Gleixner 2023-04-25 806 * See the comments in hrtimer_cancel_wait_running(). For PREEMPT_RT=n this
7d990902664506 Thomas Gleixner 2023-04-25 807 * just results in a cpu_relax().
7d990902664506 Thomas Gleixner 2023-04-25 808 *
7d990902664506 Thomas Gleixner 2023-04-25 809 * For POSIX CPU timers with CONFIG_POSIX_CPU_TIMERS_TASK_WORK=n this is
7d990902664506 Thomas Gleixner 2023-04-25 810 * just a cpu_relax(). With CONFIG_POSIX_CPU_TIMERS_TASK_WORK=y this
7d990902664506 Thomas Gleixner 2023-04-25 811 * prevents spinning on an eventually scheduled out task and a livelock
7d990902664506 Thomas Gleixner 2023-04-25 812 * when the task which tries to delete or disarm the timer has preempted
7d990902664506 Thomas Gleixner 2023-04-25 813 * the task which runs the expiry in task work context.
0bee3b601b77db Frederic Weisbecker 2019-08-20 814 */
029c3a43aaca2f Thomas Gleixner 2025-02-20 815 static struct k_itimer *timer_wait_running(struct k_itimer *timer, unsigned long *flags,
029c3a43aaca2f Thomas Gleixner 2025-02-20 816 bool delete)
6945e5c2abe008 Thomas Gleixner 2019-07-31 817 {
ec8f954a40da8c Thomas Gleixner 2019-08-02 818 const struct k_clock *kc = READ_ONCE(timer->kclock);
6945e5c2abe008 Thomas Gleixner 2019-07-31 819 timer_t timer_id = READ_ONCE(timer->it_id);
6945e5c2abe008 Thomas Gleixner 2019-07-31 820
ec8f954a40da8c Thomas Gleixner 2019-08-02 821 /* Prevent kfree(timer) after dropping the lock */
ec8f954a40da8c Thomas Gleixner 2019-08-02 822 rcu_read_lock();
da7ae390d73a82 Thomas Gleixner 2025-02-20 823 spin_unlock_irqrestore(&timer->it_lock, *flags);
ec8f954a40da8c Thomas Gleixner 2019-08-02 824
f7abf14f0001a5 Thomas Gleixner 2023-04-17 825 /*
029c3a43aaca2f Thomas Gleixner 2025-02-20 826 * kc->timer_wait_running() might drop RCU lock. So @timer cannot
029c3a43aaca2f Thomas Gleixner 2025-02-20 827 * be touched anymore after the function returns, except when
029c3a43aaca2f Thomas Gleixner 2025-02-20 828 * @delete is true!
f7abf14f0001a5 Thomas Gleixner 2023-04-17 829 */
ec8f954a40da8c Thomas Gleixner 2019-08-02 830 if (!WARN_ON_ONCE(!kc->timer_wait_running))
ec8f954a40da8c Thomas Gleixner 2019-08-02 831 kc->timer_wait_running(timer);
ec8f954a40da8c Thomas Gleixner 2019-08-02 832
ec8f954a40da8c Thomas Gleixner 2019-08-02 833 rcu_read_unlock();
029c3a43aaca2f Thomas Gleixner 2025-02-20 834
029c3a43aaca2f Thomas Gleixner 2025-02-20 835 /*
029c3a43aaca2f Thomas Gleixner 2025-02-20 836 * On deletion the timer has been marked invalid before
029c3a43aaca2f Thomas Gleixner 2025-02-20 837 * timer_delete_hook() has been invoked. That means that the
029c3a43aaca2f Thomas Gleixner 2025-02-20 838 * current task is the only one which has access to the timer and
029c3a43aaca2f Thomas Gleixner 2025-02-20 839 * even after dropping timer::it_lock above, no other thread can
029c3a43aaca2f Thomas Gleixner 2025-02-20 840 * have accessed the timer.
029c3a43aaca2f Thomas Gleixner 2025-02-20 841 */
029c3a43aaca2f Thomas Gleixner 2025-02-20 842 if (delete) {
029c3a43aaca2f Thomas Gleixner 2025-02-20 843 spin_lock_irqsave(&timer->it_lock, *flags);
029c3a43aaca2f Thomas Gleixner 2025-02-20 844 return timer;
029c3a43aaca2f Thomas Gleixner 2025-02-20 845 }
029c3a43aaca2f Thomas Gleixner 2025-02-20 846
029c3a43aaca2f Thomas Gleixner 2025-02-20 847 /*
029c3a43aaca2f Thomas Gleixner 2025-02-20 848 * If invoked from timer_set() the timer could have been deleted
029c3a43aaca2f Thomas Gleixner 2025-02-20 849 * after dropping the lock. So in that case the timer needs to be
029c3a43aaca2f Thomas Gleixner 2025-02-20 850 * looked up and validated.
029c3a43aaca2f Thomas Gleixner 2025-02-20 851 */
6945e5c2abe008 Thomas Gleixner 2019-07-31 @852 return lock_timer(timer_id, flags);
6945e5c2abe008 Thomas Gleixner 2019-07-31 853 }
6945e5c2abe008 Thomas Gleixner 2019-07-31 854
:::::: The code at line 852 was first introduced by commit
:::::: 6945e5c2abe008302b20266248d6de95575311a8 posix-timers: Rework cancel retry loops
:::::: TO: Thomas Gleixner <tglx@linutronix.de>
:::::: CC: Thomas Gleixner <tglx@linutronix.de>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-02-24 23:56 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-24 23:55 [tglx-devel:timers/posix 8/14] kernel/time/posix-timers.c:852 timer_wait_running() warn: inconsistent returns '&timer->it_lock' kernel test robot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.