+ schedule_on_each_cpu-use-preempt_disable.patch added to -mm tree
[email protected]
tree noticeThe patch titled
schedule_on_each_cpu(): use preempt_disable()
has been added to the -mm tree. Its filename is
schedule_on_each_cpu-use-preempt_disable.patch
See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find out what to do about this
------------------------------------------------------
Subject: schedule_on_each_cpu(): use preempt_disable()
From: Andrew Morton <[email protected]>
We take workqueue_mutex in there to keep CPU hotplug away. But preempt_disable() will suffice for that.
---
kernel/workqueue.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/workqueue.c renamed from kernel/workqueue.c~schedule_on_each_cpu-use-preempt_disable +2 -2
@@ -635,13 +635,13 @@ int schedule_on_each_cpu(work_func_t funif (!works)return -ENOMEM ; -mutex_lock (&workqueue_mutex); +preempt_disable ();/* CPU hotplug */ for_each_online_cpu (cpu) {INIT_WORK (per_cpu_ptr (works, cpu), func);__queue_work (per_cpu_ptr (keventd_wq->cpu_wq, cpu),per_cpu_ptr (works, cpu)); } -mutex_unlock (&workqueue_mutex); +preempt_enable ();flush_workqueue (keventd_wq);free_percpu (works);return 0 ;
_
Patches currently in -mm which might be from [email protected] are
rtc-warning-fix.patch
fix-vm_events_fold_cpu-build-breakage-fix.patch
build-compileh-earlier.patch macintosh-mangle-caps-lock-events-on-adb-keyboards.patch
git-acpi.patch
git-acpi-cpufreq-fixup.patch
acpi-dont-select-pm.patch
implementation-of-acpi_video_get_next_level.patch video-sysfs-support-take-2-add-dev-argument-for-backlight_device_register.patch sony_apci-resume.patch
sony_apci-resume-fix.patch video-sysfs-support-take-2-add-dev-argument-for-backlight_device_register-sony_acpi-fix.patch git-alsa.patch
git-alsa-more-borkage.patch
alsa-workqueue-fixes.patch
arm-systemh-build-fix.patch
git-drm.patch
ia64-enable-config_debug_spinlock_sleep.patch infiniband-fix-for-gregkh-depredations.patch
git-libata-all.patch
pata_cs5530-suspend-resume-support-tweak.patch pata_sil680-suspend-resume-tidy.patch pata_via-suspend-resume-support-fix.patch
git-lxdialog-fixup.patch
git-mmc-fixup.patch
git-mmc-tifm_sd-warning-fix.patch
git-mtd.patch
git-ubi.patch ubi-versus-add-include-linux-freezerh-and-move-definitions-from.patch update-smc91x-driver-with-arm-versatile-board-info.patch driver-for-silan-sc92031-netdev-include-fix.patch driver-for-silan-sc92031-netdev-fix-more.patch drivers-net-ns83820c-add-paramter-to-disable-auto.patch
net-use-bitrev8.patch
net-uninline-skb_put.patch
ioat-warning-fix.patch
pci-legacy-resource-fix-tidy.patch
pci-disable-multithreaded-probing.patch drivers-scsi-mca_53c9xc-save_flags-cli-removal.patch scsi-in2000-scsi_cmnd-convertion.patch aic79xx-wrong-max-memory-at-driver-init.patch scsi-cover-up-bugs-fix-up-compiler-warnings-in-megaraid-driver-fix.patch git-qla3xxx-fixup.patch
funsoft-is-bust-on-sparc.patch
nokia-e70-is-an-unusual-device.patch fix-gregkh-usb-usb-ehci-hcd-add-shadow-budget-code.patch
git-wireless.patch
revert-i386-fix-the-verify_quirk_intel_irqbalance.patch revert-x86_64-mm-add-genapic_force.patch revert-x86_64-mm-fix-the-irqbalance-quirk-for-e7320-e7520-e7525.patch revert-x86_64-mm-copy-user-nocache.patch convert-i386-pda-code-to-use-%fs-fixes.patch add-memcpy_uncached_read-fix.patch
add-memcpy_uncached_read-tidy.patch
touchkit-ps-2-touchscreen-driver.patch virtual-memmap-on-sparsemem-v3-map-and-unmap-fix-2.patch virtual-memmap-on-sparsemem-v3-map-and-unmap-fix-3.patch lumpy-reclaim-v2-page_to_pfn-fix.patch
lumpy-reclaim-v2-tidy.patch
nfs-fix-nr_file_dirty-underflow-tidy.patch deprecate-smbfs-in-favour-of-cifs.patch drivers-add-lcd-support-3-Kconfig-fix.patch drivers-add-lcd-support-workqueue-fixups.patch ecryptfs-public-key-packet-management-slab-fix.patch add-retain_initrd-boot-option-tweak.patch
count_vm_events-warning-fix.patch procfs-fix-race-between-proc_readdir-and-remove_proc_entry-fix.patch gtod-persistent-clock-support-i386.patch
hrtimers-clean-up-locking.patch
hrtimers-add-state-tracking.patch
clockevents-i386-drivers.patch workqueue-dont-hold-workqueue_mutex-in-flush_scheduled_work.patch move-page-writeback-acounting-out-of-macros.patch per-backing_dev-dirty-and-writeback-page-accounting.patch ext2-reservations.patch edac-new-opteron-athlon64-memory-controller-driver.patch sched2-sched-domain-sysctl-use-ctl_unnumbered.patch mm-implement-swap-prefetching-use-ctl_unnumbered.patch swap_prefetch-vs-zoned-counters.patch add-include-linux-freezerh-and-move-definitions-from-prefetch.patch readahead-kconfig-options-fix.patch
readahead-minmax_ra_pages.patch
readahead-sysctl-parameters.patch readahead-sysctl-parameters-use-ctl_unnumbered.patch readahead-context-based-method-locking-fix.patch readahead-context-based-method-locking-fix-2.patch readahead-call-scheme-ifdef-fix.patch
readahead-call-scheme-build-fix.patch
readahead-nfsd-case-fix.patch make-copy_from_user_inatomic-not-zero-the-tail-on-i386-vs-reiser4.patch resier4-add-include-linux-freezerh-and-move-definitions-from.patch make-kmem_cache_destroy-return-void-reiser4.patch reiser4-hardirq-include-fix.patch reiser4-run-truncate_inode_pages-in-reiser4_delete_inode.patch reiser4-get_sb_dev-fix.patch
reiser4-vs-zoned-allocator.patch
reiser4-temp-fix.patch
reiser4-kmem_cache_t-removal.patch
hpt3xx-rework-rate-filtering-tidy.patch
jmicron-warning-fix.patch statistics-infrastructure-fix-buffer-overflow-in-histogram-with-linear-tidy.patch extend-notifier_call_chain-to-count-nr_calls-made.patch extend-notifier_call_chain-to-count-nr_calls-made-fixes-2.patch define-and-use-new-eventscpu_lock_acquire-and-cpu_lock_release-fix.patch eliminate-lock_cpu_hotplug-in-kernel-schedc-fix.patch slim-main-include-fix.patch
nr_blockdev_pages-in_interrupt-warning.patch
device-suspend-debug.patch
mutex-subsystem-synchro-test-module-fix.patch
slab-leaks3-default-y.patch
vdso-print-fatal-signals-use-ctl_unnumbered.patch restore-rogue-readahead-printk.patch
put_bh-debug.patch
e1000-printk-warning-fixes.patch
acpi_format_exception-debug.patch add-debugging-aid-for-memory-initialisation-problems-fix.patch kmap_atomic-debugging.patch
squash-ipc-warnings.patch
squash-udf-warnings.patch
schedule_on_each_cpu-use-preempt_disable.patch
kernel/workqueue.c int schedule_on_each_cpu(work_func_t fun · line 644
Quoted 9 lines · * [email protected] <[email protected]> wrote:
kernel/workqueue.c renamed from kernel/workqueue.c~schedule_on_each_cpu-use-preempt_disable +2
-2-mutex_lock (&workqueue_mutex); +preempt_disable ();/* CPU hotplug */ for_each_online_cpu (cpu) {INIT_WORK (per_cpu_ptr (works, cpu), func);__queue_work (per_cpu_ptr (keventd_wq->cpu_wq, cpu),per_cpu_ptr (works, cpu)); } -mutex_unlock (&workqueue_mutex); +preempt_enable ();
Why not cpu_hotplug_lock()?
Ingo
Quoted 15 lines · On Fri, 15 Dec 2006 09:31:12 +0100 Ingo Molnar <[email protected]> wrote:
kernel/workqueue.c int schedule_on_each_cpu(work_func_t fun · line 644
Quoted 9 lines · * [email protected] <[email protected]> wrote:
kernel/workqueue.c renamed from kernel/workqueue.c~schedule_on_each_cpu-use-preempt_disable +2
-2-mutex_lock (&workqueue_mutex); +preempt_disable ();/* CPU hotplug */ for_each_online_cpu (cpu) {INIT_WORK (per_cpu_ptr (works, cpu), func);__queue_work (per_cpu_ptr (keventd_wq->cpu_wq, cpu),per_cpu_ptr (works, cpu)); } -mutex_unlock (&workqueue_mutex); +preempt_enable ();Why not
cpu_hotplug_lock()?
Because the workqueue code was explicitly switched over to per-subsystem cpu-hotplug locking.
Because lock_cpu_hotplug() is a complete turkey, source of deadlocks and overall bad idea.
This is actually a pretty simple problem. A subsystem has per-cpu reosurces, and it needs to lock them while using them. duh. We know how to do that sort of thing. But because the first implementation of lock_cpu_hotplug() was conceived with magical properties, we seem to think we need to retain magical properties. We don't...
Quoted 11 lines · Andrew Morton
Quoted 10 lines
kernel/workqueue.c int schedule_on_each_cpu(work_func_t fun · line 644
Quoted 7 lines
kernel/workqueue.c renamed from kernel/workqueue.c~schedule_on_each_cpu-use-preempt_disable +1
-1for_each_online_cpu (cpu) {INIT_WORK (per_cpu_ptr (works, cpu), func);__queue_work (per_cpu_ptr (keventd_wq->cpu_wq, cpu),per_cpu_ptr (works, cpu)); } -mutex_unlock (&workqueue_mutex); +preempt_enable ();Why not
cpu_hotplug_lock()?
Quoted 5 lines
Because the workqueue code was explicitly switched over to per-subsystem cpu-hotplug locking.
Because
lock_cpu_hotplug()is a complete turkey, source of deadlocks and overall bad idea.
not in the locking model i outlined earlier, which would turn it into a read-lock in essence.
Quoted 5 lines
This is actually a pretty simple problem. A subsystem has per-cpu reosurces, and it needs to lock them while using them. duh. We know how to do that sort of thing. But because the first implementation of
lock_cpu_hotplug()was conceived with magical properties, we seem to think we need to retain magical properties. We don't...
actually, we use two things here: cpu_online_map and the per-cpu keventd workqueues. cpu_online_map is pretty much attached to the CPU hotplug subsystem so it would be quite natural to use cpu_hotplug_read_lock() for that.
so i disagree that CPU hotplug locking should be per-subsystem. We should have one lightweight and scalable primitive that protects cpu_online_map use, and that same primitive can be used to protect other per-CPU resources too.
Ingo
Quoted 29 lines · On Fri, 15 Dec 2006 17:24:16 +0100 Ingo Molnar <[email protected]> wrote:
Quoted 11 lines · Andrew Morton
Quoted 10 lines
kernel/workqueue.c int schedule_on_each_cpu(work_func_t fun · line 644
Quoted 7 lines
kernel/workqueue.c renamed from kernel/workqueue.c~schedule_on_each_cpu-use-preempt_disable +1
-1for_each_online_cpu (cpu) {INIT_WORK (per_cpu_ptr (works, cpu), func);__queue_work (per_cpu_ptr (keventd_wq->cpu_wq, cpu),per_cpu_ptr (works, cpu)); } -mutex_unlock (&workqueue_mutex); +preempt_enable ();Why not
cpu_hotplug_lock()?Quoted 5 lines
Because the workqueue code was explicitly switched over to per-subsystem cpu-hotplug locking.
Because
lock_cpu_hotplug()is a complete turkey, source of deadlocks and overall bad idea.not in the locking model i outlined earlier, which would turn it into a read-lock in essence.
Quoted 5 lines
This is actually a pretty simple problem. A subsystem has per-cpu reosurces, and it needs to lock them while using them. duh. We know how to do that sort of thing. But because the first implementation of
lock_cpu_hotplug()was conceived with magical properties, we seem to think we need to retain magical properties. We don't...
Quoted 4 lines
actually, we use two things here:
cpu_online_mapand the per-cpu keventd workqueues.cpu_online_mapis pretty much attached to the CPU hotplug subsystem so it would be quite natural to usecpu_hotplug_read_lock()for that.
The two are connected, because cpu add/remove creates and kills keventd threads.
Quoted 4 lines
so i disagree that CPU hotplug locking should be per-subsystem. We should have one lightweight and scalable primitive that protects
cpu_online_mapuse, and that same primitive can be used to protect other per-CPU resources too.
This problem can be (is being) solved using existing locking primitives.
PATCH 1/1 struct vfsmount : keep mnt_count & mnt_expiry_mark away from mnt_flags
In reply to Andrew MortonI noticed cache misses in touch_atime() that can be avoided if we keep mnt_count & mnt_expiry_mark in a different cache line than mnt_flags (mostly read)
mnt_count & mnt_expiry_mark are modified each time a file is opened/closed in a file system.
touch_atime() is called each time a file is read, and generally needs to read mnt_flags.
Other fields of struct vfsmount are mostly read so I chose to move mnt_count & mnt_expiry_mark at the end of struct vfsmount. And adding a comment so that nobody tries to re-arrange fields to fill the holes :)
On 64bits platforms, the new offsetof(mnt_count) is 0xC0
On 32bits platforms, it is 0x60, so I didnot add a ____cacheline_aligned_in_smp because it would have a too big impact on the size of this object (in particular if CONFIG_X86_L1_CACHE_SHIFT=7)
include/linux/mount.h +8 -2
@@ -43,9 +43,8 @@ struct vfsmount {struct super_block *mnt_sb;/* pointer to superblock */ struct list_head mnt_mounts;/* list of children, anchored here */ struct list_head mnt_child;/* and going through their mnt_child */ -atomic_t mnt_count;int mnt_flags; -int mnt_expiry_mark;/* true if marked for expiry */ +/* 4 bytes hole on 64bits arches */ char *mnt_devname;/* Name of device e.g. /dev/dsk/hda1 */ struct list_head mnt_list;struct list_head mnt_expire;/* link in fs-specific expiry list */
@@ -54,6 +53,13 @@ struct vfsmount {struct list_head mnt_slave;/* slave list entry */ struct vfsmount *mnt_master;/* slave is on master->mnt_slave_list */ struct mnt_namespace *mnt_ns;/* containing namespace */ +/* +* We put mnt_count & mnt_expiry_mark at the end of struct vfsmount +* to let these frequently modified fields in a separate cache line +* (so that reads of mnt_flags wont ping-pong on SMP machines) +*/ +atomic_t mnt_count; +int mnt_expiry_mark;/* true if marked for expiry */ int mnt_pinned; };
PATCH 1/1 avoid one conditional branch in touch_atime()
I added IS_NOATIME(inode) macro definition in include/linux/fs.h, true if the inode superblock is marked readonly or noatime.
This new macro is then used in touch_atime() instead of separatly testing MS_RDONLY and MS_NOATIME
fs/inode.c +1 -3
@@ -1160,11 +1160,9 @@ void touch_atime(struct vfsmount *mnt, sstruct inode *inode = dentry->d_inode;struct timespec now; -if (IS_RDONLY (inode)) -return ;if (inode->i_flags &S_NOATIME )return ; -if (inode->i_sb->s_flags &MS_NOATIME ) +if (IS_NOATIME (inode))return ;if ((inode->i_sb->s_flags &MS_NODIRATIME ) &&S_ISDIR (inode->i_mode))return ;
include/linux/fs.h +1 -0
@@ -169,6 +169,7 @@ extern int dir_notify_enable;#define IS_DIRSYNC (inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \ ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))#define IS_MANDLOCK (inode) __IS_FLG(inode, MS_MANDLOCK) +#define IS_NOATIME (inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)#define IS_NOQUOTA (inode) ((inode)->i_flags & S_NOQUOTA)#define IS_APPEND (inode) ((inode)->i_flags & S_APPEND)