|
|
|
a volatile related bug in kernel/timer.c ? | |
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
|
Hi All,
currently, I am working on a private mips-like chip, and I came
across the following senario:
in the function "del_timer" in kernel/timer.c, there is the following code
954 if (timer_pending(timer)) {
955 base = lock_timer_base(timer, &flags);
956 if (timer_pending(timer)) {
suppose timer_pending(timer) check in line 954 is A, and in line 956 is B.
because the timer_pending(timer) check is very simple, so the result
may be saved in a register, and that register is reused
by both A and B. While this should be wrong? the check at B should
reload the value from memory instead of using previous
result kept in register, because lock_timer_base may have side-effect
which change the result of time_pending?
so I guess a barrier() is needed, so that the code should be the following?
if (timer_pending(timer)) {
base = lock_timer_base(timer, &flags);
barrier();
if (timer_pending(timer)) {
in my chip, the generated assembly is like the following:
( the function "lock_timer_base" in inlined also)
1017 del_timer:
1018 .set noreorder
1019 .set nomacro
1020
1021 lw $5,0($4)
1022 addu $3,$0,$0
1023 beq $5,$0,.L121 <=== $5 is the value of the
first "timer_pending(timer)"
1024 nop
1025
1026 lw $3,20($4)
1027 addiu $2,$0,-2
1028 and $6,$3,$2
1029 beq $6,$0,.L122
1030 nop
1031
1032 .L125:
1033 .set push ; .set opportunistic
1034 # 69 "include/asm/irqflags.h" 1
1035 __raw_local_irq_save $7
1036 # 0 "" 2
1037 .set pop
1038 addu $3,$0,$0
1039 beq $5,$0,.L124 <=== in the second check,
it's reused,
but
it should not, $5 should be updated from memory?
1040 nop
I am a compiler engineer, a newbie in kernel, please feel free to
point out if there is anything wrong
thanks very much
---
Warmest, regards,
WANG.Jiong
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Other Archives] [Linux Kernel Newbies] [Linux Driver Development] [Fedora Kernel] [Linux Kernel Testers] [Linux SH] [Linux Omap] [Linux Kbuild] [Linux Tape] [Linux Input] [Linux Kernel Janitors] [Linux Kernel Packagers] [Linux Doc] [Linux Man Pages] [Linux API] [Linux Memory Management] [Linux Modules] [Linux Standards] [Kernel Announce] [Netdev] [Git] [Linux PCI] Linux CAN Development [Linux I2C] [Linux RDMA] [Linux NUMA] [Netfilter] [Netfilter Devel] [SELinux] [Bugtraq] [FIO] [Linux Perf Users] [Linux Serial] [Linux PPP] [Linux ISDN] [Linux Next] [Kernel Stable Commits] [Linux Tip Commits] [Kernel MM Commits] [Linux Security Module] [AutoFS] [Filesystem Development] [Ext3 Filesystem] [Linux bcache] [Ext4 Filesystem] [Linux BTRFS] [Linux CEPH Filesystem] [Linux XFS] [XFS] [Linux NFS] [Linux CIFS] [Ecryptfs] [Linux NILFS] [Linux Cachefs] [Reiser FS] [Initramfs] [Linux FB Devel] [Linux OpenGL] [DRI Devel] [Fastboot] [Linux RT Users] [Linux RT Stable] [eCos] [Corosync] [Linux Clusters] [LVS Devel] [Hot Plug] [Linux Virtualization] [KVM] [KVM PPC] [KVM ia64] [Linux Containers] [Linux Hexagon] [Linux Cgroups] [Util Linux] [Wireless] [Linux Bluetooth] [Bluez Devel] [Ethernet Bridging] [Embedded Linux] [Barebox] [Linux MMC] [Linux IIO] [Sparse] [Smatch] [Linux Arch] [x86 Platform Driver] [Linux ACPI] [Linux IBM ACPI] [LM Sensors] [CPU Freq] [Linux Power Management] [Linmodems] [Linux DCCP] [Linux SCTP] [ALSA Devel] [Linux USB] [Linux PA RISC] [Linux Samsung SOC] [MIPS Linux] [IBM S/390 Linux] [ARM Linux] [ARM Kernel] [ARM MSM] [Tegra Devel] [Sparc Linux] [Linux Security] [Linux Sound] [Linux Media] [Video 4 Linux] [Linux IRDA Users] [Linux for the blind] [Linux RAID] [Linux ATA RAID] [Device Mapper] [Linux SCSI] [SCSI Target Devel] [Linux SCSI Target Infrastructure] [Linux IDE] [Linux SMP] [Linux AXP] [Linux Alpha] [Linux M68K] [Linux ia64] [Linux 8086] [Linux x86_64] [Linux Config] [Linux Apps] [Linux MSDOS] [Linux X.25] [Linux Crypto] [DM Crypt] [Linux Trace Users] [Linux Btrace] [Linux Watchdog] [Utrace Devel] [Linux C Programming] [Linux Assembly] [Dash] [DWARVES] [Hail Devel] [Linux Kernel Debugger] [Linux gcc] [Gcc Help] [X.Org] [Wine]
![]() |
![]() |
[Older Kernel Discussion] [Yosemite National Park Forum] [Large Format Photos] [Gimp] [Yosemite Photos] [Stuff]